Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public abstract class Character : MonoBehaviour
- {
- public bool facingRight;
- public bool attack { get; set; }
- public Animator MyAnimator { get; private set; }
- public bool TakingDamage { get; set; }
- [SerializeField]
- public float movementSpeed;
- [SerializeField]
- protected int health;
- [SerializeField]
- private EdgeCollider2D SwordCollider;
- [SerializeField]
- private List<string> damageSources;
- public abstract bool IsDead { get; }
- // Use this for initialization
- public virtual void Start ()
- {
- facingRight = true;
- MyAnimator = GetComponent<Animator>();
- }
- // Update is called once per frame
- void Update ()
- {
- }
- public abstract IEnumerator TakeDamage();
- public void ChangeDirection()
- {
- facingRight = !facingRight;
- transform.localScale = new Vector3(transform.localScale.x * -1, 1, 1);
- }
- public void MeleeAttack()
- {
- SwordCollider.enabled = !SwordCollider.enabled;
- }
- public virtual void OnTriggerEnter2D(Collider2D other)
- {
- if (damageSources.Contains(other.tag))
- {
- StartCoroutine(TakeDamage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment