Ejemplo n.º 1
0
    private void Start()
    {
        ConfirmationBoxNoButtonComponent.onClick.AddListener(() => SoundManager.PlaySound("MouseClick"));

        // Add Pointer Enter noises
        SoundManager.AttachOnHoverSoundToObject("MouseHover", ConfirmationBoxNoButtonComponent.gameObject);
        SoundManager.AttachOnHoverSoundToObject("MouseHover", ConfirmationBoxYesButtonComponent.gameObject);
        muniAnimator = ConfirmationBoxGameObject.GetComponent <Animator>();
        ConfirmationBoxNoButtonComponent.onClick.AddListener(() => muniAnimator.SetBool("Open", false));
    }
Ejemplo n.º 2
0
 private void Start()
 {
     musHotkeyManager = new HotKeyManager();
     musHotkeyManager.LoadHotkeyProfile();
     muniAnimator = InformationBoxGameObject.GetComponent <Animator>();
     SoundManager.AttachOnHoverSoundToObject("MouseHover", InformationOkButton.gameObject);
 }
Ejemplo n.º 3
0
    /// <summary>
    /// Method for creating save file button objects that player can click on to load files
    /// Save file buttons are dynamically generated based on info from save and number of saves in save folder
    /// Allows an undefined number of saves to be loaded, no limit for player on number of saves
    /// </summary>
    public void CreateSaveFileButtons()
    {
        List <FileInfo> arrSaveFileInfos          = new List <FileInfo>();
        Button          untButtonComponent        = null;
        GameObject      uniButtonGameObject       = null;
        GameObject      uniDeleteButtonGameObject = null;
        TextMeshProUGUI uniButtonTextComponent    = null;

        marrButtonObjects = new List <GameObject>();
        FileInfo[]    arrSavedFileInfo     = null;
        SaveData      musLoadedSaveData    = null;
        DirectoryInfo sysSaveDirectoryInfo = null;
        string        strSaveFileInfoText  = string.Empty;

        if (Directory.Exists(mstrGameSaveFileDirectory))
        {
            sysSaveDirectoryInfo = new DirectoryInfo(mstrGameSaveFileDirectory);
            arrSavedFileInfo     = sysSaveDirectoryInfo.GetFiles().OrderByDescending(file => file.LastWriteTimeUtc).ToArray();
            foreach (FileInfo sysFileInfo in arrSavedFileInfo)
            {
                // Load all "undergods" ugs files from save directory
                if (sysFileInfo.Extension.Equals(".ugs"))
                {
                    arrSaveFileInfos.Add(sysFileInfo);
                }
            }
        }

        // Load information about each save and create a load button
        foreach (FileInfo sysFileInfo in arrSaveFileInfos)
        {
            uniButtonGameObject = (GameObject)Instantiate(SaveButtonPrefab);
            uniButtonGameObject.transform.SetParent(LoadMenuScrollPanel.transform);
            untButtonComponent     = uniButtonGameObject.GetComponent <Button>();
            uniButtonTextComponent = uniButtonGameObject.GetComponentInChildren <TextMeshProUGUI>();
            untButtonComponent.onClick.AddListener(() => LoadSaveGame(sysFileInfo.FullName));
            untButtonComponent.onClick.AddListener(() => SoundManager.PlaySound("GameStart"));
            // Add callback to delete save file to callback of confirmation box
            // Callbacks within Callbacks, we javascript now
            uniDeleteButtonGameObject = uniButtonGameObject.transform.GetChild(1).gameObject;
            uniDeleteButtonGameObject.GetComponent <Button>().onClick.AddListener(
                () => SoundManager.PlaySound("MouseClick"));
            uniDeleteButtonGameObject.GetComponent <Button>().onClick.AddListener(
                () => ConfirmationBoxScript.AttachCallbackToConfirmationBox(
                    () => DeleteSaveFile(sysFileInfo.FullName),
                    "Are you sure you want do delete this file?",
                    "Delete"));

            // Buttons created dynamically, sound effects must also be added dynamically
            SoundManager.AttachOnHoverSoundToObject("MouseHover", uniDeleteButtonGameObject);


            musLoadedSaveData   = SaveAndSettingsHelper.LoadSaveData(sysFileInfo.FullName);
            strSaveFileInfoText =
                string.Format("{0} God of {1}\nCurrentTier: {2}\n{3}",
                              musLoadedSaveData.PlayerFaction.GodName,
                              musLoadedSaveData.PlayerFaction.Type.ToString(),
                              musLoadedSaveData.CurrentTier + 1,
                              sysFileInfo.LastWriteTimeUtc.ToLocalTime().ToShortDateString() + " " + sysFileInfo.LastWriteTimeUtc.ToLocalTime().ToShortTimeString());
            uniButtonTextComponent.text = strSaveFileInfoText;
            uniButtonGameObject.transform.localScale = new Vector3(1, 1, 1);
            marrButtonObjects.Add(uniButtonGameObject);
        }
    }