93 lines
3.4 KiB
C#
93 lines
3.4 KiB
C#
using System.Collections.Generic;
|
|
using Continentis.MainGame.Character;
|
|
using Continentis.MainGame.UI;
|
|
using Lean.Pool;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace Continentis.MainGame.Card
|
|
{
|
|
public partial class CardInstance
|
|
{
|
|
[Title("References")]
|
|
public DeckSubmodule deck;
|
|
public string currentPileName;
|
|
public ICardOwner owner;
|
|
public CombatTeam team;
|
|
public CharacterBase user;
|
|
public CardLogicBase cardLogic;
|
|
public HandCardView handCardView;
|
|
public IntentionCardView intentionCardView;
|
|
|
|
public CardInstance (CardLogicBase cardLogic, ICardOwner owner, string initialPileName, int index)
|
|
{
|
|
cardLogic.cardInstance = this;
|
|
this.cardLogic = cardLogic;
|
|
|
|
this.owner = owner;
|
|
this.team = owner as CombatTeam;
|
|
this.user = owner as CharacterBase;
|
|
this.deck = owner.deckSubmodule;
|
|
this.currentPileName = initialPileName;
|
|
this.deck.Pile(currentPileName).Insert(index, this);
|
|
}
|
|
|
|
public HandCardView GenerateHandCardView(PileBase pile, int index = -1)
|
|
{
|
|
GameObject handCardObjectPrefab = MainGameManager.Instance.basePrefabs.handCardObject;
|
|
HandCardView handCardView = LeanPool.Spawn(handCardObjectPrefab, pile.rectTransform).GetComponent<HandCardView>();
|
|
if (index >= 0)
|
|
{
|
|
pile.InsertCard(handCardView, index);
|
|
}
|
|
else
|
|
{
|
|
pile.AddCard(handCardView);
|
|
}
|
|
|
|
handCardView.cardInstance = this;
|
|
this.handCardView = handCardView;
|
|
|
|
handCardView.transform.localScale = pile is HandPile ? Vector3.one : Vector3.zero;
|
|
|
|
handCardView.Setup(this);
|
|
handCardView.currentPile = pile;
|
|
handCardView.cardOrb.gameObject.SetActive(false);
|
|
|
|
return handCardView;
|
|
}
|
|
|
|
public void DestroyHandCardView()
|
|
{
|
|
if (handCardView != null)
|
|
{
|
|
handCardView.currentPile.RemoveCard(handCardView);
|
|
LeanPool.Despawn(handCardView.gameObject);
|
|
handCardView = null;
|
|
}
|
|
}
|
|
|
|
public IntentionCardView GenerateIntentionCardView()
|
|
{
|
|
GameObject intentionCardObjectPrefab = MainGameManager.Instance.basePrefabs.intentionCardObject;
|
|
HUD_Intention intention = user.characterView.hudContainer.enablingHUDs["Intention"] as HUD_Intention;
|
|
IntentionCardView intentionCardView = LeanPool.Spawn(intentionCardObjectPrefab, intention.hudTransform).GetComponent<IntentionCardView>();
|
|
intention.AddCard(intentionCardView);
|
|
intentionCardView.cardInstance = this;
|
|
this.intentionCardView = intentionCardView;
|
|
intentionCardView.transform.localScale = Vector3.one;
|
|
intentionCardView.Setup(this);
|
|
return intentionCardView;
|
|
}
|
|
|
|
public void DestroyIntentionCardView()
|
|
{
|
|
if (intentionCardView != null)
|
|
{
|
|
HUD_Intention intention = user.characterView.hudContainer.enablingHUDs["Intention"] as HUD_Intention;
|
|
intention.RemoveCard(intentionCardView);
|
|
intentionCardView = null;
|
|
}
|
|
}
|
|
}
|
|
} |