示例#1
0
    public void OnButtonConfirmChoice()
    {
        GameObject.Find("CanvasGroup").GetComponent <CanvasGroup>().blocksRaycasts = true;
        GameObject.Find("CanvasGroup").GetComponent <CanvasGroup>().interactable   = true;

        m_confirmChoiceBtn.gameObject.SetActive(false);

        if (m_choiceMode == ConfirmButtonMode.GainCard)
        {
            PlayerCard card = m_lstCardChoice[m_choiceDropdown.value];
            Player.Get().AddHandCard(card.gameObject);

            GameLogic.Get().m_lstPlayerCards.Remove(card.gameObject);
            GameLogic.Shuffle(GameLogic.Get().m_lstPlayerCards);

            m_choiceDropdown.gameObject.SetActive(false);
            card.OnPointerExit(null);
            GameLogic.Get().OutputGameLog(string.Format("{0}获取了手牌:{1}\n", Player.Get().m_investigatorCard.m_cardName, card.m_cardName));
        }
        else if (m_choiceMode == ConfirmButtonMode.TextOnly)
        {
            m_choiceDropdown.gameObject.SetActive(false);
            m_lstChoiceEvent[m_choiceDropdown.value].Invoke(m_lstChoiceEvent[m_choiceDropdown.value].m_eventParam);
            m_choiceDropdown.value = 0;
        }
        else if (m_choiceMode == ConfirmButtonMode.RevealCard)
        {
            UnityEngine.Assertions.Assert.IsNotNull(m_tempHighlightCard, "Assert failed in OnButtonConfirmChoice()-DrawPlayerCard!!");
            Card card = m_tempHighlightCard.GetComponent <Card>();

            if (card is PlayerCard)
            {
                PlayerCard pc = card as PlayerCard;
                if (pc.m_isPlayerDeck)
                {
                    GameLogic.Get().OutputGameLog(string.Format("{0}花费1行动获取了<{1}>\n", Player.Get().m_investigatorCard.m_cardName, card.m_cardName));

                    Player.Get().AddHandCard(m_tempHighlightCard);

                    Player.Get().ActionDone(PlayerAction.DrawOneCard);
                }
            }
            else if (card is LocationCard)
            {
                GameLogic.Get().OutputGameLog(string.Format("地点<{0}>被揭示\n", card.m_cardName));
            }

            card.OnPointerExit(null);
            m_tempHighlightCard = null;
        }
        else if (m_choiceMode == ConfirmButtonMode.DrawEncounterCard)
        {
            UnityEngine.Assertions.Assert.IsNotNull(m_tempHighlightCard, "Assert failed in OnButtonConfirmChoice()-DrawEncounterCard!!");
            Card card = m_tempHighlightCard.GetComponent <Card>();
            GameLogic.Get().OutputGameLog(string.Format("{0}摸到了遭遇卡<{1}>\n", Player.Get().m_investigatorCard.m_cardName, card.m_cardName));

            if (card is EnemyCard)
            {
                EnemyCard enemy = card as EnemyCard;
                if (enemy.m_spawnLocation != null)
                {
                    // Prefab has no instance transform info, so we need to find it
                    var foundObjects = FindObjectsOfType <LocationCard>();
                    foreach (var location in foundObjects)
                    {
                        if (location.m_cardName == enemy.m_spawnLocation.m_cardName)
                        {
                            GameLogic.DockCard(card.gameObject, location.gameObject, 300, true, true);
                            card.OnSpawnAtLocation(location);
                            break;
                        }
                    }
                }
                else
                {
                    Player.Get().AddEngagedEnemy(enemy);
                }

                card.OnPointerExit(null);
                m_tempHighlightCard = null;
            }
            else if (card is TreacheryCard)
            {
                card.OnPointerExit(null);
                m_tempHighlightCard = null;

                TreacheryLogic treachery = card.GetComponent <TreacheryLogic>();
                treachery.OnReveal();
            }
        }
        else if (m_choiceMode == ConfirmButtonMode.SkillTest)
        {
            StartCoroutine(OnConfirmSkillTest());
        }
        else if (m_choiceMode == ConfirmButtonMode.DiscardExcessHandCards)
        {
            EndSelectCardToSpend();
        }

        m_bConfirmModeEnd = true;
    }