コード例 #1
0
    // On trigger switch the alocated item and the one carried by the player
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            items = other.GetComponent("Player_Inventory") as Player_Inventory;


            temporal = items.getCurrentObject();
            items.setInvetory(availbleItem);
            availbleItem = temporal;


            switch (availbleItem)
            {
            case Items.NullItem: tile.SetThisTiles(0, (int)Items.NullItem); break;

            case Items.DoorKey1: tile.SetThisTiles(0, (int)Items.DoorKey1); break;

            case Items.DoorKey2: tile.SetThisTiles(0, (int)Items.DoorKey2); break;

            case Items.DoorKey3: tile.SetThisTiles(0, (int)Items.DoorKey3); break;

            case Items.DoorKey4: tile.SetThisTiles(0, (int)Items.DoorKey4); break;

            case Items.DoorKey5: tile.SetThisTiles(0, (int)Items.DoorKey5); break;

            case Items.DoorKey6: tile.SetThisTiles(0, (int)Items.DoorKey6); break;

            case Items.DoorKey7: tile.SetThisTiles(0, (int)Items.DoorKey7); break;
            }
        }
    }
コード例 #2
0
    // If the payer collides with the door
    void OnTriggerEnter(Collider other)
    {
        // if is locked, ask for if the player carries the required item to open the door
        if (!locked)
        {
            if (other.gameObject.tag == "Player")
            {
                if (RequiresUseOfItem)
                {
                    inventory = other.GetComponent("Player_Inventory") as Player_Inventory;
                    if (inventory.getCurrentObject() == RequiredItem)
                    {
                        openprocess       = true;
                        RequiresUseOfItem = false;

                        /*if(inventory.getCurrentObject() == Items.DoorKey0) {
                         *      this.transform.position = new Vector3(-100,-100,0);
                         * }*/
                    }
                }
                else
                {
                    openprocess = true;
                }
            }
        }

        if (other.gameObject.tag == "Enemy")
        {
            openprocess = true;
        }
    }
コード例 #3
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         if (RequiresUseOfItem)
         {
             inventory = other.GetComponent("Player_Inventory") as Player_Inventory;
             if (inventory.getCurrentObject() == RequiredItem)
             {
                 door.unlockdoor();
             }
         }
         else
         {
             door.unlockdoor();
         }
     }
 }