From 05fee309c3f5e4282559bc6eedaa07532df4e1fb Mon Sep 17 00:00:00 2001 From: henriquenakashima Date: Sat, 19 Sep 2020 14:06:36 -0400 Subject: [PATCH] DrawPileUI and DiscardPileUI --- Assets/Battle/BattleController.cs | 13 +- Assets/Battle/BattlePlayerControls.cs | 2 +- Assets/Battle/BattleScene.unity | 260 ++++++++++++++++++++++++++ Assets/Battle/DiscardPileUI.cs | 19 ++ Assets/Battle/DiscardPileUI.cs.meta | 11 ++ Assets/Battle/DrawPileUI.cs | 19 ++ Assets/Battle/DrawPileUI.cs.meta | 11 ++ Assets/Battle/HeroDeck.cs | 10 +- 8 files changed, 338 insertions(+), 7 deletions(-) create mode 100644 Assets/Battle/DiscardPileUI.cs create mode 100644 Assets/Battle/DiscardPileUI.cs.meta create mode 100644 Assets/Battle/DrawPileUI.cs create mode 100644 Assets/Battle/DrawPileUI.cs.meta diff --git a/Assets/Battle/BattleController.cs b/Assets/Battle/BattleController.cs index 12f0b68..9707dee 100644 --- a/Assets/Battle/BattleController.cs +++ b/Assets/Battle/BattleController.cs @@ -27,11 +27,6 @@ public class BattleController : MonoBehaviour private int energy; void Awake() { - } - - // Start is called before the first frame update - void Start() - { this.heroDeck = new HeroDeck(cardIds); heroes = new BattleHero[3]; @@ -78,7 +73,11 @@ public class BattleController : MonoBehaviour this.battlePlayerControls.OnCardUsed += this.NotifyCardUsed; this.battlePlayerControls.OnTurnPassed += this.NotifyTurnPassed; this.heroDeck.OnHandPileChanged += this.battlePlayerControls.NotifyHandPileChanged; + } + // Start is called before the first frame update + void Start() + { DecideEnemyTarget(); StartHeroTurn(); } @@ -155,4 +154,8 @@ public class BattleController : MonoBehaviour public int GetMaxEnergy() { return this.maxEnergy; } + + public HeroDeck GetHeroDeck() { + return this.heroDeck; + } } diff --git a/Assets/Battle/BattlePlayerControls.cs b/Assets/Battle/BattlePlayerControls.cs index 422f9c8..1925a21 100644 --- a/Assets/Battle/BattlePlayerControls.cs +++ b/Assets/Battle/BattlePlayerControls.cs @@ -99,6 +99,6 @@ public class BattlePlayerControls : MonoBehaviour } public void NotifyHandPileChanged() { - SetHand(this.heroDeck.GetHand()); + SetHand(this.heroDeck.GetHandPile()); } } diff --git a/Assets/Battle/BattleScene.unity b/Assets/Battle/BattleScene.unity index 16933bc..510c0e3 100644 --- a/Assets/Battle/BattleScene.unity +++ b/Assets/Battle/BattleScene.unity @@ -264,6 +264,8 @@ RectTransform: m_Children: - {fileID: 1415908914} - {fileID: 24180900} + - {fileID: 1887276863} + - {fileID: 2103461257} m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -550,6 +552,84 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1242658818 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1242658819} + - component: {fileID: 1242658821} + - component: {fileID: 1242658820} + m_Layer: 5 + m_Name: DrawPileText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1242658819 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1242658818} + 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_Children: [] + m_Father: {fileID: 1887276863} + 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: -467.1, y: -316} + m_SizeDelta: {x: 171.60992, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1242658820 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1242658818} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 20 + m_FontStyle: 1 + m_BestFit: 0 + m_MinSize: 2 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 'Draw pile: 5' +--- !u!222 &1242658821 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1242658818} + m_CullTransparentMesh: 0 --- !u!1 &1415908913 GameObject: m_ObjectHideFlags: 0 @@ -727,6 +807,186 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1522237120 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1522237121} + - component: {fileID: 1522237123} + - component: {fileID: 1522237122} + m_Layer: 5 + m_Name: DiscardPileText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1522237121 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1522237120} + 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_Children: [] + m_Father: {fileID: 2103461257} + 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: -467.1, y: -345.14} + m_SizeDelta: {x: 171.60992, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1522237122 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1522237120} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 20 + m_FontStyle: 1 + m_BestFit: 0 + m_MinSize: 2 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 'Draw pile: 5' +--- !u!222 &1522237123 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1522237120} + m_CullTransparentMesh: 0 +--- !u!1 &1887276862 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1887276863} + - component: {fileID: 1887276864} + m_Layer: 5 + m_Name: DrawPileUI + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1887276863 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1887276862} + 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_Children: + - {fileID: 1242658819} + m_Father: {fileID: 35522592} + m_RootOrder: 2 + 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: 60} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1887276864 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1887276862} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b39e026c50828b04ab3d0627aaf962d6, type: 3} + m_Name: + m_EditorClassIdentifier: + text: {fileID: 1242658820} + battleController: {fileID: 359124400} +--- !u!1 &2103461256 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2103461257} + - component: {fileID: 2103461258} + m_Layer: 5 + m_Name: DiscardPileUI + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2103461257 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2103461256} + 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_Children: + - {fileID: 1522237121} + m_Father: {fileID: 35522592} + m_RootOrder: 3 + 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: 60} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2103461258 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2103461256} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b39e026c50828b04ab3d0627aaf962d6, type: 3} + m_Name: + m_EditorClassIdentifier: + text: {fileID: 1522237122} + battleController: {fileID: 359124400} --- !u!1 &2141503599 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Battle/DiscardPileUI.cs b/Assets/Battle/DiscardPileUI.cs new file mode 100644 index 0000000..f8af11d --- /dev/null +++ b/Assets/Battle/DiscardPileUI.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class DiscardPileUI : MonoBehaviour +{ + public Text text; + public BattleController battleController; + + void Start() { + this.battleController.GetHeroDeck().OnDiscardPileChanged += NotifyDiscardPileChanged; + NotifyDiscardPileChanged(); + } + + public void NotifyDiscardPileChanged() { + text.text = "Discard pile: " + this.battleController.GetHeroDeck().GetDiscardPile().Count; + } +} diff --git a/Assets/Battle/DiscardPileUI.cs.meta b/Assets/Battle/DiscardPileUI.cs.meta new file mode 100644 index 0000000..3fa3e5b --- /dev/null +++ b/Assets/Battle/DiscardPileUI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 077ba059e9689fa4990b9aea8bff3ded +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Battle/DrawPileUI.cs b/Assets/Battle/DrawPileUI.cs new file mode 100644 index 0000000..6e2a62d --- /dev/null +++ b/Assets/Battle/DrawPileUI.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class DrawPileUI : MonoBehaviour +{ + public Text text; + public BattleController battleController; + + void Start() { + this.battleController.GetHeroDeck().OnDrawPileChanged += NotifyDrawPileChanged; + NotifyDrawPileChanged(); + } + + public void NotifyDrawPileChanged() { + text.text = "Draw pile: " + this.battleController.GetHeroDeck().GetDrawPile().Count; + } +} diff --git a/Assets/Battle/DrawPileUI.cs.meta b/Assets/Battle/DrawPileUI.cs.meta new file mode 100644 index 0000000..5d29947 --- /dev/null +++ b/Assets/Battle/DrawPileUI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b39e026c50828b04ab3d0627aaf962d6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Battle/HeroDeck.cs b/Assets/Battle/HeroDeck.cs index b98d364..0be7ecb 100644 --- a/Assets/Battle/HeroDeck.cs +++ b/Assets/Battle/HeroDeck.cs @@ -29,10 +29,18 @@ public class HeroDeck this.drawPile.Shuffle(); } - public List GetHand() { + public List GetDrawPile() { + return drawPile; + } + + public List GetHandPile() { return handPile; } + public List GetDiscardPile() { + return discardPile; + } + public void DrawHand() { for (int i = 0; i < DEFAULT_HAND_DRAWN; i++) { DrawCardInternal();