コード例 #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));
    }
コード例 #2
0
 /// <summary>
 /// Public method for displaying an information box to the user.
 /// Optional parameters to add callbacks to ok button.
 /// </summary>
 /// <param name="pstrInformation"></param>
 /// <param name="puniCallback"></param>
 /// <param name="pstrOkButtonText"></param>
 public void DisplayInformationBox(string pstrInformation, UnityAction puniCallback = null, string pstrOkButtonText = "Ok")
 {
     InformationBoxTextObject.text = pstrInformation;
     InformationOkButton.onClick.RemoveAllListeners();
     if (puniCallback != null)
     {
         InformationOkButton.onClick.AddListener(puniCallback);
     }
     InformationOkButton.onClick.AddListener(DefaultOkCallback);
     InformationOkButton.onClick.AddListener(() => SoundManager.PlaySound("MouseClick"));
     InformationOkButton.GetComponentInChildren <Text>().text = pstrOkButtonText;
     muniAnimator.SetBool("Open", true);
 }
コード例 #3
0
    /// <summary>
    /// Method attached to attack upgrade button
    /// </summary>
    public void UpgradeWorshipperAttack()
    {
        AttackWorshipperUpgrade musAttackUpgrade;

        if (PlayerFaction.MaterialCount >= mintAttackUpgradeCost)
        {
            PlayerFaction.MaterialCount -= mintAttackUpgradeCost;
            musAttackUpgrade             = new AttackWorshipperUpgrade("Attack Upgrade", "Increase attack by 1", mintAttackUpgradeCost, 1);
            PlayerFaction.CurrentUpgrades.Add(musAttackUpgrade);
            mintCurrentAttackCount++;
            mintAttackUpgradeCost = (int)(mcintAttackBaseCost * Mathf.Pow(10, mintCurrentAttackCount));
            AttackText.text       = string.Format("Attack +1\n{0} Mat", mintAttackUpgradeCost);
            TotalAttackText.text  = string.Format("Attack Buff\n +{0}", mintCurrentAttackCount);
            AudioManager.PlaySound("ChaChing");
        }
        else
        {
            AudioManager.PlaySound("NotMaterials");
        }
    }
コード例 #4
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);
        }
    }