public override void EvaluateAttack() { if (character is Hero) { bool canAttackEnemy = false; if (IsInAttackRange()) { canAttackEnemy = true; } else if (character.currentTarget != null) { Melee enemyMelee = character.currentTarget.GetComponent <Melee>(); if (enemyMelee) { canAttackEnemy = enemyMelee.canAttackHero(); } } Game.game.inflictDamage(character.currentTarget, this, (float)character.getCriticalPoints() / 100.0f, !canAttackEnemy); if (canAttackEnemy) { character.currentTarget.onAttackFrom(character, this); } else { (character as Hero).abortAttackChain = true; } } }
public override void attackUpdate() { if (character is Hero) { Hero hero = character as Hero; if (currentState != AttackStates.ATTACKING) { if (hero.currentTarget != null && hero.currentTarget.needsToBeInTailToBeingAttacked && !hero.isFirstInTail(hero.currentTarget) && !hero.currentTarget.feetsAreInAValidAttackArea()) { currentState = Attack.AttackStates.IDLE; return; } float dx = hero.currentTarget.getFeetPosition().x - hero.getFeetPosition().x; SoulAvenger.Character.FACING facing = (dx <= 0.0f)?SoulAvenger.Character.FACING.LEFT:SoulAvenger.Character.FACING.RIGHT; if (hero.currentFacing != facing) { hero.currentFacing = facing; } bool canAttackEnemy = false; if (IsInAttackRange()) { canAttackEnemy = true; } else { if (hero.currentTarget != null) { Melee enemyMelee = hero.currentTarget.GetComponent <Melee>(); if (enemyMelee) { canAttackEnemy = enemyMelee.canAttackHero(); } } } if (canAttackEnemy) { if (rechargeTimer <= 0.0f && currentState != AttackStates.ATTACKING) { currentState = AttackStates.ATTACKING; } } else if (!hero.hasReachTarget) { float speed = character.getSpeed(); bool hasMoved = hero.moveToTarget(hero.currentTarget, speed, !hero.currentTarget.canBeAttackedOutsideArena); currentState = (speed > 0.0f && hasMoved)?AttackStates.RUNNING:AttackStates.IDLE; if (hasMoved == false) { hero.hasReachTarget = true; } } } else { float dx = hero.currentTarget.getFeetPosition().x - hero.getFeetPosition().x; SoulAvenger.Character.FACING facing = (dx <= 0.0f)?SoulAvenger.Character.FACING.LEFT:SoulAvenger.Character.FACING.RIGHT; if (hero.currentFacing != facing) { hero.currentFacing = facing; } } } else { if (updateDelegates[(int)_currentMeleeState] != null) { updateDelegates[(int)_currentMeleeState](); } } }