Commit 200e72d7 authored by 18손재민's avatar 18손재민

바닥 및 벽 생성 및 제거하는 함수들 구현함. 생성 함수 수정할 것

parent 03e17c74
fileFormatVersion: 2
guid: f6226b2548447a54486acfc694a44e4d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &630498074586648370
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 630498074586648373}
m_Layer: 0
m_Name: Floors
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &630498074586648373
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 630498074586648370}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 630498074781569475}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &630498074781569472
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 630498074781569475}
- component: {fileID: 630498074781569474}
m_Layer: 0
m_Name: TestStage
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &630498074781569475
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 630498074781569472}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 630498074586648373}
- {fileID: 630498075143909937}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &630498074781569474
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 630498074781569472}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: aa2c12f6bf26415469ec088e3e4c4dc3, type: 3}
m_Name:
m_EditorClassIdentifier:
testInputSizeX: 10
testInputSizeY: 10
maxMapSize: 0
floors: {fileID: 630498074586648370}
walls: {fileID: 630498075143909950}
player: {fileID: 0}
--- !u!1 &630498075143909950
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 630498075143909937}
m_Layer: 0
m_Name: Walls
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &630498075143909937
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 630498075143909950}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 630498074781569475}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
fileFormatVersion: 2
guid: 759f352c81f1b5a40b2d8d241cdf273b
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -43,12 +43,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9c46ee6a780f2c3428a79748eadabea8, type: 3}
m_Name:
m_EditorClassIdentifier:
x: 10
y: 10
floor: {fileID: 4430576614521234720, guid: 71931eea896a59a4683986cfd369b8ee, type: 3}
wall: {fileID: 337530617404887312, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d, type: 3}
floor: {fileID: 19711883686801522, guid: 71931eea896a59a4683986cfd369b8ee, type: 3}
wall: {fileID: 3736402816908646744, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d, type: 3}
player: {fileID: 0}
map: {fileID: 0}
currentMap: {fileID: 0}
surface: {fileID: 0}
xInput: {fileID: 0}
yInput: {fileID: 0}
stage:
- {fileID: 630498074781569474, guid: 759f352c81f1b5a40b2d8d241cdf273b, type: 3}
......@@ -60,7 +60,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 217b848b6a9bd7145af70d4258c38bd7, type: 2}
- {fileID: 2100002, guid: 21bb8ae9866c4304198832331df496dc, type: 3}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
......
This diff is collapsed.
......@@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 4430576614518241568}
- component: {fileID: 4430576614519241696}
- component: {fileID: 148490920766651840}
- component: {fileID: 19711883686801522}
m_Layer: 0
m_Name: floor
m_TagString: floor
......@@ -91,3 +92,15 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 1.0000005, y: 0.20000361, z: 1.0000007}
m_Center: {x: -0.000000029802322, y: 0, z: 0}
--- !u!114 &19711883686801522
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4430576614521234720}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5b47a59601255854ea2822508c284e85, type: 3}
m_Name:
m_EditorClassIdentifier:
......@@ -11,7 +11,8 @@ GameObject:
- component: {fileID: 3376343891999139780}
- component: {fileID: 3376343891998369764}
- component: {fileID: 3376343891997238564}
- component: {fileID: 6176638374464466303}
- component: {fileID: 3774729938785636153}
- component: {fileID: 1326751841616266053}
m_Layer: 0
m_Name: floorBlack
m_TagString: floor
......@@ -78,29 +79,28 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!61 &6176638374464466303
BoxCollider2D:
--- !u!65 &3774729938785636153
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3376343891999243236}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: -0.000000029802322, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.0000005, y: 0.20000361}
m_EdgeRadius: 0
m_Size: {x: 1.0000005, y: 0.20000361, z: 1.0000007}
m_Center: {x: -0.000000029802322, y: 0, z: 0}
--- !u!114 &1326751841616266053
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3376343891999243236}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5b47a59601255854ea2822508c284e85, type: 3}
m_Name:
m_EditorClassIdentifier:
......@@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 2663811710981383335}
- component: {fileID: 2663811710980417127}
- component: {fileID: 5343293505329870069}
- component: {fileID: 1281722943421799784}
m_Layer: 0
m_Name: floorWhite
m_TagString: floor
......@@ -91,3 +92,15 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 1.0000005, y: 0.20000361, z: 1.0000007}
m_Center: {x: -0.000000029802322, y: 0, z: 0}
--- !u!114 &1281722943421799784
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2663811710982420647}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5b47a59601255854ea2822508c284e85, type: 3}
m_Name:
m_EditorClassIdentifier:
......@@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 337530617402888144}
- component: {fileID: 5992419591198202452}
- component: {fileID: 1788580750165913660}
- component: {fileID: 3736402816908646744}
m_Layer: 0
m_Name: wall
m_TagString: wall
......@@ -108,3 +109,15 @@ NavMeshObstacle:
m_CarveOnlyStationary: 1
m_Center: {x: 0, y: 0.6, z: 0}
m_TimeToStationary: 0.5
--- !u!114 &3736402816908646744
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 337530617404887312}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 12e6eb2c47d8fa6439494493e8238a81, type: 3}
m_Name:
m_EditorClassIdentifier:
This diff is collapsed.
fileFormatVersion: 2
guid: 5bc10e17adc09f34d8d61ffefb655889
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Floor : MonoBehaviour
{
/// <summary>
/// Position of this floor at the map.
/// </summary>
public Vector2Int MapPos { get; private set; }
public void SetMapPos(Vector2Int pos)
{
MapPos = pos;
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: 5b47a59601255854ea2822508c284e85
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class Map : MonoBehaviour
{
//Remove when singleton added.
public MapManager mapManager;
//Remove when singleton added.
public int testInputSizeX, testInputSizeY;
public int maxMapSize;
public int mapCenterPos;
public GameObject[,] floorGrid;
private Dictionary<Vector2Int, Floor> floorGrid;
private Dictionary<Vector2, Wall> wallGrid;
public GameObject floors;
public GameObject walls;
/// <summary>
/// Get floor at position.
......@@ -18,37 +18,57 @@ public class Map : MonoBehaviour
/// <param name="x">X position of floor.</param>
/// <param name="y">Y position of floor.</param>
/// <returns></returns>
public GameObject GetFloorAtPos(int x, int y)
public Floor GetFloorAtPos(int x, int y)
{
if (floorGrid[mapCenterPos + x, mapCenterPos + y] != null)
return floorGrid[mapCenterPos + x, mapCenterPos + y];
else
if ((x >= 0 ? x > maxMapSize / 2 - 1 : x < maxMapSize / 2) || (y >= 0 ? y > maxMapSize / 2 - 1 : y < maxMapSize / 2))
{
Debug.Log("Input size exceeds map's max size.");
return null;
}
Vector2Int floorPos = new Vector2Int(x, y);
return floorGrid.ContainsKey(floorPos) ? floorGrid[floorPos] : null;
}
/// <summary>
/// Get floor at position.
/// </summary>
/// <param name="pos">Position of floor.</param>
/// <returns></returns>
public GameObject GetFloorAtPos(Vector2Int pos)
public Floor GetFloorAtPos(Vector2Int pos)
{
return GetFloorAtPos(pos.x, pos.y);
}
/// <summary>
/// Get floor at position.
/// </summary>
/// <param name="x">X position of floor.</param>
/// <param name="y">Y position of floor.</param>
/// <returns></returns>
public Wall GetWallAtPos(Floor floor1, Floor floor2)
{
Vector2 wallPos = (Vector2)(floor1.MapPos + floor2.MapPos) / 2;
return wallGrid.ContainsKey(wallPos) ? wallGrid[wallPos] : null;
}
/// <summary>
/// Create floor at position.
/// </summary>
/// <param name="x">X position of floor.</param>
/// <param name="y">Y position of floor.</param>
public void CreateFloor(int x, int y)
{
if(floorGrid[mapCenterPos + x, mapCenterPos + y] == null)
if ((x >= 0 ? (x > maxMapSize / 2 - 1) : (x < -maxMapSize / 2)) || (y >= 0 ? (y > maxMapSize / 2 - 1) : (y < -maxMapSize / 2)))
{
floorGrid[mapCenterPos + x, mapCenterPos + y] = Instantiate(mapManager.floor, new Vector3(mapCenterPos + x, 0, mapCenterPos + y), Quaternion.identity, transform);
Debug.Log("Input size exceeds map's max size.");
return;
}
else
Vector2Int floorPos = new Vector2Int(x, y);
if (!floorGrid.ContainsKey(floorPos))
{
Debug.Log("Floor already exists in : (" + x + ", " + y + ")");
floorGrid.Add(floorPos, Instantiate(MapManager.inst.floor, new Vector3(floorPos.x, 0, floorPos.y), Quaternion.identity, floors.transform).GetComponent<Floor>());
floorGrid[floorPos].SetMapPos(floorPos);
StartCoroutine(MapManager.inst.Rebaker());
}
else
Debug.Log("Floor already exists at : (" + x + ", " + y + ")");
}
/// <summary>
/// Create floor at position.
......@@ -59,20 +79,41 @@ public class Map : MonoBehaviour
CreateFloor(pos.x, pos.y);
}
/// <summary>
/// Create floor in rectangular area between pos1 and pos2.
/// </summary>
/// <param name="pos1"></param>
/// <param name="pos2"></param>
public void CreateFloor(Vector2Int pos1, Vector2Int pos2)
{
int xMax = Mathf.Max(pos1.x, pos2.x);
int yMax = Mathf.Max(pos1.y, pos2.y);
int xMin = Mathf.Min(pos1.x, pos2.x);
int yMin = Mathf.Min(pos1.y, pos2.y);
for (int i = xMin; i <= xMax; i++)
for (int j = yMin; j <= yMax; j++)
CreateFloor(i, j);
}
/// <summary>
/// Remove floor at position.
/// </summary>
/// <param name="x">X position of floor.</param>
/// <param name="y">Y position of floor.</param>
public void RemoveFloor(int x, int y)
{
if (floorGrid[mapCenterPos + x, mapCenterPos + y] != null)
if ((x >= 0 ? x > maxMapSize / 2 - 1 : x < maxMapSize / 2) || (y >= 0 ? y > maxMapSize / 2 - 1 : y < maxMapSize / 2))
{
Destroy(floorGrid[mapCenterPos + x, mapCenterPos + y].gameObject);
Debug.Log("Input size exceeds map's max size.");
return;
}
else
Vector2Int floorPos = new Vector2Int(x, y);
if (floorGrid.ContainsKey(floorPos))
{
Debug.Log("Floor doesn't exists in : (" + x + ", " + y + ")");
Destroy(floorGrid[floorPos].gameObject);
floorGrid.Remove(floorPos);
StartCoroutine(MapManager.inst.Rebaker());
}
else
Debug.Log("Floor doesn't exists at : (" + x + ", " + y + ")");
}
/// <summary>
/// Remove floor at position.
......@@ -82,42 +123,79 @@ public class Map : MonoBehaviour
{
RemoveFloor(pos.x, pos.y);
}
public void CreateWall(GameObject floor1, GameObject floor2)
/// <summary>
/// Create wall between two floors.
/// </summary>
/// <param name="floor1"></param>
/// <param name="floor2"></param>
public void CreateWall(Floor floor1, Floor floor2)
{
Vector3 wallPos = (cube1.transform.position + cube2.transform.position) / 2;
Instantiate(wall, wallPos, Quaternion.identity, transform).transform.LookAt(cube1.transform);
Vector2 wallPos = (Vector2)(floor1.MapPos + floor2.MapPos) / 2;
if (!wallGrid.ContainsKey(wallPos))
{
wallGrid.Add(wallPos, Instantiate(MapManager.inst.wall, new Vector3(wallPos.x, 0, wallPos.y), Quaternion.identity, walls.transform).GetComponent<Wall>());
wallGrid[wallPos].SetMapPos(wallPos);
wallGrid[wallPos].transform.LookAt(floor1.transform);
StartCoroutine(MapManager.inst.Rebaker());
}
else
Debug.Log("Wall already exists between : " + floor1.MapPos + ", " + floor2.MapPos);
}
public void Rebaker()
/// <summary>
/// Create walls from two floors, toward dir's direction.
/// </summary>
/// <param name="floor1"></param>
/// <param name="floor2"></param>
/// <param name="dir">Direction you want to create walls.</param>
/// <param name="length">Amount of walls you want to create.</param>
public void CreateWall(Floor floor1, Floor floor2, Vector2 dir, int length)
{
surface.BuildNavMesh();
Vector2Int floor1Pos = floor1.MapPos;
Vector2Int floor2Pos = floor2.MapPos;
for (int i = 0; i < length; i++)
{
if(GetFloorAtPos(floor1Pos) == null || GetFloorAtPos(floor2Pos) == null)
{
Debug.Log("Floor doesn't exists.\nMaybe length you input exceeded current floors' length.");
return;
}
CreateWall(GetFloorAtPos(floor1Pos), GetFloorAtPos(floor2Pos));
floor1Pos += new Vector2Int((int)dir.x, (int)dir.y);
floor2Pos += new Vector2Int((int)dir.x, (int)dir.y);
}
}
/// <summary>
/// Create wall between two cubes.
/// Remove wall between two floors.
/// </summary>
/// <param name="cube1">Cube 1</param>
/// <param name="cube2">Cube 2</param>
public void CreateWall(GameObject cube1, GameObject cube2)
/// <param name="floor1"></param>
/// <param name="floor2"></param>
public void RemoveWall(Floor floor1, Floor floor2)
{
Vector3 wallPos = (cube1.transform.position + cube2.transform.position) / 2;
GameObject abc = Instantiate(wall, wallPos, Quaternion.identity, transform);
abc.transform.LookAt(cube1.transform);
Vector2 wallPos = (Vector2)(floor1.MapPos + floor2.MapPos) / 2;
if (wallGrid.ContainsKey(wallPos))
{
Destroy(wallGrid[wallPos].gameObject);
wallGrid.Remove(wallPos);
StartCoroutine(MapManager.inst.Rebaker());
}
else
Debug.Log("Wall doesn't exists between : " + floor1.MapPos + ", " + floor2.MapPos);
}
private void Awake()
{
floorGrid = new Dictionary<Vector2Int, Floor>();
wallGrid = new Dictionary<Vector2, Wall>();
maxMapSize = 5 * Mathf.Max(testInputSizeX, testInputSizeY);
CreateFloor(new Vector2Int(0, 0), new Vector2Int(9, 9));
CreateWall(GetFloorAtPos(0, 2), GetFloorAtPos(0, 3), Vector2.right, 5);
MapManager.inst.surface.BuildNavMesh();
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Wall : MonoBehaviour
{
/// <summary>
/// Position of this floor at the map.
/// </summary>
public Vector2 MapPos { get; private set; }
public void SetMapPos(Vector2 pos)
{
MapPos = pos;
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: 12e6eb2c47d8fa6439494493e8238a81
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -2,43 +2,27 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.UI;
public class MapManager : MonoBehaviour
public class MapManager : SingletonBehaviour<MapManager>
{
public int x, y;
public GameObject floor;
public GameObject wall;
public Floor floor;
public Wall wall;
public GameObject player;
public Map currentMap;
public static NavMeshSurface surface;
public NavMeshSurface surface;
public Map[] stage;
public InputField xInput, yInput;
public void CreateMap(Map _newMap)
public void LoadMap(Map _newMap)
{
Map newMap = Instantiate(_newMap);
newMap.transform.position = new Vector3(0, 0, 0);
currentMap = Instantiate(_newMap);
currentMap.transform.position = new Vector3(0, 0, 0);
player.transform.position = currentMap.GetFloorAtPos(0, 0).transform.position + new Vector3(0, 1.5f, 0);
}
public void Rebaker()
public IEnumerator Rebaker()
{
yield return null;
surface.BuildNavMesh();
}
/// <summary>
/// Create wall between two cubes.
/// </summary>
/// <param name="cube1">Cube 1</param>
/// <param name="cube2">Cube 2</param>
public void CreateWall(GameObject cube1, GameObject cube2)
{
Vector3 wallPos = (cube1.transform.position + cube2.transform.position) / 2;
GameObject abc = Instantiate(wall, wallPos, Quaternion.identity, transform);
abc.transform.LookAt(cube1.transform);
}
private void Awake()
{
......@@ -48,17 +32,7 @@ public class MapManager : MonoBehaviour
// Start is called before the first frame update
void Start()
{
mapMaxSize = 5 * Mathf.Max(x, y);
mapCenterPos = mapMaxSize / 2;
mapGrid = new GameObject[mapMaxSize, mapMaxSize];
for (int i = mapCenterPos; i < mapCenterPos + x; i++)
for (int j = mapCenterPos; j < mapCenterPos + y; j++)
mapGrid[i, j] = Instantiate(floor, new Vector3(i, 0, j), Quaternion.identity, transform);
player.transform.position = GetCubeAtPos(0, 0).transform.position + new Vector3(0, 1.5f, 0);
CreateWall(GetCubeAtPos(2, 2), GetCubeAtPos(2, 3));
CreateWall(GetCubeAtPos(3, 2), GetCubeAtPos(2, 2));
CreateWall(GetCubeAtPos(3, 3), GetCubeAtPos(2, 3));
surface.BuildNavMesh();
LoadMap(stage[0]);
}
// Update is called once per frame
......
......@@ -21,7 +21,7 @@ public class PlayerController : MonoBehaviour
if (Physics.Raycast(mouseRay, out hit) && hit.collider.gameObject.tag.Equals("floor"))
{
GetComponent<NavMeshAgent>().SetDestination(hit.collider.gameObject.transform.position);
Debug.Log(hit.collider.gameObject.transform.position);
Debug.Log(hit.collider.gameObject.GetComponent<Floor>().MapPos);
Debug.Log(hit.collider.gameObject.tag);
}
}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TestTools : MonoBehaviour
{
public InputField floorXInput, floorYInput;
public InputField wall1XInput, wall1YInput, wall2XInput, wall2YInput;
public void AddFloor()
{
MapManager.inst.currentMap.CreateFloor(int.Parse(floorXInput.text), int.Parse(floorYInput.text));
}
public void RemoveFloor()
{
MapManager.inst.currentMap.RemoveFloor(int.Parse(floorXInput.text), int.Parse(floorYInput.text));
}
public void AddWall()
{
MapManager.inst.currentMap.CreateWall(
MapManager.inst.currentMap.GetFloorAtPos(int.Parse(wall1XInput.text), int.Parse(wall1YInput.text)),
MapManager.inst.currentMap.GetFloorAtPos(int.Parse(wall2XInput.text), int.Parse(wall2YInput.text)));
}
public void RemoveWall()
{
MapManager.inst.currentMap.RemoveWall(
MapManager.inst.currentMap.GetFloorAtPos(int.Parse(wall1XInput.text), int.Parse(wall1YInput.text)),
MapManager.inst.currentMap.GetFloorAtPos(int.Parse(wall2XInput.text), int.Parse(wall2YInput.text)));
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: 9b8e1e408cd84db4583dba90a6a06169
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment