Exemplo n.º 1
0
        public DialogueBox CreateMultiQuestion(MonsterID speaker, string speakerName, EmoteStyle emotion,
                                               string msg, bool sound, DialogueChoice[] choices, int defaultChoice, int cancelChoice)
        {
            string[] break_str = Regex.Split(msg, "\\[br\\]", RegexOptions.IgnoreCase);

            DialogueBox box = new QuestionDialog(break_str[break_str.Length - 1], sound, choices, defaultChoice, cancelChoice);

            box.SetSpeaker(speaker, speakerName, emotion);

            if (break_str.Length > 1)
            {
                string[] pre_str = new string[break_str.Length - 1];
                Array.Copy(break_str, pre_str, pre_str.Length);
                return(CreateDialogue(speaker, speakerName, emotion, sound, () => { AddMenu(box, false); }, -1, pre_str));
            }
            else
            {
                return(box);
            }
        }
Exemplo n.º 2
0
        public DialogueBox CreateQuestion(MonsterID speaker, string speakerName, EmoteStyle emotion,
                                          string msg, bool sound, Action yes, Action no, bool defaultNo)
        {
            string[] break_str = Regex.Split(msg, "\\[br\\]", RegexOptions.IgnoreCase);

            DialogueChoice[] choices = new DialogueChoice[2];
            choices[0] = new DialogueChoice(Text.FormatKey("DLG_CHOICE_YES"), yes);
            choices[1] = new DialogueChoice(Text.FormatKey("DLG_CHOICE_NO"), no);

            DialogueBox box = new QuestionDialog(break_str[break_str.Length - 1], sound, choices, defaultNo ? 1 : 0, 1);

            box.SetSpeaker(speaker, speakerName, emotion);

            if (break_str.Length > 1)
            {
                string[] pre_str = new string[break_str.Length - 1];
                Array.Copy(break_str, pre_str, pre_str.Length);
                return(CreateDialogue(speaker, speakerName, emotion, sound, () => { AddMenu(box, false); }, -1, pre_str));
            }
            else
            {
                return(box);
            }
        }
