コード例 #1
0
    // Triggered when the card at this hand index was changed.
    private void onCardChanged(int index)
    {
        if (index == HandIndex)
        {
            var handState = SL.Get <GameModel>().MyPlayer.CardState.Hand;

            // EARLY OUT! //
            if (handState == null)
            {
                Debug.LogWarning("Hand is null");
                return;
            }

            // Destroy the old figurine.
            destroyFigurine();

            var data = handState[index];
            _figurine = createFigurineFromDefinition(data);
            if (_figurine != null)
            {
                _figurine.FigurinePlacedEvent.AddListener(onFigurinePlaced);
            }

            // Update if we have enough mana to use this figurine.
            onManaChanged();

            CardChangedEvent.Invoke();
        }
    }
コード例 #2
0
 private void destroyFigurine()
 {
     if (_figurine != null)
     {
         // Destroy the figurine.
         _figurine.FigurinePlacedEvent.RemoveListener(onFigurinePlaced);
         Destroy(_figurine.gameObject);
         _figurine = null;
     }
 }
コード例 #3
0
    private CardFigurine createFigurineFromDefinition(CardData data)
    {
        CardFigurine figurine = null;

        if (_figurinePrefab != null && data != null)
        {
            // Parent to this slot.
            figurine = Utils.Instantiate(_figurinePrefab, transform);
            if (figurine != null)
            {
                figurine.transform.localPosition = Vector3.zero;
                figurine.transform.localRotation = Quaternion.identity;
                figurine.Init(data);
            }
        }
        return(figurine);
    }