1
0
Fork 0

Merge remote-tracking branch 'origin/master'

This commit is contained in:
Unknown 2018-04-22 20:18:31 +02:00
commit 830de89002
6 changed files with 119 additions and 33 deletions

View file

@ -169,7 +169,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2cf81aa4a8d45468f8184f8d5862d7eb, type: 3} m_Script: {fileID: 11500000, guid: 2cf81aa4a8d45468f8184f8d5862d7eb, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
acceleration: 3 acceleration: 4
friction: 0.1 friction: 0.1
turnSpeed: 2 turnSpeed: 2
drift: 1 drift: 1

View file

@ -986,6 +986,48 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 833134303} m_GameObject: {fileID: 833134303}
--- !u!1001 &865504979
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
m_IsPrefabParent: 0
--- !u!1 &881384367 --- !u!1 &881384367
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1079,7 +1121,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5d9a051e822e2cf4ea3ca01c5a4df37c, type: 3} m_Script: {fileID: 11500000, guid: 5d9a051e822e2cf4ea3ca01c5a4df37c, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
followThis: {fileID: 0} followThis: {fileID: 1239288696}
--- !u!1 &1001682580 --- !u!1 &1001682580
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1328,7 +1370,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!114 &1487324257 --- !u!114 &1487324257
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -68,7 +68,7 @@ public class DungeonGenerator {
foreach ( GenVertex r1 in Q ) { foreach ( GenVertex r1 in Q ) {
foreach ( GenVertex r2 in Q ) { foreach ( GenVertex r2 in Q ) {
if ( r1 == r2 ) if ( r1 == r2 )
continue; goto outer;
foreach ( GenEdge e in E ) foreach ( GenEdge e in E )
if ( e.r2 == r1 && e.r1 == r2 ) if ( e.r2 == r1 && e.r1 == r2 )
goto outer; goto outer;
@ -134,30 +134,34 @@ public class DungeonGenerator {
path.tiles.Add(pos1, Room.TileType.GROUND); path.tiles.Add(pos1, Room.TileType.GROUND);
for ( int x2 = x1 - 1; x2 <= x1 + 1; x2++ ) for ( int x2 = x1 - 1; x2 <= x1 + 1; x2++ )
for ( int y2 = y1 - 1; y2 <= y1 + 1; y2++ ) { for ( int y2 = y1 - 1; y2 <= y1 + 1; y2++ ) {
if ( !path.tiles.ContainsKey(new Vector2Int(x2, y2)) ) if (!path.tiles.ContainsKey(new Vector2Int(x2, y2)))
path.tiles.Add(new Vector2Int(x2, y2), Room.TileType.WALL); path.tiles.Add(new Vector2Int(x2, y2), Room.TileType.WALL);
} }
} }
} }
foreach ( GenRoom r in rooms ) { foreach ( GenRoom r in rooms ) {
for ( int x1 = r.bounds.x; x1 < r.bounds.x + r.bounds.width; x1++ ) for ( int x1 = r.bounds.x; x1 < r.bounds.x + r.bounds.width; x1++ )
for ( int y1 = r.bounds.y; y1 < r.bounds.y + r.bounds.height; y1++ ) { for ( int y1 = r.bounds.y; y1 < r.bounds.y + r.bounds.height; y1++ ) {
r.tiles.Add(new Vector2Int(x1, y1), Room.TileType.WALL); r.tiles.Add(new Vector2Int(x1, y1), Room.TileType.WALL);
} }
for ( int x1 = r.bounds.x + 1; x1 < r.bounds.x + r.bounds.width - 1; x1++ ) for ( int x1 = r.bounds.x + 1; x1 < r.bounds.x + r.bounds.width - 1; x1++ )
for ( int y1 = r.bounds.y + 1; y1 < r.bounds.y + r.bounds.height - 1; y1++ ) { for ( int y1 = r.bounds.y + 1; y1 < r.bounds.y + r.bounds.height - 1; y1++ ) {
r.tiles[new Vector2Int(x1, y1)] = Room.TileType.GROUND; r.tiles[new Vector2Int(x1, y1)] = Room.TileType.GROUND;
} }
foreach ( Vector2Int v in r.AllDoors() ) foreach (Vector2Int v in r.AllDoors())
r.tiles[v] = Room.TileType.DOOR; {
Debug.Log("Door: " + v);
if (!r.bounds.Contains(v))
throw new NotSupportedException("This is a bug where doors land in the wrong room. It should have been fixed.");
else
r.tiles[v] = Room.TileType.DOOR;
}
} }
foreach (GenRoom r in rooms) { foreach (GenRoom r in rooms) {
generateInterior (r); generateInterior (r);
} }
rooms.Add(path);
start = root.r; start = root.r;
end = null; foreach ( GenRoom r in rooms ) { end = null; foreach ( GenRoom r in rooms ) {
if ( end == null || r.bounds.x > end.bounds.x ) if ( end == null || r.bounds.x > end.bounds.x )
@ -218,8 +222,8 @@ public class DungeonGenerator {
rooms.Add(tunnel); rooms.Add(tunnel);
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) { for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
lower.doorsUp.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y + tunnel.bounds.height)); higher.doorsUp.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y + tunnel.bounds.height));
higher.doorsDown.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y - 1)); lower.doorsDown.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y - 1));
} }
} }
@ -338,14 +342,14 @@ public class DungeonGenerator {
lower.doorsDown.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y - 1)); lower.doorsDown.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y - 1));
} else } else
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) { for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
lower.doorsUp.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y + verticalLefter.bounds.height)); higher.doorsUp.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y + verticalLefter.bounds.height));
} }
} }
if ( addVertical2 ) { if ( addVertical2 ) {
rooms.Add(verticalRighter); rooms.Add(verticalRighter);
if ( lower == righter ) if ( lower == righter )
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) { for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
higher.doorsDown.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y - 1)); lower.doorsDown.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y - 1));
} else } else
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) { for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
higher.doorsUp.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y + verticalRighter.bounds.height)); higher.doorsUp.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y + verticalRighter.bounds.height));

