Change variables of cardDisplay.

pull/6/head
SherlockShiYL 2022-03-18 16:12:12 -07:00
parent fb93ab693f
commit 5f1965667e
3 changed files with 436 additions and 36 deletions

View File

@ -1512,6 +1512,7 @@ RectTransform:
- {fileID: 1973886306} - {fileID: 1973886306}
- {fileID: 263713420} - {fileID: 263713420}
- {fileID: 5334463587201139456} - {fileID: 5334463587201139456}
- {fileID: 6880760287070379452}
m_Father: {fileID: 3351518597856635956} m_Father: {fileID: 3351518597856635956}
m_RootOrder: 1 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -1520,6 +1521,141 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &2283412729387017120
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1190278128854001673}
- component: {fileID: 4832866463948114768}
- component: {fileID: 5443227565047484921}
m_Layer: 0
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1190278128854001673
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2283412729387017120}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6880760287070379452}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4832866463948114768
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2283412729387017120}
m_CullTransparentMesh: 1
--- !u!114 &5443227565047484921
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2283412729387017120}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Cannot get more cards
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 18
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 0
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &2339368777483364026 --- !u!1 &2339368777483364026
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1897,10 +2033,7 @@ MonoBehaviour:
- {fileID: 11400000, guid: 9eb62481994b51e4897a57499081c3db, type: 2} - {fileID: 11400000, guid: 9eb62481994b51e4897a57499081c3db, type: 2}
- {fileID: 11400000, guid: 9eb62481994b51e4897a57499081c3db, type: 2} - {fileID: 11400000, guid: 9eb62481994b51e4897a57499081c3db, type: 2}
- {fileID: 11400000, guid: 9eb62481994b51e4897a57499081c3db, type: 2} - {fileID: 11400000, guid: 9eb62481994b51e4897a57499081c3db, type: 2}
drawList: []
drawDisplayList: [] drawDisplayList: []
handList: []
discardList: []
discardDisplayList: [] discardDisplayList: []
wasteList: [] wasteList: []
randomSeed: 0 randomSeed: 0
@ -1908,6 +2041,8 @@ MonoBehaviour:
cardDisplayTemplate: {fileID: 7657681008272561115} cardDisplayTemplate: {fileID: 7657681008272561115}
drawListContent: {fileID: 624918691686486625} drawListContent: {fileID: 624918691686486625}
discardListContent: {fileID: 3370262408006457270} discardListContent: {fileID: 3370262408006457270}
maxCardinHandLimit: 10
maxCardRemainLimit: 5
--- !u!1 &4772833656592657312 --- !u!1 &4772833656592657312
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2299,6 +2434,43 @@ MonoBehaviour:
m_OnClick: m_OnClick:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
--- !u!1 &5654186365262363981
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6880760287070379452}
m_Layer: 0
m_Name: LimitWarning
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6880760287070379452
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5654186365262363981}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1190278128854001673}
m_Father: {fileID: 6342785598281792429}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 198.8}
m_SizeDelta: {x: 100, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &6593117350918236961 --- !u!1 &6593117350918236961
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -387,6 +387,54 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 1455724355} m_TransformParent: {fileID: 1455724355}
m_Modifications: m_Modifications:
- target: {fileID: 1368154424702687206, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1368154424702687206, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1368154424702687206, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1368154424702687206, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1368154424702687206, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1368154424702687206, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2224386513268639486, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2224386513268639486, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2224386513268639486, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2224386513268639486, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2224386513268639486, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2224386513268639486, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3351518597856635956, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3} - target: {fileID: 3351518597856635956, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_Pivot.x propertyPath: m_Pivot.x
value: 0.5 value: 0.5
@ -471,9 +519,129 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3949232578393738854, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3949232578393738854, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3949232578393738854, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3949232578393738854, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3949232578393738854, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3949232578393738854, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4683416251428496599, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3} - target: {fileID: 4683416251428496599, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: UIDeck value: UIDeck
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4951491574161479434, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4951491574161479434, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4951491574161479434, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4951491574161479434, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4951491574161479434, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4951491574161479434, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6691872718163008490, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6691872718163008490, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6691872718163008490, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6691872718163008490, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6691872718163008490, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6691872718163008490, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6915207597938486102, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6915207597938486102, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6915207597938486102, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6915207597938486102, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6915207597938486102, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6915207597938486102, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8299245348046405515, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8299245348046405515, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8299245348046405515, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8299245348046405515, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8299245348046405515, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8299245348046405515, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 0890cb6eff04b7c46be2a388688fe4d6, type: 3}

View File

