1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- extends Area
- export (String) var spot_name
- #FIXME: should use enum in future!!!!!!
- export (String) var status = "inactive"
- signal flowerspot_activated
- func _ready():
- var anim = self.find_node("AnimationPlayer", true, false)
- if anim != null:
- anim.connect("animation_finished", self, "anim_finished", ["MeshFlower"])
- var currentWorld = get_node("/root/global").getCurrentWorld()
- var flowerspotStatus = currentWorld.find_node("FlowerspotStatus", true, false)
- if flowerspotStatus != null:
- self.connect("flowerspot_activated", flowerspotStatus, "on_flowerspot_activated")
-
- #FIXME: what is name and name2, how to call them right???
- func anim_finished(name, name2):
- if (status == "anim"):
- status = "active"
- print ("anim finished - status = active")
- emit_signal("flowerspot_activated")
- func set_status(status):
- print ("status set to: " + status)
- self.status = status
- var anim = self.find_node("AnimationPlayer", true, false)
- if anim != null:
- if status == "active":
- anim.set_assigned_animation("MeshFlower")
- anim.advance(2.0)
-
- #anim.play("MeshFlower")
-
- elif status == "inactive":
- anim.advance(-2.0)
- else:
- print ("error in set status???")
- else:
- print ("error in set status - anim = null!!")
-
-
- func _process(delta):
- for body in get_overlapping_bodies ( ):
- if body.name == "Player" :
- var anim = self.find_node("AnimationPlayer", true, false)
- if anim == null:
- print ("fatal error - anim == null")
-
-
- #
-
- if Input.is_action_just_pressed("interact"):
- if (status == "inactive"):
- status = "anim"
- #print ("playing animation now")
- anim.play("MeshFlower")
- #part 1: emit signal here
-
-
-
- elif (status == "active"):
- set_status("inactive")
-
-
- else:
- status = "inactive"
- print ("warning: unknown state")
- print ("changed spot status to " + str(status))
-
-
|