// Use this for initialization void Start() { if (thisUnit == null) { thisUnit = GetComponent <unitInterface>(); } }
private void OnTriggerEnter2D(Collider2D other) { myTags tags = other.GetComponent <myTags>(); if (tags != null) { if (tags.isWall) { Destroy(gameObject); } if (tags.team != team && tags.team != 0) { unitInterface otherInterface = other.GetComponent <unitInterface>(); Vector2 hitDirection = transform.position - otherInterface.transform.position; int blocked = otherInterface.applyHit(hitDirection); if (blocked == 1) { otherInterface.resourceHandler.applyShieldDamage((int)(damage * blockFactor)); } else if (blocked == 0) { otherInterface.resourceHandler.applyShieldDamage(damage); } Instantiate(hitSprite, other.transform.position, other.transform.rotation); Destroy(gameObject); } } }
public bool use(unitInterface unitI) { sustained = 1; if (cd <= 0 && unitI.actionLevel < interuptPriority) { if (manaCost == 0 || unitI.resourceHandler.mana.use(manaCost)) { begin(unitI); if (unitI.currentAction != null) { unitI.currentAction.interrupt(); } unitI.currentAction = this; unitI.actionLevel = interuptPriority; return(true); } } return(false); }
private void OnTriggerStay2D(Collider2D other) { if (r <= 0 && unit.actionLevel < actionPriority) { unitInterface otherInterface = other.GetComponent <unitInterface>(); if (otherInterface != null && otherInterface.tags.team != unit.tags.team) { int blocked = otherInterface.applyHit(transform.position - other.transform.position); if (blocked == 1) { otherInterface.resourceHandler.applyDamage(shieldDamage, hpDamage); } else if (blocked == 0) { otherInterface.resourceHandler.applyHpDamage(hpDamage); } Instantiate(slashSprite, other.transform.position, other.transform.rotation); r = recharge; } } }
public void begin(unitInterface unitI) { unit = unitI; stage = startup + active + recovery; cd = coolDown + startup + active + recovery; }
public void setUnit(unitInterface unitI) { unit = unitI; }