Esempio n. 1
0
        protected void Update()
        {
            if (_tipTimer.isExpired())
            {
                _tipTimer.reset();
                TipText.gameObject.SetActive(false);
            }
            else if (_tipTimer.isStarted)
            {
                TipText.color = new Color(TipText.color.r, TipText.color.g, TipText.color.b, 1 /*_tipTimer.getRemainedTime() / _tipTimer.duration*/);
            }

            if (game == null)
            {
                return;
            }

            if (player == null)
            {
                return;
            }
            SelfMaster.update(this, player, player.master, getSkin(player.master));
            if (player.skill != null)
            {
                SelfSkill.update(this, player, player, player.skill, getSkin(player.skill));
                SelfSkill.display();
            }
            else
            {
                SelfSkill.hide();
            }
            SelfGem.Text.text = player.gem.ToString();
            SelfHandList.updateItems(player.hand.ToArray(), (item, card) => item.Card.card == card, (item, card) =>
            {
                if (item.Card.isDisplaying)
                {
                    item.Card.update(card, getSkin(card));
                }
            });
            SelfHandList.sortItems((a, b) => player.hand.indexOf(a.Card.card) - player.hand.indexOf(b.Card.card));
            foreach (var servant in SelfFieldList)
            {
                servant.update(player, servant.card, getSkin(servant.card));
            }
            if (game.currentPlayer == player)
            {
                TurnEndButton.interactable = true;
                TurnEndButton.GetComponent <Image>().color = Color.white;
            }
            else
            {
                TurnEndButton.interactable = false;
                TurnEndButton.GetComponent <Image>().color = Color.gray;
            }

            THHPlayer opponent = game.getOpponent(player);

            if (opponent == null)
            {
                return;
            }
            EnemyMaster.update(this, opponent, opponent.master, getSkin(opponent.master));
            if (opponent.skill != null)
            {
                EnemySkill.update(this, player, opponent, opponent.skill, getSkin(opponent.skill));
                EnemySkill.display();
            }
            else
            {
                EnemySkill.hide();
            }
            EnemyGem.Text.text = opponent.gem.ToString();
            EnemyHandList.updateItems(opponent.hand.ToArray(), (item, card) => item.Card.card == card, (item, card) =>
            {
                item.Card.update(card, null);
            });
            EnemyHandList.sortItems((a, b) => opponent.hand.indexOf(a.Card.card) - opponent.hand.indexOf(b.Card.card));
            foreach (var servant in EnemyFieldList)
            {
                servant.update(opponent, servant.card, getSkin(servant.card));
            }

            IRequest request = game.answers.getLastRequest(player.id);

            if (request is InitReplaceRequest initReplace)
            {
                if (!InitReplaceDialog.isDisplaying)
                {
                    InitReplaceDialog.display();
                    InitReplaceDialog.InitReplaceCardList.clearItems();
                    InitReplaceDialog.InitReplaceCardList.updateItems(player.init, (i, c) => i.Card.card == c, (item, card) =>
                    {
                        item.Card.update(card, getSkin(card));
                        item.MarkImage.enabled = false;
                        item.asButton.onClick.RemoveAllListeners();
                        item.asButton.onClick.AddListener(() =>
                        {
                            item.MarkImage.enabled = !item.MarkImage.enabled;
                        });
                    });
                    InitReplaceDialog.InitReplaceCardList.sortItems((a, b) => player.init.indexOf(a.Card.card) - player.init.indexOf(b.Card.card));
                    InitReplaceDialog.ConfirmButton.interactable = true;
                    InitReplaceDialog.ConfirmButton.GetComponent <Image>().color = Color.white;
                    InitReplaceDialog.ConfirmButton.onClick.RemoveAllListeners();
                    InitReplaceDialog.ConfirmButton.onClick.AddListener(() =>
                    {
                        game.answers.answer(player.id, new InitReplaceResponse()
                        {
                            cardsId = InitReplaceDialog.InitReplaceCardList.Where(item => item.MarkImage.enabled).Select(item => item.Card.card.id).ToArray()
                        });
                        InitReplaceDialog.ConfirmButton.interactable = false;
                        InitReplaceDialog.ConfirmButton.GetComponent <Image>().color = Color.gray;
                    });
                }
            }
            else
            {
                InitReplaceDialog.hide();
            }

            if (_animationQueue.Count > 0)
            {
                Animation animation = _animationQueue[0];
                if (animation.update(this))
                {
                    _animationQueue.RemoveAt(0);
                }
            }
        }
