示例#1
0
    void Update()
    {
        if (!TerminalState)
        {
            // DO NORMAL ANIMATIONS
            var ammo = 0;
            if (Hero.inst.currItem != null)
            {
                ammo = Hero.inst.currItem.ammo;
            }
            if (ammo == 0 || ammo >= kAmmoLabels.Length)
            {
                ammoLabel.text = "";
            }
            else
            {
                ammoLabel.text = kAmmoLabels[ammo];
            }


            var oldStatus = status;
            if (Hero.inst.grounded)
            {
                var speed    = Mathf.Abs(Hero.inst.body.velocity.x);
                var prevTime = animationTime;
                if (speed > 0.05f)
                {
                    SetStatus(Status.Running);
                    animationTime += runAnimScale * (speed + 0.25f) * Time.deltaTime;
                    pose.ApplyRunCycle(animationTime);
                }
                else
                {
                    SetStatus(Status.Idle);
                    animationTime = 0f;
                }
                var a = Mathf.FloorToInt(8f * prevTime) % 2;
                var b = Mathf.FloorToInt(8f * animationTime) % 2;
                if (a != b && b == 0)
                {
                    Jukebox.Play("Footfall");
                }
            }
            else
            {
                animationTime = 0f;
                SetStatus(Status.Jumping);
                pose.ApplyJumpCycle(Time.time);
            }
            if (status != oldStatus && oldStatus == Status.Jumping)
            {
                Jukebox.Play("Footfall");
            }
        }
        else
        {
            ammoLabel.text = "";
            if (status == Status.Ragdoll)
            {
                // DO RAGDOLL ANIMATIONS
                pose.TickRagdoll();
            }
        }
    }
示例#2
0
 void Update()
 {
     //pose.ApplyRunCycle(Time.time);
     pose.ApplyJumpCycle(Time.time);
 }