private void CornerCodeClicked(string buttonIndex)
    {
        cornerCode += buttonIndex;

        if (ExhibitBase.instance.verbose)
        {
            Debug.Log("cornerCode: " + cornerCode);
        }

        if (cornerCodeTimeoutCoroutine != null)
        {
            StopCoroutine(cornerCodeTimeoutCoroutine); cornerCodeTimeoutCoroutine = null;
        }

        if (cornerCodeListeners.ContainsKey(cornerCode))
        {
            cornerCodeListeners[cornerCode]();
            ResetCornerCode();
        }
        else
        {
            //cornerCodeTimeoutCoroutine = StartCoroutine(CornerCodeTimeout());
            cornerCodeTimeoutCoroutine = StartCoroutine(ExhibitUtilities.DoActionAfterTime(ResetCornerCode, cornerCodeTimeoutSeconds));
        }
    }
Beispiel #2
0
    private void Start()
    {
        recorder = new CCRecorder();

        scoringValues = new Dictionary <int, int>();
        scoringValues.Add(0, 0);
        scoringValues.Add(1, 0);
        scoringValues.Add(2, 2);
        scoringValues.Add(3, 3);
        scoringValues.Add(4, 8);
        scoringValues.Add(5, 10);

        for (int i = 0; i < gameGrid.Length; i++)
        {
            DieValueViewer square = gameGrid[i];
            square.SetToUnused();
            ExhibitUtilities.AddEventTrigger(square.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerUp, () => { SquareClicked(square); });
        }

        for (int i = 0; i < dice.Length; i++)
        {
            Die die = dice[i];
            ExhibitUtilities.AddEventTrigger(die.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerUp, () => { DieClicked(die); });
        }



        // game over panel
        gameOverPanel.Setup(RetryButtonPressed, RetrySameButtonPressed);


        // start game
        SetupForGame();
    }
    /// <summary>
    /// adds the corner overlay buttons in order to add Code Sequences
    /// </summary>
    public void AddButtons()
    {
        Canvas canvas = FindObjectOfType <Canvas>();

        if (canvas == null)
        {
            Debug.Log("Creating a Canvas object in the Scene for the corner code buttons.");
            canvas = ExhibitBase.CreateCanvas(1920, 1080);
        }

        cornerCodeTestParent      = new GameObject();
        cornerCodeTestParent.name = "Corner Codes";
        RectTransform cornerCodeRectTransform = cornerCodeTestParent.AddComponent <RectTransform>();

        cornerCodeRectTransform.position.Set(0, 0, 0);
        cornerCodeRectTransform.sizeDelta = new Vector2(Screen.width, Screen.height);
        cornerCodeRectTransform.SetParent(canvas.GetComponent <RectTransform>(), false);


        GameObject[] buttons = new GameObject[4];
        for (int i = 0; i < 4; i++)
        {
            GameObject buttonGameObject = new GameObject();
            buttonGameObject.name = "Corner Code Button " + i;
            RectTransform buttonRectTransform = buttonGameObject.AddComponent <RectTransform>();
            buttonRectTransform.SetParent(cornerCodeRectTransform);
            buttonRectTransform.sizeDelta = new Vector2(cornerCodeButtonSize, cornerCodeButtonSize);
            Image buttonImage = buttonGameObject.AddComponent <Image>();
            buttonImage.color = cornerCodeTestColor;
            buttons[i]        = buttonGameObject;
            cornerCodeTestImages.Add(buttonImage);
        }

        CanvasScaler canvasScaler = canvas.GetComponent <CanvasScaler>();
        Vector2      resolution   = canvasScaler.referenceResolution;

        // set positions of test images
        buttons[0].GetComponent <RectTransform>().anchoredPosition = new Vector3(-(resolution.x / 2) + (cornerCodeButtonSize / 2), (resolution.y / 2) - (cornerCodeButtonSize / 2));
        buttons[1].GetComponent <RectTransform>().anchoredPosition = new Vector3((resolution.x / 2) - (cornerCodeButtonSize / 2), (resolution.y / 2) - (cornerCodeButtonSize / 2));
        buttons[2].GetComponent <RectTransform>().anchoredPosition = new Vector3(-(resolution.x / 2) + (cornerCodeButtonSize / 2), -(resolution.y / 2) + (cornerCodeButtonSize / 2));
        buttons[3].GetComponent <RectTransform>().anchoredPosition = new Vector3((resolution.x / 2 - (cornerCodeButtonSize / 2)), -(resolution.y / 2) + (cornerCodeButtonSize / 2));

        // create rectangles
        cornerCodeRects.Add(new Rect(0, resolution.y - cornerCodeButtonSize, cornerCodeButtonSize, cornerCodeButtonSize));                                   // top-left
        cornerCodeRects.Add(new Rect(resolution.x - cornerCodeButtonSize, resolution.y - cornerCodeButtonSize, cornerCodeButtonSize, cornerCodeButtonSize)); // top-right
        cornerCodeRects.Add(new Rect(0, 0, cornerCodeButtonSize, cornerCodeButtonSize));                                                                     // bottom-left
        cornerCodeRects.Add(new Rect(resolution.x - cornerCodeButtonSize, 0, cornerCodeButtonSize, cornerCodeButtonSize));                                   // bottom-right

        if (cornerCodeTestColor == Color.clear)
        {
            for (int i = 0; i < buttons.Length; i++)
            {
                buttons[i].SetActive(false);
            }
        }

        addedCornerCodeButtons = true;

        StartCoroutine(ExhibitUtilities.DoActionAfterTime(BringToFront, 5f));
    }
    /// <summary>
    /// moves log file into into a Logs folder in the same place, keeping a record of all logs
    /// </summary>
    private void OnApplicationQuit()
    {
        if (archiveLogFiles)
        {
            string logDirectory = Application.persistentDataPath;

            string logFilepath = logDirectory + "/output_log.txt";
            if (System.IO.File.Exists(logFilepath))
            {
                string newLogFolder = logDirectory + "/Logs";
                System.IO.Directory.CreateDirectory(newLogFolder);

                string newLogFilepath = newLogFolder + "/" + DateTime.Now.ToString("MMddyyyy") + ".txt";
                if (System.IO.File.Exists(newLogFilepath))
                {
                    newLogFilepath = newLogFolder + "/" + DateTime.Now.ToString("MMddyyyy-HHmm") + ".txt";
                }
                System.IO.File.Copy(logFilepath, newLogFilepath);

                ExhibitUtilities.MakeRoomOnHardDrive(newLogFolder, logFilesToArchive, true);

                Debug.Log("Copied Log File to " + newLogFilepath);
            }
        }
    }