Esempio n. 2
0
        protected void Update()
        {
            if (_tipTimer.isExpired())
            {
                _tipTimer.reset();
                TipText.gameObject.SetActive(false);
            }
            else if (_tipTimer.isStarted)
            {
                TipText.color = new Color(TipText.color.r, TipText.color.g, TipText.color.b, 1 /*_tipTimer.getRemainedTime() / _tipTimer.duration*/);
            }

            if (game == null)
            {
                return;
            }
            if (game.turnTimer != null && game.turnTimer.remainedTime <= 15)
            {
                TimeoutSlider.display();
                TimeoutSlider.value = game.turnTimer.remainedTime / 15;
            }
            else
            {
                TimeoutSlider.hide();
            }

            if (player == null)
            {
                return;
            }
            if (player.skill != null)
            {
                SelfSkill.update(this, player, player, player.skill, getSkin(player.skill));
                SelfSkill.display();
            }
            else
            {
                SelfSkill.hide();
            }
            SelfGem.Text.text = player.gem.ToString();
            if (canControl)
            {
                TurnEndButton.interactable = true;
                TurnEndButton.GetComponent <Image>().color = Color.white;
            }
            else
            {
                TurnEndButton.interactable = false;
                TurnEndButton.GetComponent <Image>().color = Color.gray;
            }

            THHPlayer opponent = game.getOpponent(player);

            if (opponent == null)
            {
                return;
            }
            if (opponent.skill != null)
            {
                EnemySkill.update(this, player, opponent, opponent.skill, getSkin(opponent.skill));
                EnemySkill.display();
            }
            else
            {
                EnemySkill.hide();
            }
            EnemyGem.Text.text = opponent.gem.ToString();

            IRequest request = game.answers.getLastRequest(player.id);

            if (request is InitReplaceRequest initReplace)
            {
                if (!InitReplaceDialog.isDisplaying)
                {
                    InitReplaceDialog.display();
                    InitReplaceDialog.InitReplaceCardList.clearItems();
                    InitReplaceDialog.InitReplaceCardList.updateItems(player.init, (i, c) => i.Card.card == c, (item, card) =>
                    {
                        item.Card.update(card, getSkin(card));
                        item.MarkImage.enabled = false;
                        item.asButton.onClick.RemoveAllListeners();
                        item.asButton.onClick.AddListener(() =>
                        {
                            item.MarkImage.enabled = !item.MarkImage.enabled;
                        });
                    });
                    InitReplaceDialog.InitReplaceCardList.sortItems((a, b) => player.init.indexOf(a.Card.card) - player.init.indexOf(b.Card.card));
                    InitReplaceDialog.ConfirmButton.interactable = true;
                    InitReplaceDialog.ConfirmButton.GetComponent <Image>().color = Color.white;
                    InitReplaceDialog.ConfirmButton.onClick.RemoveAllListeners();
                    InitReplaceDialog.ConfirmButton.onClick.AddListener(() =>
                    {
                        game.answers.answer(player.id, new InitReplaceResponse()
                        {
                            cardsId = InitReplaceDialog.InitReplaceCardList.Where(item => item.MarkImage.enabled).Select(item => item.Card.card.id).ToArray()
                        });
                        InitReplaceDialog.ConfirmButton.interactable = false;
                        InitReplaceDialog.ConfirmButton.GetComponent <Image>().color = Color.gray;
                    });
                }
            }
            else
            {
                InitReplaceDialog.hide();
            }

            if (_animationQueue.Count > 0)
            {
                for (int i = 0; i < _animationQueue.Count; i++)
                {
                    Animation anim      = _animationQueue[i];
                    bool      isBlocked = i != 0;//第一个永远不被阻挡
                    for (int j = 0; j < i; j++)
                    {
                        Animation prevAnim = _animationQueue[j];
                        if (prevAnim.blockAnim(anim))
                        {
                            isBlocked = true;
                            break;
                        }
                    }
                    if (isBlocked)
                    {
                        continue;
                    }
                    if (anim.update(this))
                    {
                        _animationQueue.RemoveAt(i);
                        i--;
                    }
                }
            }
        }