示例#1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if ("Teleport".Equals(collision.gameObject.tag))
     {
         DoorBehavior door = collision.gameObject.GetComponent <DoorBehavior>();
         transform.position = door.getNewLocation();
     }
     else if ("InvItem".Equals(collision.gameObject.tag))
     {
         InvItemBehavior item = collision.gameObject.GetComponent <InvItemBehavior>();
         if (collision.gameObject.name == "MapPillBottle")
         {
             item.pickUp("pillBottle");
         }
         else if (collision.gameObject.name == "CureList")
         {
             item.pickUp("cureList");
         }
         else if (collision.gameObject.name == "Ingredient1")
         {
             item.pickUp("ingredient1");
         }
         else if (collision.gameObject.name == "Ingredient2")
         {
             item.pickUp("ingredient2");
         }
         else if (collision.gameObject.name == "Ingredient3")
         {
             item.pickUp("ingredient3");
         }
         else if (collision.gameObject.name == "Ingredient4")
         {
             item.pickUp("ingredient4");
         }
         Debug.Log("Got an inventory item");
     }
     else
     {
         Debug.Log("(PLAYER): Warning, collided with untagged object");
     }
 }
示例#2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if ("Teleport".Equals(collision.gameObject.tag))
        {
            DoorBehavior door = collision.gameObject.GetComponent <DoorBehavior>();
            if (!door.isLocked)
            {
                transform.position = door.getNewLocation();
            }
            else
            {
                Debug.Log("The door is locked!");
            }
            if (door.isUnlockTrigger)
            {
                door.unlockOtherDoor();
                Debug.Log("Unlocked Other Door(s)!");
            }
        }
        else if ("InvItem".Equals(collision.gameObject.tag))
        {
            InvItemBehavior item = collision.gameObject.GetComponent <InvItemBehavior>();
            if (collision.gameObject.name == "MapPillBottle")
            {
                item.pickUp("pillBottle");
                DialogueBox.QueueDialogue(new KeyValuePair <int, string>(5, "\"What’s this? A pill bottle? Prescription from Fairview Hospital . . . take as needed for the Turning.\""));
                DialogueBox.QueueDialogue(new KeyValuePair <int, string>(3, "*Click the bottle in your inventory to take a pill.*"));
            }
            else if (collision.gameObject.name == "CureList")
            {
                item.pickUp("cureList");
                List.pickedUp = true;
            }
            else if (item.puzzle != null)
            {
                SceneMan.ActivatePuzzle(item.puzzle);
            }

            if (collision.gameObject.name == "Ingredient1")
            {
                FreezePlayer.Instance.puzzleIsOpen = true;
                item.pickUp("ingredient1");
            }
            else if (collision.gameObject.name == "Ingredient2")
            {
                FreezePlayer.Instance.puzzleIsOpen = true;
                item.pickUp("ingredient2");
            }
            else if (collision.gameObject.name == "Ingredient3")
            {
                FreezePlayer.Instance.puzzleIsOpen = true;
                item.pickUp("ingredient3");
            }
            else if (collision.gameObject.name == "Ingredient4")
            {
                item.pickUp("ingredient4");
            }
            //Debug.Log("Got an inventory item");
        }
        else if ("LabBench".Equals(collision.gameObject.tag))
        {
            bench.makeCure();
        }
        else if ("Exit".Equals(collision.gameObject.tag))
        {
            ExitDoorBehavior door = collision.gameObject.GetComponent <ExitDoorBehavior>();
            if (!door.isLocked)
            {
                SceneManager.LoadScene("WinMenu");
            }
        }
        else
        {
            Debug.Log("(PLAYER): Notice- Collided with object with unprocessed tag. Object Name: \"" + collision.gameObject.name + "\"   Object Tag: \"" + collision.gameObject.tag + "\"");
        }
    }