Beispiel #5
0
    public void LogAndFade(string message, float messageFadeTime)
    {
        Log(message);

        if (fadeCoroutine != null)
        {
            StopCoroutine(fadeCoroutine); fadeCoroutine = null;
        }
        StartCoroutine(ExhibitUtilities.DoActionAfterTime(HideTextElement, messageFadeTime));
    }
Beispiel #6
0
    private void ApplySettings()
    {
        // set background image(s)
        if (settings.ContainsKey("background") && settings["background"].ContainsKey("images"))
        {
            float rotateBackgroundMinutes = settings["background"]["rotate-minutes"];
            backgroundWaitTime = rotateBackgroundMinutes * 60f;
            Debug.Log("Rotating background pictures every " + backgroundWaitTime + " seconds.");

            backgroundSprites = new List <Sprite>();
            JsonArray backgroundSettings = settings["background"]["images"] as JsonArray;
            for (int i = 0; i < backgroundSettings.Count; i++)
            {
                backgroundSprites.Add(ExhibitUtilities.LoadSpriteFromFile(backgroundSettings[i]));
            }

            backgroundSprites.ShuffleList();
            backgroundImage.sprite = backgroundSprites[0];
            backgroundImage.color  = Color.white;

            StartCoroutine(NextBackgroundImage());
        }
        else
        {
            backgroundImage.color = defaultBackgroundColor;
        }

        // set highlight color
        Color highlightColor = defaultHightlightColor;

        ColorUtility.TryParseHtmlString(settings["highlight-color"], out highlightColor);
        highlight.color  = highlightColor;
        exitButton.color = highlightColor;


        // set app icons
        JsonArray appSettings = settings["apps"] as JsonArray;

        for (int i = 0; i < appSettings.Count; i++)
        {
            GameObject iconObject = Instantiate(iconPrefab);
            iconObject.transform.SetParent(this.transform);

            Icon iconSettings = iconObject.GetComponent <Icon>();
            iconSettings.ChangeIcon(appSettings[i]["icon-image"]);
            iconSettings.SetLaunchPath(appSettings[i]["launch-path"]);
            iconSettings.highlight  = highlight.GetComponent <RectTransform>();
            iconSettings.exitButton = exitButton;

            if (i == 0)
            {
                iconObject.GetComponent <Button>().Select();
            }
        }
    }
    public void Setup(System.Action retryAction, System.Action retrySameAction)
    {
        gameOverGroup = gameOverPanel.GetComponent <CanvasGroup>();

        newButton.GetComponent <ChunkyButton>().onClick.AddListener(() => { retryAction(); });
        sameButton.GetComponent <ChunkyButton>().onClick.AddListener(() => { retrySameAction(); });
        quitButton.GetComponent <ChunkyButton>().onClick.AddListener(() => { Application.Quit(); });
        ExhibitUtilities.AddEventTrigger(gameOverPanel, UnityEngine.EventSystems.EventTriggerType.PointerDown, () => { gameOverGroup.alpha = 0; });
        ExhibitUtilities.AddEventTrigger(gameOverPanel, UnityEngine.EventSystems.EventTriggerType.PointerUp, () => { gameOverGroup.alpha = 1; });
        gameOverPanel.SetActive(false);
    }
