void ProcessBuffsAndDebuffs() { //Debug.Log("ProcessBuffsAndDebuffs"); //// Wait while all previously triggered actions are complete //while (queueIsActive) //{ // Debug.Log("Queue is active"); // yield return new WaitForSeconds(1f); //} // Set Queue is active flag //queueIsActive = true; // Next actions are applicably only to active or escaping unit if ((ActiveUnitUI.LPartyUnit.UnitStatus == UnitStatus.Active) || (ActiveUnitUI.LPartyUnit.UnitStatus == UnitStatus.Escaping)) { ActiveUnitUI.HighlightActiveUnitInBattle(true); // Trigger buffs and debuffs before applying highlights // Verify if unit has buffs which should be removed, example: defense // ActiveUnitUI.DeactivateExpiredBuffs(); // Verify if unit has debuffs which should be applied, example: poison // Deactivate debuffs which has expired, example: poison duration may last 2 turns // This is checked and done after debuff trigger ActiveUnitUI.TriggerAppliedUniquePowerModifiers(); } //yield return null; }
private void DisplayActiveUnits() { PlayerTurnManager turnManager = currentPlayer.turnManager; foreach (ActiveUnitUI unitUI in unitUIs) { unitUI.ClearUnit(); } int idx = 0; foreach (KeyValuePair <Unit, ActionPoints> activeUnit in turnManager.ActiveUnits) { ActiveUnitUI unitUI = unitUIs[idx]; unitUI.SetUnit(currentPlayer, activeUnit.Key, activeUnit.Value, true); idx++; } bool hasSelectedNonActiveUnit = currentPlayer.CurrentUnit && !turnManager.ActiveUnits.ContainsKey(currentPlayer.CurrentUnit); bool hasFreeSlots = turnManager.ActiveUnits.Count < turnManager.MaxUnitsPerTurn; if (hasSelectedNonActiveUnit && hasFreeSlots) { ActiveUnitUI unitUI = unitUIs[turnManager.ActiveUnits.Count]; unitUI.SetUnit(currentPlayer, currentPlayer.CurrentUnit, new ActionPoints(true, true), false); } }
// Used in Editor in BattleScreen public void OnDefend() { Debug.Log("OnDefend"); // Get active unit party panel //PartyPanel partyPanel = ActiveUnitUI.GetUnitPartyPanel(); // Apply defense stance status //partyPanel.SetUnitDefenseBuffActive(ActiveUnitUI); ActiveUnitUI.SetDefenseBuffActive(); // proceed with default post-move actions Proceed(); }
void UpdateBattleControlPanelAccordingToUnitPossibilities() { // replaced with event //verify if party can flee //if (ActiveUnitUI.LPartyUnit.GetUnitParty().CanEscapeFromBattle) //{ // // activate flee button // SetBattleControlButtonActive("Retreat", true); //} //else //{ // // deactivate flee button // SetBattleControlButtonActive("Retreat", false); //} // reset all party inventory panels to disabled state transform.root.Find("MiscUI/LeftHeroParty/PartyInventory").gameObject.SetActive(false); transform.root.Find("MiscUI/RightHeroParty/PartyInventory").gameObject.SetActive(false); // verify if active unit is party leader if (ActiveUnitUI.LPartyUnit.IsLeader) { // activate party leader battle inventory ActiveUnitUI.GetComponentInParent <HeroPartyUI>().transform.Find("PartyInventory").gameObject.SetActive(true); } }
IEnumerator ActivateUnit() { //Debug.Log("ActivateUnit"); // Wait while all previously triggered actions are complete //while (queueIsActive) //{ // Debug.Log("Queue is active"); // yield return new WaitForSeconds(1f); //} //// Set Queue is active flag //queueIsActive = true; UnitStatus unitStatus = ActiveUnitUI.LPartyUnit.UnitStatus; switch (unitStatus) { case UnitStatus.Active: // Activate highlights of which cells can or cannot be targeted // Trigger event for all required listeners CoroutineQueueManager.Run(TriggerNewUnitHasBeenActivatedEvent()); // SetHighlight(); // verify if active unit's party panel is AI controlled => faction not equal to player's faction if (ActiveUnitUI.GetUnitPartyPanel().IsAIControlled) { // give control to battle AI CoroutineQueueManager.Run(battleAI.Act()); } else { // wait for user to act } // canActivate = true; break; case UnitStatus.Escaping: // If there were debuffs applied and unit has survived, // then unit may escape now // Escape unit CoroutineQueueManager.Run(EscapeUnit()); break; case UnitStatus.Dead: // This unit can't act any more // This can happen here due to applied debuffs // Skip post-move actions and Activate next unit // canActivate = ActivateNextUnit(); ActivateNextUnit(); break; case UnitStatus.Waiting: case UnitStatus.Escaped: Debug.LogError("This status [" + unitStatus.ToString() + "] should not be here."); break; default: Debug.LogError("Unknown unit status " + unitStatus.ToString()); break; } // Unblock mouse input // InputBlocker inputBlocker = transform.root.Find("MiscUI/InputBlocker").GetComponent<InputBlocker>(); InputBlocker.SetActive(false); Debug.Log("Unit has been activated"); yield return(null); }
IEnumerator EndBattle() { Debug.Log("EndBattle"); // set battle has ended BattleHasEnded = true; battleHasEnded.Raise(); // Remove highlight from active unit ActiveUnitUI.HighlightActiveUnitInBattle(false); //// Set exit button variable //BattleExit exitButton = GetBattleExitButton(); //// Activate exit battle button; //exitButton.gameObject.SetActive(true); // Deactivate all other battle buttons; // SetBattleControlsActive(false); // Check who win battle if (!playerPartyPanel.CanFight()) { Debug.Log("Player cannot fight anymore"); // player cannot fight anymore // verify if player has flee from battle if (playerPartyPanel.HasEscapedBattle()) { Debug.Log("Player has escaped battle"); // On exit: move it 2 tiles away from other party exitOption = ExitOption.FleePlayer; } else { Debug.Log("Player lost battle and was destroyed"); // verify if battle was with city Garnizon: // .. this is not needed here because city garnizon cannot initiate fight // On exit: destroy player party exitOption = ExitOption.DestroyPlayer; } // Show how much experience was earned by enemy party enemyPartyPanel.GrantAndShowExperienceGained(playerPartyPanel); } else { Debug.Log("Enemy cannot fight anymore"); // verify if enemy has flee from battle if (enemyPartyPanel.HasEscapedBattle()) { Debug.Log("Enemy has escaped battle"); // On exit: move it 2 tiles away from other party exitOption = ExitOption.FleeEnemy; } else { Debug.Log("Enemy lost battle and was destroyed"); // verify if battle was with city Garnizon: if (enemyPartyPanel.GetHeroParty().PartyMode == PartyMode.Garnizon) { // On exit: enter city Debug.Log("Enter city on exit"); exitOption = ExitOption.EnterCity; } else if (enemyPartyPanel.GetHeroParty().PartyMode == PartyMode.Party) { // On exit: destroy enemy party exitOption = ExitOption.DestroyEnemy; } else { Debug.LogError("Unknown party mode " + enemyPartyPanel.GetHeroParty().PartyMode.ToString()); } } // Show how much experience was earned by player party playerPartyPanel.GrantAndShowExperienceGained(enemyPartyPanel); } // Remove all buffs and debuffs enemyPartyPanel.RemoveAllBuffsAndDebuffs(); playerPartyPanel.RemoveAllBuffsAndDebuffs(); // unblock input InputBlocker.SetActive(false); yield return(null); }