Exemple #1
0
    private void InitCard(ref List <CardDeckSettingData> settingDataList, ref List <CharacterCard> inGameDataList, bool isPlayerTeam)
    {
        ObjectPoolManager objectPoolMgr = GameObject.Find("CharacterCardPool").GetComponent <ObjectPoolManager>();

        for (int i = 0; i < settingDataList.Count; ++i)
        {
            CharacterCard settingCardPrefab = settingDataList[i].CardPrefab.GetComponent <CharacterCard>();
            CharacterCard inGameCardObject  = objectPoolMgr.GetObject().GetComponent <CharacterCard>();

            // 카드에 나오는 캐릭터 스프라이트를 바꿔준다.
            SpriteRenderer settingPortraitSpr  = settingCardPrefab.m_PortraitRenderer;
            SpriteRenderer inGamePortraitSpr   = inGameCardObject.m_PortraitRenderer;
            SpriteRenderer inGameBackgroundSpr = inGameCardObject.m_BackgroundRenderer;
            inGamePortraitSpr.sprite  = settingPortraitSpr.sprite;
            inGameBackgroundSpr.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);

            inGameCardObject.IsPlayerTeam  = isPlayerTeam;
            inGameCardObject.m_HealthPoint = settingCardPrefab.m_HealthPoint;
            inGameCardObject.m_AttackPoint = (settingDataList[i].IsDefensiveCard) ? (int)(settingCardPrefab.m_AttackPoint * 0.5f)
                                                                    : settingCardPrefab.m_AttackPoint;
            inGameCardObject.m_Speed         = settingCardPrefab.m_Speed;
            inGameCardObject.IsDefensiveCard = settingDataList[i].IsDefensiveCard;
            inGameCardObject.ResetStatus();

            StartCoroutine(inGameCardObject.UpdateCardStatus());

            inGameDataList.Add(inGameCardObject);
        }
    }
Exemple #2
0
    void Awake()
    {
        m_CharacterCardVisualizer = gameObject.AddComponent <CardVisualizer>();
        m_CharacterCardVisualizer.RegisterOnActionActive((CardVisualizeEffect.EffectType effectType) =>
        {
            switch (effectType)
            {
            case CardVisualizeEffect.EffectType.AttackEffect:
                {
                    if (m_TargetCard != null)
                    {
                        if (m_TargetCard.isActiveAndEnabled)
                        {
                            m_TargetCard.OnCardAttacked();
                            m_TargetCard.CurrentHealthPoint -= m_AttackPoint;
                            m_TargetCard.StartCoroutine(m_TargetCard.UpdateCardStatus());
                            m_TargetCard = null;
                        }
                    }
                }
                break;

            case CardVisualizeEffect.EffectType.HitEffect:
                {
                    if (isActiveAndEnabled)
                    {
                        StartCoroutine(UpdateCardStatus());
                    }
                }
                break;

            case CardVisualizeEffect.EffectType.GlowingEffect:
                {
                }
                break;

            default:
                {}
                break;
            }
        });

        m_CharacterCardVisualizer.RegisterOnActionEnded(() =>
        {
            m_CardStatus = CardStatus.TurnActionEnded;
        });

        m_CardFrameWorkRenderer = gameObject.GetComponent <SpriteRenderer>();
    }