Jelajahi Sumber

Setup again

Axel Nordh 3 tahun lalu
induk
melakukan
c4faaed033

+ 36 - 0
Assets/Prefabs/Tiles/HilightMapMovement.asset

@@ -0,0 +1,36 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 13312, guid: 0000000000000000e000000000000000, type: 0}
+  m_Name: HilightMapMovement
+  m_EditorClassIdentifier: 
+  m_Sprite: {fileID: 7482667652216324306, guid: a3ea9db81590f1b4ea6da84e72ae1808, type: 3}
+  m_Color: {r: 1, g: 1, b: 1, a: 0.19607843}
+  m_Transform:
+    e00: 1
+    e01: 0
+    e02: 0
+    e03: 0
+    e10: 0
+    e11: 1
+    e12: 0
+    e13: 0
+    e20: 0
+    e21: 0
+    e22: 1
+    e23: 0
+    e30: 0
+    e31: 0
+    e32: 0
+    e33: 1
+  m_InstancedGameObject: {fileID: 0}
+  m_Flags: 1
+  m_ColliderType: 1

+ 8 - 0
Assets/Prefabs/Tiles/HilightMapMovement.asset.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 87fb53d72ee52484aa58f1c331c20c2a
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 11400000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 6
Assets/Scenes/SampleScene.unity

@@ -134,7 +134,7 @@ GameObject:
   - component: {fileID: 43246149}
   - component: {fileID: 43246151}
   - component: {fileID: 43246150}
-  m_Layer: 6
+  m_Layer: 9
   m_Name: HighlightTileMap
   m_TagString: Untagged
   m_Icon: {fileID: 0}
@@ -192,8 +192,8 @@ TilemapRenderer:
   m_AutoUVMaxDistance: 0.5
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
-  m_SortingLayerID: 1491650219
-  m_SortingLayer: 1
+  m_SortingLayerID: 664561713
+  m_SortingLayer: 2
   m_SortingOrder: 5
   m_ChunkSize: {x: 32, y: 32, z: 32}
   m_ChunkCullingBounds: {x: 0, y: 0, z: 0}
@@ -6752,7 +6752,7 @@ TilemapCollider2D:
   m_Enabled: 1
   m_Density: 1
   m_Material: {fileID: 0}
-  m_IsTrigger: 1
+  m_IsTrigger: 0
   m_UsedByEffector: 0
   m_UsedByComposite: 0
   m_Offset: {x: 0, y: 0}
@@ -7030,7 +7030,7 @@ SpriteRenderer:
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: -156833673
-  m_SortingLayer: 2
+  m_SortingLayer: 3
   m_SortingOrder: 0
   m_Sprite: {fileID: -6426286884345725158, guid: 948009065a290d14296cd54174479615, type: 3}
   m_Color: {r: 1, g: 1, b: 1, a: 1}
@@ -7433,6 +7433,7 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   highlightMap: {fileID: 43246151}
   hilightTile: {fileID: 11400000, guid: b47bf3005a56c9d47817b5372cd53c84, type: 2}
+  hilightMovementAreaTile: {fileID: 11400000, guid: 87fb53d72ee52484aa58f1c331c20c2a, type: 2}
 --- !u!1 &1095186198
 GameObject:
   m_ObjectHideFlags: 0
@@ -7504,7 +7505,7 @@ SpriteRenderer:
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: -156833673
-  m_SortingLayer: 2
+  m_SortingLayer: 3
   m_SortingOrder: 0
   m_Sprite: {fileID: 4343691258111002008, guid: 948009065a290d14296cd54174479615, type: 3}
   m_Color: {r: 1, g: 1, b: 1, a: 1}
@@ -7875,6 +7876,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   executeRoundButton: {fileID: 1580095773}
+  activeCreature: {fileID: 0}
   decitionButtonsPanel: {fileID: 405602147}
   moveActionButton: {fileID: 670570518}
   attackActionButton: {fileID: 2038126661}

+ 3 - 4
Assets/Scripts/Creatures/Actions/AttackAction.cs

