/// <summary>
        /// 显示抛硬币面板
        /// </summary>
        public void ShowTossCoinPanel(bool showSelectCoinPanel, Action <CoinType, CoinType> actionTossCoin, CoinType coinType = CoinType.Unknown)
        {
            tossCoinPanel.SetActive(true);
            this.actionTossCoin = actionTossCoin;
            if (showSelectCoinPanel)
            {
                tossCoinPanel.transform.GetChild(0).gameObject.SetActive(true);
                tossCoinPanel.transform.GetChild(1).gameObject.SetActive(false);
            }
            else
            {
                tossCoinPanel.transform.GetChild(0).gameObject.SetActive(false);
                tossCoinPanel.transform.GetChild(1).gameObject.SetActive(true);
                StringResConfig stringResConfig = ConfigManager.GetConfigByName("StringRes") as StringResConfig;
                Text            playInfoText    = tossCoinPanel.transform.GetChild(1).GetChild(0).gameObject.GetComponent <Text>();
                switch (coinType)
                {
                case CoinType.Unknown:
                    playInfoText.text = "";
                    break;

                case CoinType.Front:
                    playInfoText.text = stringResConfig.GetRecordById(19).value + "正面";
                    break;

                case CoinType.Back:
                    playInfoText.text = stringResConfig.GetRecordById(19).value + "反面";
                    break;

                default:
                    break;
                }
            }

            CoinType resultCoinType = (CoinType)UnityEngine.Random.Range(1, 3);
            Sprite   coinSprite     = tossCoinPanel.transform.GetChild(0).GetChild((int)resultCoinType).GetChild(0).gameObject.GetComponent <Image>().sprite;

            tossCoinPanel.transform.GetChild(1).GetChild(1).gameObject.GetComponent <Image>().sprite = coinSprite;

            TimerFunction timerFunction = new TimerFunction();

            timerFunction.SetFunction(1, () =>
            {
                tossCoinPanel.SetActive(false);
                actionTossCoin(coinType, resultCoinType);
            });

            GameManager.AddTimerFunction(timerFunction);
        }
        /// <summary>
        /// 显示掷骰子面板
        /// </summary>
        /// <param name="actionIndex"></param>
        public void ShowThrowDicePanel(Action <int> actionIndex)
        {
            throwDicePanel.SetActive(true);
            int resultNumber = UnityEngine.Random.Range(1, 7);

            for (int i = 1; i < 7; i++)
            {
                throwDicePanel.transform.GetChild(0).GetChild(i).gameObject.SetActive(false);
            }
            throwDicePanel.transform.GetChild(0).GetChild(resultNumber).gameObject.SetActive(true);
            StringResConfig stringResConfig = ConfigManager.GetConfigByName("StringRes") as StringResConfig;

            throwDicePanel.transform.GetChild(0).GetChild(0).gameObject.GetComponent <Text>().text = stringResConfig.GetRecordById(20).value + resultNumber;

            TimerFunction timerFunction = new TimerFunction();

            timerFunction.SetFunction(1, () =>
            {
                throwDicePanel.SetActive(false);
                actionIndex(resultNumber);
            });

            GameManager.AddTimerFunction(timerFunction);
        }
Exemple #3
0
 /// <summary>
 /// 添加计时器
 /// </summary>
 public static void AddTimerFunction(TimerFunction timerFunction)
 {
     gameManagerInstance.timerFunctions.Add(timerFunction);
 }