Beispiel #1
0
 /// <summary>
 /// When the player attacks (As you can see I pass a AudioClip as a parameter for the sound to this GameObject as different attacks can have different sounds).
 /// When a player is attacking we have to take care of a few things by default (atleast for this case of the demo).
 /// The animation, attack sound any any movement restrictions applied for attacking.
 /// </summary>
 public void Attack(string animationNameValue, AudioClip clip)
 {
     // IF we are currently not attacking.
     if (!CharacterAnimator.GetBool(animationNameValue))
     {
         // Set the Attack Animation.
         CharacterAnimator.SetBool(animationNameValue, true);
         // Play the attack sound (if there is one).
         Grid.soundManager.PlaySound(clip);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Whenever this monster attacks we will associate a few actions.  (Keep in mind monsters that just run into the player to do damage with no attack animation should not call this method.)
 /// 1) Animation (Not all enemies have an attack animation, example being the bat in the Demo.)
 /// 2) Attack Sound (Not all enemies have an attack animation, example being the bat in the Demo.)
 /// 3) Movement Restriction
 /// </summary>
 /// <param name="clip">Clip.</param>
 public void Attack(string animationNameValue, AudioClip clip)
 {
     // IF we are currently not attacking.
     if (!CharacterAnimator.GetBool(animationNameValue))
     {
         // Set the Attack Animation.
         CharacterAnimator.SetBool(animationNameValue, true);
         // Play the attack sound (if there is one).
         Grid.soundManager.PlaySound(clip);
         // Set the IsMoving variable for the animation to false since the character will not be moving while attacking.
         CharacterAnimator.SetBool("IsMoving", false);
         // Make it to where the GameObject cannot move.
         CanMove = false;
     }
 }