//the intention, and its result to that frame //"choose the action to partake in" public IEnumerator <YieldInstruction> ProcessInput(GameAction action, Character character, ActionResult result) { //translates commands into actions if (character.AttackOnly && character.CantWalk && action.Type == GameAction.ActionType.Wait) { action = new GameAction(GameAction.ActionType.Attack, action.Dir); } ProcessDir(action.Dir, character); switch (action.Type) { case GameAction.ActionType.Dir: { //result.Success = ActionResult.ResultType.Success; break; } case GameAction.ActionType.Wait: { result.Success = ActionResult.ResultType.TurnTaken; //if it's a team character and it's team mode, wait a little while if (DataManager.Instance.Save.TeamMode && character.MemberTeam == ActiveTeam) { DungeonScene.Instance.LogMsg(Text.FormatKey("MSG_SKIP_TURN", character.GetDisplayName(false)), false, true); yield return(new WaitForFrames(GameManager.Instance.ModifyBattleSpeed(20))); } else if (character == FocusedCharacter) //add just one little wait to slow down the turn-passing when no enemies are in view { yield return(new WaitForFrames(1)); //this will cause 1-frame breaks when waiting with walking characters in view, but it's barely noticable } yield return(CoroutineManager.Instance.StartCoroutine(FinishTurn(character, true, false, false))); break; } case GameAction.ActionType.Move: { yield return(CoroutineManager.Instance.StartCoroutine(ProcessWalk(character, (action[0] == 1), result))); break; } case GameAction.ActionType.Pickup: { yield return(CoroutineManager.Instance.StartCoroutine(ProcessPickup(character, result))); break; } case GameAction.ActionType.Drop: { //takes an index argument //[0] = item slot to use (-1 for the held item) yield return(CoroutineManager.Instance.StartCoroutine(ProcessPlaceItem(character, action[0], result))); break; } case GameAction.ActionType.Give: { //[0] = item slot to use (-1 for the ground item) //[1] = who to give it to (-1 for the user) yield return(CoroutineManager.Instance.StartCoroutine(ProcessGiveItem(character, action[0], action[1], result))); break; } case GameAction.ActionType.Take: { //[0] = team slot to take from yield return(CoroutineManager.Instance.StartCoroutine(ProcessTakeItem(character, action[0], result))); break; } case GameAction.ActionType.Tile: { yield return(CoroutineManager.Instance.StartCoroutine(ProcessTileInteract(character, result))); break; } case GameAction.ActionType.Attack: { yield return(CoroutineManager.Instance.StartCoroutine(ProcessObjectInteract(character, result))); break; } case GameAction.ActionType.UseSkill: { yield return(CoroutineManager.Instance.StartCoroutine(ProcessUseSkill(character, action[0], result))); break; } case GameAction.ActionType.UseItem: { //[0] = item slot to use (-1 for held item, -2 for the ground item) //[1] = who to use it on (-1 for the user) //others: which slot to delete, //which intrinsic to have, which team member/item to send in, etc. yield return(CoroutineManager.Instance.StartCoroutine(ProcessUseItem(character, action[0], action[1], result))); break; } case GameAction.ActionType.Throw: { //[0] = item slot to use (-1 for held item, -2 for the ground item) yield return(CoroutineManager.Instance.StartCoroutine(ProcessThrowItem(character, action[0], result))); break; } case GameAction.ActionType.TeamMode: { yield return(CoroutineManager.Instance.StartCoroutine(ToggleTeamMode(result))); break; } case GameAction.ActionType.ShiftTeam: { result.Success = ActionResult.ResultType.Success; SwitchTeam(action[0]); break; } case GameAction.ActionType.SetLeader: { yield return(CoroutineManager.Instance.StartCoroutine(MakeLeader(action[0], result))); break; } case GameAction.ActionType.SendHome: { result.Success = ActionResult.ResultType.Success; yield return(CoroutineManager.Instance.StartCoroutine(SendHome(action[0]))); break; } case GameAction.ActionType.GiveUp: { result.Success = ActionResult.ResultType.Success; yield return(CoroutineManager.Instance.StartCoroutine(GameManager.Instance.EndSegment((GameProgress.ResultType)action[0]))); break; } case GameAction.ActionType.Tactics: { result.Success = ActionResult.ResultType.Success; //saves all the settings to the characters for (int ii = 0; ii < ActiveTeam.Players.Count; ii++) { int choice = action[ii]; Character target = ActiveTeam.Players[ii]; AITactic tactic = DataManager.Instance.GetAITactic(choice); if (tactic.ID != target.Tactic.ID) { target.Tactic = new AITactic(tactic); } target.Tactic.Initialize(target); } break; } case GameAction.ActionType.SetSkill: { result.Success = ActionResult.ResultType.Success; Skill skill = ActiveTeam.Players[action[0]].Skills[action[1]].Element; skill.Enabled = !skill.Enabled; break; } case GameAction.ActionType.ShiftSkill: { result.Success = ActionResult.ResultType.Success; ActiveTeam.Players[action[0]].SwitchSkills(action[1]); break; } case GameAction.ActionType.SortItems: { result.Success = ActionResult.ResultType.Success; ActiveTeam.SortItems(); break; } default: { throw new Exception("Undefined Command: " + action.Type); } } }
public IEnumerator <YieldInstruction> ProcessRescue(GameAction action, SOSMail mail) { //delete all enemies for (int ii = ZoneManager.Instance.CurrentMap.MapTeams.Count - 1; ii >= 0; ii--) { for (int jj = ZoneManager.Instance.CurrentMap.MapTeams[ii].Players.Count - 1; jj >= 0; jj--) { yield return(CoroutineManager.Instance.StartCoroutine(ZoneManager.Instance.CurrentMap.MapTeams[ii].Players[jj].DieSilent())); } for (int jj = ZoneManager.Instance.CurrentMap.MapTeams[ii].Guests.Count - 1; jj >= 0; jj--) { yield return(CoroutineManager.Instance.StartCoroutine(ZoneManager.Instance.CurrentMap.MapTeams[ii].Guests[jj].DieSilent())); } } //heal players foreach (Character character in ActiveTeam.IterateMainByRank()) { if (character.Dead) { Loc?endLoc = ZoneManager.Instance.CurrentMap.GetClosestTileForChar(character, ActiveTeam.Leader.CharLoc); if (endLoc == null) { endLoc = ActiveTeam.Leader.CharLoc; } character.CharLoc = endLoc.Value; character.HP = character.MaxHP; character.Dead = false; character.DefeatAt = ""; ZoneManager.Instance.CurrentMap.UpdateExploration(character); } } ZoneManager.Instance.CurrentMap.CurrentTurnMap.CurrentOrder.TurnIndex = 0; ZoneManager.Instance.CurrentMap.CurrentTurnMap.CurrentOrder.Faction = Faction.Player; ZoneManager.Instance.CurrentMap.CurrentTurnMap.CurrentOrder.TurnTier = 0; ZoneManager.Instance.CurrentMap.CurrentTurnMap.CurrentOrder.SkipAll = false; RegenerateTurnMap(); RemoveDeadTeams(); DataManager.Instance.Save.RescuesLeft--; //fade white back with music //remove reward item MapItem offeredItem = new MapItem((action[0] == 1), action[1]); offeredItem.HiddenValue = action[2]; if (offeredItem.Value > -1) { if (offeredItem.IsMoney) { ActiveTeam.Bank -= offeredItem.Value; } else { ItemData entry = DataManager.Instance.GetItem(offeredItem.Value); if (entry.MaxStack > 1) { List <int> itemsToTake = new List <int>(); for (int ii = 0; ii < offeredItem.HiddenValue; ii++) { itemsToTake.Add(offeredItem.Value); } ActiveTeam.TakeItems(itemsToTake); } else if (entry.UsageType == ItemData.UseType.Box) { int chosenIndex = 0; for (int ii = 0; ii < ActiveTeam.BoxStorage.Count; ii++) { if (ActiveTeam.BoxStorage[ii].ID == offeredItem.Value && ActiveTeam.BoxStorage[ii].HiddenValue == offeredItem.HiddenValue) { chosenIndex = ii; break; } } List <int> itemsToTake = new List <int>(); itemsToTake.Add(DataManager.Instance.DataIndices[DataManager.DataType.Item].Count + chosenIndex); } else { List <int> itemsToTake = new List <int>(); itemsToTake.Add(offeredItem.Value); ActiveTeam.TakeItems(itemsToTake); } } } if (DataManager.Instance.CurrentReplay == null) { yield return(CoroutineManager.Instance.StartCoroutine(ZoneManager.Instance.CurrentZone.OnRescued(mail))); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(Text.FormatKey("MSG_RESCUES_LEFT", DataManager.Instance.Save.RescuesLeft)))); yield return(new WaitForFrames(1)); } else { GameManager.Instance.SE(GraphicsManager.ReviveSE); GameManager.Instance.SetFade(true, true); yield return(CoroutineManager.Instance.StartCoroutine(GameManager.Instance.FadeIn())); int nameLength = action[3]; string name = ""; for (int ii = 0; ii < nameLength; ii++) { name += (char)action[4 + ii]; } LogMsg(Text.FormatKey("MSG_RESCUED_BY", name)); } ZoneManager.Instance.CurrentMap.NoRescue = true; yield return(CoroutineManager.Instance.StartCoroutine(ProcessTurnStart(CurrentCharacter))); }