Exemplo n.º 3
0
        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)
                {
                    //wait for an SOS
                    ActivitySendHelp sendHelp = NetworkManager.Instance.Activity as ActivitySendHelp;

                    if (sendHelp.CurrentState == ExchangeRescueState.SOSReady)
                    {
                        SOSMail sos = sendHelp.OfferedMail;

                        aokPath = DataManager.FindRescueMail(DataManager.RESCUE_OUT_PATH + DataManager.AOK_PATH, sos, DataManager.AOK_EXTENSION);

                        if (aokPath == null)
                        {
                            //no aok found; ask to receive SOS
                            //TODO: check to see if SOS has already been sent
                            //it needs to check if the reward is the same.
                            SetSOS(sendHelp.OfferedMail);

                            CurrentState = ExchangeRescueState.SOSReady;
                            sendHelp.SetReady(CurrentState);

                            QuestionDialog dialog = MenuManager.Instance.CreateQuestion(Text.FormatKey("DLG_RESCUE_RECEIVE_SOS_ASK", sendHelp.TargetInfo.Data.TeamName), () =>
                            {
                                CurrentState = ExchangeRescueState.SOSTrading;
                                sendHelp.SetReady(CurrentState);
                            }, () =>
                            {
                                //just disconnect
                                MenuManager.Instance.RemoveMenu();
                                NetworkManager.Instance.Disconnect();
                            });
                            MenuManager.Instance.AddMenu(dialog, true);
                        }
                        else
                        {
                            //aok found; ask to send AOK
                            aok = (AOKMail)DataManager.LoadRescueMail(aokPath);
                            SetAOK(aok);

                            CurrentState = ExchangeRescueState.AOKReady;

                            sendHelp.OfferMail(aok);
                            sendHelp.SetReady(CurrentState);
                        }
                    }
                }
                else if (CurrentState == ExchangeRescueState.SOSTrading)
                {
                    //wait for the other party to also be SOSTrading or Completed
                    ActivitySendHelp sendHelp = NetworkManager.Instance.Activity as ActivitySendHelp;

                    if (sendHelp.CurrentState == ExchangeRescueState.SOSTrading || sendHelp.CurrentState == ExchangeRescueState.Completed)
                    {
                        //save the SOS mail
                        DataManager.SaveRescueMail(DataManager.RESCUE_IN_PATH + DataManager.SOS_PATH, sendHelp.OfferedMail, false);

                        MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(Text.FormatKey("DLG_RESCUE_RECEIVE_SOS", sendHelp.TargetInfo.Data.TeamName)), false);
                        CurrentState = ExchangeRescueState.Completed;
                        sendHelp.SetReady(CurrentState);
                    }
                    //the other possible outcome is that they just disconnect
                }
                else if (CurrentState == ExchangeRescueState.AOKReady)
                {
                    //wait for other party's ready to receive SOS or ready to send AOK
                    ActivitySendHelp sendHelp = NetworkManager.Instance.Activity as ActivitySendHelp;

                    if (sendHelp.CurrentState == ExchangeRescueState.AOKReady)
                    {
                        //ready to receive SOS
                        string         baseAskString = (aok.OfferedItem.Value > -1) ? "DLG_RESCUE_SEND_AOK_ASK_REWARD" : "DLG_RESCUE_SEND_AOK_ASK";
                        QuestionDialog dialog        = MenuManager.Instance.CreateQuestion(Text.FormatKey(baseAskString, sendHelp.TargetInfo.Data.TeamName), () =>
                        {
                            CurrentState = ExchangeRescueState.AOKTrading;
                            sendHelp.SetReady(CurrentState);
                        }, () =>
                        {
                            //just disconnect
                            MenuManager.Instance.RemoveMenu();
                            NetworkManager.Instance.Disconnect();
                        });
                        MenuManager.Instance.AddMenu(dialog, true);
                    }
                    //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
                    ActivitySendHelp sendHelp = NetworkManager.Instance.Activity as ActivitySendHelp;

                    if (sendHelp.CurrentState == ExchangeRescueState.AOKTrading || sendHelp.CurrentState == ExchangeRescueState.Completed)
                    {
                        //delete the AOK file
                        File.Delete(aokPath);

                        if (aok.OfferedItem.Value > -1)
                        {
                            if (aok.OfferedItem.IsMoney)
                            {
                                DataManager.Instance.Save.ActiveTeam.Bank += aok.OfferedItem.Value;
                            }
                            else
                            {
                                List <InvItem> itemsToStore = new List <InvItem>();
                                itemsToStore.Add(aok.OfferedItem.MakeInvItem());
                                DataManager.Instance.Save.ActiveTeam.StoreItems(itemsToStore);
                            }
                            DataManager.Instance.SaveMainGameState();

                            MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(Text.FormatKey("DLG_RESCUE_SEND_AOK", sendHelp.TargetInfo.Data.TeamName), Text.FormatKey("DLG_RESCUE_SEND_AOK_REWARD")), false);
                        }
                        else
                        {
                            MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(Text.FormatKey("DLG_RESCUE_SEND_AOK", sendHelp.TargetInfo.Data.TeamName)), false);
                        }
                        CurrentState = ExchangeRescueState.Completed;
                        sendHelp.SetReady(CurrentState);
                    }
                    //the other possible outcome is that they just disconnect
                }
                else if (CurrentState == ExchangeRescueState.Completed)
                {
                    ActivitySendHelp sendHelp = NetworkManager.Instance.Activity as ActivitySendHelp;
                    //wait for the other party to also be Completed to leave the transaction
                    if (sendHelp.CurrentState == ExchangeRescueState.Completed)
                    {
                        MenuManager.Instance.RemoveMenu();
                        NetworkManager.Instance.Disconnect();
                    }
                }

                UpdateStatus();
            }
        }
