예제 #1
0
    void Update()
    {
        if (Forest.Paused)
        {
            if (animator.isAnimating())
            {
                animator.PauseAnimation();
            }

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                animator.ContinueAnimation();
            }
            return;
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            //TakeDamage(new Damage(1000, gameObject, 0));
        }


        if (!dead)
        {
            posTracker--;
            if (posTracker <= 0)
            {
                lastPos.Add(transform.position);
                posTracker = posTrackerMax;

                if (lastPos.Count > 30)
                {
                    lastPos.RemoveAt(0);
                }
            }

            stuckSayTick--;
            if (CheckForStuck() && stuckSayTick <= 0)
            {
                stuckSayTick = 300;
                HelpText.Say("I'm stuck! Mash [BACKSPACE]!!!");
            }

            justFired = false;
            if (Input.GetButtonDown("SwitchWeapons"))
            {
                SwitchWeapons();
            }

            if (Input.GetKeyDown(KeyCode.Backspace) && CheckForStuck())
            {
                transform.position = lastPos[lastPos.Count - 1];
                lastPos.RemoveAt(lastPos.Count - 1);
            }

            if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
            {
                stepTick--;
                if (stepTick < 0)
                {
                    PlaySound(Resources.Load <AudioClip>("Sounds/step"), true);
                    stepTick = stepTickMax;
                }
            }
            else
            {
                stepTick = 0;
            }


            Animate();
            DetectItems();
            Move();
        }
    }