Commit 6e8b713f authored by 18손재민's avatar 18손재민

승리 조건 판정 모두 구현함

parent 543c1c41
...@@ -381,10 +381,10 @@ MonoBehaviour: ...@@ -381,10 +381,10 @@ MonoBehaviour:
clearConditions: clearConditions:
- type: 0 - type: 0
count: 0 count: 0
goal: 3 goal: 2
- type: 3 - type: 7
count: 0 count: 0
goal: 3 goal: 1
--- !u!1 &2104754727029010325 --- !u!1 &2104754727029010325
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -20,7 +20,7 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor ...@@ -20,7 +20,7 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
public void Init(Floor floor) public void Init(Floor floor)
{ {
if (GameManager.aCase >= 0) MapManager.inst.currentMap.clearConditions[GameManager.aCase].goal++; if (GameManager.aCase >= 0) MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone(0, 1);
this.floor = floor; this.floor = floor;
PlayerController.inst.OnPlayerMove += Interact; PlayerController.inst.OnPlayerMove += Interact;
} }
...@@ -31,15 +31,9 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor ...@@ -31,15 +31,9 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
if (Position == position) if (Position == position)
{ {
if (GameManager.aCase >= 0) if (GameManager.aCase >= 0)
{ MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone(1);
MapManager.inst.currentMap.clearConditions[GameManager.aCase].count++;
MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone();
}
if (GameManager.nCase >= 0) if (GameManager.nCase >= 0)
{ MapManager.inst.currentMap.clearConditions[GameManager.nCase].IsDone(1);
MapManager.inst.currentMap.clearConditions[GameManager.nCase].count++;
MapManager.inst.currentMap.clearConditions[GameManager.nCase].IsDone();
}
Destroy(gameObject); Destroy(gameObject);
} }
} }
......
...@@ -16,6 +16,10 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto ...@@ -16,6 +16,10 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto
public void Break() public void Break()
{ {
if (GameManager.aTurret >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.aTurret].IsDone(1);
if (GameManager.nTurret >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.nTurret].IsDone(1);
Destroy(gameObject); Destroy(gameObject);
} }
......
...@@ -41,13 +41,22 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor ...@@ -41,13 +41,22 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor
public void Interact(Bullet bullet) public void Interact(Bullet bullet)
{ {
if (bullet is TruthBullet) Color tempColor = Color;
if (bullet is TruthBullet && tempColor == Color.black)
{ {
Color = Color.white; Color = Color.white;
if (GameManager.white >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.white].IsDone(1);
if (GameManager.black >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.black].IsDone(-1);
} }
if (bullet is FakeBullet) else if (bullet is FakeBullet && tempColor == Color.white)
{ {
Color = Color.black; Color = Color.black;
if (GameManager.black >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.black].IsDone(1);
if (GameManager.white >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.white].IsDone(-1);
} }
} }
...@@ -60,6 +69,10 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor ...@@ -60,6 +69,10 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor
public void SetColor(bool isWhite) public void SetColor(bool isWhite)
{ {
Color = isWhite ? Color.white : Color.black; Color = isWhite ? Color.white : Color.black;
if (GameManager.white >= 0 && isWhite)
MapManager.inst.currentMap.clearConditions[GameManager.white].IsDone(1);
if (GameManager.black >= 0 && !isWhite)
MapManager.inst.currentMap.clearConditions[GameManager.black].IsDone(1);
} }
#region IObject Override #region IObject Override
......
...@@ -23,25 +23,29 @@ public class ClearCondition ...@@ -23,25 +23,29 @@ public class ClearCondition
public int goal; public int goal;
bool isDone = false; bool isDone = false;
public ClearCondition(ClearType _type, int _goal) /*public ClearCondition(ClearType _type, int _goal)
{ {
type = _type; type = _type;
goal = _goal; goal = _goal;
count = 0; count = 0;
} }*/
public void IsDone() public void IsDone(int _count = 0, int _goal = 0)
{
if (!isDone)
{ {
count += _count;
goal += _goal;
if (goal <= count) if (goal <= count)
{ {
GameManager.inst.clearCounter--; GameManager.inst.clearCounter--;
GameManager.inst.clearIndex[(int)type] = -1;
isDone = true; isDone = true;
Debug.Log(GameManager.inst.clearCounter);
if (GameManager.inst.clearCounter == 0) if (GameManager.inst.clearCounter == 0)
GameManager.inst.ClearStage(); GameManager.inst.ClearStage();
} }
else if (goal > count && isDone)
{
GameManager.inst.clearCounter++;
isDone = false;
} }
} }
} }
...@@ -8,7 +8,6 @@ public class Floor : MonoBehaviour ...@@ -8,7 +8,6 @@ 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; public bool isGoalFloor = false;
// Start is called before the first frame update // Start is called before the first frame update
......
...@@ -48,7 +48,7 @@ public class Map : MonoBehaviour ...@@ -48,7 +48,7 @@ public class Map : MonoBehaviour
/// Create floor at position. /// Create floor at position.
/// </summary> /// </summary>
/// <param name="pos">Position of floor.</param> /// <param name="pos">Position of floor.</param>
public void CreateFloor(Vector2Int pos) public void CreateFloor(Vector2Int pos, bool isGoal = false)
{ {
if ((pos.x >= 0 ? (pos.x > maxMapSize / 2) : (pos.x < -maxMapSize / 2)) || (pos.y >= 0 ? (pos.y > maxMapSize / 2) : (pos.y < -maxMapSize / 2))) if ((pos.x >= 0 ? (pos.x > maxMapSize / 2) : (pos.x < -maxMapSize / 2)) || (pos.y >= 0 ? (pos.y > maxMapSize / 2) : (pos.y < -maxMapSize / 2)))
{ {
...@@ -59,9 +59,9 @@ public class Map : MonoBehaviour ...@@ -59,9 +59,9 @@ 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; floorGrid[pos].isGoalFloor = isGoal;
if (GameManager.aFloor >= 0) if (GameManager.aFloor >= 0 && isGoal)
MapManager.inst.currentMap.clearConditions[GameManager.aFloor].goal++; MapManager.inst.currentMap.clearConditions[GameManager.aFloor].IsDone(0, 1);
StartCoroutine(MapManager.inst.Rebaker()); StartCoroutine(MapManager.inst.Rebaker());
} }
else else
...@@ -95,6 +95,8 @@ public class Map : MonoBehaviour ...@@ -95,6 +95,8 @@ public class Map : MonoBehaviour
} }
if (floorGrid.ContainsKey(pos)) if (floorGrid.ContainsKey(pos))
{ {
if (GameManager.aFloor >= 0 && floorGrid[pos].isGoalFloor)
MapManager.inst.currentMap.clearConditions[GameManager.aFloor].IsDone(0, -1);
Destroy(floorGrid[pos].gameObject); Destroy(floorGrid[pos].gameObject);
floorGrid.Remove(pos); floorGrid.Remove(pos);
StartCoroutine(MapManager.inst.Rebaker()); StartCoroutine(MapManager.inst.Rebaker());
...@@ -216,9 +218,13 @@ public class Map : MonoBehaviour ...@@ -216,9 +218,13 @@ public class Map : MonoBehaviour
{ {
case ObjType.Briefcase: case ObjType.Briefcase:
objectGrid.Add(pos, Instantiate(MapManager.inst.briefCase, new Vector3(pos.x, 0, pos.y), Quaternion.identity, objects.transform).GetComponent<IObject>()); objectGrid.Add(pos, Instantiate(MapManager.inst.briefCase, new Vector3(pos.x, 0, pos.y), Quaternion.identity, objects.transform).GetComponent<IObject>());
if (GameManager.aCase >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone(0, 1);
break; break;
case ObjType.Camera: case ObjType.Camera:
objectGrid.Add(pos, Instantiate(MapManager.inst.cameraTurret, new Vector3(pos.x, 0, pos.y), Quaternion.identity, objects.transform).GetComponent<IObject>()); objectGrid.Add(pos, Instantiate(MapManager.inst.cameraTurret, new Vector3(pos.x, 0, pos.y), Quaternion.identity, objects.transform).GetComponent<IObject>());
if (GameManager.aTurret >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.aTurret].IsDone(0, 1);
break; break;
case ObjType.Mannequin: case ObjType.Mannequin:
objectGrid.Add(pos, Instantiate(MapManager.inst.mannequins[Random.Range(0, 5)], new Vector3(pos.x, 0, pos.y), Quaternion.identity, objects.transform).GetComponent<IObject>()); objectGrid.Add(pos, Instantiate(MapManager.inst.mannequins[Random.Range(0, 5)], new Vector3(pos.x, 0, pos.y), Quaternion.identity, objects.transform).GetComponent<IObject>());
...@@ -239,6 +245,17 @@ public class Map : MonoBehaviour ...@@ -239,6 +245,17 @@ public class Map : MonoBehaviour
{ {
if (objectGrid.ContainsKey(pos)) if (objectGrid.ContainsKey(pos))
{ {
if(objectGrid[pos].GetType() == ObjType.Briefcase && GameManager.aCase >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone(0, -1);
else if (objectGrid[pos].GetType() == ObjType.Camera && GameManager.aTurret >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.aTurret].IsDone(0, -1);
else if(objectGrid[pos].GetType() == ObjType.Mannequin)
{
if(objectGrid[pos].GetObject().GetComponent<Mannequin>().Color == Color.white && GameManager.white >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.white].IsDone(0, -1);
else if (objectGrid[pos].GetObject().GetComponent<Mannequin>().Color == Color.black && GameManager.black >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.black].IsDone(0, -1);
}
Destroy(objectGrid[pos].GetObject()); Destroy(objectGrid[pos].GetObject());
objectGrid.Remove(pos); objectGrid.Remove(pos);
StartCoroutine(MapManager.inst.Rebaker()); StartCoroutine(MapManager.inst.Rebaker());
......
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