void ClickTileOrUI(bool left) { var accepter = FindInputAccepter(); if (accepter == null) { if (unitCursor.HasFoundTile()) { AbstractAttack attack = null; if (left) { attack = new RoundAttack(unitCursor.GetSpawnPoint(false)); } else { attack = new StraightAttack(unitCursor.GetSpawnPoint(false)); } if (attack.GetComsumption() <= GameDataManager.Instance.UnitPower) { mainCharacter.AnimateAttack(); attack.Animate(unitCursor.GetSpawnPoint(false)); ObjectManager.Instance.WaveManager.enemies .Where(e => attack.IsInRange(e.transform.position)) .ToList() .ForEach(e => e.Damaged(attack.GetDamage())); GameDataManager.Instance.UnitPower -= attack.GetComsumption(); } } } else { accepter.Execute(); } }
private void HandleAttack() { if (attacks == null || attacks.Length == 0) { return; } if (isAttacking || IsStunned()) { // player is already attacking or is stunned, nothing to do return; } AbstractAttack attack = null; if (superAttackPressed && attacks[2].CanUseAttack()) { attack = attacks[2]; } else if (attack1Pressed && attacks[0].CanUseAttack()) { attack = attacks[0]; } else if (attack2Pressed && attacks[1].CanUseAttack()) { attack = attacks[1]; } if (attack != null) { StartCoroutine(DoAttack(attack)); } }
void Start() { attackList = new AbstractAttack[7]; attackList[0] = crouchingAttack; attackList[1] = standingNeutral; attackList[2] = standingAir; attackList[3] = airNeutral; attackList[4] = airBack; attackList[5] = airFront; attackList[6] = airDown; if (useActorForce) { forceType = GetComponent <Actor>().forceType; } for (int i = 0; i < attackList.Length; i++) { _tempAtk = (AbstractAttack)Instantiate(attackList[i], this.transform.position, Quaternion.identity) as AbstractAttack; _tempAtk.transform.parent = this.transform; _tempAtk.forceType = forceType; attackList[i] = _tempAtk; } }
/// <summary> /// Method goes through all of character's attacks and picks the first usable attack. /// </summary> private void PickAttackToUse() { if (attacks == null) { return; } foreach (AbstractAttack attack in attacks) { if (attack.CanUseAttack()) { //nextAttackToUse = attack; //break; if (attack.IsInAttackingRange()) { nextAttackToUse = attack; break; } else { Debug.Log(name + " can use attack " + attack.name + " but the attack is not in range."); } } else { Debug.Log(name + " can't use attack " + attack.name); } } }
/// <summary> /// Coroutine which uses the attack, waits for the attack animation to finish and /// then re-sets the nextAttack object. /// This way, enemy starts moving again only after the attack is finished. /// </summary> /// <returns></returns> private IEnumerator UseAndResetAttack() { attacking = true; yield return(StartCoroutine(nextAttackToUse.UseAttack(this))); Debug.Log("Attacking coroutine finished."); nextAttackToUse = null; attacking = false; }
/// <summary> /// Coroutine which will raise attacking flag, executes actual attack /// and after its finished, resets the attacking flag again. /// </summary> /// <param name="attack">Attack to execute.</param> /// <returns></returns> private IEnumerator DoAttack(AbstractAttack attack) { isAttacking = true; yield return(StartCoroutine(attack.UseAttack(this))); Debug.Log("Player attack finished."); isAttacking = false; killedEnemies += attack.GetTargetKillCount(); Debug.Log("Killed enemies:" + killedEnemies); }
public AbstractAttack CreateAttack(Vector3 pos, AttackType type) { AbstractAttack attack = null; switch (type) { case AttackType.Round: attack = new RoundAttack(pos); break; case AttackType.Straight: attack = new StraightAttack(pos); break; } return(attack); }
public override void OnSwitch() { if (GetFSM().CurrentAttack != null) { m_time = GetFSM().CurrentAttack.GetStateBlockTime(); m_attackReference = GetFSM().CurrentAttack; m_attackStart = true; if (m_time == 0.0f) { m_noTimer = true; } else { GetFSM().BlockStateSwitch(m_time); } } else { GetFSM().GoToPreviousState(true, 1); } }
private void Awake() { attack = GetComponent <AbstractAttack>(); }