Beispiel #8
0
    public void ChangeIcon(string iconPath)
    {
        if (iconPath != "")
        {
            if (!iconPath.StartsWith("C:"))
            {
                iconPath = Application.streamingAssetsPath + "/Icons/" + iconPath;
            }

            image.sprite = ExhibitUtilities.LoadSpriteFromFile(iconPath);
            image.color  = Color.white;
        }
    }
Beispiel #9
0
        public void Show(string guess, bool correct, JoPlayer player, string actualAnswer, System.Action onComplete)
        {
            image.rectTransform.localScale = Vector2.zero;

            image.color = player.color.mainColor;

            ParticleSystem.MainModule particleMain = particles.main;
            particleMain.startColor = correct ? correctColor : incorrectColor;

            guessText.text      = guess;
            playerNameText.text = $"{player.name} guessed";
            actualWordText.text = $"The word was {actualAnswer}";

            image.rectTransform.DOScale(1f, 0.8f).SetEase(Ease.OutElastic);
            particles.Play();

            StartCoroutine(ExhibitUtilities.DoActionAfterTime(() => { onComplete.Invoke(); }, showTime));
        }
Beispiel #10
0
    /// <summary>
    /// checks every frame for a few things:
    ///     - if the "ESC" button is pressed, the application exits.
    ///     - if the "`" (Backquote) button is pressed, the cursor toggles visibility
    ///     - mouse presses, which restart the inactivity timer
    /// </summary>
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.BackQuote))
        {
            Cursor.visible = !Cursor.visible;
        }

        if (exitOnEscapeKey && Input.GetKeyDown(KeyCode.Escape))
        {
            ExhibitUtilities.ExitApplication();
        }

        if (inactivityTimeout && Input.GetMouseButtonUp(0))
        {
            RestartInactivityTimer();
            if (cornerCodes != null)
            {
                cornerCodes.BringToFront();
            }
        }
    }
 public void Play()
 {
     Stop();
     animationCoroutine = StartCoroutine(ExhibitUtilities.DoActionForever(NextSprite, speed, speed));
     isPlaying          = true;
 }
Beispiel #12
0
 private void Start()
 {
     ExhibitUtilities.AddEventTrigger(rollButton, UnityEngine.EventSystems.EventTriggerType.PointerDown, () => {
         Roll();
     });
 }