View file

@ -21,6 +21,13 @@ public class GenRoom {
public float Distance(GenRoom r) { public float Distance(GenRoom r) {
return Math.Abs(GetCenter().x - r.GetCenter().x) + Math.Abs(GetCenter().y - r.GetCenter().y); return Math.Abs(GetCenter().x - r.GetCenter().x) + Math.Abs(GetCenter().y - r.GetCenter().y);
//float power = 2;
//float dist = (float) Math.Pow(
// Math.Pow(GetCenter().x - r.GetCenter().x, power)
// + Math.Pow(GetCenter().y - r.GetCenter().y, power),
// 1 / power);
//Debug.Log(bounds.center + " " + bounds + " " + dist);
//return dist;
} }
public Vector2Int GetCenter() { public Vector2Int GetCenter() {

View file

@ -32,19 +32,19 @@ public class NotificationManager : MonoBehaviour {
// Use this for initialization // Use this for initialization
void Start() { void Start() {
delay = 0; delay = 0;
showingMessage = false;
messages = new List<Notification>(); messages = new List<Notification>();
text = GetComponent<Text>(); text = GetComponent<Text>();
hide();
} }
void Update() { void Update() {
if ( showingMessage ) { if ( showingMessage ) {
if ( Time.time > delay ) { if ( Time.time > delay ) {
if ( messages.Count == 1 ) { if (messages.Count <= 1) {
GetComponentInParent<Image>().enabled = false; messages.Remove(messages[0]);
messages.Remove(messages[0]); hide();
showingMessage = false;
} else { } else {
messages.Remove(messages[0]);
text.text = messages[0].getText(); text.text = messages[0].getText();
delay = Time.time + messages[0].getDuration(); delay = Time.time + messages[0].getDuration();
} }
@ -60,7 +60,19 @@ public class NotificationManager : MonoBehaviour {
GetComponent<Text>().text = text; GetComponent<Text>().text = text;
delay = Time.time + duration; delay = Time.time + duration;
GetComponentInParent<Image>().enabled = true; show();
} }
} }
void show() {
GetComponentInParent<Image>().enabled = true;
text.enabled = true;
showingMessage = true;
}
void hide() {
GetComponentInParent<Image>().enabled = false;
text.enabled = false;
showingMessage = false;
}
} }

View file

@ -2,53 +2,74 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class UIController : MonoBehaviour { public class UIController : MonoBehaviour
{
GameObject score; GameObject score;
GameObject pauseMenu; GameObject pauseMenu;
[SerializeField]
NotificationManager notifications;
[SerializeField] [SerializeField]
GameObject gameOverPanel; GameObject gameOverPanel;
[SerializeField] [SerializeField]
private HealthbarController healthcontroller; HealthbarController healthcontroller;
public void ShowPauseMenu() {
public void ShowPauseMenu()
{
pauseMenu.SetActive(true); pauseMenu.SetActive(true);
} }
public void ClosePauseMenu() { public void ClosePauseMenu()
{
pauseMenu.SetActive(false); pauseMenu.SetActive(false);
} }
public void LoadSceneByIndex(int index) { public void LoadSceneByIndex(int index)
{
Debug.Log("Loaded scene " + index); Debug.Log("Loaded scene " + index);
UnityEngine.SceneManagement.SceneManager.LoadScene(index); UnityEngine.SceneManagement.SceneManager.LoadScene(index);
} }
public void QuitGame() { public void QuitGame()
{
Debug.Log("Quit game"); Debug.Log("Quit game");
Application.Quit(); Application.Quit();
} }
public void ShowGameOverUI() { public void ShowGameOverUI()
if ( gameOverPanel != null ) { {
if (gameOverPanel != null)
{
Canvas gameOverCanvas = gameOverPanel.GetComponent<Canvas>(); Canvas gameOverCanvas = gameOverPanel.GetComponent<Canvas>();
Debug.Log("Loading Canvas"); Debug.Log("Loading Canvas");
if ( gameOverCanvas != null ) { if (gameOverCanvas != null)
{
Debug.Log("Loaded Canvas"); Debug.Log("Loaded Canvas");
gameOverCanvas.enabled = true; gameOverCanvas.enabled = true;
} else { }
else
{
Debug.Log("Gameover panel has no Canvas"); Debug.Log("Gameover panel has no Canvas");
} }
} else { }
else
{
Debug.Log("No game over panel assigned"); Debug.Log("No game over panel assigned");
} }
} }
public void InitHealthController(Player ply) { public void InitHealthController(Player ply)
{
healthcontroller.SetPlayer(ply); healthcontroller.SetPlayer(ply);
} }
public NotificationManager GetNotificationManager() {
return notifications;
}
} }