From 5717dd259bbe387ed62c54e8ca5382f78a1331e5 Mon Sep 17 00:00:00 2001 From: Piegames <14054505+piegamesde@users.noreply.github.com> Date: Mon, 23 Apr 2018 19:39:37 +0200 Subject: [PATCH] Win with the flag (TODO for the flag) --- Assets/Scenes/CodeDEV.unity | 1 + Assets/Scripts/GameController.cs | 16 ++++++++++------ Assets/Scripts/Generation/GenerationProcessor.cs | 4 ++-- Assets/Scripts/Objectives/FinishObjective.cs | 3 ++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Assets/Scenes/CodeDEV.unity b/Assets/Scenes/CodeDEV.unity index 21c0de8..ff3d5fc 100644 --- a/Assets/Scenes/CodeDEV.unity +++ b/Assets/Scenes/CodeDEV.unity @@ -1409,6 +1409,7 @@ MonoBehaviour: RockLUR: {fileID: 1938166751346222, guid: 6b83a6a46c57a634fa5085684bad0085, type: 2} RockURD: {fileID: 1437035058628240, guid: 30338afac8ce7054fbff8de89db815e8, type: 2} RockLRD: {fileID: 1251219893662246, guid: e37e0c5d4b013304cbcb32b223264452, type: 2} + Flag: {fileID: 1971451785855062, guid: ff87b9de73979cd40a9853419833a91f, type: 2} playerPrefab: {fileID: 1679161327080020, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} ui: {fileID: 1379476069} diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 239720f..0b92843 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -67,9 +67,11 @@ public class GameController : MonoBehaviour { [SerializeField] GameObject RockLUR; [SerializeField] - GameObject RockURD; + GameObject RockURD; [SerializeField] - GameObject RockLRD; + GameObject RockLRD; + [SerializeField] + GameObject Flag; private Dictionary genPrefabs; private Dictionary enemyPrefabs; @@ -127,8 +129,9 @@ public class GameController : MonoBehaviour { { GenerationProcessor.ExtendedTileType.Ground1, Ground1 }, { GenerationProcessor.ExtendedTileType.Ground2, Ground2 }, { GenerationProcessor.ExtendedTileType.Ground3, Ground3 }, - { GenerationProcessor.ExtendedTileType.DoorInner, DoorInner }, - { GenerationProcessor.ExtendedTileType.DoorOuter, DoorOuter } + { GenerationProcessor.ExtendedTileType.DoorInner, DoorInner }, + { GenerationProcessor.ExtendedTileType.DoorOuter, DoorOuter }, + { GenerationProcessor.ExtendedTileType.Flag, Flag } }; enemyPrefabs = new Dictionary { { Enemy.Enemys.SCORPION, scorpion } @@ -228,9 +231,10 @@ public class GameController : MonoBehaviour { finish.SetDoorsRootObject(doorRootf); finish.Reload(); finish.transform.SetParent(mapRoot.transform); + gp.CreateGOFromType(finish.GetCenter(), 0, Room.TileType.DOOR, GenerationProcessor.ExtendedTileType.Flag, goFinish); - // Other Rooms - foreach (GenRoom gr in dg.rooms) { + // Other Rooms + foreach (GenRoom gr in dg.rooms) { GameObject groom = gp.ProcessRoom(gr.tiles); List ltg = new List(groom.GetComponentsInChildren()); diff --git a/Assets/Scripts/Generation/GenerationProcessor.cs b/Assets/Scripts/Generation/GenerationProcessor.cs index 19bf598..ddc89a7 100644 --- a/Assets/Scripts/Generation/GenerationProcessor.cs +++ b/Assets/Scripts/Generation/GenerationProcessor.cs @@ -4,7 +4,7 @@ using UnityEngine; public class GenerationProcessor { public enum ExtendedTileType { - BorderOuter, BorderInner, BorderSingle, Ground0, Ground1, Ground2, Ground3, DoorInner, DoorOuter, Rock, RockL, RockU, RockR, RockD, RockLU, RockLR, RockLD, RockUR, RockUD, RockRD, RockLURD, RockLUD, RockLUR, RockURD, RockLRD + BorderOuter, BorderInner, BorderSingle, Ground0, Ground1, Ground2, Ground3, DoorInner, DoorOuter, Rock, RockL, RockU, RockR, RockD, RockLU, RockLR, RockLD, RockUR, RockUD, RockRD, RockLURD, RockLUD, RockLUR, RockURD, RockLRD, Flag } Dictionary prefabs; public GenerationProcessor(Dictionary prefabs) { @@ -39,7 +39,7 @@ public class GenerationProcessor { return root; } - private GameObject CreateGOFromType(Vector2 v, int rotation, Room.TileType type, ExtendedTileType t, GameObject root) { + public GameObject CreateGOFromType(Vector2 v, int rotation, Room.TileType type, ExtendedTileType t, GameObject root) { GameObject tmp = null; if (type != Room.TileType.GROUND) CreateGOFromType(v, 0, Room.TileType.GROUND, GetRandomGroundType(), root); diff --git a/Assets/Scripts/Objectives/FinishObjective.cs b/Assets/Scripts/Objectives/FinishObjective.cs index 4a309b5..e5c887e 100644 --- a/Assets/Scripts/Objectives/FinishObjective.cs +++ b/Assets/Scripts/Objectives/FinishObjective.cs @@ -13,7 +13,8 @@ public class FinishObjective : Objective { } public override void UpdateGoal() { - ReachedGoal(); + if ((room.GetCenter() - (Vector2)player.transform.position).magnitude < 2) + ReachedGoal(); } protected override void ReachedGoal() {