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

            energy.ConsumeEnergy(5);
            Assert.Equal(15, energy.CurrentSoc);
        }
Example #3
0
 public override void DoActionAlpha()
 {
     if (energy.ConsumeEnergy(energyCost.Value))
     {
         playMaker.SendEvent("dash");
     }
 }
 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;
     }
 }
Example #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);
        }
Example #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");
        }