public override void Execute() { //If there is no formation for the enemy child cell to take, query the postionQuery to get which formation to get for the specific situation if (m_CurrentFormation == Formation.Empty) { m_AttackType = PositionQuery.Instance.GetMostSignificantAttack(); m_CurrentFormation = PositionQuery.Instance.GetDefensiveFormation(); FormationDatabase.Instance.RefreshDatabases(m_Main.GetComponent <EnemyMainFSM>().ECList); FormationDatabase.Instance.UpdateDatabaseFormation(m_CurrentFormation, m_fMainScale); if (m_CurrentFormation != Formation.QuickCircle) { FormationDatabase.Instance.CheckOtherOverlapADRange(); } } if (m_CurrentFormation == Formation.QuickCircle) { m_TargetPos = FormationDatabase.Instance.CheckCircleOverlapADRange(FormationDatabase.Instance.GetTargetFormationPosition(m_CurrentFormation, m_Child)); } if (m_CurrentFormation != Formation.QuickCircle) { m_TargetPos = FormationDatabase.Instance.GetTargetFormationPosition(m_CurrentFormation, m_Child); } }
public override void Execute() { //If there is no formation for the enemy child cell to take, query the postionQuery to get which formation to get for the specific situation if(m_CurrentFormation == Formation.Empty) { m_AttackType = PositionQuery.Instance.GetMostSignificantAttack(); m_CurrentFormation = PositionQuery.Instance.GetDefensiveFormation(); FormationDatabase.Instance.RefreshDatabases(m_Main.GetComponent<EnemyMainFSM>().ECList); FormationDatabase.Instance.UpdateDatabaseFormation(m_CurrentFormation,m_fMainScale); if(m_CurrentFormation != Formation.QuickCircle){FormationDatabase.Instance.CheckOtherOverlapADRange();} } if(m_CurrentFormation == Formation.QuickCircle){m_TargetPos = FormationDatabase.Instance.CheckCircleOverlapADRange(FormationDatabase.Instance.GetTargetFormationPosition(m_CurrentFormation, m_Child));} if(m_CurrentFormation != Formation.QuickCircle){m_TargetPos = FormationDatabase.Instance.GetTargetFormationPosition(m_CurrentFormation, m_Child);} }
private GameObject GetAttackSource(PlayerAttackMode _Attack) { for (int i = 0; i < PlayerChildFSM.childrenInAttack.Length - 1; i++) { if (PlayerChildFSM.childrenInAttack[i] == -1) { break; } if (PlayerChildFSM.playerChildPool[PlayerChildFSM.childrenInAttack[i]].attackMode == _Attack) { return(PlayerChildFSM.playerChildPool[PlayerChildFSM.childrenInAttack[i]].gameObject); } } return(null); }
private GameObject GetAttackSource(PlayerAttackMode _Attack) { for(int i = 0; i < PlayerChildFSM.childrenInAttack.Length - 1; i++) { if(PlayerChildFSM.childrenInAttack[i] == -1){break;} if(PlayerChildFSM.playerChildPool[PlayerChildFSM.childrenInAttack[i]].attackMode == _Attack) { return PlayerChildFSM.playerChildPool[PlayerChildFSM.childrenInAttack[i]].gameObject; } } return null; }
public Formation GetDefensiveFormation() { // Factors - Types of Attack, Amount of Defenders, Attack Source float QCDesirability = 0; float RCDesirability = 0; float TurtleDesirability = 0; float LadderDesirability = 0; PlayerAttackMode AttackToDefendAgainst = GetMostSignificantAttack(); int DefendingCellsCount = ECTracker.Instance.DefendCells.Count; GameObject AttackSource = GetAttackSource(AttackToDefendAgainst); if (AttackSource == null) { return(Formation.ReverseCircular); } float EnemyToAttackSourceXDifference = GameObject.Find("Enemy_Cell").transform.position.x - AttackSource.transform.position.x; if (AttackToDefendAgainst == PlayerAttackMode.BurstShot) { if (EnemyToAttackSourceXDifference >= 1.5f || EnemyToAttackSourceXDifference <= -1.5f) { if (DefendingCellsCount <= 20) { TurtleDesirability += 1; } else { RCDesirability += 1; } } else { if (DefendingCellsCount <= 20) { TurtleDesirability += 1; } else if (DefendingCellsCount <= 20 && DefendingCellsCount > 10) { RCDesirability += 1; } else { QCDesirability += 1; } } } else if (AttackToDefendAgainst == PlayerAttackMode.SwarmTarget) { if (EnemyToAttackSourceXDifference >= 1.5f || EnemyToAttackSourceXDifference <= -1.5f) { if (DefendingCellsCount <= 10) { QCDesirability += 1; } else if (DefendingCellsCount <= 20 && DefendingCellsCount > 10) { QCDesirability += 1; } else { RCDesirability += 1; } } else { QCDesirability += 1; } } else if (AttackToDefendAgainst == PlayerAttackMode.ScatterShot) { if (EnemyToAttackSourceXDifference >= 1.5f || EnemyToAttackSourceXDifference <= -1.5f) { if (DefendingCellsCount <= 10) { LadderDesirability += 1; } else if (DefendingCellsCount <= 20 && DefendingCellsCount > 10) { TurtleDesirability += 1; } else { QCDesirability += 1; } } else { TurtleDesirability += 1; } } QCDesirability *= Settings.s_fEnemyDefendQCWeight; RCDesirability *= Settings.s_fEnemyDefendRCWeight; TurtleDesirability *= Settings.s_fEnemyDefendTurtleWeight; LadderDesirability *= Settings.s_fEnemyDefendLadderWeight; float HighestDesirability = Mathf.Max(QCDesirability, Mathf.Max(RCDesirability, Mathf.Max(TurtleDesirability, LadderDesirability))); if (HighestDesirability == QCDesirability) { return(Formation.QuickCircle); } if (HighestDesirability == RCDesirability) { return(Formation.ReverseCircular); } if (HighestDesirability == TurtleDesirability) { return(Formation.Turtle); } if (HighestDesirability == LadderDesirability) { return(Formation.Ladder); } return(Formation.ReverseCircular); }