A game created for the Godot Wild Jam #21
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.1KB

  1. extends Node2D
  2. export var color:Color
  3. export var transition_rate = 0.75
  4. func _dominant_color():
  5. if color.r > color.g and color.r > color.b:
  6. return "r"
  7. if color.g > color.r and color.g > color.b:
  8. return "g"
  9. if color.b > color.r and color.b > color.g:
  10. return "b"
  11. return "n"
  12. func _ready():
  13. $LeftDoor.set_color(color)
  14. $LeftDoor.transition_rate = transition_rate
  15. $RightDoor.set_color(color)
  16. $RightDoor.transition_rate = transition_rate
  17. func open():
  18. $LeftDoor.open()
  19. $RightDoor.open()
  20. func close():
  21. $LeftDoor.close()
  22. $RightDoor.close()
  23. func stop():
  24. $LeftDoor.stop()
  25. $RightDoor.stop()
  26. func _on_Area2D_body_entered(body):
  27. if body.is_in_group("Player"):
  28. var mood = body.get_mood()
  29. var dc = _dominant_color()
  30. print ("Dominant Color: ", dc)
  31. print ("Is Aggressive: ", mood.is_aggressive())
  32. print ("Is Needie: ", mood.is_needie())
  33. print ("Is Content: ", mood.is_content())
  34. if (dc == "r" and mood.is_aggressive()) or \
  35. (dc == "g" and mood.is_needie()) or \
  36. (dc == "b" and mood.is_content()) or \
  37. (dc == "n" and mood.is_neutral()):
  38. open()
  39. func _on_Area2D_body_exited(body):
  40. if body.is_in_group("Player"):
  41. close()