コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <summary>
        /// 显示决斗结果面板
        /// </summary>
        /// <param name="winnerPlayer"></param>
        /// <param name="duelEndReason"></param>
        public void ShowDuelResultPanel(Player winnerPlayer, DuelEndReason duelEndReason)
        {
            duelResultPanel.SetActive(true);
            StringResConfig stringResConfig = ConfigManager.GetConfigByName("StringRes") as StringResConfig;
            string          resultText      = "";

            if (winnerPlayer == null)
            {
                resultText = stringResConfig.GetRecordById(16).value;
            }
            else if (winnerPlayer == duelScene.GetMyPlayer())
            {
                resultText = stringResConfig.GetRecordById(17).value;
            }
            else
            {
                resultText = stringResConfig.GetRecordById(18).value;
            }
            duelResultPanel.transform.GetChild(1).GetComponent <Text>().text = resultText;

            DuelEndReasonConfig duelEndReasonConfig = ConfigManager.GetConfigByName("DuelEndReason") as DuelEndReasonConfig;

            duelResultPanel.transform.GetChild(3).GetComponent <Text>().text = duelEndReasonConfig.GetRecordById((int)duelEndReason).value;
        }
コード例 #3
0
ファイル: UserData.cs プロジェクト: wlzs04/DuelMonsters
        /// <summary>
        /// 添加新卡组并返回名称
        /// </summary>
        /// <returns></returns>
        public UserCardGroup AddNewCardGroup()
        {
            StringResConfig stringResConfig  = ConfigManager.GetConfigByName("StringRes") as StringResConfig;
            string          newCardGroupName = stringResConfig.GetRecordById(0).value;

            int index = 1;

            while (GetCardGroupByName(newCardGroupName + index) != null)
            {
                index++;
            }
            newCardGroupName = newCardGroupName + index;

            UserCardGroup userCardGroup = new UserCardGroup();

            userCardGroup.cardGroupName = newCardGroupName;
            userCardGroupList.Add(userCardGroup);

            return(userCardGroup);
        }
コード例 #4
0
        /// <summary>
        /// 重新设置决斗流程面板信息面板
        /// </summary>
        public void ResetPhaseTypePanelInfo()
        {
            if (!phaseTypePanel.activeSelf)
            {
                return;
            }
            bool  isMyTurn         = GameManager.GetDuelScene().GetMyPlayer().IsMyTurn();
            Color color            = isMyTurn ? Color.green : Color.red;
            int   currentPhaseType = (int)GameManager.GetDuelScene().GetCurrentPhaseType();

            for (int i = 1; i < phaseTypePanel.transform.GetChild(0).childCount; i++)
            {
                if (currentPhaseType > i)
                {
                    if (phaseTypePanel.transform.GetChild(0).GetChild(i).GetComponent <Button>() != null)
                    {
                        phaseTypePanel.transform.GetChild(0).GetChild(i).GetComponent <Button>().interactable = false;
                    }
                    phaseTypePanel.transform.GetChild(0).GetChild(i).GetComponent <Text>().color = Color.gray;
                }
                else if (currentPhaseType == i)
                {
                    if (phaseTypePanel.transform.GetChild(0).GetChild(i).GetComponent <Button>() != null)
                    {
                        phaseTypePanel.transform.GetChild(0).GetChild(i).GetComponent <Button>().interactable = false;
                    }
                    phaseTypePanel.transform.GetChild(0).GetChild(i).GetComponent <Text>().color = Color.yellow;
                }
                else
                {
                    if (phaseTypePanel.transform.GetChild(0).GetChild(i).GetComponent <Button>() != null)
                    {
                        phaseTypePanel.transform.GetChild(0).GetChild(i).GetComponent <Button>().interactable = isMyTurn;
                    }
                    phaseTypePanel.transform.GetChild(0).GetChild(i).GetComponent <Text>().color = color;
                }
            }
            StringResConfig stringResConfig = ConfigManager.GetConfigByName("StringRes") as StringResConfig;

            phaseTypePanel.transform.GetChild(1).GetComponent <Text>().text = stringResConfig.GetRecordById(15).value + duelScene.GetCurrentTurnNumber();
        }
