Ejemplo n.º 1
0
        private void OnTriggerStay(Collider other)
        {
            if (other.gameObject.CompareTag("TrapSquare"))
            {
                trapUI.UpdateTrapUIDetails(trapState, trapGnomeOn, selectedTrap);

                if (other.gameObject.GetComponent <TrapPlacementArea>() && !currentTrapLocation)
                {
                    currentTrapLocation = other.gameObject.GetComponent <TrapPlacementArea>();
                    trapGnomeOn         = currentTrapLocation.currentTrap;
                }

                // check to if there is a trap here...
                // if not allow the user to place a trap here....
                if (currentTrapLocation && !other.gameObject.GetComponent <TrapPlacementArea>().hasTrap)
                {
                    trapState = TrapStates.PlaceTrap;
                }
                else if (currentTrapLocation && other.gameObject.GetComponent <TrapPlacementArea>().hasTrap)
                {
                    // else allow the user to pickup what is there.
                    trapState = TrapStates.PickupTrap;
                }

                // updates the trap location
                if (trapGnomeOn != currentTrapLocation.currentTrap)
                {
                    trapGnomeOn = currentTrapLocation.currentTrap;
                }
            }
        }
Ejemplo n.º 2
0
 private void OnTriggerExit(Collider other)
 {
     // resets the current trap and gnome state on exit
     if (other.gameObject.CompareTag("TrapSquare"))
     {
         trapState           = TrapStates.NoTraps;
         currentTrapLocation = null;
         trapGnomeOn         = TrapTypes.None;
         trapUI.HideTrapUI();
     }
 }
Ejemplo n.º 3
0
 private void OnTriggerEnter(Collider other)
 {
     // sets up the trap square if the user is on one
     if (other.gameObject.CompareTag("TrapSquare"))
     {
         if (other.gameObject.GetComponent <TrapPlacementArea>())
         {
             currentTrapLocation = other.gameObject.GetComponent <TrapPlacementArea>();
             trapGnomeOn         = currentTrapLocation.currentTrap;
             trapUI.UpdateTrapUIDetails(trapState, trapGnomeOn, selectedTrap);
             trapUI.DisplayTrapUI(currentTrapLocation.transform.GetChild(0).transform);
         }
     }
 }