private void choose(int choice) { //open summary CharData charData = DataManager.Instance.Save.ActiveTeam.Assembly[choice]; OfferFeaturesMenu menu = new OfferFeaturesMenu(this.Bounds, this); menu.SetCurrentChar(charData); MenuManager.Instance.AddMenu(menu, true); CurrentState = ExchangeState.Viewing; ActivityTradeTeam tradeTeam = NetworkManager.Instance.Activity as ActivityTradeTeam; tradeTeam.OfferChar(charData); tradeTeam.SetReady(CurrentState); }
public override void Update(InputManager input) { Visible = true; NetworkManager.Instance.Update(); if (NetworkManager.Instance.Status == OnlineStatus.Offline) { //give offline message in a dialogue MenuManager.Instance.RemoveMenu(); MenuManager.Instance.RemoveMenu(); MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(NetworkManager.Instance.ExitMsg), false); } else { ActivityTradeTeam tradeTeam = NetworkManager.Instance.Activity as ActivityTradeTeam; if (baseMenu.CurrentState == ExchangeState.Viewing) { if (input.JustPressed(FrameInput.InputType.Confirm)) { baseMenu.CurrentState = ExchangeState.Ready; tradeTeam.SetReady(baseMenu.CurrentState); } else if (input.JustPressed(FrameInput.InputType.Cancel)) { GameManager.Instance.SE("Menu/Cancel"); MenuManager.Instance.RemoveMenu(); baseMenu.CurrentState = ExchangeState.Selecting; tradeTeam.OfferChar(null); tradeTeam.SetReady(baseMenu.CurrentState); } } else if (baseMenu.CurrentState == ExchangeState.Ready) { if (tradeTeam.CurrentState == ExchangeState.Ready) { DialogueBox dialog = MenuManager.Instance.CreateQuestion(Text.FormatKey("DLG_TRADE_TEAM_ASK", CurrentChar.BaseName, tradeTeam.OfferedChar.BaseName), () => { baseMenu.CurrentState = ExchangeState.Exchange; tradeTeam.SetReady(baseMenu.CurrentState); }, () => { baseMenu.CurrentState = ExchangeState.Viewing; tradeTeam.SetReady(baseMenu.CurrentState); }); MenuManager.Instance.AddMenu(dialog, true); } else { if (input.JustPressed(FrameInput.InputType.Cancel)) { GameManager.Instance.SE("Menu/Cancel"); baseMenu.CurrentState = ExchangeState.Viewing; tradeTeam.SetReady(baseMenu.CurrentState); } } } else if (baseMenu.CurrentState == ExchangeState.Exchange) { if (tradeTeam.CurrentState == ExchangeState.Exchange || tradeTeam.CurrentState == ExchangeState.PostTradeWait) { int chosenIndex = baseMenu.CurrentPage * baseMenu.SpacesPerPage + baseMenu.CurrentChoice; DataManager.Instance.Save.ActiveTeam.Assembly[chosenIndex] = new Character(tradeTeam.OfferedChar, DataManager.Instance.Save.ActiveTeam); DataManager.Instance.Save.RegisterMonster(DataManager.Instance.Save.ActiveTeam.Assembly[chosenIndex].BaseForm.Species); baseMenu.CurrentState = ExchangeState.PostTradeWait; tradeTeam.SetReady(baseMenu.CurrentState); } else if (tradeTeam.CurrentState != ExchangeState.Ready) { MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(Text.FormatKey("DLG_TRADE_CANCELED")), true); baseMenu.CurrentState = ExchangeState.Viewing; tradeTeam.SetReady(baseMenu.CurrentState); } } else if (baseMenu.CurrentState == ExchangeState.PostTradeWait) { if (tradeTeam.CurrentState != ExchangeState.Exchange) { DataManager.Instance.SaveMainGameState(); int chosenIndex = baseMenu.CurrentPage * baseMenu.SpacesPerPage + baseMenu.CurrentChoice; bool sendBack = CurrentChar.OriginalUUID == tradeTeam.TargetInfo.UUID; bool receiveBack = tradeTeam.OfferedChar.OriginalUUID == DataManager.Instance.Save.UUID; string sendString = Text.FormatKey(sendBack ? "DLG_TRADE_TEAM_SENT_BACK" : "DLG_TRADE_TEAM_SENT", CurrentChar.BaseName, tradeTeam.TargetInfo.Data.TeamName); string receiveString = Text.FormatKey(receiveBack ? "DLG_TRADE_TEAM_RECEIVED_BACK" : "DLG_TRADE_TEAM_RECEIVED", tradeTeam.OfferedChar.BaseName, tradeTeam.TargetInfo.Data.TeamName); tradeTeam.OfferChar(null); MenuManager.Instance.RemoveMenu(); MenuManager.Instance.ReplaceMenu(new TradeTeamMenu(chosenIndex)); GameManager.Instance.Fanfare("Fanfare/Note"); MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue( () => { MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue( () => { GameManager.Instance.Fanfare("Fanfare/JoinTeam"); MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(receiveString), false); }, Text.FormatKey("DLG_TRADE_TEAM_AND")), false); }, sendString), false); tradeTeam.SetReady(ExchangeState.Selecting); } } baseMenu.UpdateStatus(); } }