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

승리 조건 판정 모두 구현함

parent 543c1c41
......@@ -381,10 +381,10 @@ MonoBehaviour:
clearConditions:
- type: 0
count: 0
goal: 3
- type: 3
goal: 2
- type: 7
count: 0
goal: 3
goal: 1
--- !u!1 &2104754727029010325
GameObject:
m_ObjectHideFlags: 0
......
......@@ -20,7 +20,7 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
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;
PlayerController.inst.OnPlayerMove += Interact;
}
......@@ -31,15 +31,9 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
if (Position == position)
{
if (GameManager.aCase >= 0)
{
MapManager.inst.currentMap.clearConditions[GameManager.aCase].count++;
MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone();
}
MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone(1);
if (GameManager.nCase >= 0)
{
MapManager.inst.currentMap.clearConditions[GameManager.nCase].count++;
MapManager.inst.currentMap.clearConditions[GameManager.nCase].IsDone();
}
MapManager.inst.currentMap.clearConditions[GameManager.nCase].IsDone(1);
Destroy(gameObject);
}
}
......
......@@ -16,6 +16,10 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto
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);
}
......
......@@ -41,13 +41,22 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor
public void Interact(Bullet bullet)
{
if (bullet is TruthBullet)
Color tempColor = Color;
if (bullet is TruthBullet && tempColor == Color.black)
{
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;
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
public void SetColor(bool isWhite)
{
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
......
......@@ -23,25 +23,29 @@ public class ClearCondition
public int goal;
bool isDone = false;
public ClearCondition(ClearType _type, int _goal)
/*public ClearCondition(ClearType _type, int _goal)
{
type = _type;
goal = _goal;
count = 0;
}
}*/
public void IsDone()
{
if (!isDone)
public void IsDone(int _count = 0, int _goal = 0)
{
count += _count;
goal += _goal;
if (goal <= count)
{
GameManager.inst.clearCounter--;
GameManager.inst.clearIndex[(int)type] = -1;
isDone = true;
Debug.Log(GameManager.inst.clearCounter);
if (GameManager.inst.clearCounter == 0)
GameManager.inst.ClearStage();
}
else if (goal > count && isDone)
{
GameManager.inst.clearCounter++;
isDone = false;
}
}
}
......@@ -8,7 +8,6 @@ public class Floor : MonoBehaviour
/// Position of this floor at the map.
/// </summary>
public Vector2Int mapPos;
public bool isPassed;
public bool isGoalFloor = false;
// Start is called before the first frame update
......
......@@ -48,7 +48,7 @@ public class Map : MonoBehaviour
/// Create floor at position.
/// </summary>
/// <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)))
{
......@@ -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[pos].mapPos = pos;
floorGrid[pos].isPassed = false;
if (GameManager.aFloor >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.aFloor].goal++;
floorGrid[pos].isGoalFloor = isGoal;
if (GameManager.aFloor >= 0 && isGoal)
MapManager.inst.currentMap.clearConditions[GameManager.aFloor].IsDone(0, 1);
StartCoroutine(MapManager.inst.Rebaker());
}
else
......@@ -95,6 +95,8 @@ public class Map : MonoBehaviour
}
if (floorGrid.ContainsKey(pos))
{
if (GameManager.aFloor >= 0 && floorGrid[pos].isGoalFloor)
MapManager.inst.currentMap.clearConditions[GameManager.aFloor].IsDone(0, -1);
Destroy(floorGrid[pos].gameObject);
floorGrid.Remove(pos);
StartCoroutine(MapManager.inst.Rebaker());
......@@ -216,9 +218,13 @@ public class Map : MonoBehaviour
{
case ObjType.Briefcase:
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;
case ObjType.Camera:
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;
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>());
......@@ -239,6 +245,17 @@ public class Map : MonoBehaviour
{
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());
objectGrid.Remove(pos);
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