int TurnOnSpeaker(bool success) { if (success) { this.GetComponent <Animator>().Play("SpeakerBouncing"); float thisx = transform.position.x; float thisy = transform.position.y; List <GameObject> objects = grid.GetObjectsFromGrid(thisx - 2.0f, thisy, thisx + 2.0f, thisy - 4.0f); // Iterate through objects in speaker range and make them dance if it's an NPC foreach (GameObject o in objects) { InteractableInfo info = o.GetComponent <Interactable>().info; // Check if object is an NPC if (info.GetType() == dummyPersonInfo.GetType()) { PersonInfo newInfo = (PersonInfo)info; // Tell NPC to dance newInfo.Dance(); } } } return(0); }
int TurnOffSpeaker(bool success) { if (success) { this.GetComponent <Animator>().Play("Idle"); float thisx = transform.position.x; float thisy = transform.position.y; List <GameObject> objects = grid.GetObjectsFromGrid(thisx - 2.0f, thisy, thisx + 2.0f, thisy - 4.0f); // Iterate through objects in speaker range and make them stand still if NPC foreach (GameObject o in objects) { InteractableInfo info = o.GetComponent <Interactable>().info; PersonInfo targetType = new PersonInfo(); // Check if object is an NPC if (info.GetType() == targetType.GetType()) { PersonInfo newInfo = (PersonInfo)info; // Tell NPC to stop dancing newInfo.StopDancing(); } } } return(0); }
public override void Selection3() { GetComponent <Animator>().Play("Dancing"); HighlightSquares(); var thisx = transform.position.x; var thisy = transform.position.y; var objects = grid.GetObjectsSurroundingCoords(thisx, thisy); foreach (GameObject obj in objects) { InteractableInfo info = obj.GetComponent <Interactable>().info; PersonInfo targetType = new PersonInfo(); // Check if object is an NPC if (info && info.GetType() == targetType.GetType()) { PersonInfo newInfo = (PersonInfo)info; newInfo.React("Dancing"); } } }