public void UpdateStatus() { ActivityGetHelp getHelp = NetworkManager.Instance.Activity as ActivityGetHelp; switch (CurrentState) { case ExchangeRescueState.Communicating: yourStatus.Text = Text.FormatKey("MENU_RESCUE_STATUS_COMMUNICATING"); break; case ExchangeRescueState.SOSReady: yourStatus.Text = Text.FormatKey("MENU_RESCUE_STATUS_SOS_CONFIRMING"); break; case ExchangeRescueState.SOSTrading: yourStatus.Text = Text.FormatKey("MENU_RESCUE_STATUS_SOS_RECEIVING"); break; case ExchangeRescueState.AOKReady: yourStatus.Text = Text.FormatKey("MENU_RESCUE_STATUS_AOK_CONFIRMING"); break; case ExchangeRescueState.AOKTrading: yourStatus.Text = Text.FormatKey("MENU_RESCUE_STATUS_AOK_SENDING"); break; case ExchangeRescueState.Completed: yourStatus.Text = Text.FormatKey("MENU_RESCUE_STATUS_WAITING"); break; } }
private void ActivityAction(ActivityType activityType) { MenuManager.Instance.RemoveMenu(); MenuManager.Instance.RemoveMenu(); OnlineActivity activity = null; switch (activityType) { case ActivityType.SendHelp: activity = new ActivitySendHelp(targetServer, DataManager.Instance.Save.CreateContactInfo(), targetContact); break; case ActivityType.GetHelp: activity = new ActivityGetHelp(targetServer, DataManager.Instance.Save.CreateContactInfo(), targetContact); break; case ActivityType.TradeTeam: activity = new ActivityTradeTeam(targetServer, DataManager.Instance.Save.CreateContactInfo(), targetContact); break; case ActivityType.TradeItem: activity = new ActivityTradeItem(targetServer, DataManager.Instance.Save.CreateContactInfo(), targetContact); break; case ActivityType.TradeMail: activity = new ActivityTradeMail(targetServer, DataManager.Instance.Save.CreateContactInfo(), targetContact); break; } action(activity); }
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(); if (CurrentState != ExchangeRescueState.Completed) { MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(NetworkManager.Instance.ExitMsg), false); } } else { if (CurrentState == ExchangeRescueState.Communicating) { //first send the SOS SOSMail mail = DataManager.Instance.Save.Rescue.SOS; CurrentState = ExchangeRescueState.SOSReady; ActivityGetHelp getHelp = NetworkManager.Instance.Activity as ActivityGetHelp; getHelp.OfferMail(mail); getHelp.SetReady(CurrentState); } else if (CurrentState == ExchangeRescueState.SOSReady) { //wait for other party's ready to receive SOS or ready to send AOK ActivityGetHelp getHelp = NetworkManager.Instance.Activity as ActivityGetHelp; if (getHelp.CurrentState == ExchangeRescueState.SOSReady) { //ready to receive SOS DialogueBox dialog = MenuManager.Instance.CreateQuestion(Text.FormatKey("DLG_RESCUE_SEND_SOS_ASK", getHelp.TargetInfo.Data.TeamName), () => { CurrentState = ExchangeRescueState.SOSTrading; getHelp.SetReady(CurrentState); }, () => { //just disconnect MenuManager.Instance.RemoveMenu(); NetworkManager.Instance.Disconnect(); }); MenuManager.Instance.AddMenu(dialog, true); } else if (getHelp.CurrentState == ExchangeRescueState.AOKReady) { //ready to receive AOK SetAOK(getHelp.OfferedMail); CurrentState = ExchangeRescueState.AOKReady; getHelp.SetReady(CurrentState); string baseAskString = (getHelp.OfferedMail.OfferedItem.Value > -1) ? "DLG_RESCUE_GET_AOK_ASK_REWARD" : "DLG_RESCUE_GET_AOK_ASK"; DialogueBox dialog = MenuManager.Instance.CreateQuestion(Text.FormatKey(baseAskString, getHelp.TargetInfo.Data.TeamName), () => { CurrentState = ExchangeRescueState.AOKTrading; getHelp.SetReady(CurrentState); }, () => { //just disconnect MenuManager.Instance.RemoveMenu(); NetworkManager.Instance.Disconnect(); }); MenuManager.Instance.AddMenu(dialog, true); } else if (getHelp.CurrentState == ExchangeRescueState.Completed) { //TODO: signal that an SOS has already been sent //MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(Text.FormatKey("DLG_RESCUE_SEND_SOS_ALREADY", getHelp.TargetInfo.Data.TeamName)), false); CurrentState = ExchangeRescueState.Completed; getHelp.SetReady(CurrentState); } } else if (CurrentState == ExchangeRescueState.SOSTrading) { //wait for the other party to also be SOSTrading or Completed ActivityGetHelp getHelp = NetworkManager.Instance.Activity as ActivityGetHelp; if (getHelp.CurrentState == ExchangeRescueState.SOSTrading || getHelp.CurrentState == ExchangeRescueState.Completed) { MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(Text.FormatKey("DLG_RESCUE_SEND_SOS", getHelp.TargetInfo.Data.TeamName)), false); CurrentState = ExchangeRescueState.Completed; getHelp.SetReady(CurrentState); } //the other possible outcome is that they just disconnect } else if (CurrentState == ExchangeRescueState.AOKTrading) { //wait for the other party to also be AOKTrading or Completed ActivityGetHelp getHelp = NetworkManager.Instance.Activity as ActivityGetHelp; if (getHelp.CurrentState == ExchangeRescueState.AOKTrading || getHelp.CurrentState == ExchangeRescueState.Completed) { //save the AOK file DataManager.SaveRescueMail(PathMod.NoMod(DataManager.RESCUE_IN_PATH + DataManager.AOK_FOLDER), getHelp.OfferedMail, false); if (getHelp.OfferedMail.OfferedItem.Value > -1) { //deduct your reward and save it to the base file GameState state = DataManager.Instance.LoadMainGameState(); state.Save.Rescue.SOS.OfferedItem = getHelp.OfferedMail.OfferedItem; DataManager.Instance.SaveGameState(state); MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(Text.FormatKey("DLG_RESCUE_GOT_AOK", getHelp.TargetInfo.Data.TeamName), Text.FormatKey("DLG_RESCUE_GOT_AOK_REWARD")), false); } else { MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(Text.FormatKey("DLG_RESCUE_GOT_AOK", getHelp.TargetInfo.Data.TeamName)), false); } CurrentState = ExchangeRescueState.Completed; getHelp.SetReady(CurrentState); } //the other possible outcome is that they just disconnect } else if (CurrentState == ExchangeRescueState.Completed) { ActivityGetHelp getHelp = NetworkManager.Instance.Activity as ActivityGetHelp; //wait for the other party to also be Completed to leave the transaction if (getHelp.CurrentState == ExchangeRescueState.Completed) { MenuManager.Instance.RemoveMenu(); NetworkManager.Instance.Disconnect(); } } UpdateStatus(); } }