Camera_pause.gd 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. extends Camera
  2. onready var global_v=get_node("../../scene")
  3. onready var gui_cc=get_tree().get_root().get_node("scene/gui_c/vp/gui")
  4. onready var cam2=get_tree().get_root().get_node("scene/Sky_p/scene/Camera")
  5. onready var cbb=get_node("../../scene/conf_group/conf/StaticBody/CollisionShape")
  6. onready var pbb=get_node("../../scene/play_group/play/StaticBody/CollisionShape")
  7. onready var pb=get_node("../../scene/play_group/play_back")
  8. onready var pbp=get_node("../../scene/play_group/play_p")
  9. onready var cbr=get_node("../../scene/conf_group/conf_back")
  10. onready var cbrp=get_node("../../scene/conf_group/conf_p")
  11. onready var outlinep=get_node("../../scene/play_group/outline")
  12. onready var outlinec=get_node("../../scene/conf_group/outline")
  13. onready var post_p=get_tree().get_root().get_node("scene/main_screen")
  14. onready var ptmr=get_node("../../scene/play_group/pause_tmr")
  15. onready var rtfx=get_node("../../scene/play_group/pause_tmr/rtxxx")
  16. onready var ptmr2=get_node("../../scene/play_group/pause_tmr2")
  17. onready var floorx=get_node("../../scene/floor_anix/floor")
  18. onready var floor_l=get_node("../../scene/floor_anix/left_f")
  19. onready var floor_r=get_node("../../scene/floor_anix/right_f")
  20. onready var floor_lfa=get_node("../../scene/floor_anix/floor_lp_r")
  21. onready var floor_rfa=get_node("../../scene/floor_anix/floor_lp_l")
  22. var _mouse_position = Vector2(0.0, 0.0)
  23. var _yaw = 0.0
  24. var _pitch = 0.0
  25. var _total_yaw = 0.0
  26. var _total_pitch = 0.0
  27. var click_time=0.0
  28. var unclick_time=0.0
  29. var lpt=0.0
  30. var isclick=false
  31. var isinm=false
  32. var pause_clicks=0
  33. func _ready():
  34. self.environment.background_sky.set_panorama(global_v.iChannel_panorama)
  35. func _input(event):
  36. if event is InputEventKey:
  37. if ((event.scancode == KEY_ESCAPE)or(event.scancode == KEY_1))and(!global_v.conf_clicked)and(!get_tree().paused):
  38. display_on_esc()
  39. return
  40. func _physics_process(delta):
  41. if (Input.is_mouse_button_pressed(BUTTON_LEFT)):
  42. get_object_under_mouse(true)
  43. else:
  44. get_object_under_mouse(false)
  45. onready var p_ex=get_node("../../scene/refl_body/sup_p")
  46. onready var p_ex_a=get_node("../../scene/refl_body/sup_p/Attractor")
  47. onready var p_ex_v=get_node("../../scene/refl_body/sup_p/Vortex")
  48. onready var player_bgl=get_node("../../scene/refl_body/glow")
  49. var rc_once=false
  50. var rc_d=false
  51. var rc_time=0
  52. var dex=false
  53. var dex_timer=0
  54. var pxtime=0
  55. func e_ex_action(delta):
  56. if(get_tree().paused):
  57. if(dex):
  58. pxtime+=delta
  59. return
  60. if(rc_d):
  61. dex=true
  62. dex_timer=global_v.iTime-pxtime-rc_time
  63. if(global_v.iTime-pxtime-rc_time>11.0):
  64. pxtime=0
  65. dex=false
  66. if(dex):
  67. player_bgl.get_surface_material(0).set("shader_param/glow_c",Color(0.08,0.3,1.0,1.0)*smoothstep(rc_time+11.0,rc_time+7.0,global_v.iTime-pxtime)*smoothstep(rc_time+1.5,rc_time+3.0,global_v.iTime-pxtime))
  68. if(global_v.iTime-pxtime-rc_time<02.60):
  69. p_ex.set_emitting(true)
  70. else:
  71. p_ex.set_emitting(false)
  72. if(global_v.iTime-pxtime-rc_time<3.0):
  73. p_ex_a.strength=1.80*smoothstep(rc_time+0.5,rc_time+2.50,global_v.iTime-pxtime)
  74. else:
  75. p_ex_a.strength=-15.0*smoothstep(rc_time+1.0,rc_time+5.0,global_v.iTime-pxtime)
  76. p_ex_a.strength*=smoothstep(rc_time+7.0,rc_time+2.90,global_v.iTime-pxtime)
  77. p_ex_v.strength=2.0*smoothstep(rc_time+0.85,rc_time+2.50,global_v.iTime-pxtime)
  78. p_ex_v.strength*=smoothstep(rc_time+5.0,rc_time+2.90,global_v.iTime-pxtime)
  79. else:
  80. player_bgl.get_surface_material(0).set("shader_param/glow_c",Color(0.0,0.0,0.0,1.0))
  81. p_ex.set_emitting(false)
  82. p_ex_a.strength=0.0001
  83. p_ex_v.strength=0.0001
  84. func right_click():
  85. if ((Input.is_mouse_button_pressed(BUTTON_RIGHT))&&(AP>=0.9999)&&(!post_p.ispause)&&(!rc_once)&&(!rc_d)):
  86. rc_once=true
  87. rc_time=global_v.iTime
  88. if((!Input.is_mouse_button_pressed(BUTTON_RIGHT))&&(rc_once)):
  89. rc_once=false
  90. func _process(delta):
  91. e_process(delta)
  92. right_click()
  93. e_ex_action(delta)
  94. var _yval=0.0
  95. var _pval=0.0
  96. if(post_p.ispause):
  97. _yval=50.0
  98. _pval=45.0
  99. else:
  100. _yval=15.0
  101. _pval=30.0
  102. if(global_v.conf_clicked):
  103. cam2.set_fov(gui_cc.fov_val)
  104. self.set_fov(gui_cc.fov_val)
  105. if (Input.is_mouse_button_pressed(BUTTON_LEFT))&&(!isinm)&&((global_v.play_clicked)||(!global_v.conf_clicked)&&(!global_v.play_clicked)):
  106. _mouse_position = get_viewport().get_mouse_position()/OS.get_window_size()-Vector2(0.5,0.5)
  107. _mouse_position.x=clamp(_mouse_position.x,-0.5,0.5)
  108. _mouse_position.y=clamp(_mouse_position.y,-0.5,0.5)
  109. if !isclick:
  110. click_time=global_v.iTime
  111. isclick=true
  112. var eval=0.1+0.9*smoothstep(click_time,click_time+0.5,global_v.iTime)
  113. lpt=eval*0.75*global_v.get_pause_anim_timer()
  114. _yaw = _mouse_position.x*lpt
  115. _pitch = _mouse_position.y*lpt
  116. else:
  117. if isclick:
  118. unclick_time=global_v.iTime
  119. var eval=smoothstep(unclick_time+1.5,unclick_time+4.0,global_v.iTime)
  120. isclick=false
  121. if(global_v.iTime-unclick_time<1.5):
  122. eval=smoothstep(unclick_time+1.5,unclick_time,global_v.iTime)
  123. _yaw = eval*_mouse_position.x*lpt
  124. _pitch = eval*_mouse_position.y*lpt
  125. else:
  126. _yaw=-0.35*eval*_total_yaw/_yval
  127. _pitch=-0.35*eval*_total_pitch/_pval
  128. if sign(_total_yaw)==sign(_yaw):
  129. _yaw = _yaw *(_yval-abs(_total_yaw))/_yval
  130. if sign(_total_pitch)==sign(_pitch):
  131. _pitch = _pitch*(_pval-abs(_total_pitch))/_pval
  132. if abs(_total_yaw+_yaw)<50:
  133. _total_yaw += _yaw
  134. rotate_y(deg2rad(-_yaw))
  135. if abs(_total_pitch+_pitch)<45:
  136. _total_pitch += _pitch
  137. rotate_object_local(Vector3(1,0,0), deg2rad(-_pitch))
  138. func get_object_under_mouse(mouse_press):
  139. var mouse_pos = get_viewport().get_mouse_position()
  140. var ray_from = self.project_ray_origin(mouse_pos)
  141. var RAY_LENGTH=10
  142. var ray_to = ray_from + self.project_ray_normal(mouse_pos) * RAY_LENGTH
  143. var space_state = get_world().direct_space_state
  144. var selection = space_state.intersect_ray(ray_from, ray_to)
  145. if(selection.size()!=0):
  146. if(selection.get("collider")!=null):
  147. if(selection.get("collider").has_method("mouse_entered_event")):
  148. isinm=false
  149. if !isclick:
  150. isinm=true
  151. selection.get("collider").mouse_entered_event(mouse_press)
  152. else:
  153. selection.get("collider").mouse_entered_event(false)
  154. else:
  155. global_v.get_node("play_group/play/StaticBody").mouse_out_event()
  156. global_v.get_node("conf_group/conf/StaticBody").mouse_out_event()
  157. isinm=false
  158. else:
  159. global_v.get_node("play_group/play/StaticBody").mouse_out_event()
  160. global_v.get_node("conf_group/conf/StaticBody").mouse_out_event()
  161. isinm=false
  162. #return selection
  163. func display_on_esc():
  164. if(!get_tree().paused):
  165. get_tree().paused=true
  166. gui_cc.disable_refl(true)
  167. pbb.set_disabled(false)
  168. cbb.set_disabled(false)
  169. cbr.set_visible(true)
  170. pb.set_visible(true)
  171. pbp.set_emitting(true)
  172. cbrp.set_emitting(true)
  173. cbrp.set_visible(true)
  174. pbp.set_visible(true)
  175. outlinep.set_visible(true)
  176. outlinec.set_visible(true)
  177. floorx.set_visible(false)
  178. floorxa.set_visible(false)
  179. floorxb.set_visible(false)
  180. floorx.process_material.set("shader_param/vval",100000.0)
  181. pause_clicks+=1
  182. if(global_v.is_played_once):
  183. if(pause_clicks%2==1):
  184. ptmr.set_visible(true)
  185. rtfx.ctime=global_v.iTime
  186. ptmr.material_override.set("shader_param/ctime",global_v.iTime)
  187. else:
  188. ptmr2.set_visible(true)
  189. ptmr2.material_override.set("shader_param/ctime",global_v.iTime)
  190. global_v.conf_clicked=false
  191. global_v.play_clicked=false
  192. post_p.material.set("shader_param/minif",global_v.conf_clicked)
  193. post_p.material.set("shader_param/minif2",global_v.play_clicked)
  194. post_p.ispause=true
  195. #global_v.is_played_once=false
  196. #it here, bad I know
  197. var SPEED=0.0 #0-1
  198. var AP=0.0 #0-1
  199. var GO_flag=false
  200. var minus_speed_val=0
  201. var speed_pf=(1.0/60.0)*(1.0/60.0)
  202. var ap_pf=(1.0/20.0)*(1.0/60.0)
  203. onready var parts_oob=get_node("../../scene/particles_oob")
  204. onready var parts_oob_v4=get_node("../../scene/particles_oob/Vortex4")
  205. onready var player_b=get_node("../../scene/refl_body")
  206. onready var cubevp=get_node("../../scene/cube_vp")
  207. onready var floorxa=get_node("../../scene/floor_anix/floor_a")
  208. onready var floorxb=get_node("../../scene/floor_anix/floor_b")
  209. onready var floor_lw2=get_node("../../scene/floor_anix/left_f/wind2")
  210. onready var floor_rw2=get_node("../../scene/floor_anix/right_f/wind2")
  211. onready var pgg=get_node("../../scene/play_group/")
  212. onready var cgg=get_node("../../scene/conf_group/")
  213. func move_player(pos):
  214. #-19.5,17.5
  215. if(pos<0.0):
  216. var vvl=smoothstep(-19.5,-17.0,self.translation.x)
  217. pos*=vvl
  218. else:
  219. var vvl=smoothstep(17.5,15.0,self.translation.x)
  220. pos*=vvl
  221. self.translation.x+=pos
  222. parts_oob.translation.x+=pos
  223. #print("oob: "+str(parts_oob.translation.x)) #they not equal(sometime)...maybe bug
  224. player_b.translation.x+=pos
  225. #print("player: "+str(player_b.translation.x))
  226. pgg.translation.x+=pos
  227. cgg.translation.x+=pos
  228. for a in range(6):
  229. cubevp.get_child(a).get_child(0).translation.x+=pos
  230. if((player_b.translation.x)<-14.50):
  231. floor_lfa.set_emitting(true)
  232. floorxa.set_visible(true)
  233. floorxa.get_surface_material(0).set("shader_param/ppos",smoothstep(15.50,19.0,abs(player_b.translation.x)))
  234. else:
  235. floor_lfa.set_emitting(false)
  236. floorxa.set_visible(false)
  237. if((player_b.translation.x)>13.50):
  238. floor_rfa.set_emitting(true)
  239. floorxb.set_visible(true)
  240. floorxa.get_surface_material(0).set("shader_param/ppos",smoothstep(13.50,17.0,abs(player_b.translation.x)))
  241. else:
  242. floor_rfa.set_emitting(false)
  243. floorxb.set_visible(false)
  244. var vmdl=smoothstep(unclick_time+05.5,unclick_time+1.0,global_v.iTime)
  245. if(isclick):
  246. vmdl=1.0
  247. if(_mouse_position.x>=0.0):
  248. parts_oob_v4.strength=max(max((lpt)*10.5*_mouse_position.x*vmdl,parts_oob_v4.strength*vmdl),0.15)
  249. else:
  250. parts_oob_v4.strength=min(min((lpt)*10.5*_mouse_position.x*vmdl,parts_oob_v4.strength*vmdl),-0.15)
  251. func update_uniforms():
  252. post_p.material.set("shader_param/sval",smoothstep(0,1,SPEED))
  253. post_p.material.set("shader_param/ssval",smoothstep(0,1,AP))
  254. post_p.material.set("shader_param/msval",min(minus_speed_val,1.0))
  255. post_p.material.set("shader_param/psval",rc_d)
  256. func player_speed(delta):
  257. #if(GO_flag):
  258. # return
  259. SPEED+=-minus_speed_val*delta*2.0
  260. minus_speed_val+=-minus_speed_val*delta*2.0
  261. minus_speed_val=max(minus_speed_val,0.0)
  262. if(SPEED<0.0):
  263. GO_flag=true
  264. #return
  265. if(minus_speed_val<=0.01):
  266. SPEED+=1.0*speed_pf
  267. if(rc_once&&(AP>=0.9999)):
  268. rc_d=true
  269. if(rc_d):
  270. AP=smoothstep(rc_time+4.0,rc_time,global_v.iTime)-smoothstep(rc_time,rc_time+2.0,global_v.iTime)
  271. if(AP<=0.0001):
  272. rc_d=false
  273. else:
  274. if(!dex):
  275. AP+=ap_pf
  276. SPEED=clamp(SPEED,0,1)
  277. AP=clamp(AP,0,1)
  278. onready var sky_bS=get_tree().get_root().get_node("scene/Sky/Sprite")
  279. var pause_rt=Vector3(-0.65244*2.0, 1.29969, -2.26926)
  280. func tunp(delta):
  281. var vtr=0.0
  282. if(global_v.play_clicked):
  283. vtr=smoothstep(0.0,pause_rt.x,self.translation.x-player_b.translation.x)
  284. else:
  285. vtr=1.0-smoothstep(0.0,pause_rt.x,(self.translation.x-player_b.translation.x))
  286. vtr*=-1
  287. if(!post_p.ispause):
  288. sky_bS.sun_pos+=(1.0-abs(vtr))*delta
  289. else:
  290. sky_bS.sun_pos+=abs(vtr)*delta
  291. self.translation.x+=vtr*delta*0.5
  292. func e_process(delta):
  293. tunp(delta)
  294. if(global_v.play_clicked):
  295. player_speed(delta)
  296. update_uniforms()
  297. if(!post_p.ispause):
  298. var mv=_mouse_position.x
  299. mv=sign(mv)*mv*mv*lpt+mv*lpt
  300. var vmd=smoothstep(unclick_time+0.45,unclick_time,global_v.iTime)
  301. if(isclick):
  302. vmd=1.0
  303. move_player(-6.5*mv*delta*vmd)
  304. if(global_v.play_clicked)&&(post_p.play_click+10.0<post_p.iTime):
  305. cbrp.set_visible(false)
  306. pbp.set_visible(false)
  307. outlinep.set_visible(false)
  308. outlinec.set_visible(false)
  309. if(post_p.ispause)&&(floor_l.get_speed_scale()>0.001):
  310. var vsp=floor_l.get_speed_scale()-01.3850*floor_l.get_speed_scale()*delta
  311. vsp=max(vsp,0.001)
  312. floor_l.set_speed_scale(vsp)
  313. floor_r.set_speed_scale(vsp)
  314. p_ex.set_speed_scale(vsp)
  315. floor_lw2.set_strength(vsp*1.0)
  316. floor_rw2.set_strength(vsp*1.0)
  317. if(!post_p.ispause)&&(floor_l.get_speed_scale()<1.0):
  318. var vsp=floor_l.get_speed_scale()+01.3850*delta
  319. vsp=min(vsp,1.0)
  320. floor_l.set_speed_scale(vsp)
  321. floor_r.set_speed_scale(vsp)
  322. p_ex.set_speed_scale(vsp)
  323. floor_lw2.set_strength(vsp*1.0)
  324. floor_rw2.set_strength(vsp*1.0)
  325. func minus_speed():
  326. minus_speed_val+=0.12