コード例 #5
0
ファイル: DuelScene.cs プロジェクト: wlzs04/DuelMonsters
        /// <summary>
        /// 显示指定玩家当前指定类型的卡牌列表
        /// </summary>
        /// <param name="ownerPlayer"></param>
        /// <param name="cardGameState"></param>
        public void ShowCardList(Player ownerPlayer, CardGameState cardGameState, bool canHideByPlayer, CardBase launchEffectCard, Action <CardBase, CardBase> clickCallback)
        {
            if (duelSceneScript.CardListPanelIsShowing())
            {
                return;
            }
            StringResConfig stringResConfig = ConfigManager.GetConfigByName("StringRes") as StringResConfig;
            string          titleText       = ownerPlayer == myPlayer?stringResConfig.GetRecordById(9).value : stringResConfig.GetRecordById(10).value;

            switch (cardGameState)
            {
            case CardGameState.Tomb:
                duelSceneScript.ShowCardListPanel(ownerPlayer.GetTombCards(), titleText + stringResConfig.GetRecordById(11).value, canHideByPlayer, launchEffectCard, clickCallback);
                break;

            case CardGameState.Exclusion:
                duelSceneScript.ShowCardListPanel(ownerPlayer.GetExceptCards(), titleText + stringResConfig.GetRecordById(12).value, canHideByPlayer, launchEffectCard, clickCallback);
                break;

            default:
                Debug.LogError("无法显示当前卡牌状态的列表:" + cardGameState);
                break;
            }
        }
コード例 #6
0
        /// <summary>
        /// 显示帮助信息面板
        /// </summary>
        public void ShowHelpInfoPanel(int myRemainCardNumberText, int opponentRemainCardNumberText)
        {
            helpInfoPanel.SetActive(true);
            StringResConfig stringResConfig = ConfigManager.GetConfigByName("StringRes") as StringResConfig;

            helpInfoPanel.transform.Find("MyRemainCardNumberText").GetComponent <Text>().text       = stringResConfig.GetRecordById(8).value + myRemainCardNumberText;
            helpInfoPanel.transform.Find("OpponentRemainCardNumberText").GetComponent <Text>().text = stringResConfig.GetRecordById(8).value + opponentRemainCardNumberText;
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
    /// <summary>
    /// 决定谁先出牌
    /// </summary>
    public void DecideGuessFirst()
    {
        if (iGuessWin != 0)
        {
            return;
        }
        GuessEnum myGuessEnum       = duelScene.GetMyPlayer().GetGuessEnum();
        GuessEnum opponentGuessEnum = duelScene.GetOpponentPlayer().GetGuessEnum();

        if (myGuessEnum != GuessEnum.Unknown && opponentGuessEnum != GuessEnum.Unknown)
        {
            if (myGuessEnum == opponentGuessEnum)
            {
                TimerFunction reguessTimeFunction = new TimerFunction();
                reguessTimeFunction.SetFunction(1, () =>
                {
                    ClearChoose();
                });

                GameManager.AddTimerFunction(reguessTimeFunction);
                GameManager.ShowMessage("双方选择相同,需重新选择!");

                return;
            }

            int             tempValue       = (int)myGuessEnum - (int)opponentGuessEnum;
            StringResConfig stringResConfig = ConfigManager.GetConfigByName("StringRes") as StringResConfig;
            string          title;
            if (tempValue == 1 || tempValue == -2)
            {
                iGuessWin = 1;
                title     = stringResConfig.GetRecordById(13).value;
            }
            else
            {
                iGuessWin = 2;
                title     = stringResConfig.GetRecordById(14).value;
            }

            TimerFunction timerFunction = new TimerFunction();

            timerFunction.SetFunction(1, () =>
            {
                selectCardGroupPanel.SetActive(false);
                guessFirstPanel.SetActive(false);
                selectFirstPanel.SetActive(true);
                selectFirstPanel.transform.GetChild(0).GetComponent <Text>().text = title;

                if (iGuessWin == 1)
                {
                    duelScene.GetMyPlayer().SelectFristOrBack();
                }

                if (iGuessWin == 2)
                {
                    duelScene.GetOpponentPlayer().SelectFristOrBack();
                }
            });
            GameManager.AddTimerFunction(timerFunction);
        }
    }