Esempio n. 1
0
 private void Dodge()
 {
     if (Input.GetButtonDown("Dodge"))
     {
         if (m_energy.ConsumeEnergy(m_dodgeEnergyConsumption))
         {
             StartCoroutine(DodgeOvertime());
         }
     }
 }
Esempio n. 2
0
        public void ConsumeEnergy_SmallerValueThanSoc_ConsumesSocFirst()
        {
            Energy energy = new Energy(20, 3);

            energy.ConsumeEnergy(5);
            Assert.Equal(15, energy.CurrentSoc);
        }
Esempio n. 3
0
 public override void DoActionAlpha()
 {
     if (energy.ConsumeEnergy(energyCost.Value))
     {
         playMaker.SendEvent("dash");
     }
 }
Esempio n. 4
0
 public void MoveInDirection(Vector3 direction, float speedFraction)
 {
     GetComponent <ActionScheduler>().StartAction(this);
     if (speedFraction > 1)
     {
         if (energy.CanConsumeEnergy(energyToSprint))
         {
             energy.ConsumeEnergy(energyToSprint);
         }
         else
         {
             speedFraction = 1;
         }
     }
     if (jumper.IsJumping())
     {
         jumper.MoveWhileJumping(direction, maxSpeed * Mathf.Max(0, speedFraction), elapsedRotationTime);
     }
     else
     {
         navMeshAgent.destination = transform.position + direction;
         navMeshAgent.speed       = maxSpeed * Mathf.Max(0, speedFraction);
         navMeshAgent.isStopped   = false;
     }
 }
Esempio n. 5
0
        public void ConsumeEnergy_GreaterValueThanSoc_ConsumesSocFirstThenFuel()
        {
            Energy energy = new Energy(20, 3);

            energy.ConsumeEnergy(22);
            Assert.Equal(0, energy.CurrentSoc);
            Assert.Equal(1, energy.CurrentFuel);
        }
Esempio n. 6
0
        public void Jump()
        {
            if (isJumping)
            {
                return;
            }
            if (!energy.CanConsumeEnergy(energyToJump))
            {
                return;
            }

            GetComponent <ActionScheduler>().StartAction(this);
            energy.ConsumeEnergy(energyToJump);
            navMeshAgent.enabled = false;
            rbody.isKinematic    = false;
            rbody.useGravity     = true;
            cachedPosition       = transform.position;
            transform.Translate(0, initialBoost, 0);
            rbody.AddForce(0, jumpForce, 0, ForceMode.Impulse);
            isJumping = true;
            GetComponent <Animator>().SetTrigger("jump");
        }