public NPCCombatTurn ChooseCombatAction(CharMgrScript npc, List <CharMgrScript> possibleTargets) { NPCCombatTurn thisTurn = new NPCCombatTurn(); //TODO: Implement logic for NPC combat action selection int actChoiceProb = Random.Range(0, 100); int subSelectionProb = Random.Range(0, 100); //Choose action based on the NPC's internal logic GameConstants.ActionOptionIndices selectedAction = this.ChooseAction(npc, actChoiceProb); //Create list that will hold targets and their priority List <PrioritizedTarget> weightedTargets = new List <PrioritizedTarget>(); List <CharMgrScript> randomTargets = new List <CharMgrScript>(); CharAbility turnAbility = new CharAbility(); /*Generate list of all targets based on a conditional statement based off the chosen action by the NPC*/ switch (selectedAction) { case (GameConstants.ActionOptionIndices.Ability): break; case (GameConstants.ActionOptionIndices.Attack): //Get reference to the npc's attack turnAbility = npc.GetBasicAttack(); //Get list of targets that the attack effects randomTargets = this.GetNPCTargets(turnAbility, CombatMgr._instance.PlayerParty); break; default: Debug.Log("Selected action was" + selectedAction.ToString() + " and NPC Turn Switch Fell through - Performing default action"); break; } //Add priorities to targets from above selection and put them into a list TODO: prioitize via function foreach (CharMgrScript target in randomTargets) { weightedTargets.Add(new PrioritizedTarget(100, target)); } //TODO perform some function to prioritize list of targets and grab the preffered one List <CharMgrScript> turnTargets = new List <CharMgrScript>(); foreach (PrioritizedTarget t in weightedTargets) { turnTargets.Add(t.target); } //Set the fields of the created turn and return it thisTurn.SelectedAbility = turnAbility; thisTurn.SelectedTargets = turnTargets; thisTurn.SelectedAction = selectedAction; //return the created turn data return(thisTurn); }
public IEnumerator TakeNPCTurn(CharMgrScript npc, List <CharMgrScript> pTargets) { Debug.Log("NPC" + CombatMgr._instance.currentTurnChar.stats.name + " is taking their turn!"); /*Select Character's action*/ NPCCombatTurn npcTurnData = NPCChoiceMgr._instance.ChooseCombatAction(npc, pTargets); //this.PerformAttack( npcTurnData.SelectedTargets, npcTurnData.ability ); this.PerformAttack(npcTurnData.SelectedAbility, npcTurnData.SelectedTargets); //this.EndCombatTurn(); yield return(null); }