Example #1
0
 private void MessageResponse(string pressedButton)
 {
     HideOverlay();
     if (pressedButton == "Exit game")
     {
         DeviceInput.ExitGame(this);
     }
     else if (pressedButton == "Take me to Settings")
     {
         DeviceInput.ShowDeviceSettings();
     }
 }
Example #2
0
 public void ExitGame()
 {
     buttonCanvas.HideOverlay();
     buttonCanvas.ShowQuestionOverlay("Are you sure you want to exit?",
                                      "Exit game",
                                      "Continue playing",
                                      delegate(string pressedButton)
     {
         buttonCanvas.HideOverlay();
         if (pressedButton == "Exit game")
         {
             DeviceInput.ExitGame(buttonCanvas);
         }
         else
         {
             buttonCanvas.ShowOptionsOverlay(closeDelegate);
         }
     });
 }
Example #3
0
    public void ButtonPress()
    {
        GameObject obj = EventSystem.current.currentSelectedGameObject;

        if (obj == null)
        {
            return;
        }
        string nextCard = obj.name;

        buttonCanvas.HideOverlay();
        try
        {
            TSVLookup tsv = new TSVLookup("Cards/" + cardName);
            foreach (string condition in tsv.Lookup(nextCard))
            {
                string flags = condition;
                if (condition.IndexOf('#') != -1)
                {
                    flags = condition.Substring(0, condition.IndexOf('#'));
                }

                if (gameState.EvaluateFlags(flags))
                {
                    string coords  = tsv.Lookup(nextCard, condition)[0];
                    string message = tsv.Lookup(nextCard, condition, coords)[0];

                    if (nextCard.Contains("%"))
                    {
                        // this card loads a level
                        gameState.SetFlag("Global%LeaveMapOption", int.Parse(message));
                        if (!gameState.GetFlag(nextCard + "%End"))
                        {
                            gameState.EncodeAnalyticsLeaveMap(int.Parse(message));
                        }
                        gameState.LoadARScene(nextCard);
                    }
                    else
                    {
                        // this card displays a dialogue and (potentially) resets to a module
                        message = message.Replace("\\n", "\n");
                        while (message.IndexOf('{') != -1)
                        {
                            int i = message.IndexOf('{');
                            int j = i + 1;
                            while (j < message.Length && message[j] != '}')
                            {
                                j++;
                            }
                            string variableName = message.Substring(i + 1, j - i - 1);
                            string variableValue;
                            if (variableName == "SERIAL")
                            {
                                variableValue = DeviceInput.HumanReadableEncoding(DeviceInput.deviceSerial);
                            }
                            else
                            {
                                variableValue = "" + gameState.GetFlagIntValue(variableName);
                            }
                            if (j != message.Length)
                            {
                                j++;
                            }
                            message = message.Substring(0, i) + variableValue + message.Substring(j);
                        }
                        buttonCanvas.ShowQuestionOverlay(
                            message,
                            nextCard[0] >= '0' && nextCard[0] <= '9' ? "Proceed" : "OK",
                            nextCard[0] >= '0' && nextCard[0] <= '9' ? "Don't Proceed" : null,
                            delegate(string pressedButton)
                        {
                            buttonCanvas.HideOverlay();
                            if (pressedButton == "Proceed")
                            {
                                gameState.AppendToAnalyticsString("_" + nextCard[0]);
                                gameState.ResetFlags(gameState.GetFlagsStartingWith("M"));
                                gameState.SetFlag("Global%Module", int.Parse(nextCard));
                                gameState.SetFlag("Global%ReplayModule", int.Parse(nextCard));
                                gameState.SetFlag("Global%GameEnd", true);
                            }
                            else
                            {
                                buttonCanvas.ShowCardOverlay(cardName, previousCardName);
                            }
                        }
                            );
                    }
                    return;
                }
            }
        }
        catch (NullReferenceException)
        {
        }
        catch (UnityException)
        {
        }

        if (nextCard == "Options")
        {
            buttonCanvas.ShowOptionsOverlay(delegate()
            {
                startTime = 0;
                buttonCanvas.ShowCardOverlay(cardName, previousCardName);
            });
        }
        else if (nextCard == "Exit")
        {
            buttonCanvas.ShowQuestionOverlay("Are you sure you want to exit?",
                                             "Exit game",
                                             "Continue playing",
                                             delegate(string pressedButton)
            {
                buttonCanvas.HideOverlay();
                if (pressedButton == "Exit game")
                {
                    DeviceInput.ExitGame(buttonCanvas);
                }
                else
                {
                    startTime = 0;
                    buttonCanvas.ShowCardOverlay(cardName, previousCardName);
                }
            });
        }
        else if (nextCard != "Close")
        {
            buttonCanvas.ShowCardOverlay(nextCard, cardName);
        }
    }