Esempio n. 1
0
    public bool ProcessMapSceneModuleIncrement(bool scenesAvailable)
    {
        // if not in edit mode and there are no active waypoints, we have reached the end of a module
        // and should increment the module number and reread the waypoints
        if (scenesAvailable)
        {
            hasIncrementedModuleNumber = false;
        }
        else if (!hasIncrementedModuleNumber)
        {
            hasIncrementedModuleNumber = true;
            AppendToAnalyticsString("_");
            SetFlag("Global%Module", GetFlagIntValue("Global%Module") + 1);
        }
        else
        {
            hasIncrementedModuleNumber = false;
            Debug.LogError("No activatable scenes for module " + GetFlagIntValue("Global%Module") + "!");

            // decrement the module number that we have erroneously incremented
            if (GetFlagIntValue("Global%Module") == GetFlagIntValue("Global%HighestModule"))
            {
                SetFlag("Global%HighestModule", GetFlagIntValue("Global%HighestModule") - 1);
            }
            SetFlag("Global%Module", GetFlagIntValue("Global%Module") - 1);
        }
        if (!hasIncrementedModuleNumber)
        {
            Debug.Log("Analytics: " + DeviceInput.HumanReadableEncoding(PlayerPrefs.GetString("AnalyticsCode")));
        }
        return(hasIncrementedModuleNumber);
    }
Esempio n. 2
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);
        }
    }
Esempio n. 3
0
    private void Start()
    {
        gameState = GameObject.Find("GameState").GetComponent <GameStateBehaviour>();
        if (GameObject.FindWithTag("AREngine") != null)
        {
            engine = GameObject.FindWithTag("AREngine").GetComponent <AREngineBehaviour>();
        }

        GameObject.Find("Panel/AppDetails/AppIconMask/AppIcon").GetComponent <UnityEngine.UI.Image>().overrideSprite = Resources.Load <Sprite>("AppIcon");
        GameObject.Find("Panel/AppDetails/AppTitle").GetComponent <UnityEngine.UI.Text>().text   = Application.productName;
        GameObject.Find("Panel/AppDetails/AppVersion").GetComponent <UnityEngine.UI.Text>().text = "Version " + Application.version + "  <color=#000080>Credits...</color>  " + DeviceInput.HumanReadableEncoding(DeviceInput.deviceSerial);

        bool tutorialExists = false;

        if (Resources.Load <TextAsset>("Cards/Tutorial") != null)
        {
            tutorialExists = true;
        }
        else
        {
            for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
            {
                string scenePath = SceneUtility.GetScenePathByBuildIndex(i);
                scenePath = scenePath.Substring(scenePath.LastIndexOf("/") + 1);
                if (scenePath == "M0%Scene1.unity")
                {
                    tutorialExists = true;
                }
            }
        }

        if (engine != null)
        {
            if (gameState.sceneName == "M0%Scene1" && !gameState.GetFlag("M0%Scene1%End"))
            {
                GameObject.Find("Panel/ReturnToMap/Label").GetComponent <UnityEngine.UI.Text>().text = "Skip tutorial";
            }
            Destroy(GameObject.Find("Panel/ReplayTutorial"));
            Destroy(GameObject.Find("Panel/ReplayEnding"));
        }
        else if (!gameState.GetFlag("Global%GameEnd"))
        {
            if (tutorialExists)
            {
                GameObject.Find("Panel/ReturnToMap/Label").GetComponent <UnityEngine.UI.Text>().text = "Replay tutorial";
            }
            else
            {
                Destroy(GameObject.Find("Panel/ReturnToMap"));
            }
            Destroy(GameObject.Find("Panel/ReplayTutorial"));
            Destroy(GameObject.Find("Panel/ReplayEnding"));
        }
        else
        {
            if (tutorialExists)
            {
                Destroy(GameObject.Find("Panel/ReturnToMap"));
            }
            else
            {
                GameObject.Find("Panel/ReturnToMap/Label").GetComponent <UnityEngine.UI.Text>().text = "Replay ending";
                Destroy(GameObject.Find("Panel/ReplayTutorial"));
                Destroy(GameObject.Find("Panel/ReplayEnding"));
            }
        }

        GameObject.Find("Panel/LeftHandedMode").GetComponent <UnityEngine.UI.Toggle>().isOn = gameState.GetFlag("System%SwapButtonGroups");
        if (!DeviceInput.gyroPresent)
        {
            GameObject.Find("Panel/UseGyroscope").GetComponent <UnityEngine.UI.Toggle>().enabled   = false;
            GameObject.Find("Panel/UseGyroscope/Label").GetComponent <UnityEngine.UI.Text>().color = Color.gray;
            GameObject.Find("Panel/UseGyroscope/Text").GetComponent <UnityEngine.UI.Text>().text   = "Unable to detect gyroscope";
            GameObject.Find("Panel/UseGyroscope/Text").GetComponent <UnityEngine.UI.Text>().color  = Color.red;
        }
        GameObject.Find("Panel/UseGyroscope").GetComponent <UnityEngine.UI.Toggle>().isOn = gameState.GetFlag("System%UseGyroscope");
        if (!DeviceInput.compassPresent)
        {
            GameObject.Find("Panel/UseCompass").GetComponent <UnityEngine.UI.Toggle>().enabled   = false;
            GameObject.Find("Panel/UseCompass/Label").GetComponent <UnityEngine.UI.Text>().color = Color.gray;
            GameObject.Find("Panel/UseCompass/Text").GetComponent <UnityEngine.UI.Text>().text   = "Unable to detect compass";
            GameObject.Find("Panel/UseCompass/Text").GetComponent <UnityEngine.UI.Text>().color  = Color.red;
        }
        GameObject.Find("Panel/UseCompass").GetComponent <UnityEngine.UI.Toggle>().isOn = gameState.GetFlag("System%UseCompass");

#if !UNITY_ANDROID
        // compass only supported on android
        Destroy(GameObject.Find("Panel/UseCompass"));
#endif
    }