Ejemplo n.º 1
0
    /// <summary>
    /// Called when player presses the use key
    /// </summary>
    private void useAction()
    {
        RaycastHit useHit;

        if (Physics.Raycast(_playerCamera.transform.position, _playerCamera.transform.forward, out useHit, _useRange))
        {
            Transform target = useHit.transform;

            if (target.CompareTag("Door"))
            {
                DoorTrigger door = target.GetComponent <DoorTrigger>();
                if (door != null)
                {
                    door.Use();
                }
            }

            if (target.CompareTag("Message Switch"))
            {
                MessageSwitch mSwitch = target.GetComponent <MessageSwitch>();
                if (mSwitch != null)
                {
                    mSwitch.Use();
                }
            }

            if (target.CompareTag("Platform Switch"))
            {
                PlatformSwitch pSwitch = target.GetComponent <PlatformSwitch>();
                if (pSwitch != null)
                {
                    pSwitch.Use();
                }
            }

            if (target.CompareTag("Turret"))
            {
                TurretHealth turretHealth = target.GetComponent <TurretHealth>();
                if (turretHealth != null)
                {
                    turretHealth.Die();
                }
            }
        }
    }
Ejemplo n.º 2
0
    //public Rigidbody Player;


    private void Start()
    {
        Switch = GameObject.Find("Manager").GetComponent <PlatformSwitch>();
        //Player = GetComponent<Rigidbody>();
    }