arc.gd 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. extends Spatial
  2. var state_o=[true,false,false,false] # [white,blue,green,red]
  3. var state_n=Color(1,0,0,0)
  4. const fspeed=1
  5. const gspeed=1.5
  6. onready var nodef=[]
  7. onready var nodel=[]
  8. onready var vps
  9. var ppos=[0,0]
  10. var ppos2=[0,0]
  11. var iTime=0
  12. func _ready():
  13. nodef.append(get_node("f1"))
  14. nodef.append(get_node("f2"))
  15. nodef.append(get_node("f3"))
  16. nodef.append(get_node("f4"))
  17. nodef.append(get_node("f5"))
  18. nodel.append(get_node("l1"))
  19. nodel.append(get_node("l4"))
  20. nodel.append(get_node("l2"))
  21. nodel.append(get_node("l3"))
  22. vps=get_node("viewport/Sprite")
  23. func _process(delta):
  24. iTime+=delta
  25. nodel[1].material_override.set("shader_param/iTime",iTime)
  26. vps.material.set("shader_param/delta",delta)
  27. vps.material.set("shader_param/ppos",PoolIntArray(ppos))
  28. vps.material.set("shader_param/ppos2",PoolIntArray(ppos2))
  29. for a in range(4):
  30. if(state_o[a]):
  31. state_n[a]+=delta*gspeed
  32. else:
  33. state_n[a]-=delta*fspeed
  34. state_n[a]=clamp(state_n[a],0,1)
  35. for a in range(4):
  36. nodef[a].material_override.set("shader_param/blendx",state_n)
  37. if(state_n[a]>0):
  38. nodel[a].get_child(0).visible=true
  39. nodel[a].get_child(0).light_energy=state_n[a]
  40. if(a==1):
  41. nodel[a].material_override.set("shader_param/blendx",state_n)
  42. else:
  43. nodel[a].material_override.emission_energy=state_n[a]*10
  44. else:
  45. nodel[a].get_child(0).visible=false
  46. if(a==1):
  47. nodel[a].material_override.set("shader_param/blendx",state_n)
  48. else:
  49. nodel[a].material_override.emission_energy=state_n[a]*10
  50. nodef[4].material_override.set("shader_param/blendx",state_n)
  51. func update_ppos(pposx):
  52. ppos[0]=pposx.x
  53. ppos[1]=pposx.y
  54. func update_ppos2(pposx):
  55. ppos2[0]=pposx.x
  56. ppos2[1]=pposx.y
  57. func _on_Areao_body_entered(body):
  58. if(body.is_a_parent_of(self)):
  59. return
  60. if(body.is_in_group("player")):
  61. state_o[0]=true
  62. state_o[1]=false
  63. state_o[2]=false
  64. state_o[3]=false
  65. func _on_Areao_body_exited(body):
  66. pass
  67. func _on_Areagreen_body_entered(body):
  68. if(body.is_a_parent_of(self)):
  69. return
  70. if(body.is_in_group("player")):
  71. state_o[2]=true
  72. state_o[0]=false
  73. state_o[1]=false
  74. # state_o[3]=false
  75. func _on_Areagreen_body_exited(body):
  76. pass
  77. func _on_Areared_body_entered(body):
  78. if(body.is_a_parent_of(self)):
  79. return
  80. if(body.is_in_group("player")):
  81. state_o[3]=true
  82. state_o[0]=false
  83. state_o[1]=false
  84. # state_o[2]=false
  85. func _on_Areared_body_exited(body):
  86. pass
  87. func _on_Areablue_body_entered(body):
  88. if(body.is_a_parent_of(self)):
  89. return
  90. if(body.is_in_group("player")):
  91. state_o[0]=false
  92. state_o[1]=true
  93. state_o[2]=false
  94. state_o[3]=false
  95. func _on_Areablue_body_exited(body):
  96. pass