Bläddra i källkod

Modified the Doorway triggers to watch the player's mood. If the mood changes to match the door while the body in IN the trigger area, then the door will open, instead of needing to exit the trigger area and move back in.

master
Bryan Miller 4 år sedan
förälder
incheckning
7a8b22b814
1 ändrade filer med 22 tillägg och 13 borttagningar
  1. +22
    -13
      Data/Scripts/Doorway.gd

+ 22
- 13
Data/Scripts/Doorway.gd Visa fil

@@ -4,6 +4,9 @@ extends Node2D
export var color:Color
export var transition_rate = 0.75

var _body = null
var _triggered = false


func _dominant_color():
if color.r > color.g and color.r > color.b:
@@ -19,6 +22,19 @@ func _ready():
$LeftDoor.transition_rate = transition_rate
$RightDoor.set_color(color)
$RightDoor.transition_rate = transition_rate
set_process(true)

func _process(delta):
if _body == null or _triggered:
return
var mood = _body.get_mood()
var dc = _dominant_color()
if (dc == "r" and mood.is_aggressive()) or \
(dc == "g" and mood.is_needie()) or \
(dc == "b" and mood.is_content()) or \
(dc == "n" and mood.is_neutral()):
_triggered = true
open()

func open():
$LeftDoor.open()
@@ -35,20 +51,13 @@ func stop():


func _on_Area2D_body_entered(body):
if body.is_in_group("Player"):
var mood = body.get_mood()
var dc = _dominant_color()
print ("Dominant Color: ", dc)
print ("Is Aggressive: ", mood.is_aggressive())
print ("Is Needie: ", mood.is_needie())
print ("Is Content: ", mood.is_content())
if (dc == "r" and mood.is_aggressive()) or \
(dc == "g" and mood.is_needie()) or \
(dc == "b" and mood.is_content()) or \
(dc == "n" and mood.is_neutral()):
open()
if _body == null and body.is_in_group("Player"):
_body = body
_triggered = false


func _on_Area2D_body_exited(body):
if body.is_in_group("Player"):
if body == _body:
_body = null
_triggered = false
close()

Laddar…
Avbryt
Spara