Esempio n. 1
0
	/// <summary>
	/// Starts the attack, activating the cast if needed, playing the animation, and starting
	/// timer for the attack.
	/// </summary>
	/// <param name="attackToStart">Attack to start.</param>
	void StartAttack (AttackData attackToStart)
	{
		// TODO This is bad practice. When we refactor this, let's properly enapsulate
		// the current attack in one of these classes.
		enemy.currentAttack = attackToStart;
		attackAnimation.Play (attackToStart.swingAnimation.name);
		if (!attackToStart.IsRanged ()) {
			attackCaster.OnHit += OnAttackHit;
			attackCaster.Begin ();
			trailRenderer.enabled = true;
		}
		attackTime.StartTimer (attackToStart.swingAnimation.length);
		isAttacking = true;
	}
Esempio n. 2
0
 /*
  * Cancels and cleans up after an active attack.
  */
 void CancelAttack()
 {
     // Stop the existing attack sound
     attackAndBlockChannel.Stop();
     // Clear any unfinished forced attack move speed
     forcedAttackMoveSpeed = 0;
     UnplantFeet();
     damping = defaultDamping;
     // Cancel Attack can be called even if the player isn't attacking
     if (currentAttack != null)
     {
         // Only deactivate non-projectile attacks
         if (!currentAttack.IsRanged())
         {
             EndAttackCast();
         }
     }
     // Kill any attack trail
     SetAttackTrailActive(false);
     // Cancel charge ups
     chargeUpTimer.StopTimer();
     currentChargeUpTime = 0;
     isAttacking         = false;
 }
Esempio n. 3
0
 /// <summary>
 /// Starts the attack, activating the cast if needed, playing the animation, and starting
 /// timer for the attack.
 /// </summary>
 /// <param name="attackToStart">Attack to start.</param>
 void StartAttack(AttackData attackToStart)
 {
     // TODO This is bad practice. When we refactor this, let's properly enapsulate
     // the current attack in one of these classes.
     enemy.currentAttack = attackToStart;
     attackAnimation.Play (attackToStart.swingAnimation.name);
     if (!attackToStart.IsRanged ()) {
         attackCaster.OnHit += OnAttackHit;
         attackCaster.Begin ();
         trailRenderer.enabled = true;
     }
     attackTime.StartTimer (attackToStart.swingAnimation.length);
     isAttacking = true;
 }