Guest User

Untitled

a guest
May 9th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public abstract class Character : MonoBehaviour
  6. {
  7.     public bool facingRight;
  8.  
  9.     public bool attack { get; set; }
  10.     public Animator MyAnimator { get; private set; }
  11.     public bool TakingDamage { get; set; }
  12.  
  13.     [SerializeField]
  14.     public float movementSpeed;
  15.     [SerializeField]
  16.     protected int health;
  17.     [SerializeField]
  18.     private EdgeCollider2D SwordCollider;
  19.     [SerializeField]
  20.     private List<string> damageSources;
  21.  
  22.     public abstract bool IsDead { get; }
  23.  
  24.  
  25.     // Use this for initialization
  26.     public virtual void Start ()
  27.     {
  28.         facingRight = true;
  29.  
  30.         MyAnimator = GetComponent<Animator>();
  31.     }
  32.    
  33.     // Update is called once per frame
  34.     void Update ()
  35.     {
  36.        
  37.     }
  38.  
  39.    
  40.  
  41.     public abstract IEnumerator TakeDamage();
  42.  
  43.     public void ChangeDirection()
  44.     {
  45.         facingRight = !facingRight;
  46.         transform.localScale = new Vector3(transform.localScale.x * -1, 1, 1);
  47.     }
  48.  
  49.     public void MeleeAttack()
  50.     {
  51.         SwordCollider.enabled = !SwordCollider.enabled;
  52.     }
  53.  
  54.     public virtual void OnTriggerEnter2D(Collider2D other)
  55.     {
  56.         if (damageSources.Contains(other.tag))
  57.         {
  58.             StartCoroutine(TakeDamage());
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment