Added comments to unfinished code | Tile tags changed | WIP Spawnpoint
This commit is contained in:
parent
4119fdb2c6
commit
5a01e45f0c
13 changed files with 217 additions and 145 deletions
|
@ -21,9 +21,11 @@ GameObject:
|
||||||
- component: {fileID: 4704489882212962}
|
- component: {fileID: 4704489882212962}
|
||||||
- component: {fileID: 212166467098511970}
|
- component: {fileID: 212166467098511970}
|
||||||
- component: {fileID: 61866627210428188}
|
- component: {fileID: 61866627210428188}
|
||||||
|
- component: {fileID: 114053119853995034}
|
||||||
|
- component: {fileID: 61243635969098510}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: door
|
m_Name: door
|
||||||
m_TagString: Untagged
|
m_TagString: door
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
@ -41,6 +43,31 @@ Transform:
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!61 &61243635969098510
|
||||||
|
BoxCollider2D:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 1065161683117842}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Density: 1
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IsTrigger: 1
|
||||||
|
m_UsedByEffector: 0
|
||||||
|
m_UsedByComposite: 0
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_SpriteTilingProperty:
|
||||||
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
pivot: {x: 0.5, y: 0.5}
|
||||||
|
oldSize: {x: 1, y: 1}
|
||||||
|
newSize: {x: 1, y: 1}
|
||||||
|
adaptiveTilingThreshold: 0.5
|
||||||
|
drawMode: 0
|
||||||
|
adaptiveTiling: 0
|
||||||
|
m_AutoTiling: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Size: {x: 1, y: 1}
|
||||||
|
m_EdgeRadius: 0
|
||||||
--- !u!61 &61866627210428188
|
--- !u!61 &61866627210428188
|
||||||
BoxCollider2D:
|
BoxCollider2D:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
|
@ -66,6 +93,18 @@ BoxCollider2D:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 1, y: 1}
|
m_Size: {x: 1, y: 1}
|
||||||
m_EdgeRadius: 0
|
m_EdgeRadius: 0
|
||||||
|
--- !u!114 &114053119853995034
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 1065161683117842}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 8b8cc30ac6e59724bba6536a17fbf027, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
parent: {fileID: 0}
|
||||||
--- !u!212 &212166467098511970
|
--- !u!212 &212166467098511970
|
||||||
SpriteRenderer:
|
SpriteRenderer:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
|
|
|
@ -20,7 +20,6 @@ GameObject:
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 4167595944037000}
|
- component: {fileID: 4167595944037000}
|
||||||
- component: {fileID: 212910617741009226}
|
- component: {fileID: 212910617741009226}
|
||||||
- component: {fileID: 61790205413884498}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: ground
|
m_Name: ground
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -41,31 +40,6 @@ Transform:
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!61 &61790205413884498
|
|
||||||
BoxCollider2D:
|
|
||||||
m_ObjectHideFlags: 1
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 100100000}
|
|
||||||
m_GameObject: {fileID: 1487413182883822}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_Density: 1
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_IsTrigger: 0
|
|
||||||
m_UsedByEffector: 0
|
|
||||||
m_UsedByComposite: 0
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
m_SpriteTilingProperty:
|
|
||||||
border: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
pivot: {x: 0.5, y: 0.5}
|
|
||||||
oldSize: {x: 1, y: 1}
|
|
||||||
newSize: {x: 1, y: 1}
|
|
||||||
adaptiveTilingThreshold: 0.5
|
|
||||||
drawMode: 0
|
|
||||||
adaptiveTiling: 0
|
|
||||||
m_AutoTiling: 0
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Size: {x: 1, y: 1}
|
|
||||||
m_EdgeRadius: 0
|
|
||||||
--- !u!212 &212910617741009226
|
--- !u!212 &212910617741009226
|
||||||
SpriteRenderer:
|
SpriteRenderer:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
|
|
|
@ -23,7 +23,7 @@ GameObject:
|
||||||
- component: {fileID: 61976448807984186}
|
- component: {fileID: 61976448807984186}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: wallCornerIn
|
m_Name: wallCornerIn
|
||||||
m_TagString: Untagged
|
m_TagString: wall
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|
|
@ -23,7 +23,7 @@ GameObject:
|
||||||
- component: {fileID: 61112856149238616}
|
- component: {fileID: 61112856149238616}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: wallCornerOut
|
m_Name: wallCornerOut
|
||||||
m_TagString: Untagged
|
m_TagString: wall
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|
|
@ -23,7 +23,7 @@ GameObject:
|
||||||
- component: {fileID: 61106583680129832}
|
- component: {fileID: 61106583680129832}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: wallSide
|
m_Name: wallSide
|
||||||
m_TagString: Untagged
|
m_TagString: wall
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
[RequireComponent(typeof(SpriteRenderer))]
|
||||||
public class Door : MonoBehaviour {
|
public class Door : MonoBehaviour {
|
||||||
private bool locked = false;
|
private bool locked = false;
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
GameObject graphics;
|
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
Room parent;
|
Room parent;
|
||||||
|
|
||||||
|
@ -18,15 +15,23 @@ public class Door : MonoBehaviour {
|
||||||
foreach ( BoxCollider2D collider in colliders ) {
|
foreach ( BoxCollider2D collider in colliders ) {
|
||||||
if ( collider.isTrigger ) {
|
if ( collider.isTrigger ) {
|
||||||
triggerBox = collider;
|
triggerBox = collider;
|
||||||
Debug.Log("Found Door trigger");
|
//Debug.Log("Found Door trigger");
|
||||||
} else {
|
} else {
|
||||||
boundingBox = collider;
|
boundingBox = collider;
|
||||||
Debug.Log("Found Door collider");
|
//Debug.Log("Found Door collider");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the parent Room Object reference.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="room"></param>
|
||||||
|
public void SetParent(Room room) {
|
||||||
|
this.parent = room;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Locks the door.
|
/// Locks the door.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -34,7 +39,7 @@ public class Door : MonoBehaviour {
|
||||||
locked = true;
|
locked = true;
|
||||||
boundingBox.enabled = true;
|
boundingBox.enabled = true;
|
||||||
triggerBox.enabled = false;
|
triggerBox.enabled = false;
|
||||||
graphics.GetComponent<SpriteRenderer>().enabled = true;
|
GetComponent<SpriteRenderer>().enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -44,7 +49,7 @@ public class Door : MonoBehaviour {
|
||||||
locked = false;
|
locked = false;
|
||||||
boundingBox.enabled = false;
|
boundingBox.enabled = false;
|
||||||
triggerBox.enabled = true;
|
triggerBox.enabled = true;
|
||||||
graphics.GetComponent<SpriteRenderer>().enabled = false;
|
GetComponent<SpriteRenderer>().enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -60,10 +65,12 @@ public class Door : MonoBehaviour {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="collision"></param>
|
/// <param name="collision"></param>
|
||||||
private void OnTriggerExit2D(Collider2D collision) {
|
private void OnTriggerExit2D(Collider2D collision) {
|
||||||
if ( collision.tag == "Player" ) {
|
if ( collision.tag == "Player") {
|
||||||
// TODO better checks
|
// TODO better checks
|
||||||
Debug.Log("Leaving Trigger");
|
Debug.Log("Leaving Trigger");
|
||||||
parent.OnPlayerEnter(collision.gameObject.GetComponent<Player>());
|
if (parent != null) {
|
||||||
|
parent.OnPlayerEnter(collision.gameObject.GetComponent<Player>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class Player : Mob {
|
||||||
/// This is called when a Player died.
|
/// This is called when a Player died.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void Death() {
|
protected override void Death() {
|
||||||
|
Debug.Log("Player died...");
|
||||||
Destroy(this.gameObject);
|
Destroy(this.gameObject);
|
||||||
GameController.instance.ChangeState(GameController.GameState.ENDED);
|
GameController.instance.ChangeState(GameController.GameState.ENDED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,8 @@ using UnityEngine;
|
||||||
|
|
||||||
public class GameController : MonoBehaviour {
|
public class GameController : MonoBehaviour {
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
GameObject playerPrefab;
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
private Room start;
|
private Room start;
|
||||||
private Room finish;
|
private Room finish;
|
||||||
|
|
||||||
|
@ -58,14 +56,24 @@ public class GameController : MonoBehaviour {
|
||||||
|
|
||||||
private Dictionary<GenerationProcessor.ExtendedTileType, GameObject> genPrefabs;
|
private Dictionary<GenerationProcessor.ExtendedTileType, GameObject> genPrefabs;
|
||||||
|
|
||||||
|
[Space(10)]
|
||||||
|
[Header("References")]
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private GameObject playerPrefab;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private GameObject ui;
|
private GameObject ui;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private GameObject cam;
|
private GameObject cam;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private GameObject mapRoot;
|
||||||
|
|
||||||
private bool engineInitDone;
|
private bool engineInitDone;
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
public static GameController instance;
|
public static GameController instance;
|
||||||
public GameController() {
|
public GameController() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
@ -146,23 +154,67 @@ public class GameController : MonoBehaviour {
|
||||||
DungeonGenerator dg = new DungeonGenerator();
|
DungeonGenerator dg = new DungeonGenerator();
|
||||||
GenerationProcessor gp = new GenerationProcessor(genPrefabs);
|
GenerationProcessor gp = new GenerationProcessor(genPrefabs);
|
||||||
dg.Generate();
|
dg.Generate();
|
||||||
|
|
||||||
|
// Start room
|
||||||
GameObject goStart = gp.ProcessRoom(dg.start.tiles);
|
GameObject goStart = gp.ProcessRoom(dg.start.tiles);
|
||||||
|
goStart.name = "Start";
|
||||||
|
List<Transform> lt = new List<Transform>(goStart.GetComponentsInChildren<Transform>());
|
||||||
|
GameObject doorRoot = new GameObject();
|
||||||
|
doorRoot.name = "Doors";
|
||||||
|
doorRoot.transform.SetParent(goStart.transform);
|
||||||
start = goStart.AddComponent<Room>();
|
start = goStart.AddComponent<Room>();
|
||||||
//start.SetDoorsRootObject(new List<Transform>(goStart.GetComponentsInChildren<Transform>()).Find(x => x.tag == "DoorRoot").gameObject);
|
lt = lt.FindAll(x => x.tag == "door");
|
||||||
|
lt.ForEach(x => {
|
||||||
|
x.SetParent(doorRoot.transform);
|
||||||
|
x.gameObject.GetComponent<Door>().SetParent(start);
|
||||||
|
});
|
||||||
|
start.SetDoorsRootObject(doorRoot);
|
||||||
|
|
||||||
|
// WIP
|
||||||
|
GameObject spawnpointRoot = new GameObject();
|
||||||
|
spawnpointRoot.name = "Spawnpoints";
|
||||||
|
spawnpointRoot.transform.SetParent(goStart.transform);
|
||||||
|
spawnpointRoot.transform.position = new Vector3(dg.start.roomPosition.x, dg.start.roomPosition.y, 0);
|
||||||
|
GameObject spawn = new GameObject();
|
||||||
|
spawn.transform.SetParent(spawnpointRoot.transform);
|
||||||
|
spawn.transform.position = new Vector3(3, 3, 0);
|
||||||
|
start.SetSpawnPointsRootObject(spawnpointRoot);
|
||||||
|
|
||||||
start.Reload();
|
start.Reload();
|
||||||
start.transform.SetParent(mapRoot.transform);
|
start.transform.SetParent(mapRoot.transform);
|
||||||
|
|
||||||
|
// Finish room
|
||||||
GameObject goFinish = gp.ProcessRoom(dg.end.tiles);
|
GameObject goFinish = gp.ProcessRoom(dg.end.tiles);
|
||||||
|
goFinish.name = "Finish";
|
||||||
|
List<Transform> ltf = new List<Transform>(goFinish.GetComponentsInChildren<Transform>());
|
||||||
|
GameObject doorRootf = new GameObject();
|
||||||
|
doorRootf.name = "Doors";
|
||||||
|
doorRootf.transform.SetParent(goFinish.transform);
|
||||||
|
ltf = ltf.FindAll(x => x.tag == "door");
|
||||||
|
ltf.ForEach(x => x.SetParent(doorRootf.transform));
|
||||||
finish = goFinish.AddComponent<Room>();
|
finish = goFinish.AddComponent<Room>();
|
||||||
//finish.SetDoorsRootObject(new List<Transform>(goFinish.GetComponentsInChildren<Transform>()).Find(x => x.tag == "DoorRoot").gameObject);
|
finish.SetDoorsRootObject(doorRootf);
|
||||||
finish.Reload();
|
finish.Reload();
|
||||||
finish.transform.SetParent(mapRoot.transform);
|
finish.transform.SetParent(mapRoot.transform);
|
||||||
|
|
||||||
|
// Other Rooms
|
||||||
foreach (GenRoom gr in dg.rooms) {
|
foreach (GenRoom gr in dg.rooms) {
|
||||||
GameObject groom = gp.ProcessRoom(gr.tiles);
|
GameObject groom = gp.ProcessRoom(gr.tiles);
|
||||||
groom.AddComponent<Room>();
|
List<Transform> ltg = new List<Transform>(groom.GetComponentsInChildren<Transform>());
|
||||||
|
GameObject doorRootg = new GameObject();
|
||||||
|
doorRootg.name = "Doors";
|
||||||
|
doorRootg.transform.SetParent(groom.transform);
|
||||||
|
ltg = ltg.FindAll(x => x.tag == "door");
|
||||||
|
ltg.ForEach(x => x.SetParent(doorRootg.transform));
|
||||||
|
Room grom = groom.AddComponent<Room>();
|
||||||
|
grom.SetDoorsRootObject(doorRootg);
|
||||||
|
grom.Reload();
|
||||||
groom.transform.SetParent(mapRoot.transform);
|
groom.transform.SetParent(mapRoot.transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hallways
|
||||||
GameObject goHallways = gp.ProcessRoom(dg.path.tiles);
|
GameObject goHallways = gp.ProcessRoom(dg.path.tiles);
|
||||||
|
goHallways.name = "Hallways";
|
||||||
goHallways.AddComponent<Room>();
|
goHallways.AddComponent<Room>();
|
||||||
goHallways.transform.SetParent(mapRoot.transform);
|
goHallways.transform.SetParent(mapRoot.transform);
|
||||||
}
|
}
|
||||||
|
@ -172,11 +224,11 @@ public class GameController : MonoBehaviour {
|
||||||
start.SetObjective(goal);
|
start.SetObjective(goal);
|
||||||
start.OnPlayerEnter(player);
|
start.OnPlayerEnter(player);
|
||||||
player = goal.GetPlayer();
|
player = goal.GetPlayer();
|
||||||
cam.GetComponent<CameraControl>().SetFollow(player.gameObject);
|
if ( player != null ) {
|
||||||
}
|
cam.GetComponent<CameraControl>().SetFollow(player.gameObject);
|
||||||
|
} else {
|
||||||
private void Starting() {
|
Debug.Log("No Player spawned!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Running() {
|
private void Running() {
|
||||||
|
@ -187,10 +239,10 @@ public class GameController : MonoBehaviour {
|
||||||
Debug.Log("Game ended");
|
Debug.Log("Game ended");
|
||||||
//Time.timeScale = 0;
|
//Time.timeScale = 0;
|
||||||
if ( ui != null ) {
|
if ( ui != null ) {
|
||||||
Debug.Log("show gameover UI");
|
Debug.Log("show Gameover UI");
|
||||||
ui.GetComponent<UIController>().ShowGameOverUI();
|
ui.GetComponent<UIController>().ShowGameOverUI();
|
||||||
} else {
|
} else {
|
||||||
Debug.Log("No ui specified");
|
Debug.Log("No UI specified");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class DungeonGenerator {
|
||||||
// All rooms except the three above
|
// All rooms except the three above
|
||||||
public HashSet<GenRoom> rooms;
|
public HashSet<GenRoom> rooms;
|
||||||
|
|
||||||
private const float percentageRocks = 0.03;
|
private const float percentageRocks = 0.03f;
|
||||||
private const int maxRockCluster = 5;
|
private const int maxRockCluster = 5;
|
||||||
|
|
||||||
public void Generate() {
|
public void Generate() {
|
||||||
|
@ -355,30 +355,30 @@ public class DungeonGenerator {
|
||||||
|
|
||||||
public static void generateInterior(GenRoom r)
|
public static void generateInterior(GenRoom r)
|
||||||
{
|
{
|
||||||
int width = r.bounds.width;
|
//int width = r.bounds.width;
|
||||||
int height = r.bounds.height;
|
//int height = r.bounds.height;
|
||||||
|
|
||||||
Vector2Int root = new Vector2Int (1, 1);
|
//Vector2Int root = new Vector2Int (1, 1);
|
||||||
Random rand = new Random (System.DateTime.Now);
|
//Random rand = new Random (System.DateTime.Now);
|
||||||
|
|
||||||
for(int x = 0; i != width; ++x)
|
//for(int x = 0; i != width; ++x)
|
||||||
{
|
//{
|
||||||
for(int y = 0; y != width; ++y)
|
// for(int y = 0; y != width; ++y)
|
||||||
{
|
// {
|
||||||
Room.TileType tempTile;
|
// Room.TileType tempTile;
|
||||||
r.tiles.TryGetValue (root + new Vector2Int (x, y), tempTile);
|
// r.tiles.TryGetValue (root + new Vector2Int (x, y), tempTile);
|
||||||
|
|
||||||
if(rand.NextDouble() <= percentageRocks && tempTile.Equals(Room.TileType.GROUND)
|
// if(rand.NextDouble() <= percentageRocks && tempTile.Equals(Room.TileType.GROUND)
|
||||||
{
|
// {
|
||||||
int clusterSize = rand.Next (1, maxRockCluster + 1);
|
// int clusterSize = rand.Next (1, maxRockCluster + 1);
|
||||||
r.tiles.Add (root + new Vector2Int (x, y), Room.TileType.ROCK);
|
// r.tiles.Add (root + new Vector2Int (x, y), Room.TileType.ROCK);
|
||||||
|
|
||||||
for(int i = 0; i != clusterSize; ++i)
|
// for(int i = 0; i != clusterSize; ++i)
|
||||||
{
|
// {
|
||||||
Vector2Int newRock = root + new Vector2Int(x + rand.Next(0, 2), y + rand.Next(0, 2));
|
// Vector2Int newRock = root + new Vector2Int(x + rand.Next(0, 2), y + rand.Next(0, 2));
|
||||||
r.tiles.TryGetValue (newRock, tempTile);
|
// r.tiles.TryGetValue (newRock, tempTile);
|
||||||
if(!tempTile.Equals(Room.TileType.GROUND))
|
// if(!tempTile.Equals(Room.TileType.GROUND))
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class GenRoom {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateInteror()
|
public void generateInteror() {
|
||||||
{
|
|
||||||
b
|
}
|
||||||
}
|
}
|
|
@ -1,66 +1,66 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class NotificationManager : MonoBehaviour {
|
|
||||||
|
|
||||||
|
|
||||||
List<Notification> messages;
|
|
||||||
bool showingMessage;
|
|
||||||
float delay;
|
|
||||||
Text text;
|
|
||||||
|
|
||||||
class Notification {
|
|
||||||
string text;
|
|
||||||
float duration;
|
|
||||||
|
|
||||||
public Notification(string text, float duration) {
|
|
||||||
this.text = text;
|
|
||||||
this.duration = duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string getText() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getDuration() {
|
|
||||||
return duration;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use this for initialization
|
|
||||||
void Start () {
|
|
||||||
delay = 0;
|
|
||||||
showingMessage = false;
|
|
||||||
messages = new List<Notification>();
|
|
||||||
text = GetComponent<Text>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Update() {
|
public class NotificationManager : MonoBehaviour {
|
||||||
if (showingMessage) {
|
|
||||||
if (Time.time > delay) {
|
|
||||||
if (messages.Count == 1) {
|
List<Notification> messages;
|
||||||
GetComponentInParent<Image>().enabled = false;
|
bool showingMessage;
|
||||||
messages.Remove(messages[0]);
|
float delay;
|
||||||
showingMessage = false;
|
Text text;
|
||||||
} else {
|
|
||||||
text.text = messages[0].getText();
|
class Notification {
|
||||||
delay = Time.time + messages[0].getDuration();
|
string text;
|
||||||
}
|
float duration;
|
||||||
}
|
|
||||||
|
public Notification(string text, float duration) {
|
||||||
|
this.text = text;
|
||||||
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void showMessage(string text, float duration) {
|
public string getText() {
|
||||||
if (showingMessage) {
|
return text;
|
||||||
messages.Add(new Notification(text, duration));
|
}
|
||||||
} else {
|
|
||||||
showingMessage = true;
|
|
||||||
|
|
||||||
GetComponent<Text>().text = text;
|
public float getDuration() {
|
||||||
delay = Time.time + duration;
|
return duration;
|
||||||
GetComponentInParent<Image>().enabled = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
// Use this for initialization
|
||||||
|
void Start() {
|
||||||
|
delay = 0;
|
||||||
|
showingMessage = false;
|
||||||
|
messages = new List<Notification>();
|
||||||
|
text = GetComponent<Text>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update() {
|
||||||
|
if ( showingMessage ) {
|
||||||
|
if ( Time.time > delay ) {
|
||||||
|
if ( messages.Count == 1 ) {
|
||||||
|
GetComponentInParent<Image>().enabled = false;
|
||||||
|
messages.Remove(messages[0]);
|
||||||
|
showingMessage = false;
|
||||||
|
} else {
|
||||||
|
text.text = messages[0].getText();
|
||||||
|
delay = Time.time + messages[0].getDuration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showMessage(string text, float duration) {
|
||||||
|
if ( showingMessage ) {
|
||||||
|
messages.Add(new Notification(text, duration));
|
||||||
|
} else {
|
||||||
|
showingMessage = true;
|
||||||
|
|
||||||
|
GetComponent<Text>().text = text;
|
||||||
|
delay = Time.time + duration;
|
||||||
|
GetComponentInParent<Image>().enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ public class StartObjective : Objective {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ply">Player is ignored </param>
|
/// <param name="ply">Player is ignored </param>
|
||||||
public override void ActivateGoal(Player player) {
|
public override void ActivateGoal(Player player) {
|
||||||
Debug.Log(room == null);
|
|
||||||
if ( room.GetSpawnpoints().Count > 0 ) {
|
if ( room.GetSpawnpoints().Count > 0 ) {
|
||||||
GameObject ply = GameObject.Instantiate(playerPrefab);
|
GameObject ply = GameObject.Instantiate(playerPrefab);
|
||||||
ply.transform.position = room.GetSpawnpoints()[0].position;
|
ply.transform.position = room.GetSpawnpoints()[0].position;
|
||||||
|
@ -34,7 +33,6 @@ public class StartObjective : Objective {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Player</returns>
|
/// <returns>Player</returns>
|
||||||
public Player GetPlayer() {
|
public Player GetPlayer() {
|
||||||
Debug.Log(player == null);
|
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class Room : MonoBehaviour {
|
||||||
foreach ( Door d in doorsRootObject.GetComponentsInChildren<Door>() ) {
|
foreach ( Door d in doorsRootObject.GetComponentsInChildren<Door>() ) {
|
||||||
doors.Add(d);
|
doors.Add(d);
|
||||||
}
|
}
|
||||||
Debug.Log("[ROOMS] Doors: " + doors.Count);
|
//Debug.Log("[ROOMS] Doors: " + doors.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnpoints = new List<Transform>();
|
spawnpoints = new List<Transform>();
|
||||||
|
@ -36,8 +36,9 @@ public class Room : MonoBehaviour {
|
||||||
spawnpoints.Add(t);
|
spawnpoints.Add(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Debug.Log("[ROOMS] Spawnpoints: " + spawnpoints.Count);
|
//Debug.Log("[ROOMS] Spawnpoints: " + spawnpoints.Count);
|
||||||
}
|
}
|
||||||
|
//Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -49,7 +50,7 @@ public class Room : MonoBehaviour {
|
||||||
foreach ( Door d in doorsRootObject.GetComponentsInChildren<Door>() ) {
|
foreach ( Door d in doorsRootObject.GetComponentsInChildren<Door>() ) {
|
||||||
doors.Add(d);
|
doors.Add(d);
|
||||||
}
|
}
|
||||||
Debug.Log("[ROOMS] Doors: " + doors.Count);
|
//Debug.Log("[ROOMS] Doors: " + doors.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnpoints = new List<Transform>();
|
spawnpoints = new List<Transform>();
|
||||||
|
@ -59,7 +60,7 @@ public class Room : MonoBehaviour {
|
||||||
spawnpoints.Add(t);
|
spawnpoints.Add(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Debug.Log("[ROOMS] Spawnpoints: " + spawnpoints.Count);
|
//Debug.Log("[ROOMS] Spawnpoints: " + spawnpoints.Count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue