/// <summary> /// Sets specified action item to be selected UI state /// </summary> /// <param name="menuItem">Menu item.</param> public void SetSelectedState(GameConstants.ActionOptionIndices menuItem, bool selectionState) { switch (menuItem) { case (GameConstants.ActionOptionIndices.Ability): break; case (GameConstants.ActionOptionIndices.Attack): //enable ui image to indicate item is selected this.ActionMenuItems[(int)GameConstants.ActionOptionIndices.Attack].SetActive(selectionState); //Enable UI indicator for first applicable target //CombatUIManager._instance.c break; case (GameConstants.ActionOptionIndices.Flee): break; case (GameConstants.ActionOptionIndices.Item): break; default: break; } }
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 void UpdateMenuFromSelection(GameConstants.ActionOptionIndices selection) { if (TestScript._instance.TestMode) { Debug.Log("UPDATE menu from selection called in Combat UI mgr!!"); } //Set the selected menu state as active CombatUIManager._instance.actMenuScript.SetSelectedState(selection, true); CharMgrScript character = CombatMgr._instance.currentTurnChar; switch (selection) { //Update menu level to reflect game state case (GameConstants.ActionOptionIndices.Attack): if (TestScript._instance.TestMode) { Debug.Log("UpdateMenuFromSelection - Entered switch and refreshed targets!!"); } //Update menu level to the match CombatUIManager._instance.MenuLevel = GameConstants.CombatMenuPage.Attack; //Update lists of targets - First check to see who is attacking, player party or enemy bool playerParty = CombatMgr._instance.PlayerParty.Contains(character); //Get list of all possible targets for moving selection UI possibleTargets = CombatMgr._instance.GetPossibleTargets(character, character.GetBasicAttack(), playerParty); //Get list of the currently higlighted targets for the start currTargets = CombatMgr._instance.GetNextTargets(character, character.GetBasicAttack(), currTargets, possibleTargets, playerParty, 1); //Turn on highlight arrows for current targets foreach (CharMgrScript c in currTargets) { c.HighlightArrowStatus(true); } break; default: break; } }
public void EndCombatTurn() { Debug.LogWarning("End Combat Turn Called! Ending: " + CombatMgr._instance.currentTurnChar.stats.CharName + "'s turn!!"); /*Check victory and loss conditions - If either is met then end combat in the appropriate fashion*/ //If all player party is down then trigger combat ending as a loss for party 1 and game over reset if vs. ai if (PlayerParty.FindAll(x => x.stats.Status != GameConstants.StatusType.Downed).Count == 0) { //TODO:Handle player loss Debug.Log("Player Loss! End Combat"); } //If all enemy party is down then trigger combat ending for party 2 as a loss for party 2 and loading the passed in scene if vs. ai else if (EnemyParty.FindAll(x => x.stats.Status != GameConstants.StatusType.Downed).Count == 0) { //TODO:Calculate xp from enemy party by adding up the exp from enemy party or some other format int winXp = 0; foreach (CharMgrScript c in EnemyParty) { winXp += c.stats.XP; } //TODO: Determine retrieved items based off enemy party script string battleEndMessage = "Victory!!"; //Party one was the victor so use their scene as the return point CombatEndData d = new CombatEndData(GameConstants.CombatEndType.Party1Win, this.PartyOneReturnScene, FoundItems, winXp, battleEndMessage); //Handle procedures for end of combat : displaying UI messages, etc. EndCombat(d); } else { //Reset button active state using the stored action menu index GameConstants.ActionOptionIndices index = (GameConstants.ActionOptionIndices)CombatUIManager._instance.actMenuScript.CurrIndex; //Reset menu selected state CombatUIManager._instance.actMenuScript.SetSelectedState(index, false); //Update menu status - if player didn't win CombatUIManager._instance.MenuLevel = GameConstants.CombatMenuPage.Action; //Wipe list of current targets from Combat UI mgr CombatUIManager._instance.currTargets.Clear(); //Wipe list of possible targets from Combat UI mgr CombatUIManager._instance.possibleTargets.Clear(); //Flag the current chracter as having acted this round - NOTE: May need to add additional initiative logic here for multiple actors, etc. this.currentTurnChar.ActedThisRound = true; //add the lists of both parties together to get a list of total combatants // List<CharMgrScript> currCombatants = this.PlayerParty; // foreach (CharMgrScript enemyChar in this.EnemyParty) // { // currCombatants.Add(enemyChar); // } //If all NON-DOWNED characters have moved this round, then reset their flags if (this.PlayerParty.FindAll(x => x.ActedThisRound == false && x.stats.Status != GameConstants.StatusType.Downed).Count == 0 && this.EnemyParty.FindAll(x => x.ActedThisRound == false && x.stats.Status != GameConstants.StatusType.Downed).Count == 0) { foreach (CharMgrScript c in this.PlayerParty) { c.ActedThisRound = false; } foreach (CharMgrScript e in this.EnemyParty) { e.ActedThisRound = false; } Debug.Log("All characters acted this round! resetting characters to act again!"); } //Turn off highlighting showing it's this character's turn this.currentTurnChar.UITurnEmphasisStatus(false); //Reset flags for which team is taking its turn - In a PVE encounter, either payer party or NPC party this._waitForNPC = false; this._waitForPlayer = false; /* **Reset flag so that next player can take their turn** */ this._turnStarted = false; } }
public GameConstants.ActionOptionIndices ChooseAction(CharMgrScript npc, int actionProb) { GameConstants.ActionOptionIndices selectedAction = GameConstants.ActionOptionIndices.Default; switch (npc.stats.BehaviorType) { case (GameConstants.EnemyCombatBehaviorType.Standard): /*Standard enemies select between attack and abilities when health is greather than half of the max. When health is under half of the max, may use a healing item or ability * For the time being, 'standard' units just attack to keep things simple */ Debug.Log("Current turn NPC is:" + npc.stats.CharName + " and has " + npc.stats.HP + "out of " + npc.stats.MaxHP + " remaining."); if (npc.stats.HP > (npc.stats.MaxHP / 2)) { //CharAbility abilitySelection = ; if (actionProb < probFavored) //Select favored action { selectedAction = GameConstants.ActionOptionIndices.Attack; //Test DEBUG OUTPUT if (TestScript._instance.TestMode) { Debug.Log("**Random number is:" + actionProb + "**Action selected:" + selectedAction.ToString()); } } else if (actionProb < probFavored + probNeutral) { selectedAction = GameConstants.ActionOptionIndices.Attack; } else if (actionProb < probFavored + probNeutral + probDisliked) { selectedAction = GameConstants.ActionOptionIndices.Attack; } else { //Strongly disliked action selectedAction = GameConstants.ActionOptionIndices.Attack; } } else { //CharAbility abilitySelection = ; if (actionProb < probFavored) { //Select favored action selectedAction = GameConstants.ActionOptionIndices.Attack; } else if (actionProb < probFavored + probNeutral) { selectedAction = GameConstants.ActionOptionIndices.Attack; } else if (actionProb < probFavored + probNeutral + probDisliked) { selectedAction = GameConstants.ActionOptionIndices.Attack; } else { //Strongly disliked action selectedAction = GameConstants.ActionOptionIndices.Attack; } } break; case (GameConstants.EnemyCombatBehaviorType.Offensive): break; case (GameConstants.EnemyCombatBehaviorType.Defensive): break; case (GameConstants.EnemyCombatBehaviorType.Healer): break; default: //No conditions met and case fell through break; } return(selectedAction); }
public NPCCombatTurn(GameConstants.ActionOptionIndices sAction, List <CharMgrScript> targets, CharAbility cAbility) { this.SelectedAction = sAction; this.SelectedTargets = targets; this.SelectedAbility = cAbility; }