@ -7,14 +7,13 @@ public class Deck : MonoBehaviour
{ {
public List<CardData> cardDataList; public List<CardData> cardDataList;
public List<CardData> drawList; //public List<CardData> drawList;
// Control Card Display
public List<GameObject> drawDisplayList; public List<GameObject> drawDisplayList;
public List<CardData> handList; //public List<CardData> handList;
//public List<GameObject> handDisplayList;
public List<CardData> discardList; //public List<CardData> discardList;
// Control Card Display
public List<GameObject> discardDisplayList; public List<GameObject> discardDisplayList;
public List<CardData> wasteList; public List<CardData> wasteList;
@ -26,14 +25,26 @@ public class Deck : MonoBehaviour
public GameObject drawListContent; public GameObject drawListContent;
public GameObject discardListContent; public GameObject discardListContent;
private int cardInHandAmount = 0;
// Card Limit
public int maxCardinHandLimit = 10;
public int maxCardRemainLimit = 5;
private GameObject reachCardinHandLimitWarningDisplay;
private float warningDisplayCountDown;
private float warningDisplayTime = 1.0f;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
reachCardinHandLimitWarningDisplay = transform.Find("Content/LimitWarning").gameObject;
reachCardinHandLimitWarningDisplay.SetActive(false);
randomSeed = 200; randomSeed = 200;
Random.InitState(randomSeed); Random.InitState(randomSeed);
for (int i = 0; i < cardDataList.Count; i++) for (int i = 0; i < cardDataList.Count; i++)
{ {
drawList.Add(cardDataList[i]); //drawList.Add(cardDataList[i]);
GameObject tempDrawDisplay = Instantiate(cardDisplayTemplate.gameObject, transform.Find("DrawListContent/Viewport/Content")); GameObject tempDrawDisplay = Instantiate(cardDisplayTemplate.gameObject, transform.Find("DrawListContent/Viewport/Content"));
tempDrawDisplay.transform.Find("Card").gameObject.GetComponent<CardDisplay>().SetCardData(cardDataList[i]); tempDrawDisplay.transform.Find("Card").gameObject.GetComponent<CardDisplay>().SetCardData(cardDataList[i]);
tempDrawDisplay.transform.Find("Button").gameObject.GetComponent<Image>().sprite = cardDataList[i].artwork; tempDrawDisplay.transform.Find("Button").gameObject.GetComponent<Image>().sprite = cardDataList[i].artwork;
@ -50,24 +61,44 @@ public class Deck : MonoBehaviour
} }
private void FixedUpdate()
{
if (warningDisplayCountDown >= 0.0f)
{
warningDisplayCountDown -= Time.deltaTime;
if (warningDisplayCountDown <= 0.0f)
{
DeactivateCardInHandLimitWarning();
}
}
}
public void DrawCards(int amount) public void DrawCards(int amount)
{ {
for (int i = 0; i < amount; i++) for (int i = 0; i < amount; i++)
{ {
if (drawList.Count == 0) if (cardInHandAmount > maxCardinHandLimit - 1)
{
ActivateCardInHandLimitWarning();
return;
}
if (drawDisplayList.Count == 0)
{ {
Shuffle(); Shuffle();
} }
if(drawList.Count==0) if (drawDisplayList.Count == 0)
{ {
return; return;
} }
int randomIndex = Random.Range(0, drawList.Count); int randomIndex = Random.Range(0, drawDisplayList.Count);
GameObject cardObj = Instantiate(handCardTemplate.gameObject, transform.Find("Content/HandList")); GameObject cardObj = Instantiate(handCardTemplate.gameObject, transform.Find("Content/HandList"));
var tempCardData = drawDisplayList[randomIndex].transform.Find("Card").gameObject.GetComponent<CardDisplay>().cardData;
cardObj.transform.Find("Card").gameObject.GetComponent<CardDisplay>().SetCardData(tempCardData);
cardObj.transform.Find("Button").gameObject.GetComponent<Image>().sprite = tempCardData.artwork;
cardObj.SetActive(true); cardObj.SetActive(true);
cardObj.transform.Find("Card").gameObject.GetComponent<CardDisplay>().SetCardData(drawList[randomIndex]); cardInHandAmount++;
cardObj.transform.Find("Button").gameObject.GetComponent<Image>().sprite = drawList[randomIndex].artwork; //handDisplayList.Add(cardObj);
drawList.RemoveAt(randomIndex); //handList.Add(drawList[randomIndex]);
Destroy(drawDisplayList[randomIndex]); Destroy(drawDisplayList[randomIndex]);
drawDisplayList.RemoveAt(randomIndex); drawDisplayList.RemoveAt(randomIndex);
} }
@ -83,55 +114,65 @@ public class Deck : MonoBehaviour
//} //}
//else //else
//{ //{
discardList.Add(handList[index]);
//} //}
handList.RemoveAt(index);
} }
public void UseThisCard(GameObject card) public void UseThisCard(GameObject card)
{ {
GameObject tempDiscardDisplay = Instantiate(cardDisplayTemplate.gameObject, transform.Find("DiscardListContent/Viewport/Content")); GameObject tempDiscardDisplay = Instantiate(cardDisplayTemplate.gameObject, transform.Find("DiscardListContent/Viewport/Content"));
tempDiscardDisplay.SetActive(true); tempDiscardDisplay.SetActive(true);
tempDiscardDisplay.transform.Find("Card").gameObject.GetComponent<CardDisplay>().SetCardData(card.transform.Find("Card").gameObject.gameObject.GetComponent<CardDisplay>().cardData); tempDiscardDisplay.transform.Find("Card").gameObject.GetComponent<CardDisplay>().SetCardData(card.transform.Find("Card").GetComponent<CardDisplay>().cardData);
tempDiscardDisplay.transform.Find("Button").gameObject.GetComponent<Image>().sprite = card.transform.Find("Card").gameObject.gameObject.GetComponent<CardDisplay>().cardData.artwork; tempDiscardDisplay.transform.Find("Button").gameObject.GetComponent<Image>().sprite = card.transform.Find("Card").GetComponent<CardDisplay>().cardData.artwork;
discardDisplayList.Add(tempDiscardDisplay); discardDisplayList.Add(tempDiscardDisplay);
discardList.Add(card.transform.Find("Card").gameObject.gameObject.GetComponent<CardDisplay>().cardData); //discardList.Add(card.transform.Find("Card").gameObject.gameObject.GetComponent<CardDisplay>().cardData);
//handDisplayList.Find(card);
Destroy(card); Destroy(card);
cardInHandAmount--;
} }
// When unit dead // When unit dead
public void AddACardIntoDiscardList(CardData card) public void AddACardIntoDiscardList(CardData card)
{ {
discardList.Add(card);
} }
public void Shuffle() public void Shuffle()
{ {
// Put all cards in drawList into discardList // Put all cards in drawList into discardList
for (int i = 0; i < drawList.Count; i++) List<CardData> tempCardDataList = new List<CardData>();
for (int i = 0; i < drawDisplayList.Count; i++)
{ {
discardList.Add(drawList[i]); tempCardDataList.Add(drawDisplayList[i].transform.Find("Card").GetComponent<CardDisplay>().cardData);
Destroy(drawDisplayList[i]); Destroy(drawDisplayList[i]);
} }
drawDisplayList.Clear(); drawDisplayList.Clear();
drawList.Clear(); //drawList.Clear();
while (discardList.Count != 0) for (int i = 0; i < tempCardDataList.Count; i++)
{ {
int index = Random.Range(0, discardList.Count);
drawList.Add(discardList[index]);
GameObject tempCardDisplay = Instantiate(cardDisplayTemplate.gameObject,transform.Find("DrawListContent/Viewport/Content")); GameObject tempCardDisplay = Instantiate(cardDisplayTemplate.gameObject,transform.Find("DrawListContent/Viewport/Content"));
tempCardDisplay.transform.Find("Card").gameObject.GetComponent<CardDisplay>().SetCardData(discardList[index]); tempCardDisplay.transform.Find("Card").gameObject.GetComponent<CardDisplay>().SetCardData(tempCardDataList[i]);
tempCardDisplay.transform.Find("Button").gameObject.GetComponent<Image>().sprite = discardList[index].artwork; tempCardDisplay.transform.Find("Button").gameObject.GetComponent<Image>().sprite = tempCardDataList[i].artwork;
tempCardDisplay.SetActive(true); tempCardDisplay.SetActive(true);
drawDisplayList.Add(tempCardDisplay); drawDisplayList.Add(tempCardDisplay);
discardList[index] = discardList[discardList.Count - 1];
discardList.RemoveAt(discardList.Count - 1);
};
for (int i = 0; i < discardDisplayList.Count; i++)
{
Destroy(discardDisplayList[i]);
} }
tempCardDataList.Clear();
while (discardDisplayList.Count != 0)
{
int index = Random.Range(0, discardDisplayList.Count);
GameObject tempCardDisplay = Instantiate(cardDisplayTemplate.gameObject, transform.Find("DrawListContent/Viewport/Content"));
CardData tempCardData = discardDisplayList[index].transform.Find("Card").GetComponent<CardDisplay>().cardData;
tempCardDisplay.transform.Find("Card").gameObject.GetComponent<CardDisplay>().SetCardData(tempCardData);
tempCardDisplay.transform.Find("Button").gameObject.GetComponent<Image>().sprite = tempCardData.artwork;
tempCardDisplay.SetActive(true);
drawDisplayList.Add(tempCardDisplay);
Destroy(discardDisplayList[index]);
discardDisplayList.RemoveAt(index);
};
Debug.LogError(discardDisplayList.Count);
discardDisplayList.Clear();
} }
public void ActivateDisplayDrawList() public void ActivateDisplayDrawList()
@ -153,4 +194,23 @@ public class Deck : MonoBehaviour
{ {
discardListContent.SetActive(false); discardListContent.SetActive(false);
} }
private void ActivateCardInHandLimitWarning()
{
reachCardinHandLimitWarningDisplay.SetActive(true);
warningDisplayCountDown = warningDisplayTime;
}
private void DeactivateCardInHandLimitWarning()
{
reachCardinHandLimitWarningDisplay.SetActive(false);
}
public void EndRound()
{
if (cardInHandAmount > maxCardRemainLimit)
{
}
}
} }