Exemplo n.º 1
0
    public void SetHoveringCard(CardUIObject cardObj)
    {
        if (isCardSelected)
        {
            return;
        }
        if (hoverCard != null)
        {
            hoverCard.Show();
        }

        hoverCard = cardObj;
        if (cardObj != null)
        {
            cardImageAtMouse.sprite = cardObj.card.image;
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        combatManager = FindObjectOfType <CombatManager>();
        levelLoader   = FindObjectOfType <LevelLoader>();

        //HideBackToMapButton();

        currentCardDeckCardUIObjects   = new List <CardUIObject>();
        discardedCardDeckCardUIObjects = new List <CardUIObject>();

        if (combatManager != null)
        {
            foreach (Card card in combatManager.playerCurrentCardDeck)
            {
                if (currentCardDeckGridContent != null)
                {
                    GameObject   cardUIObjectInstance = Instantiate(cardUIObject, currentCardDeckGridContent.transform);
                    CardUIObject cardUI = cardUIObjectInstance.GetComponent <CardUIObject>();
                    cardUI.SetCardDefinition(card);
                    currentCardDeckCardUIObjects.Add(cardUI);
                }

                if (discardedCardDeckGridContent != null)
                {
                    GameObject cardUIObjectInstance = Instantiate(cardUIObject, discardedCardDeckGridContent.transform);
                    cardUIObjectInstance.SetActive(false);
                    CardUIObject cardUI = cardUIObjectInstance.GetComponent <CardUIObject>();
                    cardUI.SetCardDefinition(card);
                    discardedCardDeckCardUIObjects.Add(cardUI);
                }
            }

            int numCharacterStatsObjects = combatManager.enemyCharacters.Count;
            enemyCharacterStatsObjects = new List <GameObject>(numCharacterStatsObjects);

            for (int i = 0; i < numCharacterStatsObjects; i++)
            {
                enemyCharacterStatsObjects.Add(Instantiate(characterStatsObject, characterStatsParent));
                //SetCharacterStatsObject(enemyCharacterStatsObjects[i], combatManager.enemyCharacters[i]);
            }

            playerCharacterStatsObject = Instantiate(characterStatsObject, characterStatsParent);
            playerCharacterStatsObject.GetComponent <RectTransform>().localPosition = Vector3.zero;
            playerCharacterStats = playerCharacterStatsObject.GetComponent <CharacterStats>();
            //SetCharacterStatsObject(playerCharacterStatsObject, combatManager.playerCharacterObject);
        }

        CombatManager.OnCardsDealt     -= UpdateCurrentCardDeckList;
        CombatManager.OnCardsDealt     += UpdateCurrentCardDeckList;
        CombatManager.OnCardDiscarded  -= UpdateDiscardedCardDeckListAdded;
        CombatManager.OnCardDiscarded  += UpdateDiscardedCardDeckListAdded;
        CombatManager.OnDiscardEmptied -= UpdateDiscardedCardDeckListEmptied;
        CombatManager.OnDiscardEmptied += UpdateDiscardedCardDeckListEmptied;

        CombatManager.OnUpdateCardPoints -= UpdateCardPointsText;
        CombatManager.OnUpdateCardPoints += UpdateCardPointsText;
        CombatManager.OnHasWon           -= AnimateVictoryPanel;
        CombatManager.OnHasWon           += AnimateVictoryPanel;
        CombatManager.OnPlayerDestroyed  -= AnimateGameOverPanel;
        CombatManager.OnPlayerDestroyed  += AnimateGameOverPanel;

        CombatManager.OnTurnComplete -= UpdateBuffStatsObjects;
        CombatManager.OnTurnComplete += UpdateBuffStatsObjects;

        CombatManager.OnEnemyTurn         -= HideEndTurnButton;
        CombatManager.OnEnemyTurn         += HideEndTurnButton;
        CombatManager.OnEnemyTurnComplete -= ShowEndTurnButton;
        CombatManager.OnEnemyTurnComplete += ShowEndTurnButton;

        CharacterObject.OnPlayerExecuteTurn -= HideEndTurnButton;
        CharacterObject.OnPlayerExecuteTurn += HideEndTurnButton;
        CharacterObject.OnPlayerUseAbility  -= UpdateBlockStat;
        CharacterObject.OnPlayerUseAbility  += UpdateBlockStat;

        CharacterObject.OnPlayerAttackComplete -= ShowEndTurnButton;
        CharacterObject.OnPlayerAttackComplete += ShowEndTurnButton;

        CharacterObject.OnAnimationHit -= UpdateStats;
        CharacterObject.OnAnimationHit += UpdateStats;

        CharacterObject.OnCharacterDestroy -= RemovePlayerStatsObject;
        CharacterObject.OnCharacterDestroy += RemovePlayerStatsObject;

        //remove stats ui for enemies from combat manager
        CombatManager.OnEnemyRemoved -= RemoveCharacterStatsObject;
        CombatManager.OnEnemyRemoved += RemoveCharacterStatsObject;

        BuffText.OnEnterBuffText -= UpdateBuffInfoTextPanel;
        BuffText.OnEnterBuffText += UpdateBuffInfoTextPanel;
        BuffText.OnExitBuffText  -= HideBuffInfoPanel;
        BuffText.OnExitBuffText  += HideBuffInfoPanel;
    }