Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3ff42053c4
@ -94503,6 +94503,7 @@ GameObject:
|
|||||||
- component: {fileID: 419250167}
|
- component: {fileID: 419250167}
|
||||||
- component: {fileID: 419250166}
|
- component: {fileID: 419250166}
|
||||||
- component: {fileID: 419250165}
|
- component: {fileID: 419250165}
|
||||||
|
- component: {fileID: 419250170}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: GatewayCatacombs
|
m_Name: GatewayCatacombs
|
||||||
m_TagString: SceneTransition
|
m_TagString: SceneTransition
|
||||||
@ -94541,7 +94542,7 @@ MonoBehaviour:
|
|||||||
coords: {x: 0, y: 0, z: 0}
|
coords: {x: 0, y: 0, z: 0}
|
||||||
nextMapName: Catacombs
|
nextMapName: Catacombs
|
||||||
respawnCoords: {x: 0, y: -1, z: 0}
|
respawnCoords: {x: 0, y: -1, z: 0}
|
||||||
isEnabled: 1
|
isEnabled: 0
|
||||||
--- !u!50 &419250167
|
--- !u!50 &419250167
|
||||||
Rigidbody2D:
|
Rigidbody2D:
|
||||||
serializedVersion: 4
|
serializedVersion: 4
|
||||||
@ -94603,6 +94604,19 @@ Transform:
|
|||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 9
|
m_RootOrder: 9
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &419250170
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 419250164}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 261dfaba248bb5644becedc6c832e3ca, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
bars: {fileID: 0}
|
||||||
--- !u!1 &419616843
|
--- !u!1 &419616843
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -99259,7 +99273,6 @@ GameObject:
|
|||||||
- component: {fileID: 502298260}
|
- component: {fileID: 502298260}
|
||||||
- component: {fileID: 502298262}
|
- component: {fileID: 502298262}
|
||||||
- component: {fileID: 502298261}
|
- component: {fileID: 502298261}
|
||||||
- component: {fileID: 502298263}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Tombstone2
|
m_Name: Tombstone2
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -99363,28 +99376,6 @@ SpriteRenderer:
|
|||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
--- !u!114 &502298263
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 502298259}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 8d0c116465fe18f49addcc4e95a35f0c, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
position:
|
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
temp: {x: 0, y: 0, z: 0}
|
|
||||||
tombstone: tombstone7
|
|
||||||
goal:
|
|
||||||
speed: 3
|
|
||||||
pos:
|
|
||||||
m_ClipName:
|
|
||||||
player: {fileID: 0}
|
|
||||||
--- !u!1 &507712396
|
--- !u!1 &507712396
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -108588,7 +108579,6 @@ GameObject:
|
|||||||
- component: {fileID: 680287735}
|
- component: {fileID: 680287735}
|
||||||
- component: {fileID: 680287737}
|
- component: {fileID: 680287737}
|
||||||
- component: {fileID: 680287736}
|
- component: {fileID: 680287736}
|
||||||
- component: {fileID: 680287738}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Tombstone9
|
m_Name: Tombstone9
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -108692,28 +108682,6 @@ SpriteRenderer:
|
|||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
--- !u!114 &680287738
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 680287734}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 8d0c116465fe18f49addcc4e95a35f0c, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
position:
|
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
temp: {x: 0, y: 0, z: 0}
|
|
||||||
tombstone: tombstone5
|
|
||||||
goal:
|
|
||||||
speed: 3
|
|
||||||
pos:
|
|
||||||
m_ClipName:
|
|
||||||
player: {fileID: 0}
|
|
||||||
--- !u!1 &680989708
|
--- !u!1 &680989708
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -117826,7 +117794,6 @@ GameObject:
|
|||||||
- component: {fileID: 816566231}
|
- component: {fileID: 816566231}
|
||||||
- component: {fileID: 816566233}
|
- component: {fileID: 816566233}
|
||||||
- component: {fileID: 816566232}
|
- component: {fileID: 816566232}
|
||||||
- component: {fileID: 816566234}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Tombstone4
|
m_Name: Tombstone4
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -117930,28 +117897,6 @@ SpriteRenderer:
|
|||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
--- !u!114 &816566234
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 816566230}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 8d0c116465fe18f49addcc4e95a35f0c, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
position:
|
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
temp: {x: 0, y: 0, z: 0}
|
|
||||||
tombstone: tombstone8
|
|
||||||
goal:
|
|
||||||
speed: 3
|
|
||||||
pos:
|
|
||||||
m_ClipName:
|
|
||||||
player: {fileID: 0}
|
|
||||||
--- !u!1 &816804117
|
--- !u!1 &816804117
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -188231,7 +188176,6 @@ GameObject:
|
|||||||
- component: {fileID: 1300921221}
|
- component: {fileID: 1300921221}
|
||||||
- component: {fileID: 1300921223}
|
- component: {fileID: 1300921223}
|
||||||
- component: {fileID: 1300921222}
|
- component: {fileID: 1300921222}
|
||||||
- component: {fileID: 1300921224}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Tombstone7
|
m_Name: Tombstone7
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -188335,28 +188279,6 @@ SpriteRenderer:
|
|||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
--- !u!114 &1300921224
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1300921220}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 8d0c116465fe18f49addcc4e95a35f0c, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
position:
|
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
temp: {x: 0, y: 0, z: 0}
|
|
||||||
tombstone: tombstone4
|
|
||||||
goal:
|
|
||||||
speed: 3
|
|
||||||
pos:
|
|
||||||
m_ClipName:
|
|
||||||
player: {fileID: 0}
|
|
||||||
--- !u!1 &1301056682
|
--- !u!1 &1301056682
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1,149 +1,162 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Tilemaps;
|
using UnityEngine.Tilemaps;
|
||||||
|
|
||||||
public class NodeMap : MonoBehaviour
|
public class NodeMap : MonoBehaviour
|
||||||
{
|
{
|
||||||
public Vector2Int mapSize;
|
public Vector2Int mapSize;
|
||||||
public Node[,] nodeGrid = new Node[0,0];
|
public Node[,] nodeGrid = new Node[0,0];
|
||||||
public float cellSize;
|
public float cellSize;
|
||||||
public TileData[] TileDatas;
|
public TileData[] TileDatas;
|
||||||
public Dictionary<TileBase, TileData> DataFromTiles = new Dictionary<TileBase, TileData>();
|
public Dictionary<TileBase, TileData> DataFromTiles = new Dictionary<TileBase, TileData>();
|
||||||
public bool hasEverRun = false;
|
public bool hasEverRun = false;
|
||||||
public Tilemap tilemap;
|
public Tilemap tilemap;
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void LateUpdate()
|
|
||||||
{
|
|
||||||
if (!hasEverRun){
|
void Start()
|
||||||
DataFromTiles = new Dictionary<TileBase, TileData>();
|
{
|
||||||
foreach (var tileData in TileDatas)
|
DataFromTiles = new Dictionary<TileBase, TileData>();
|
||||||
{
|
foreach (var tileData in TileDatas)
|
||||||
foreach (var tile in tileData.Tiles)
|
{
|
||||||
{
|
foreach (var tile in tileData.Tiles)
|
||||||
DataFromTiles.Add(tile, tileData);
|
{
|
||||||
}
|
DataFromTiles.Add(tile, tileData);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
hasEverRun = true;
|
hasEverRun = true;
|
||||||
CreateNodes();
|
CreateNodes();
|
||||||
TileCheck();
|
TileCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public void Generate()
|
||||||
|
{
|
||||||
|
DataFromTiles = new Dictionary<TileBase, TileData>();
|
||||||
|
foreach (var tileData in TileDatas)
|
||||||
public void TileCheck()
|
{
|
||||||
{
|
foreach (var tile in tileData.Tiles)
|
||||||
foreach (var n in nodeGrid)
|
{
|
||||||
{
|
DataFromTiles.Add(tile, tileData);
|
||||||
Vector2Int gridPosition = n.gridPosition;
|
}
|
||||||
|
}
|
||||||
Vector3Int TileGridPosition = tilemap.WorldToCell(n.worldPosition);
|
hasEverRun = true;
|
||||||
TileBase Tile = tilemap.GetTile(TileGridPosition);
|
CreateNodes();
|
||||||
if (Tile == null) continue;
|
TileCheck();
|
||||||
if (!DataFromTiles.ContainsKey(Tile))
|
}
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
n.walkable = DataFromTiles[Tile].walkable;
|
public void TileCheck()
|
||||||
}
|
{
|
||||||
}
|
foreach (var n in nodeGrid)
|
||||||
|
{
|
||||||
// Update is called once per frame
|
Vector2Int gridPosition = n.gridPosition;
|
||||||
void Update()
|
|
||||||
{
|
Vector3Int TileGridPosition = tilemap.WorldToCell(n.worldPosition);
|
||||||
|
TileBase Tile = tilemap.GetTile(TileGridPosition);
|
||||||
}
|
if (Tile == null) continue;
|
||||||
|
if (!DataFromTiles.ContainsKey(Tile))
|
||||||
public void TeleportTo(GameObject g, Node node)
|
{
|
||||||
{
|
continue;
|
||||||
g.transform.position = node.worldPosition;
|
}
|
||||||
}
|
n.walkable = DataFromTiles[Tile].walkable;
|
||||||
|
}
|
||||||
public List<Node> GetNeighbours(Node node)
|
}
|
||||||
{
|
|
||||||
List<Node> neighbours = new List<Node>();
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
for (int x = -1; x <= 1; x++)
|
{
|
||||||
{
|
|
||||||
for (int y = -1; y <= 1; y++)
|
}
|
||||||
{
|
|
||||||
if (x == 0 && y == 0)
|
public void TeleportTo(GameObject g, Node node)
|
||||||
continue;
|
{
|
||||||
|
g.transform.position = node.worldPosition;
|
||||||
int checkX = node.gridPosition.x + x;
|
}
|
||||||
int checkY = node.gridPosition.y + y;
|
|
||||||
|
public List<Node> GetNeighbours(Node node)
|
||||||
if (checkX >= 0 && checkX < mapSize.x && checkY >= 0 && checkY < mapSize.y)
|
{
|
||||||
{
|
List<Node> neighbours = new List<Node>();
|
||||||
Node item = nodeGrid[checkX, checkY];
|
|
||||||
neighbours.Add(item);
|
for (int x = -1; x <= 1; x++)
|
||||||
}
|
{
|
||||||
}
|
for (int y = -1; y <= 1; y++)
|
||||||
}
|
{
|
||||||
|
if (x == 0 && y == 0)
|
||||||
return neighbours;
|
continue;
|
||||||
}
|
|
||||||
|
int checkX = node.gridPosition.x + x;
|
||||||
|
int checkY = node.gridPosition.y + y;
|
||||||
public void CreateNodes()
|
|
||||||
{
|
if (checkX >= 0 && checkX < mapSize.x && checkY >= 0 && checkY < mapSize.y)
|
||||||
nodeGrid = new Node[mapSize.x, mapSize.y];
|
{
|
||||||
for (int x = 0; x < nodeGrid.GetLength(0); x++)
|
Node item = nodeGrid[checkX, checkY];
|
||||||
{
|
neighbours.Add(item);
|
||||||
for (int y = 0; y < nodeGrid.GetLength(1); y++)
|
}
|
||||||
{
|
}
|
||||||
Vector2Int gridPosition = new Vector2Int(x, y);
|
}
|
||||||
nodeGrid[x, y] = new Node(gridPosition, GetWorldPosition(gridPosition));
|
|
||||||
Vector3Int TileGridPosition = tilemap.WorldToCell(nodeGrid[x,y].worldPosition);
|
return neighbours;
|
||||||
TileBase Tile = tilemap.GetTile(TileGridPosition);
|
}
|
||||||
|
|
||||||
//nodeGrid[x, y].walkable = DataFromTiles[Tile].walkable;
|
|
||||||
|
public void CreateNodes()
|
||||||
}
|
{
|
||||||
}
|
nodeGrid = new Node[mapSize.x, mapSize.y];
|
||||||
}
|
for (int x = 0; x < nodeGrid.GetLength(0); x++)
|
||||||
|
{
|
||||||
public Node NodeFromWorldPoint(Vector2 worldPosition)
|
for (int y = 0; y < nodeGrid.GetLength(1); y++)
|
||||||
{
|
{
|
||||||
float percentX = (worldPosition.x + mapSize.x / 2) / mapSize.x;
|
Vector2Int gridPosition = new Vector2Int(x, y);
|
||||||
float percentY = (worldPosition.y + mapSize.y / 2) / mapSize.y;
|
nodeGrid[x, y] = new Node(gridPosition, GetWorldPosition(gridPosition));
|
||||||
percentX = Mathf.Clamp01(percentX);
|
Vector3Int TileGridPosition = tilemap.WorldToCell(nodeGrid[x,y].worldPosition);
|
||||||
percentY = Mathf.Clamp01(percentY);
|
TileBase Tile = tilemap.GetTile(TileGridPosition);
|
||||||
|
|
||||||
int x = Mathf.RoundToInt((mapSize.x - 1) * percentX);
|
//nodeGrid[x, y].walkable = DataFromTiles[Tile].walkable;
|
||||||
int y = Mathf.RoundToInt((mapSize.y - 1) * percentY);
|
|
||||||
return nodeGrid[x, y];
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Vector3 GetWorldPosition(Vector2Int position)
|
public Node NodeFromWorldPoint(Vector2 worldPosition)
|
||||||
{
|
{
|
||||||
Vector3 worldBottomLeft = transform.position - (Vector3.right * (mapSize.x / 2)) - (Vector3.up * (mapSize.y / 2));
|
float percentX = (worldPosition.x + mapSize.x / 2) / mapSize.x;
|
||||||
Vector3 worldPoint = worldBottomLeft + (Vector3.right * position.x) + (Vector3.up * position.y);
|
float percentY = (worldPosition.y + mapSize.y / 2) / mapSize.y;
|
||||||
Vector3 cellSizeOffset = new Vector3(cellSize / 2, cellSize / 2, 0);
|
percentX = Mathf.Clamp01(percentX);
|
||||||
return worldPoint * cellSize + cellSizeOffset;
|
percentY = Mathf.Clamp01(percentY);
|
||||||
}
|
|
||||||
|
int x = Mathf.RoundToInt((mapSize.x - 1) * percentX);
|
||||||
public bool showIndividualNodes;
|
int y = Mathf.RoundToInt((mapSize.y - 1) * percentY);
|
||||||
|
return nodeGrid[x, y];
|
||||||
|
}
|
||||||
public void OnDrawGizmos()
|
|
||||||
{
|
|
||||||
Gizmos.DrawWireCube(transform.position,new Vector3(mapSize.x,mapSize.y,1) * cellSize);
|
public Vector3 GetWorldPosition(Vector2Int position)
|
||||||
if (!showIndividualNodes)
|
{
|
||||||
{
|
Vector3 worldBottomLeft = transform.position - (Vector3.right * (mapSize.x / 2)) - (Vector3.up * (mapSize.y / 2));
|
||||||
return;
|
Vector3 worldPoint = worldBottomLeft + (Vector3.right * position.x) + (Vector3.up * position.y);
|
||||||
}
|
Vector3 cellSizeOffset = new Vector3(cellSize / 2, cellSize / 2, 0);
|
||||||
|
return worldPoint * cellSize + cellSizeOffset;
|
||||||
foreach (var n in nodeGrid)
|
}
|
||||||
{
|
|
||||||
Vector3 size = Vector3.one * cellSize;
|
public bool showIndividualNodes;
|
||||||
Gizmos.DrawWireCube(n.worldPosition, size);
|
|
||||||
}
|
|
||||||
}
|
public void OnDrawGizmos()
|
||||||
}
|
{
|
||||||
|
Gizmos.DrawWireCube(transform.position,new Vector3(mapSize.x,mapSize.y,1) * cellSize);
|
||||||
|
if (!showIndividualNodes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var n in nodeGrid)
|
||||||
|
{
|
||||||
|
Vector3 size = Vector3.one * cellSize;
|
||||||
|
Gizmos.DrawWireCube(n.worldPosition, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,142 +1,148 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using GUI_Scripts.ProceduralGeneration;
|
using GUI_Scripts.ProceduralGeneration;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Tilemaps;
|
using UnityEngine.Tilemaps;
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
using Vector2 = System.Numerics.Vector2;
|
using Vector2 = System.Numerics.Vector2;
|
||||||
|
|
||||||
public class TileMapGenerator : MonoBehaviour
|
public class TileMapGenerator : MonoBehaviour
|
||||||
{
|
{
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
|
|
||||||
public Tilemap ground, walls;
|
public Tilemap ground, walls;
|
||||||
public Tile ground1, wall1, corner_left_up, corner_left_down, corner_right_down, corner_right_up, left, right, up, down;
|
public Tile ground1, wall1, corner_left_up, corner_left_down, corner_right_down, corner_right_up, left, right, up, down;
|
||||||
public Graph graph;
|
public Graph graph;
|
||||||
public List<Vector3> availablePos;
|
public List<Vector3> availablePos;
|
||||||
|
public bool generated=false;
|
||||||
private void Start()
|
public bool nodeMapGenerated = false;
|
||||||
{
|
|
||||||
while (!Generate())
|
private void Start()
|
||||||
{
|
{
|
||||||
|
while (!(generated=Generate()))
|
||||||
}
|
{
|
||||||
}
|
|
||||||
|
}
|
||||||
|
}
|
||||||
bool Generate()
|
|
||||||
{
|
void Update()
|
||||||
Map map = new Map(new Vector2Int(100, 100));
|
{
|
||||||
List<FloodFill> fillers = new List<FloodFill>();
|
if (generated && !nodeMapGenerated)
|
||||||
|
{
|
||||||
|
GameObject.FindObjectOfType<NodeMap>().Generate();
|
||||||
for (int i = 0; i < 60; i++)
|
nodeMapGenerated = true;
|
||||||
{
|
}
|
||||||
FloodFill filler = new FloodFill(map, 1, new Vector2Int(Random.Range(0, 70), Random.Range(0, 70)));
|
}
|
||||||
fillers.Add(filler);
|
|
||||||
}
|
|
||||||
map.Fill(fillers);
|
bool Generate()
|
||||||
|
{
|
||||||
Graph graph = new Graph(map);
|
Map map = new Map(new Vector2Int(100, 100));
|
||||||
foreach (var filler in fillers)
|
List<FloodFill> fillers = new List<FloodFill>();
|
||||||
{
|
|
||||||
graph.graphNodes.Add(filler);
|
|
||||||
}
|
for (int i = 0; i < 60; i++)
|
||||||
graph.Connect();
|
{
|
||||||
Debug.Log(graph.checkConnectivity());
|
FloodFill filler = new FloodFill(map, 1, new Vector2Int(Random.Range(0, 70), Random.Range(0, 70)));
|
||||||
|
fillers.Add(filler);
|
||||||
int count = fillers.Count;
|
}
|
||||||
for (int i = 0; i < 101; i++)
|
map.Fill(fillers);
|
||||||
{
|
|
||||||
GraphNode random = graph.graphNodes[Random.Range(0, graph.graphNodes.Count)];
|
Graph graph = new Graph(map);
|
||||||
graph.removeNode(random);
|
foreach (var filler in fillers)
|
||||||
random.id = 2;
|
{
|
||||||
|
graph.graphNodes.Add(filler);
|
||||||
if (!graph.checkConnectivity())
|
}
|
||||||
{
|
graph.Connect();
|
||||||
graph.AddNode(random);
|
Debug.Log(graph.checkConnectivity());
|
||||||
random.id = 1;
|
|
||||||
}
|
int count = fillers.Count;
|
||||||
|
for (int i = 0; i < 101; i++)
|
||||||
if (graph.graphNodes.Count < count / 2)
|
{
|
||||||
{
|
GraphNode random = graph.graphNodes[Random.Range(0, graph.graphNodes.Count)];
|
||||||
break;
|
graph.removeNode(random);
|
||||||
}
|
random.id = 2;
|
||||||
|
|
||||||
}
|
if (!graph.checkConnectivity())
|
||||||
|
{
|
||||||
if (graph.graphNodes.Count > count * 0.8)
|
graph.AddNode(random);
|
||||||
{
|
random.id = 1;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
if (graph.graphNodes.Count < count / 2)
|
||||||
GraphNode playerPosStart = graph.graphNodes[Random.Range(0, graph.graphNodes.Count)];
|
{
|
||||||
Vector2Int startPos = playerPosStart.positions.ElementAt(Random.Range(0, playerPosStart.positions.Count));
|
break;
|
||||||
Vector3 possiblePos = default;
|
}
|
||||||
foreach (var filler in fillers)
|
|
||||||
{
|
}
|
||||||
int id = filler.id;
|
|
||||||
foreach (var pos in filler.positions)
|
if (graph.graphNodes.Count > count * 0.8)
|
||||||
{
|
{
|
||||||
if (id == 1)
|
return false;
|
||||||
{
|
}
|
||||||
ground.SetTile(new Vector3Int(pos.x,pos.y,0), ground1);
|
|
||||||
possiblePos = new Vector3Int(pos.x, pos.y, 0);
|
GraphNode playerPosStart = graph.graphNodes[Random.Range(0, graph.graphNodes.Count)];
|
||||||
availablePos.Add(possiblePos);
|
Vector2Int startPos = playerPosStart.positions.ElementAt(Random.Range(0, playerPosStart.positions.Count));
|
||||||
}
|
Vector3 possiblePos = default;
|
||||||
else if (id == 2)
|
foreach (var filler in fillers)
|
||||||
{
|
{
|
||||||
walls.SetTile(new Vector3Int(pos.x,pos.y,0), wall1);
|
int id = filler.id;
|
||||||
|
foreach (var pos in filler.positions)
|
||||||
}
|
{
|
||||||
}
|
if (id == 1)
|
||||||
}
|
{
|
||||||
|
ground.SetTile(new Vector3Int(pos.x,pos.y,0), ground1);
|
||||||
|
possiblePos = new Vector3Int(pos.x, pos.y, 0);
|
||||||
|
availablePos.Add(possiblePos);
|
||||||
walls.SetTile(new Vector3Int(-1,-1,0), corner_left_down);
|
}
|
||||||
walls.SetTile(new Vector3Int(-1,100,0), corner_left_up);
|
else if (id == 2)
|
||||||
walls.SetTile(new Vector3Int(100,100,0), corner_right_up);
|
{
|
||||||
walls.SetTile(new Vector3Int(100,-1,0), corner_right_down);
|
walls.SetTile(new Vector3Int(pos.x,pos.y,0), wall1);
|
||||||
|
|
||||||
for (int i=0; i<100; i++){walls.SetTile(new Vector3Int(-1,i,0), left);}
|
}
|
||||||
for (int i=0; i<100; i++){walls.SetTile(new Vector3Int(100,i,0), right);}
|
}
|
||||||
for (int i=0; i<100; i++){walls.SetTile(new Vector3Int(i,-1,0), down);}
|
}
|
||||||
for (int i=0; i<100; i++){walls.SetTile(new Vector3Int(i,100,0), up);}
|
|
||||||
|
|
||||||
|
|
||||||
Debug.Log(startPos);
|
walls.SetTile(new Vector3Int(-1,-1,0), corner_left_down);
|
||||||
Debug.Log("cell added");
|
walls.SetTile(new Vector3Int(-1,100,0), corner_left_up);
|
||||||
|
walls.SetTile(new Vector3Int(100,100,0), corner_right_up);
|
||||||
GameObject Player = GameObject.FindWithTag("Player");
|
walls.SetTile(new Vector3Int(100,-1,0), corner_right_down);
|
||||||
Player.transform.position = randomCoordsForStanding();
|
|
||||||
|
for (int i=0; i<100; i++){walls.SetTile(new Vector3Int(-1,i,0), left);}
|
||||||
//randomCoordsForStanding();
|
for (int i=0; i<100; i++){walls.SetTile(new Vector3Int(100,i,0), right);}
|
||||||
|
for (int i=0; i<100; i++){walls.SetTile(new Vector3Int(i,-1,0), down);}
|
||||||
return true;
|
for (int i=0; i<100; i++){walls.SetTile(new Vector3Int(i,100,0), up);}
|
||||||
}
|
|
||||||
|
|
||||||
|
Debug.Log(startPos);
|
||||||
public Vector3 randomCoordsForStanding()
|
Debug.Log("cell added");
|
||||||
{
|
|
||||||
//Tile test = new Tile();
|
GameObject Player = GameObject.FindWithTag("Player");
|
||||||
while (true)
|
Player.transform.position = randomCoordsForStanding();
|
||||||
{
|
|
||||||
int bound = availablePos.Count;
|
//randomCoordsForStanding();
|
||||||
int randomVal;
|
|
||||||
randomVal = Random.Range(0, bound);
|
return true;
|
||||||
|
}
|
||||||
return availablePos[randomVal] + new Vector3( 0.5f, 0.5f, 0f);
|
|
||||||
}
|
|
||||||
|
public Vector3 randomCoordsForStanding()
|
||||||
|
{
|
||||||
}
|
//Tile test = new Tile();
|
||||||
|
while (true)
|
||||||
// Update is called once per frame
|
{
|
||||||
void Update()
|
int bound = availablePos.Count;
|
||||||
{
|
int randomVal;
|
||||||
|
randomVal = Random.Range(0, bound);
|
||||||
}
|
|
||||||
}
|
return availablePos[randomVal] + new Vector3( 0.5f, 0.5f, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
8
Assets/Scripts/REFACTORING/Story/Cementary.meta
Normal file
8
Assets/Scripts/REFACTORING/Story/Cementary.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: af373c4a2b82452468b4399aca61e8c5
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,45 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class TombstoneDoorBlock : MonoBehaviour
|
||||||
|
{
|
||||||
|
public GameObject bars;
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
bars = GameObject.Find("CatacombsDoor");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
string tomb1 = PlayerPrefs.GetString("tombstone2");
|
||||||
|
string tomb3 = PlayerPrefs.GetString("tombstone3");
|
||||||
|
string tomb5 = PlayerPrefs.GetString("tombstone6");
|
||||||
|
string tomb6 = PlayerPrefs.GetString("tombstone1");
|
||||||
|
string tomb8 = PlayerPrefs.GetString("tombstone9");
|
||||||
|
|
||||||
|
if (tomb1 == "left" && tomb3 == "left" && tomb5 == "right" && tomb6 == "bottom" && tomb8 == "right")
|
||||||
|
{
|
||||||
|
if (gameObject.GetComponent<DoorBehaviour>())
|
||||||
|
gameObject.GetComponent<DoorBehaviour>().isEnabled = true;
|
||||||
|
|
||||||
|
if (gameObject.GetComponent<AnimatedDoorBehaviour>())
|
||||||
|
gameObject.GetComponent<AnimatedDoorBehaviour>().isEnabled = true;
|
||||||
|
|
||||||
|
bars.SetActive(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (gameObject.GetComponent<DoorBehaviour>())
|
||||||
|
gameObject.GetComponent<DoorBehaviour>().isEnabled = false;
|
||||||
|
|
||||||
|
if (gameObject.GetComponent<AnimatedDoorBehaviour>())
|
||||||
|
gameObject.GetComponent<AnimatedDoorBehaviour>().isEnabled = false;
|
||||||
|
|
||||||
|
bars.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 261dfaba248bb5644becedc6c832e3ca
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user