@@ -6,7 +6,8 @@ using UnityEngine;
 public class AttackAction : IAction {
     private Creature Target;
     private Creature Attacker;
-
+    bool hilightEnbled = true;
+    public bool HilightEnabled { get => hilightEnbled; set => hilightEnbled = value; }
     public AttackAction(Creature attacker, Creature target) {
         Target = target;
         Attacker = attacker;
@@ -31,7 +32,5 @@ public class AttackAction : IAction {
         actionPerformed = true;
         yield return new WaitForSeconds(3);
     }
-    bool IAction.GetHilightEnabled() {
-        return true;
-    }
+
 }

+ 1 - 1
Assets/Scripts/Creatures/Actions/IAction.cs

@@ -7,5 +7,5 @@ public interface IAction {
     public bool ActionPerformed { get; set; }
     public IEnumerator PerformAction();
 
-    public abstract bool GetHilightEnabled();
+    public bool HilightEnabled { get; set; }
 }

+ 2 - 3
Assets/Scripts/Creatures/Actions/MoveAction.cs

@@ -18,6 +18,8 @@ public class MoveAction : IAction {
     private LineRenderer LR;
 
     public bool ActionPerformed { get => actionPerformed; set => actionPerformed = value; }
+    bool hilightEnbled = true;
+    public bool HilightEnabled { get => hilightEnbled; set => hilightEnbled = value; }
 
     public void SetStartPosition(Vector3 startPos) {
         startPosition = startPos;
@@ -159,7 +161,4 @@ public class MoveAction : IAction {
         return returnValue;
     }
 
-    bool IAction.GetHilightEnabled() {
-        return true;
-    }
 }

+ 3 - 3
Assets/Scripts/Creatures/Actions/SpellAction.cs

@@ -7,6 +7,8 @@ public class SpellAction : IAction {
     private GameObject target;
 
     public bool ActionPerformed { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
+    bool hilightEnbled = true;
+    public bool HilightEnabled { get => hilightEnbled; set => hilightEnbled = value; }
 
     public IEnumerator PerformAction() {
         throw new System.NotImplementedException();
@@ -23,7 +25,5 @@ public class SpellAction : IAction {
     void Update() {
 
     }
-    bool IAction.GetHilightEnabled() {
-        return true;
-    }
+
 }

+ 17 - 3
Assets/Scripts/Grid/GridController.cs

@@ -8,20 +8,26 @@ public class GridController : MonoBehaviour {
 
     [SerializeField] Tilemap highlightMap = null;
     [SerializeField] TileBase hilightTile = null;
+    [SerializeField] TileBase hilightMovementAreaTile = null;
     private IAction hilightAction;
 
     public IAction HilightAction { get => hilightAction; set => hilightAction = value; }
 
     // Update is called once per frame
     void Update() {
-        if (Input.GetMouseButtonDown(0) && hilightAction != null && hilightAction.GetHilightEnabled()) {
+        if (Input.GetMouseButtonDown(0) && hilightAction != null && hilightAction.HilightEnabled) {
+            PaintMovementArea(RoundManager.GetInstance().activeCreature);
             Vector3Int clickedPos = GetMousePosition();
             highlightMap.SetTile(clickedPos, hilightTile);
-
+            hilightAction.HilightEnabled = false;
             // TODO needs better handling.. Should be in MoveAction???
             YesNoDilougueUI.Instance.ShowDialog("Are you sure you want to move here?",
                 () => { Debug.Log("YES PRESSED"); /* Confirm the move and paint the path to take. */},
-                () => { Debug.Log("NO PRESSED"); highlightMap.SetTile(clickedPos, null); });
+                () => {
+                    Debug.Log("NO PRESSED");
+                    highlightMap.SetTile(clickedPos, null);
+                    hilightAction.HilightEnabled = true;
+                });
         }
     }
 
@@ -32,4 +38,12 @@ public class GridController : MonoBehaviour {
         return GameManagerScript.GetInstance().TileMap.WorldToCell(worldPoint);
     }
 
+    public void PaintMovementArea(Creature toMove) {
+        Vector3 startPos = toMove.transform.position;
+        int movementInSquares = Mathf.FloorToInt(toMove.GetComponent<Creature>().movementRate / 5);
+        //Physics2D.OverlapCircle(startPos); Maybe this one.. don't know
+        Collider2D[] collider2Ds = Physics2D.OverlapCircleAll(new Vector2(startPos.x, startPos.y), movementInSquares, LayerMask.NameToLayer("Ground"));
+
+        Debug.Log("Hitting " + collider2Ds.Length);
+    }
 }

+ 8 - 1
Assets/Scripts/RoundManager.cs

@@ -12,17 +12,24 @@ public class RoundManager : MonoBehaviour {
     int round;
 
     private bool executing = false;
-    private Creature activeCreature;
+    public Creature activeCreature;
     [SerializeField] GameObject decitionButtonsPanel;
     [SerializeField] Button moveActionButton;
     [SerializeField] Button attackActionButton;
     private bool movingAction;
     private List<Vector3> highlightedTiles;
 
+    static RoundManager instance;
+
     private void Start() {
         executeRoundButton.onClick.AddListener(ExecuteRound);
         moveActionButton.onClick.AddListener(CreateMoveAction);
         attackActionButton.onClick.AddListener(CreateAttackAction);
+        instance = this;
+    }
+
+    public static RoundManager GetInstance() {
+        return instance;
     }
 
     private void CreateAttackAction() {

+ 5 - 2
ProjectSettings/TagManager.asset

@@ -13,12 +13,12 @@ TagManager:
   - Water
   - UI
   - Ground
-  - enemies
-  - 
   - 
   - 
+  - Hilight
   - 
   - 
+  - enemies
   - 
   - 
   - 
@@ -45,6 +45,9 @@ TagManager:
   - name: Ground
     uniqueID: 1491650219
     locked: 0
+  - name: Hilihght
+    uniqueID: 664561713
+    locked: 0
   - name: Creatures
     uniqueID: 4138133623
     locked: 0