Пример #1
0
        // Update is called once per frame
        void Update()
        {
            if (Cooldown > 0.0f)
            {
                Cooldown -= Time.deltaTime;
                sentryTipText.text = "Sentry cooldown: " + Mathf.CeilToInt(Cooldown);
            }
            else
                sentryTipText.text = (sentryGun.IsDeployed) ? "(T near sentry)    pick the sentry" : "(T)    place the sentry";

            if (Input.GetButtonDown("PlaceSentry"))
            {
                if (sentryGun.IsDeployed && Vector3.Magnitude(sentryGun.transform.position - transform.position) < 4.0f)
                {
                    sentryGun.PickUp();
                }
                else if (!sentryGun.IsDeployed)
                {
                    if (Cooldown > 0.0f)
                    {
                        return;
                    }

                    bool status = sentryGun.Deploy(transform.position + transform.forward + (Vector3.up * 0.5f), transform.rotation);
                    if (!status)
                    {
                        // TODO write error message
                    }
                }
            }
        }
Пример #2
0
        void Death()
        {
            // Set the death flag so this function won't be called again.
            isDead = true;

            // Pick the sentry up.
            sentryComp.PickUp();
            playerSentry.Cooldown = 5.0f;
        }