Commit 88e50fd3 authored by 18손재민's avatar 18손재민

스테이지 클리어 판정 추가

n개의 목표 바닥 밟기 판정 WIP
parent b8f25489
...@@ -106,6 +106,8 @@ MonoBehaviour: ...@@ -106,6 +106,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 1, y: 0} mapPos: {x: 1, y: 0}
isPassed: 0
isGoalFloor: 0
--- !u!1 &1634709099193762938 --- !u!1 &1634709099193762938
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -212,6 +214,8 @@ MonoBehaviour: ...@@ -212,6 +214,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: -2, y: -1} mapPos: {x: -2, y: -1}
isPassed: 0
isGoalFloor: 0
--- !u!1 &1638206002697659172 --- !u!1 &1638206002697659172
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -318,6 +322,8 @@ MonoBehaviour: ...@@ -318,6 +322,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 1, y: 1} mapPos: {x: 1, y: 1}
isPassed: 0
isGoalFloor: 0
--- !u!1 &1737410653383664023 --- !u!1 &1737410653383664023
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -375,16 +381,10 @@ MonoBehaviour: ...@@ -375,16 +381,10 @@ MonoBehaviour:
clearConditions: clearConditions:
- type: 0 - type: 0
count: 0 count: 0
goal: 0 goal: 4
- type: 0 - type: 3
count: 0
goal: 0
- type: 0
count: 0
goal: 0
- type: 0
count: 0 count: 0
goal: 0 goal: 3
--- !u!1 &2104754727029010325 --- !u!1 &2104754727029010325
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -491,6 +491,8 @@ MonoBehaviour: ...@@ -491,6 +491,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 2, y: 0} mapPos: {x: 2, y: 0}
isPassed: 0
isGoalFloor: 0
--- !u!1 &2189700681577347922 --- !u!1 &2189700681577347922
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -597,6 +599,8 @@ MonoBehaviour: ...@@ -597,6 +599,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: -2, y: 2} mapPos: {x: -2, y: 2}
isPassed: 0
isGoalFloor: 0
--- !u!1 &2292282653549884484 --- !u!1 &2292282653549884484
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -703,6 +707,8 @@ MonoBehaviour: ...@@ -703,6 +707,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: -1, y: 2} mapPos: {x: -1, y: 2}
isPassed: 0
isGoalFloor: 0
--- !u!1 &2339437859421285817 --- !u!1 &2339437859421285817
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -809,6 +815,8 @@ MonoBehaviour: ...@@ -809,6 +815,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: -2, y: -2} mapPos: {x: -2, y: -2}
isPassed: 0
isGoalFloor: 0
--- !u!1 &2681926362236754680 --- !u!1 &2681926362236754680
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -915,6 +923,8 @@ MonoBehaviour: ...@@ -915,6 +923,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 2, y: 1} mapPos: {x: 2, y: 1}
isPassed: 0
isGoalFloor: 0
--- !u!1 &3525591482656589422 --- !u!1 &3525591482656589422
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1021,6 +1031,8 @@ MonoBehaviour: ...@@ -1021,6 +1031,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 2, y: -2} mapPos: {x: 2, y: -2}
isPassed: 0
isGoalFloor: 0
--- !u!1 &4007647678807291638 --- !u!1 &4007647678807291638
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1252,6 +1264,8 @@ MonoBehaviour: ...@@ -1252,6 +1264,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 1, y: -2} mapPos: {x: 1, y: -2}
isPassed: 0
isGoalFloor: 0
--- !u!1 &4592160369612705167 --- !u!1 &4592160369612705167
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1358,6 +1372,8 @@ MonoBehaviour: ...@@ -1358,6 +1372,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 1, y: -1} mapPos: {x: 1, y: -1}
isPassed: 0
isGoalFloor: 0
--- !u!1 &4709249395185914413 --- !u!1 &4709249395185914413
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1464,6 +1480,8 @@ MonoBehaviour: ...@@ -1464,6 +1480,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 1, y: 2} mapPos: {x: 1, y: 2}
isPassed: 0
isGoalFloor: 0
--- !u!1 &4810397660174508062 --- !u!1 &4810397660174508062
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1570,6 +1588,8 @@ MonoBehaviour: ...@@ -1570,6 +1588,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: -1, y: -1} mapPos: {x: -1, y: -1}
isPassed: 0
isGoalFloor: 0
--- !u!1 &5069305046428251933 --- !u!1 &5069305046428251933
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1676,6 +1696,8 @@ MonoBehaviour: ...@@ -1676,6 +1696,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: -1, y: 0} mapPos: {x: -1, y: 0}
isPassed: 0
isGoalFloor: 0
--- !u!1 &5342110572568681991 --- !u!1 &5342110572568681991
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1782,6 +1804,8 @@ MonoBehaviour: ...@@ -1782,6 +1804,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 0, y: -2} mapPos: {x: 0, y: -2}
isPassed: 0
isGoalFloor: 0
--- !u!1 &5390496715387352304 --- !u!1 &5390496715387352304
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2068,6 +2092,8 @@ MonoBehaviour: ...@@ -2068,6 +2092,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 0, y: 1} mapPos: {x: 0, y: 1}
isPassed: 0
isGoalFloor: 0
--- !u!1 &6532917746544365902 --- !u!1 &6532917746544365902
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2208,6 +2234,8 @@ MonoBehaviour: ...@@ -2208,6 +2234,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: -2, y: 1} mapPos: {x: -2, y: 1}
isPassed: 0
isGoalFloor: 0
--- !u!1 &7141810549857698684 --- !u!1 &7141810549857698684
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2314,6 +2342,8 @@ MonoBehaviour: ...@@ -2314,6 +2342,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 0, y: 0} mapPos: {x: 0, y: 0}
isPassed: 0
isGoalFloor: 0
--- !u!1 &7422189717627061705 --- !u!1 &7422189717627061705
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2545,6 +2575,8 @@ MonoBehaviour: ...@@ -2545,6 +2575,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: -2, y: 0} mapPos: {x: -2, y: 0}
isPassed: 0
isGoalFloor: 0
--- !u!1 &7560450311381198066 --- !u!1 &7560450311381198066
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2806,6 +2838,8 @@ MonoBehaviour: ...@@ -2806,6 +2838,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: -1, y: 1} mapPos: {x: -1, y: 1}
isPassed: 0
isGoalFloor: 0
--- !u!1 &8683807963293059402 --- !u!1 &8683807963293059402
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2912,6 +2946,8 @@ MonoBehaviour: ...@@ -2912,6 +2946,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 0, y: 2} mapPos: {x: 0, y: 2}
isPassed: 0
isGoalFloor: 0
--- !u!1 &8695425579486219508 --- !u!1 &8695425579486219508
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -3018,6 +3054,8 @@ MonoBehaviour: ...@@ -3018,6 +3054,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 2, y: 2} mapPos: {x: 2, y: 2}
isPassed: 0
isGoalFloor: 0
--- !u!1 &8852115476851130467 --- !u!1 &8852115476851130467
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -3124,6 +3162,8 @@ MonoBehaviour: ...@@ -3124,6 +3162,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 0, y: -1} mapPos: {x: 0, y: -1}
isPassed: 0
isGoalFloor: 0
--- !u!1 &9046791506793280589 --- !u!1 &9046791506793280589
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -3230,6 +3270,8 @@ MonoBehaviour: ...@@ -3230,6 +3270,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: -1, y: -2} mapPos: {x: -1, y: -2}
isPassed: 0
isGoalFloor: 0
--- !u!1 &9206324191454810788 --- !u!1 &9206324191454810788
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -3336,3 +3378,5 @@ MonoBehaviour: ...@@ -3336,3 +3378,5 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 2, y: -1} mapPos: {x: 2, y: -1}
isPassed: 0
isGoalFloor: 0
...@@ -9,6 +9,7 @@ GameObject: ...@@ -9,6 +9,7 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 52444459818764335} - component: {fileID: 52444459818764335}
- component: {fileID: 2122327709}
m_Layer: 0 m_Layer: 0
m_Name: GameManager m_Name: GameManager
m_TagString: Untagged m_TagString: Untagged
...@@ -30,3 +31,18 @@ Transform: ...@@ -30,3 +31,18 @@ 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!114 &2122327709
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 52444459818764334}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f94477ce50cfef746baa12d77bb9d4eb, type: 3}
m_Name:
m_EditorClassIdentifier:
mirrorMaterial: {fileID: 0}
clearIndex: 000000000000000000000000000000000000000000000000000000000000000000000000
clearCounter: 0
...@@ -52,15 +52,15 @@ MonoBehaviour: ...@@ -52,15 +52,15 @@ MonoBehaviour:
- {fileID: 2534561534465535505, guid: 0b323beb318071144aef94132be66541, type: 3} - {fileID: 2534561534465535505, guid: 0b323beb318071144aef94132be66541, type: 3}
- {fileID: 6001025753464815805, guid: df6f1d8b9377ec346af4255abe290fbb, type: 3} - {fileID: 6001025753464815805, guid: df6f1d8b9377ec346af4255abe290fbb, type: 3}
- {fileID: 33432975985984805, guid: ec20e06c4a993924791d02d7a4c9375c, type: 3} - {fileID: 33432975985984805, guid: ec20e06c4a993924791d02d7a4c9375c, type: 3}
players: []
player: {fileID: 494213313239918027, guid: 449b2ca4d925da541bb45c84b63aab98, type: 3}
currentMap: {fileID: 0}
surface: {fileID: 0}
stage:
- {fileID: 2496973653136699540, guid: dbb2e09c19fe5ad49b11a6b95e5ac9e8, type: 3}
truthBullet: {fileID: 7554112578236620015, guid: bfe2c93abf5421b4a9b142f60d689533, truthBullet: {fileID: 7554112578236620015, guid: bfe2c93abf5421b4a9b142f60d689533,
type: 3} type: 3}
fakeBullet: {fileID: 5866539243986221368, guid: a1830defb592fe841ab1732fd18f73a1, fakeBullet: {fileID: 5866539243986221368, guid: a1830defb592fe841ab1732fd18f73a1,
type: 3} type: 3}
mirrorBullet: {fileID: 3200095709359611570, guid: bb70103aa487bc346a6df423335477a2, mirrorBullet: {fileID: 3200095709359611570, guid: bb70103aa487bc346a6df423335477a2,
type: 3} type: 3}
players: []
player: {fileID: 494213313239918027, guid: 449b2ca4d925da541bb45c84b63aab98, type: 3}
currentMap: {fileID: 0}
surface: {fileID: 0}
stage:
- {fileID: 2496973653136699540, guid: dbb2e09c19fe5ad49b11a6b95e5ac9e8, type: 3}
...@@ -802,11 +802,6 @@ PrefabInstance: ...@@ -802,11 +802,6 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 7277015661519863741, guid: 20dee07e28273f049a9093ae4453912f,
type: 3}
propertyPath: m_NavMeshData
value:
objectReference: {fileID: 0}
- target: {fileID: 7277015661519863740, guid: 20dee07e28273f049a9093ae4453912f, - target: {fileID: 7277015661519863740, guid: 20dee07e28273f049a9093ae4453912f,
type: 3} type: 3}
propertyPath: m_Name propertyPath: m_Name
...@@ -817,6 +812,11 @@ PrefabInstance: ...@@ -817,6 +812,11 @@ PrefabInstance:
propertyPath: m_IsActive propertyPath: m_IsActive
value: 1 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7277015661519863741, guid: 20dee07e28273f049a9093ae4453912f,
type: 3}
propertyPath: m_NavMeshData
value:
objectReference: {fileID: 0}
- target: {fileID: 7277015661519863742, guid: 20dee07e28273f049a9093ae4453912f, - target: {fileID: 7277015661519863742, guid: 20dee07e28273f049a9093ae4453912f,
type: 3} type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
......
...@@ -7,8 +7,6 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor ...@@ -7,8 +7,6 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
[SerializeField] [SerializeField]
private Floor floor = null; private Floor floor = null;
public Vector2Int Position { get { return floor != null ? floor.mapPos : throw new UnassignedReferenceException("Floor of Interactor is not assigned"); } } public Vector2Int Position { get { return floor != null ? floor.mapPos : throw new UnassignedReferenceException("Floor of Interactor is not assigned"); } }
private int aCase;
private int nCase;
public GameObject GetObject() public GameObject GetObject()
{ {
...@@ -22,9 +20,7 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor ...@@ -22,9 +20,7 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
public void Init(Floor floor) public void Init(Floor floor)
{ {
aCase = GameManager.inst.clearIndex[(int)ClearType.AllCase]; if (GameManager.aCase >= 0) MapManager.inst.currentMap.clearConditions[GameManager.aCase].goal++;
nCase = GameManager.inst.clearIndex[(int)ClearType.NCase];
if (aCase >= 0) MapManager.inst.currentMap.clearConditions[aCase].goal++;
this.floor = floor; this.floor = floor;
PlayerController.inst.OnPlayerMove += Interact; PlayerController.inst.OnPlayerMove += Interact;
} }
...@@ -34,16 +30,10 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor ...@@ -34,16 +30,10 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
Debug.Log(Position + " " + position); Debug.Log(Position + " " + position);
if (Position == position) if (Position == position)
{ {
if (aCase >= 0) if (GameManager.aCase >= 0)
{ MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone();
MapManager.inst.currentMap.clearConditions[aCase].count++; if (GameManager.nCase >= 0)
MapManager.inst.currentMap.clearConditions[aCase].IsDone(); MapManager.inst.currentMap.clearConditions[GameManager.nCase].IsDone();
}
if (nCase >= 0)
{
MapManager.inst.currentMap.clearConditions[nCase].count++;
MapManager.inst.currentMap.clearConditions[nCase].IsDone();
}
Destroy(gameObject); Destroy(gameObject);
} }
} }
......
...@@ -9,8 +9,9 @@ public class GameManager : SingletonBehaviour<GameManager> ...@@ -9,8 +9,9 @@ public class GameManager : SingletonBehaviour<GameManager>
public int[] clearIndex = new int[9]; public int[] clearIndex = new int[9];
public int clearCounter = 0; public int clearCounter = 0;
public static int nFloor, nTurret, nCase, nPlayer, aFloor, aTurret, aCase, white, black;
private void GetClearIndex(Map map) public void SetClearIndex(Map map)
{ {
for (int i = 0; i < 9; i++) clearIndex[i] = -1; for (int i = 0; i < 9; i++) clearIndex[i] = -1;
foreach (var child in map.clearConditions) foreach (var child in map.clearConditions)
...@@ -18,5 +19,26 @@ public class GameManager : SingletonBehaviour<GameManager> ...@@ -18,5 +19,26 @@ public class GameManager : SingletonBehaviour<GameManager>
clearIndex[(int)child.type] = map.clearConditions.IndexOf(child); clearIndex[(int)child.type] = map.clearConditions.IndexOf(child);
clearCounter++; clearCounter++;
} }
nFloor = clearIndex[(int)ClearType.NFloor];
nTurret = clearIndex[(int)ClearType.NTurret];
nCase = clearIndex[(int)ClearType.NCase];
nPlayer = clearIndex[(int)ClearType.NPlayer];
aFloor = clearIndex[(int)ClearType.AllFloor];
aTurret = clearIndex[(int)ClearType.AllTurret];
aCase = clearIndex[(int)ClearType.AllCase];
white = clearIndex[(int)ClearType.White];
black = clearIndex[(int)ClearType.Black];
}
public void ClearStage()
{
Debug.Log("Stage Clear!");
}
// Start is called before the first frame update
void Start()
{
if (!MapManager.inst.isMapEditingOn)
MapManager.inst.LoadMap(MapManager.inst.stage[0]);
} }
} }
...@@ -21,6 +21,7 @@ public class ClearCondition ...@@ -21,6 +21,7 @@ public class ClearCondition
public ClearType type; public ClearType type;
public int count; public int count;
public int goal; public int goal;
bool isDone = false;
public ClearCondition(ClearType _type, int _goal) public ClearCondition(ClearType _type, int _goal)
{ {
...@@ -29,14 +30,19 @@ public class ClearCondition ...@@ -29,14 +30,19 @@ public class ClearCondition
count = 0; count = 0;
} }
public bool IsDone() public void IsDone()
{ {
if (goal <= count) if (!isDone)
{ {
GameManager.inst.clearCounter--; count++;
GameManager.inst.clearIndex[(int)type] = -1; if (goal <= count)
return true; {
GameManager.inst.clearCounter--;
GameManager.inst.clearIndex[(int)type] = -1;
isDone = true;
if (GameManager.inst.clearCounter == 0)
GameManager.inst.ClearStage();
}
} }
else return false;
} }
} }
...@@ -8,6 +8,8 @@ public class Floor : MonoBehaviour ...@@ -8,6 +8,8 @@ public class Floor : MonoBehaviour
/// Position of this floor at the map. /// Position of this floor at the map.
/// </summary> /// </summary>
public Vector2Int mapPos; public Vector2Int mapPos;
public bool isPassed;
public bool isGoalFloor = false;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
......
...@@ -59,6 +59,7 @@ public class Map : MonoBehaviour ...@@ -59,6 +59,7 @@ public class Map : MonoBehaviour
{ {
floorGrid.Add(pos, Instantiate(MapManager.inst.floor, new Vector3(pos.x, 0, pos.y), Quaternion.identity, floors.transform).GetComponent<Floor>()); floorGrid.Add(pos, Instantiate(MapManager.inst.floor, new Vector3(pos.x, 0, pos.y), Quaternion.identity, floors.transform).GetComponent<Floor>());
floorGrid[pos].mapPos = pos; floorGrid[pos].mapPos = pos;
floorGrid[pos].isPassed = false;
StartCoroutine(MapManager.inst.Rebaker()); StartCoroutine(MapManager.inst.Rebaker());
} }
else else
......
...@@ -7,16 +7,17 @@ using UnityEngine.AI; ...@@ -7,16 +7,17 @@ using UnityEngine.AI;
public class MapManager : SingletonBehaviour<MapManager> public class MapManager : SingletonBehaviour<MapManager>
{ {
public bool isMapEditingOn; public bool isMapEditingOn;
[Header("Instances")]
public Floor floor; public Floor floor;
public NormalWall normalWall; public NormalWall normalWall;
public Mirror mirror; public Mirror mirror;
public GameObject[] objects; public GameObject[] objects;
public GameObject truthBullet, fakeBullet, mirrorBullet;
public List<GameObject> players; public List<GameObject> players;
public GameObject player; public GameObject player;
public Map currentMap; public Map currentMap;
public NavMeshSurface surface; public NavMeshSurface surface;
public Map[] stage; public Map[] stage;
public GameObject truthBullet, fakeBullet, mirrorBullet;
public BulletFactory bulletFactory; public BulletFactory bulletFactory;
public void LoadMap(Map _newMap) public void LoadMap(Map _newMap)
...@@ -26,8 +27,9 @@ public class MapManager : SingletonBehaviour<MapManager> ...@@ -26,8 +27,9 @@ public class MapManager : SingletonBehaviour<MapManager>
currentMap = Instantiate(_newMap); currentMap = Instantiate(_newMap);
currentMap.transform.position = new Vector3(0, 0, 0); currentMap.transform.position = new Vector3(0, 0, 0);
surface.BuildNavMesh(); surface.BuildNavMesh();
GameManager.inst.SetClearIndex(currentMap);
for (int i = 0; i < currentMap.startFloors.Count; i++) for (int i = 0; i < currentMap.startFloors.Count; i++)
players.Add(Instantiate(player, currentMap.startFloors[i].transform.position + new Vector3(0, 0.1f, 0), Quaternion.identity)); PlayerController.inst.CreatePlayer(currentMap.startFloors[i].transform.position);
} }
public IEnumerator Rebaker() public IEnumerator Rebaker()
{ {
...@@ -44,8 +46,7 @@ public class MapManager : SingletonBehaviour<MapManager> ...@@ -44,8 +46,7 @@ public class MapManager : SingletonBehaviour<MapManager>
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
if(!isMapEditingOn)
LoadMap(stage[0]);
} }
// Update is called once per frame // Update is called once per frame
......
...@@ -55,9 +55,7 @@ public class Player : MonoBehaviour ...@@ -55,9 +55,7 @@ public class Player : MonoBehaviour
GetComponent<NavMeshAgent>().SetDestination(destination); GetComponent<NavMeshAgent>().SetDestination(destination);
} }
else else
{
Debug.Log("Destination is not reachable."); Debug.Log("Destination is not reachable.");
}
} }
/// <summary> /// <summary>
/// Check if player is arrived at the destination. /// Check if player is arrived at the destination.
...@@ -68,10 +66,17 @@ public class Player : MonoBehaviour ...@@ -68,10 +66,17 @@ public class Player : MonoBehaviour
{ {
anim.SetBool("isWalking", true); anim.SetBool("isWalking", true);
while (Mathf.Abs(transform.position.x - destination.x) > 0.01f || Mathf.Abs(transform.position.z - destination.z) > 0.01f) while (Mathf.Abs(transform.position.x - destination.x) > 0.01f || Mathf.Abs(transform.position.z - destination.z) > 0.01f)
{
yield return null; yield return null;
}
transform.position = new Vector3(destination.x, transform.position.y, destination.z); transform.position = new Vector3(destination.x, transform.position.y, destination.z);
Floor currentFloor = MapManager.inst.currentMap.GetFloorAtPos(new Vector2Int((int)destination.x, (int)destination.z));
if (!currentFloor.isPassed)
{
currentFloor.isPassed = true;
if (GameManager.aFloor >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.aFloor].IsDone();
if (GameManager.nFloor >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.nFloor].IsDone();
}
anim.SetBool("isWalking", false); anim.SetBool("isWalking", false);
PlayerController.inst.isPlayerMoving = false; PlayerController.inst.isPlayerMoving = false;
} }
......
...@@ -27,6 +27,16 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -27,6 +27,16 @@ public class PlayerController : SingletonBehaviour<PlayerController>
public event Action<Vector2Int> OnPlayerMove; public event Action<Vector2Int> OnPlayerMove;
public void CreatePlayer(Vector3 playerPos)
{
MapManager.inst.players.Add(Instantiate(MapManager.inst.player, playerPos + new Vector3(0, 0.1f, 0), Quaternion.identity));
MapManager.inst.currentMap.clearConditions[GameManager.nPlayer].count = MapManager.inst.players.Count - 1;
Debug.Log(MapManager.inst.players.Count - 1);
MapManager.inst.currentMap.clearConditions[GameManager.nPlayer].IsDone();
}
//For test
public string GetCurrentBullet() public string GetCurrentBullet()
{ {
return bulletList.Count > 0 ? bulletList[bulletCount].ToString() : null; return bulletList.Count > 0 ? bulletList[bulletCount].ToString() : null;
...@@ -58,7 +68,7 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -58,7 +68,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
{ {
if (prePos != MapPos) if (prePos != MapPos)
{ {
Debug.Log(MapPos); //Debug.Log(MapPos);
OnPlayerMove?.Invoke(MapPos); OnPlayerMove?.Invoke(MapPos);
prePos = MapPos; prePos = MapPos;
} }
...@@ -80,13 +90,13 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -80,13 +90,13 @@ public class PlayerController : SingletonBehaviour<PlayerController>
currentPlayer = hit.transform.gameObject.GetComponent<Player>(); currentPlayer = hit.transform.gameObject.GetComponent<Player>();
StartCoroutine(currentPlayer.SetCurrentPlayer()); StartCoroutine(currentPlayer.SetCurrentPlayer());
StartCoroutine(currentPlayer.CountPlayerClick(Time.time)); StartCoroutine(currentPlayer.CountPlayerClick(Time.time));
Debug.Log(hit.collider.gameObject.tag); //Debug.Log(hit.collider.gameObject.tag);
} }
else if (Physics.Raycast(mouseRay, out hit) && hit.collider.gameObject.tag.Equals("floor")) else if (Physics.Raycast(mouseRay, out hit) && hit.collider.gameObject.tag.Equals("floor"))
{ {
if (currentPlayer != null) if (currentPlayer != null)
currentPlayer.MovePlayer(hit.collider.gameObject.transform.position); currentPlayer.MovePlayer(hit.collider.gameObject.transform.position);
Debug.Log(hit.collider.gameObject.tag); //Debug.Log(hit.collider.gameObject.tag);
} }
else if (hit.collider == null) else if (hit.collider == null)
{ {
......
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