Пример #1
0
 void exhaust()
 {
     EnergyManager.exhaustPlayer(exhaustToGive);
 }
Пример #2
0
    void Update()
    {
        Turn();
        if (canMove)
        {
            if (dash == true)
            {
                transform.Translate(Vector3.forward * moveSetting.forwardVel * speedo * Time.smoothDeltaTime);
                Invoke("StopMoving", 1.15f);
            }
            if (dashR == true)
            {
                transform.Translate(Vector3.right * moveSetting.forwardVel * speedo * Time.smoothDeltaTime);
                Invoke("StopMoving", 1.15f);
            }
            if (dashL == true)
            {
                transform.Translate(Vector3.left * moveSetting.forwardVel * speedo * Time.smoothDeltaTime);
                Invoke("StopMoving", 1.15f);
            }
            if (Input.GetKeyDown("0"))
            {
                int n = UnityEngine.Random.Range(0, 2);
                if (n == 1)
                {
                    anim.Play("WAIT01", -1, 0f);
                }
                else
                {
                    anim.Play("WAIT03", -1, 0f);
                }
            }
            if (moveSetting.forwardVel < 4f)
            {
                if (Input.GetKey(KeyCode.R))
                {
                    run = true;
                    moveSetting.forwardVel = 3.5f;
                }
                else
                {
                    run = false;
                    moveSetting.forwardVel = 2f;
                }
            }
            if (forwardInput == -1)
            {
                moveSetting.forwardVel = 1f;
            }
            if (Input.GetKeyDown(KeyCode.A))
            {
                sideLTotal += 1;
            }
            if ((sideLTotal == 1) && (sideTimeDelay < .3))
            {
                sideTimeDelay += Time.deltaTime;
            }

            if ((sideLTotal == 1) && (sideTimeDelay >= .3))
            {
                sideTimeDelay = 0;
                sideLTotal    = 0;
            }
            if (Input.GetKeyDown(KeyCode.D))
            {
                sideRTotal += 1;
            }
            if ((sideRTotal == 1) && (sideTimeDelay < .3))
            {
                sideTimeDelay += Time.deltaTime;
            }

            if ((sideRTotal == 1) && (sideTimeDelay >= .3))
            {
                sideTimeDelay = 0;
                sideRTotal    = 0;
            }
            if (Input.GetKeyDown(KeyCode.W))
            {
                sideFTotal += 1;
            }
            if ((sideFTotal == 1) && (sideTimeDelay < .3))
            {
                sideTimeDelay += Time.deltaTime;
            }

            if ((sideFTotal == 1) && (sideTimeDelay >= .3))
            {
                sideTimeDelay = 0;
                sideFTotal    = 0;
            }

            if ((sideFTotal == 2) && (sideTimeDelay < .3) && EnergyManager.playerEnergy >= 10)
            {
                dash = true;
                EnergyManager.exhaustPlayer(100);
                Invoke("stopSlide", 1.15f);
                sideRTotal = 0;
                sideFTotal = 0;
                sideLTotal = 0;
                anim.Play("SLIDE00");
                anim.SetBool("Slide", true);
                slide = true;
                gameObject.GetComponent <CapsuleCollider>().enabled = false;
                StartCoroutine(LateCall());
            }
            if ((sideLTotal == 2) && (sideTimeDelay < .3) && EnergyManager.playerEnergy >= 10)
            {
                dashL = true;
                EnergyManager.exhaustPlayer(100);
                Invoke("stopSlide", 1.15f);
                sideRTotal = 0;
                sideFTotal = 0;
                sideLTotal = 0;
                anim.Play("SLIDE00");
                anim.SetBool("Slide", true);
                slide = true;
                gameObject.GetComponent <CapsuleCollider>().enabled = false;
                StartCoroutine(LateCall());
            }
            if ((sideRTotal == 2) && (sideTimeDelay < .3) && EnergyManager.playerEnergy >= 10)
            {
                dashR = true;
                EnergyManager.exhaustPlayer(100);
                Invoke("stopSlide", 1.15f);
                sideRTotal = 0;
                sideFTotal = 0;
                sideLTotal = 0;
                anim.Play("SLIDE00");
                anim.SetBool("Slide", true);
                slide = true;
                gameObject.GetComponent <CapsuleCollider>().enabled = false;
                StartCoroutine(LateCall());
            }

            forwardInput = Input.GetAxis("Vertical");
            turnInput    = Input.GetAxis("Horizontal");

            anim.SetFloat("InputH", turnInput);
            anim.SetFloat("InputV", forwardInput);
            anim.SetBool("Run", run);

            if (Input.GetKeyDown(KeyCode.Space) && !jump)
            {
                anim.SetBool("Jump", true);
                jumpInput = Input.GetAxisRaw(inputSetting.JUMP_AXIS);

                jump = true;

                Invoke("StopJumping", 0.5f);
            }
            else
            {
                jump      = false;
                jumpInput = 0;
            }
            if (Input.GetKeyDown(KeyCode.V) && EnergyManager.playerEnergy >= 100)
            {
                dash = true;
                EnergyManager.exhaustPlayer(100);
                anim.SetBool("Slide", true);
                slide = true;
                gameObject.GetComponent <CapsuleCollider>().enabled = false;
                StartCoroutine(LateCall());
            }
            else
            {
                slide = false;
            }
            anim.SetBool("Slide", slide);
        }
    }