예제 #1
0
    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);
    }