Advertisement
renderbydavid

Attacking

Oct 22nd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.46 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Attacking : MonoBehaviour
  6. {
  7.     public string Attker;
  8.     public bool isAttking, hasAttacked;
  9.     public Animator AttkAnimator;
  10.     public void AttackLeft()
  11.     {
  12.         //Do Attack
  13.         if(!isAttking)
  14.         {
  15.             hasAttacked = true;
  16.             isAttking = true;
  17.             AttkAnimator.Play(Attker + "Attack0Left");
  18.         }
  19.     }
  20.     public void AttackRight()
  21.     {
  22.         //Do Attack
  23.         if (!isAttking)
  24.         {
  25.             hasAttacked = true;
  26.             isAttking = true;
  27.             AttkAnimator.Play(Attker + "Attack0Right");
  28.         }
  29.     }
  30.     public void AttackUp()
  31.     {
  32.         //Do Attack
  33.         if (!isAttking)
  34.         {
  35.             hasAttacked = true;
  36.             isAttking = true;
  37.             AttkAnimator.Play(Attker + "Attack0Up");
  38.         }
  39.     }
  40.     public void AttackDown()
  41.     {
  42.         //Do Attack
  43.         if (!isAttking)
  44.         {
  45.             hasAttacked = true;
  46.             isAttking = true;
  47.             AttkAnimator.Play(Attker + "Attack0Down");
  48.         }
  49.     }
  50.  
  51.     public void StopAttk()
  52.     {
  53.         isAttking = false;
  54.         hasAttacked = false;
  55.     }
  56.  
  57.     public void DamageUp()
  58.     {
  59.         RaycastHit2D up = Physics2D.Raycast(transform.position, Vector2.up, 1.3f, 1 << 0);
  60.         if (up && up.transform.tag == "Player" | up.transform.tag == "Enemy")
  61.         {
  62.             up.transform.GetComponent<Health>().TakeDamage(.5f);
  63.         }
  64.     }
  65.  
  66.     public void DamageDown()
  67.     {
  68.         RaycastHit2D down = Physics2D.Raycast(transform.position, Vector2.down, 1.3f, 1 << 0);
  69.         if (down && down.transform.tag == "Player" | down.transform.tag == "Enemy")
  70.         {
  71.             down.transform.GetComponent<Health>().TakeDamage(.5f);
  72.         }
  73.     }
  74.  
  75.     public void DamageLeft()
  76.     {
  77.         RaycastHit2D left = Physics2D.Raycast(transform.position, Vector2.left, 1.3f, 1 << 0);
  78.         if (left && left.transform.tag == "Player" | left.transform.tag == "Enemy")
  79.         {
  80.             left.transform.GetComponent<Health>().TakeDamage(.5f);
  81.         }
  82.     }
  83.  
  84.     public void DamageRight()
  85.     {
  86.         RaycastHit2D right = Physics2D.Raycast(transform.position, Vector2.right, 1.3f, 1 << 0);
  87.         if (right && right.transform.tag == "Player" | right.transform.tag == "Enemy")
  88.         {
  89.             right.transform.GetComponent<Health>().TakeDamage(.5f);
  90.         }
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement