private void confirmAction() { //MenuManager.Instance.RemoveMenu(); SaveCurrentChoices(); GameAction cmd = new GameAction(GameAction.ActionType.Tactics, Dir8.None); for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.Players.Count; ii++) { cmd.AddArg(TotalChoices[ii + 1].CurrentChoice); } MenuManager.Instance.NextAction = (GameManager.Instance.CurrentScene == DungeonScene.Instance) ? DungeonScene.Instance.ProcessPlayerInput(cmd) : GroundScene.Instance.ProcessInput(cmd); }
protected override IEnumerator <YieldInstruction> ProcessInput(InputManager input) { GameAction action = new GameAction(GameAction.ActionType.None, Dir8.None); if (!input[FrameInput.InputType.Skills] && input.JustPressed(FrameInput.InputType.Menu)) { GameManager.Instance.SE("Menu/Skip"); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(new MainMenu()))); } else if (input.JustPressed(FrameInput.InputType.SkillMenu)) { GameManager.Instance.SE("Menu/Skip"); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(new SkillMenu(DataManager.Instance.Save.ActiveTeam.LeaderIndex)))); } else if (input.JustPressed(FrameInput.InputType.ItemMenu)) { bool heldItems = false; foreach (Character character in DataManager.Instance.Save.ActiveTeam.Players) { if (!character.Dead && character.EquippedItem.ID > -1) { heldItems = true; break; } } if (!(DataManager.Instance.Save.ActiveTeam.GetInvCount() == 0 && !heldItems)) { GameManager.Instance.SE("Menu/Skip"); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(new ItemMenu()))); } else { GameManager.Instance.SE("Menu/Cancel"); } } else if (input.JustPressed(FrameInput.InputType.TacticMenu)) { if (DataManager.Instance.Save.ActiveTeam.Players.Count > 1) { GameManager.Instance.SE("Menu/Skip"); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(new TacticsMenu()))); } else { GameManager.Instance.SE("Menu/Cancel"); } } else if (input.JustPressed(FrameInput.InputType.TeamMenu)) { GameManager.Instance.SE("Menu/Skip"); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(new TeamMenu(false)))); } else { bool run = input[FrameInput.InputType.Run]; if (input.JustPressed(FrameInput.InputType.Attack)) { //if confirm was the only move, then the command is an attack action = new GameAction(GameAction.ActionType.Attack, Dir8.None); } else if (input.Direction != Dir8.None) { GameAction.ActionType cmdType = GameAction.ActionType.Dir; //if (FrameTick.FromFrames(input.InputTime) > FrameTick.FromFrames(2)) //TODO: ensure that it does not freeze when transitioning walk to run and vice versa cmdType = GameAction.ActionType.Move; action = new GameAction(cmdType, input.Direction); if (cmdType == GameAction.ActionType.Move) { action.AddArg(input[FrameInput.InputType.Run] ? 1 : 0); } } if (action.Type == GameAction.ActionType.None) { if (input.JustPressed(FrameInput.InputType.LeaderSwap1)) { action = new GameAction(GameAction.ActionType.SetLeader, Dir8.None, 0, 0); } else if (input.JustPressed(FrameInput.InputType.LeaderSwap2)) { action = new GameAction(GameAction.ActionType.SetLeader, Dir8.None, 1, 0); } else if (input.JustPressed(FrameInput.InputType.LeaderSwap3)) { action = new GameAction(GameAction.ActionType.SetLeader, Dir8.None, 2, 0); } else if (input.JustPressed(FrameInput.InputType.LeaderSwap4)) { action = new GameAction(GameAction.ActionType.SetLeader, Dir8.None, 3, 0); } else if (input.JustPressed(FrameInput.InputType.LeaderSwapBack)) { action = new GameAction(GameAction.ActionType.SetLeader, Dir8.None, (DataManager.Instance.Save.ActiveTeam.LeaderIndex + DataManager.Instance.Save.ActiveTeam.Players.Count - 1) % DataManager.Instance.Save.ActiveTeam.Players.Count, 0); } else if (input.JustPressed(FrameInput.InputType.LeaderSwapForth)) { action = new GameAction(GameAction.ActionType.SetLeader, Dir8.None, (DataManager.Instance.Save.ActiveTeam.LeaderIndex + 1) % DataManager.Instance.Save.ActiveTeam.Players.Count, 0); } } } if (action.Type != GameAction.ActionType.None) { yield return(CoroutineManager.Instance.StartCoroutine(ProcessInput(action))); } }
public IEnumerator <YieldInstruction> EndSegment(GameProgress.ResultType result) { if ((result == GameProgress.ResultType.Failed || result == GameProgress.ResultType.Downed || result == GameProgress.ResultType.TimedOut) && DataManager.Instance.CurrentReplay == null) { SE("Menu/Skip"); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(new MsgLogMenu()))); } BGM("", true); yield return(CoroutineManager.Instance.StartCoroutine(FadeOut(false))); yield return(new WaitForFrames(40)); if (DataManager.Instance.CurrentReplay != null) { //try to get the game state. if we can't get any states, then we must have quicksaved here if (DataManager.Instance.CurrentReplay.CurrentState < DataManager.Instance.CurrentReplay.States.Count) { GameState state = DataManager.Instance.CurrentReplay.ReadState(); DataManager.Instance.SetProgress(state.Save); LuaEngine.Instance.LoadSavedData(DataManager.Instance.Save); //notify script engine ZoneManager.LoadFromState(state.Zone); SceneOutcome = MoveToZone(DataManager.Instance.Save.NextDest); } else { //check for a rescue input GameAction rescued = null; if (DataManager.Instance.CurrentReplay.CurrentAction < DataManager.Instance.CurrentReplay.Actions.Count) { GameAction nextAction = DataManager.Instance.CurrentReplay.ReadCommand(); if (nextAction.Type == GameAction.ActionType.Rescue) { rescued = nextAction; } else//we shouldn't be hitting this point! give an error notification! { yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(Text.FormatKey("DLG_REPLAY_DESYNC")))); } } if (rescued != null) //run the action { yield return(CoroutineManager.Instance.StartCoroutine(DungeonScene.Instance.ProcessRescue(rescued, null))); } else if (DataManager.Instance.Save.Rescue != null && !DataManager.Instance.Save.Rescue.Rescuing) { //resuming a game that was just rescued DataManager.Instance.ResumePlay(DataManager.Instance.CurrentReplay.RecordDir, DataManager.Instance.CurrentReplay.QuicksavePos); DataManager.Instance.CurrentReplay = null; DataManager.Instance.Loading = DataManager.LoadMode.None; SOSMail mail = DataManager.Instance.Save.Rescue.SOS; //and then run the action rescued = new GameAction(GameAction.ActionType.Rescue, Dir8.None); rescued.AddArg(mail.OfferedItem.IsMoney ? 1 : 0); rescued.AddArg(mail.OfferedItem.Value); rescued.AddArg(mail.OfferedItem.HiddenValue); rescued.AddArg(mail.RescuedBy.Length); for (int ii = 0; ii < mail.RescuedBy.Length; ii++) { rescued.AddArg(mail.RescuedBy[ii]); } DataManager.Instance.LogPlay(rescued); yield return(CoroutineManager.Instance.StartCoroutine(DungeonScene.Instance.ProcessRescue(rescued, mail))); } else { if (DataManager.Instance.Loading == DataManager.LoadMode.Rescuing) { if (result == GameProgress.ResultType.Rescue) { //mark as verified RescueMenu menu = (RescueMenu)TitleScene.TitleMenuSaveState[TitleScene.TitleMenuSaveState.Count - 1]; menu.Verified = true; } //default is failure to verify yield return(CoroutineManager.Instance.StartCoroutine(EndReplay())); } else if (DataManager.Instance.Loading == DataManager.LoadMode.Loading) { //the game accepts loading into a file that has been downed, or passed its section with nothing else DataManager.Instance.ResumePlay(DataManager.Instance.CurrentReplay.RecordDir, DataManager.Instance.CurrentReplay.QuicksavePos); DataManager.Instance.CurrentReplay = null; SetFade(true, false); DataManager.Instance.Loading = DataManager.LoadMode.None; bool rescuing = DataManager.Instance.Save.Rescue != null && DataManager.Instance.Save.Rescue.Rescuing; //if failed, just show the death plaque //if succeeded, run the script that follows. SceneOutcome = ZoneManager.Instance.CurrentZone.OnExitSegment(result, rescuing); } else //we've reached the end of the replay { yield return(CoroutineManager.Instance.StartCoroutine(EndReplay())); } } } } else { string dateDefeated = String.Format("{0:yyyy-MM-dd}", DateTime.Now); bool rescue = false; if (result == GameProgress.ResultType.Downed && DataManager.Instance.Save.RescuesLeft > 0) { yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(MenuManager.Instance.CreateQuestion(Text.FormatKey("DLG_RESCUE_ASK"), () => { rescue = true; }, () => { })))); } //trigger the end-segment script if (rescue) { DataManager.Instance.SuspendPlay(); GameState state = DataManager.Instance.LoadMainGameState(); SOSMail awaiting = new SOSMail(DataManager.Instance.Save, new ZoneLoc(ZoneManager.Instance.CurrentZoneID, ZoneManager.Instance.CurrentMapID), ZoneManager.Instance.CurrentMap.Name, dateDefeated, Versioning.GetVersion()); state.Save.Rescue = new RescueState(awaiting, false); DataManager.Instance.SaveGameState(state); DataManager.SaveRescueMail(DataManager.RESCUE_OUT_PATH + DataManager.SOS_PATH, state.Save.Rescue.SOS, true); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(Text.FormatKey("DLG_RESCUE_INFO_1")))); yield return(new WaitForFrames(1)); MenuBase.Transparent = false; SceneOutcome = RestartToTitle(); yield return(CoroutineManager.Instance.StartCoroutine(DungeonScene.Instance.SuspendGame())); } else { bool rescuing = DataManager.Instance.Save.Rescue != null && DataManager.Instance.Save.Rescue.Rescuing; SceneOutcome = ZoneManager.Instance.CurrentZone.OnExitSegment(result, rescuing); } } }