Exemplo n.º 4
0
        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
            {
                ActivityTradeItem tradeItem = NetworkManager.Instance.Activity as ActivityTradeItem;

                if (baseMenu.CurrentState == ExchangeState.Viewing)
                {
                    if (input.JustPressed(FrameInput.InputType.Confirm))
                    {
                        baseMenu.CurrentState = ExchangeState.Ready;

                        tradeItem.SetReady(baseMenu.CurrentState);
                    }
                    else if (input.JustPressed(FrameInput.InputType.Cancel))
                    {
                        GameManager.Instance.SE("Menu/Cancel");
                        MenuManager.Instance.RemoveMenu();

                        baseMenu.CurrentState = ExchangeState.Selecting;

                        tradeItem.OfferItems(new List <InvItem>());
                        tradeItem.SetReady(baseMenu.CurrentState);
                    }
                }
                else if (baseMenu.CurrentState == ExchangeState.Ready)
                {
                    if (tradeItem.CurrentState == ExchangeState.Ready)
                    {
                        QuestionDialog dialog = MenuManager.Instance.CreateQuestion(Text.FormatKey("DLG_TRADE_ITEM_ASK"), () =>
                        {
                            baseMenu.CurrentState = ExchangeState.Exchange;
                            tradeItem.SetReady(baseMenu.CurrentState);
                        }, () =>
                        {
                            baseMenu.CurrentState = ExchangeState.Viewing;
                            tradeItem.SetReady(baseMenu.CurrentState);
                        });
                        MenuManager.Instance.AddMenu(dialog, true);
                    }
                    else
                    {
                        if (input.JustPressed(FrameInput.InputType.Cancel))
                        {
                            GameManager.Instance.SE("Menu/Cancel");

                            baseMenu.CurrentState = ExchangeState.Viewing;
                            tradeItem.SetReady(baseMenu.CurrentState);
                        }
                    }
                }
                else if (baseMenu.CurrentState == ExchangeState.Exchange)
                {
                    if (tradeItem.CurrentState == ExchangeState.Exchange || tradeItem.CurrentState == ExchangeState.PostTradeWait)
                    {
                        int chosenIndex = baseMenu.CurrentPage * baseMenu.SpacesPerPage + baseMenu.CurrentChoice;

                        List <int> offerItems = new List <int>();
                        foreach (InvItem item in CurrentOffer)
                        {
                            offerItems.Add(item.ID);
                        }
                        DataManager.Instance.Save.ActiveTeam.TakeItems(offerItems);

                        DataManager.Instance.Save.ActiveTeam.StoreItems(tradeItem.OfferedItems);

                        baseMenu.CurrentState = ExchangeState.PostTradeWait;
                        tradeItem.SetReady(baseMenu.CurrentState);
                    }
                    else if (tradeItem.CurrentState != ExchangeState.Ready)
                    {
                        MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(Text.FormatKey("DLG_TRADE_CANCELED")), true);

                        baseMenu.CurrentState = ExchangeState.Viewing;
                        tradeItem.SetReady(baseMenu.CurrentState);
                    }
                }
                else if (baseMenu.CurrentState == ExchangeState.PostTradeWait)
                {
                    if (tradeItem.CurrentState != ExchangeState.Exchange)
                    {
                        DataManager.Instance.SaveMainGameState();

                        int chosenIndex = baseMenu.CurrentPage * baseMenu.SpacesPerPage + baseMenu.CurrentChoice;

                        tradeItem.OfferItems(new List <InvItem>());

                        MenuManager.Instance.RemoveMenu();
                        MenuManager.Instance.ReplaceMenu(new TradeItemMenu(chosenIndex));

                        GameManager.Instance.Fanfare("Fanfare/Treasure");
                        MenuManager.Instance.AddMenu(MenuManager.Instance.CreateDialogue(Text.FormatKey("DLG_TRADE_ITEM_COMPLETE")), false);

                        tradeItem.SetReady(ExchangeState.Selecting);
                    }
                }

                baseMenu.UpdateStatus();
            }
        }
Exemplo n.º 5
0
        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
                        QuestionDialog 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";

                        QuestionDialog 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(DataManager.RESCUE_IN_PATH + DataManager.AOK_PATH, 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();
            }
        }
Exemplo n.º 6
0
        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)
                    {
                        QuestionDialog 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);

                        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();
            }
        }