public void Realizeto(Unit realizer, Unit unit, int queue = -1) { if (unit != null) { if (unit.unitlogic.Hp <= 0) { return; } } if (realizer is HeroLogic) { if (unit != null) { if (spellImage.spellTarget.HasFlag(Spell.SpellTarget.Enemy) && unit.Alien || spellImage.spellTarget.HasFlag(Spell.SpellTarget.Alies) && !unit.Alien) { return; } } HeroLogic heroLogic = (HeroLogic)realizer; heroLogic.Energy -= spellImage.EnergyCost; heroLogic.Mana -= spellImage.ManaCost; } GoReload(spellImage.ReloadTurns); spellImage.Execute(this, unit, true, queue); }
public bool HasBlocked(Unit unit = null) { if (unit != null && unit.unitObject.IsRangeUnit) { return(false); } UnitLogic unitLogic = transform.GetComponent <UnitLogic>(); if (unitLogic != null && BattleControll.battleControll.EnemyLines > 1 && unitLogic.position.y == BattleControll.battleControll.EnemyLines - 1) { if (unitLogic.position.x > 0) { if (BattleControll.battleControll.ConstainsPositionUnit(unitLogic.position.x - 1) == null) { return(false); } } if (unitLogic.position.x < BattleControll.loadedLevel.EnemyRows - 1) { if (BattleControll.battleControll.ConstainsPositionUnit(unitLogic.position.x + 1) == null) { return(false); } } UnitLogic lg = BattleControll.battleControll.ConstainsPositionUnit(unitLogic.position.x); if (lg != unitLogic && lg != null) { return(true); } } else if (unit != null && BattleControll.battleControll.EnemyLines > 1) { UnitLogic un = (transform.GetComponent <UnitLogic>()) ? transform.GetComponent <UnitLogic>() : unit.unitlogic.transform.GetComponent <UnitLogic>(); HeroLogic hr = (transform.GetComponent <HeroLogic>()) ? transform.GetComponent <HeroLogic>() : unit.unitlogic.transform.GetComponent <HeroLogic>(); // if (un.position.y == BattleControll.battleControll.EnemyLines - 1) return false; if (un != null && hr != null) { if (Math.Abs(hr.unitlogic.position - un.unitlogic.position) < .6f) { if (BattleControll.battleControll.ConstainsPositionUnit(un.position.x) == null) { return(false); } else { return(true); } } if (hr.unitlogic.position > un.unitlogic.position) { for (int i = un.position.x + 1; i < Mathf.FloorToInt(hr.unitlogic.position) + 1; i++) { if (BattleControll.battleControll.ConstainsPositionUnit(i) != null) { return(true); } } } else { for (int i = un.position.x - 1; i > Mathf.CeilToInt(hr.unitlogic.position) - 1; i--) { if (BattleControll.battleControll.ConstainsPositionUnit(i) != null) { return(true); } } } } } return(false); }
private void Awake() { heroDrag = this; myhero = transform.parent.GetComponent <HeroLogic>(); startPos = transform.parent.position; }