Commit a60d01e7 authored by 18신대성's avatar 18신대성

거울 로직 변경 및 거울로 사라지면 파괴로 카운트 안하게 만듬

parent aed576ba
...@@ -11,11 +11,14 @@ public class Pair ...@@ -11,11 +11,14 @@ public class Pair
{ {
this.l = _l; this.l = _l;
this.r = _r; this.r = _r;
if (_l > _r) Swap();
} }
public Pair Swap() public void Swap()
{ {
return new Pair(r, l); float temp = l;
l = r;
r = temp;
} }
public Pair ApplyMargin(float margin) public Pair ApplyMargin(float margin)
......
...@@ -126,7 +126,7 @@ public class Map : MonoBehaviour ...@@ -126,7 +126,7 @@ public class Map : MonoBehaviour
/// </summary> /// </summary>
/// <param name="pos">Position of wall.</param> /// <param name="pos">Position of wall.</param>
/// <param name="wallType">Type of wall.</param> /// <param name="wallType">Type of wall.</param>
public void CreateWall(Vector2 pos, WallType wallType) public void CreateWall(Vector2 pos, WallType wallType, bool isBreak = true)
{ {
if (((int)pos.x >= 0 ? ((int)pos.x > maxMapSize / 2) : ((int)pos.x < -maxMapSize / 2)) || ((int)pos.y >= 0 ? ((int)pos.y > maxMapSize / 2) : ((int)pos.y < -maxMapSize / 2))) if (((int)pos.x >= 0 ? ((int)pos.x > maxMapSize / 2) : ((int)pos.x < -maxMapSize / 2)) || ((int)pos.y >= 0 ? ((int)pos.y > maxMapSize / 2) : ((int)pos.y < -maxMapSize / 2)))
{ {
...@@ -157,7 +157,12 @@ public class Map : MonoBehaviour ...@@ -157,7 +157,12 @@ public class Map : MonoBehaviour
Debug.Log("Wall already exists at : " + pos); Debug.Log("Wall already exists at : " + pos);
if (wallGrid[pos].type == WallType.Normal && wallType == WallType.Mirror) // change to Mirror if (wallGrid[pos].type == WallType.Normal && wallType == WallType.Mirror) // change to Mirror
{ {
MapManager.inst.currentMap.ChangeToMirror(pos); MapManager.inst.currentMap.ChangeToMirror(pos, isBreak);
}
else if (wallGrid[pos].type == WallType.Mirror && wallType == WallType.Normal)
{
RemoveWall(pos);
CreateWall(pos, WallType.Normal);
} }
} }
} }
...@@ -181,7 +186,7 @@ public class Map : MonoBehaviour ...@@ -181,7 +186,7 @@ public class Map : MonoBehaviour
/// Change normal wall at position to mirror. /// Change normal wall at position to mirror.
/// </summary> /// </summary>
/// <param name="pos">Position of wall.</param> /// <param name="pos">Position of wall.</param>
public void ChangeToMirror(Vector2 pos) public void ChangeToMirror(Vector2 pos, bool isBreak = true)
{ {
if (((int)pos.x >= 0 ? ((int)pos.x > maxMapSize / 2) : ((int)pos.x < -maxMapSize / 2)) || ((int)pos.y >= 0 ? ((int)pos.y > maxMapSize / 2) : ((int)pos.y < -maxMapSize / 2))) if (((int)pos.x >= 0 ? ((int)pos.x > maxMapSize / 2) : ((int)pos.x < -maxMapSize / 2)) || ((int)pos.y >= 0 ? ((int)pos.y > maxMapSize / 2) : ((int)pos.y < -maxMapSize / 2)))
{ {
...@@ -195,7 +200,7 @@ public class Map : MonoBehaviour ...@@ -195,7 +200,7 @@ public class Map : MonoBehaviour
} }
if (wallGrid.ContainsKey(pos)) if (wallGrid.ContainsKey(pos))
{ {
(wallGrid[pos] as NormalWall).Break(); if (isBreak) (wallGrid[pos] as NormalWall).Break();
RemoveWall(pos); RemoveWall(pos);
wallGrid.Add(pos, Instantiate(MapManager.inst.mirror, new Vector3(pos.x, 0, pos.y), Quaternion.identity, walls.transform).GetComponent<Wall>()); wallGrid.Add(pos, Instantiate(MapManager.inst.mirror, new Vector3(pos.x, 0, pos.y), Quaternion.identity, walls.transform).GetComponent<Wall>());
wallGrid[pos].mapPos = pos; wallGrid[pos].mapPos = pos;
...@@ -278,8 +283,6 @@ public class Map : MonoBehaviour ...@@ -278,8 +283,6 @@ public class Map : MonoBehaviour
case ObjType.Camera: case ObjType.Camera:
if (GameManager.aTurret >= 0) if (GameManager.aTurret >= 0)
clearConditions[GameManager.aTurret].IsDone(0, -1); clearConditions[GameManager.aTurret].IsDone(0, -1);
if (GameManager.nTurret >= 0)
clearConditions[GameManager.nTurret].IsDone(1);
PlayerController.inst.OnPlayerMove -= objectGrid[pos].GetObject().GetComponent<IPlayerInteractor>().Interact; PlayerController.inst.OnPlayerMove -= objectGrid[pos].GetObject().GetComponent<IPlayerInteractor>().Interact;
break; break;
case ObjType.Mannequin: case ObjType.Mannequin:
......
...@@ -60,241 +60,164 @@ public class Mirror : Wall, IBulletInteractor, IBreakable ...@@ -60,241 +60,164 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
foreach (var wall in MapManager.inst.currentMap.wallGrid) foreach (var wall in MapManager.inst.currentMap.wallGrid)
{ {
float wallPos = (dir ? wall.Key.y : wall.Key.x); float wallPos = (dir ? wall.Key.y : wall.Key.x);
if (wall.Value.GetInstanceID() != GetInstanceID() && (side < 0 ? wallPos < mirrorPos && wallPos > stPosFix : wallPos > mirrorPos && wallPos < stPosFix)) if (wall.Value.mapPos != mapPos && (side < 0 ? wallPos < mirrorPos && wallPos > stPosFix : wallPos > mirrorPos && wallPos < stPosFix))
{ {
Pair pair = new Pair(PointToParRay(stPos, wall.Value.ldPos, false), PointToParRay(stPos, wall.Value.rdPos, false)); Pair pair = new Pair(PointToParRay(stPos, wall.Value.ldPos, false), PointToParRay(stPos, wall.Value.rdPos, false));
if (pair.l > pair.r) pair = pair.Swap();
if (IsInRay(parRay, pair)) SubtractRay(parRay, pair); if (IsInRay(parRay, pair)) SubtractRay(parRay, pair);
yield return null; yield return null;
} }
} }
Dictionary<Vector2Int, Floor> copyFloorGrid = new Dictionary<Vector2Int, Floor>(MapManager.inst.currentMap.floorGrid); Dictionary<Vector2Int, Floor> copyFloorGrid = new Dictionary<Vector2Int, Floor>(MapManager.inst.currentMap.floorGrid);
Dictionary<Vector2, Wall> copyWallGrid = new Dictionary<Vector2, Wall>(MapManager.inst.currentMap.wallGrid);
Dictionary<Vector2Int, int> floorCountGrid = new Dictionary<Vector2Int, int>(); Dictionary<Vector2Int, int> floorCountGrid = new Dictionary<Vector2Int, int>();
foreach (var floor in copyFloorGrid) foreach (var floor in copyFloorGrid)
{ {
floorCountGrid.Add(floor.Key, 0); floorCountGrid.Add(floor.Key, 0);
} }
Dictionary<Vector2Int, IObject> copyObjGrid = new Dictionary<Vector2Int, IObject>(MapManager.inst.currentMap.objectGrid);
Dictionary<Vector2, Wall> copyWallGrid = new Dictionary<Vector2, Wall>(MapManager.inst.currentMap.wallGrid);
List<GameObject> copyPlayers = new List<GameObject>(MapManager.inst.players);
float minMap = -1 * MapManager.inst.currentMap.maxMapSize - 1.5f; int minMapRange = -1 * MapManager.inst.currentMap.maxMapSize - 1;
float maxMap = MapManager.inst.currentMap.maxMapSize + 1.5f; int maxMapRange = MapManager.inst.currentMap.maxMapSize + 1;
Debug.Log("Start Reflecting."); for (; Mathf.Abs(i) < maxMapRange; i += side)
// check after reflect, if obj or floor, copy else if wall or mirror, Subtract
for (; Mathf.Abs(i) < MapManager.inst.currentMap.maxMapSize; i += side)
{ {
while (true) // check walls and copy
{ for (float j = minMapRange + 0.5f; j < maxMapRange + 0.5f; j++)
yield return null;
if (Input.GetKeyUp(KeyCode.A)) break;
}
for (float j = minMap; j < maxMap; j++)
{ {
// copy / remove wall
Vector2 wallPos = dir ? new Vector2(j, i) : new Vector2(i, j); Vector2 wallPos = dir ? new Vector2(j, i) : new Vector2(i, j);
float nextx = dir ? wallPos.x : 2 * mapPos.x - wallPos.x; Vector2 oppoPos = GetOpposite(wallPos);
float nexty = dir ? 2 * mapPos.y - wallPos.y : wallPos.y; Pair wallPair = dir ?
Vector2 oppWallPos = new Vector2(nextx, nexty); (new Pair(PointToParRay(stPos, wallPos + new Vector2(0, -0.5f), true), PointToParRay(stPos, wallPos + new Vector2(0, 0.5f), true))) :
Wall wallAtPos = MapManager.inst.currentMap.GetWallAtPos(wallPos); (new Pair(PointToParRay(stPos, wallPos + new Vector2(-0.5f, 0), true), PointToParRay(stPos, wallPos + new Vector2(0.5f, 0), true)));
if (wallAtPos != null) // have wall at wallpos
{
Pair wallPair = new Pair(PointToParRay(stPos, wallAtPos.ldPos, true), PointToParRay(stPos, wallAtPos.rdPos, true));
if (wallPair.l > wallPair.r) wallPair = wallPair.Swap();
if (IsInRay(parRay, wallPair)) if (IsInRay(parRay, wallPair))
{ {
MapManager.inst.currentMap.CreateWall(oppWallPos, wallAtPos.type); if (copyWallGrid.ContainsKey(wallPos))
{
Wall originWall = copyWallGrid[wallPos];
MapManager.inst.currentMap.CreateWall(oppoPos, originWall.type, false);
SubtractRay(parRay, wallPair); SubtractRay(parRay, wallPair);
} }
} else
else if (MapManager.inst.currentMap.GetWallAtPos(oppWallPos) != null) // no wall at wallPos but have at opposite
{ {
Pair tempPair = new Pair(PointToParRay(stPos, wallPos + (dir ? new Vector2(-0.5f, 0) : new Vector2(0, -0.5f)), true), PointToParRay(stPos, wallPos + (dir ? new Vector2(0.5f, 0) : new Vector2(0, 0.5f)), true)); if (copyWallGrid.ContainsKey(oppoPos)) MapManager.inst.currentMap.RemoveWall(oppoPos);
if (IsInRay(parRay, tempPair)) MapManager.inst.currentMap.RemoveWall(oppWallPos); }
} }
} }
while (true) for (int j = minMapRange + 1; j < maxMapRange; j++)
{ {
yield return null; // check floors
if (Input.GetKeyUp(KeyCode.A)) break; Vector2Int floorPos = dir ? new Vector2Int(j, i) : new Vector2Int(i, j);
if (IsInRay(parRay, PointToParRay(stPos, floorPos, true)))
{
int floorCount;
if (floorCountGrid.TryGetValue(floorPos, out floorCount))
{
if (floorCount == 0) floorCountGrid[floorPos]++; // have floor
} }
float iMid = i + 0.5f * side; else // no floor on there
for (float j = minMap; j < maxMap; j++)
{
//Debug.Log("iMid:" + iMid + " j:" + j);
// copy / remove wall
Vector2 wallPos = dir ? new Vector2(j - 0.5f, iMid) : new Vector2(iMid, j - 0.5f);
//Debug.Log(wallPos);
float nextx = dir ? wallPos.x : 2 * mapPos.x - wallPos.x;
float nexty = dir ? 2 * mapPos.y - wallPos.y : wallPos.y;
Vector2 oppWallPos = new Vector2(nextx, nexty);
Wall wallAtPos = MapManager.inst.currentMap.GetWallAtPos(wallPos);
if (wallAtPos != null) // have wall at wallpos
{
Pair wallPair = new Pair(PointToParRay(stPos, wallAtPos.ldPos, true), PointToParRay(stPos, wallAtPos.rdPos, true));
if (wallPair.l > wallPair.r) wallPair = wallPair.Swap();
if (IsInRay(parRay, wallPair))
{ {
MapManager.inst.currentMap.CreateWall(oppWallPos, wallAtPos.type); floorCountGrid.Add(floorPos, -1);
SubtractRay(parRay, wallPair);
} }
} }
else if (MapManager.inst.currentMap.GetWallAtPos(oppWallPos) != null) // no wall at wallPos but have at opposite
{
Pair tempPair = new Pair(PointToParRay(stPos, wallPos + (dir ? new Vector2(-0.5f, 0) : new Vector2(0, -0.5f)), true), PointToParRay(stPos, wallPos + (dir ? new Vector2(0.5f, 0) : new Vector2(0, 0.5f)), true));
if (IsInRay(parRay, tempPair)) MapManager.inst.currentMap.RemoveWall(oppWallPos);
} }
// copy / remove floor and object yield return null;
Vector2 pointPos = dir ? new Vector2(j, iMid) : new Vector2(iMid, j); float iMid = i + 0.5f * side;
if (IsInRayWeak(parRay, PointToParRay(stPos, pointPos, true))) // check walls and copy
{ for (int j = minMapRange; j < maxMapRange; j++)
//Debug.Log("inside " + pointPos); {
Vector2Int floorPos = new Vector2Int(Mathf.FloorToInt(pointPos.x), Mathf.FloorToInt(pointPos.y)); Vector2 wallPos = dir ? new Vector2(j, iMid) : new Vector2(iMid, j);
int nextFloorx = dir ? floorPos.x : Mathf.RoundToInt(2 * ldPos.x - floorPos.x); Vector2 oppoPos = GetOpposite(wallPos);
int nextFloory = dir ? Mathf.RoundToInt(2 * ldPos.y - floorPos.y) : floorPos.y; Pair wallPair = !dir ?
Vector2Int oppFloorPos = new Vector2Int(nextFloorx, nextFloory); (new Pair(PointToParRay(stPos, wallPos + new Vector2(0, -0.5f), true), PointToParRay(stPos, wallPos + new Vector2(0, 0.5f), true))) :
Floor floor = MapManager.inst.currentMap.GetFloorAtPos(floorPos); (new Pair(PointToParRay(stPos, wallPos + new Vector2(-0.5f, 0), true), PointToParRay(stPos, wallPos + new Vector2(0.5f, 0), true)));
if (floor != null) if (IsInRay(parRay, wallPair))
{ {
//Debug.Log(oppFloorPos); if (copyWallGrid.ContainsKey(wallPos))
if (floorCountGrid[floor.mapPos] == 0 && IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true)))
{ {
floorCountGrid[floor.mapPos] = 1; Wall originWall = copyWallGrid[wallPos];
MapManager.inst.currentMap.CreateWall(oppoPos, originWall.type, false);
SubtractRay(parRay, wallPair);
} }
if (floorCountGrid[floor.mapPos] == 1)
{
MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor);
MapManager.inst.currentMap.RemoveObject(oppFloorPos);
if (floor.objOnFloor != null)
{
if (floor.objOnFloor.GetType() == ObjType.Briefcase)
MapManager.inst.currentMap.CreateObject(oppFloorPos, ObjType.Briefcase, ((Briefcase)floor.objOnFloor).dropBullet);
else else
MapManager.inst.currentMap.CreateObject(oppFloorPos, floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite)); {
if (copyWallGrid.ContainsKey(oppoPos)) MapManager.inst.currentMap.RemoveWall(oppoPos);
} }
if (floor.isPlayerOn)
PlayerController.inst.CreatePlayer(oppFloorPos);
} }
floorCountGrid[floor.mapPos]++;
} }
else if ((floor = MapManager.inst.currentMap.GetFloorAtPos(oppFloorPos)) != null) // check floors
for (int j = minMapRange; j < maxMapRange; j++)
{ {
if (floor.isPlayerOn) PlayerController.inst.RemovePlayer(floor); Vector2 crossPoint = dir ? new Vector2(j + 0.5f, iMid) : new Vector2(iMid, j + 0.5f);
if (floor.objOnFloor != null) MapManager.inst.currentMap.RemoveObject(oppFloorPos); if (IsInRayWeak(parRay, PointToParRay(stPos, crossPoint, true)))
MapManager.inst.currentMap.RemoveFloor(oppFloorPos);
}
floorPos = new Vector2Int(Mathf.FloorToInt(pointPos.x), Mathf.CeilToInt(pointPos.y));
nextFloorx = dir ? floorPos.x : Mathf.RoundToInt(2 * ldPos.x - floorPos.x);
nextFloory = dir ? Mathf.RoundToInt(2 * ldPos.y - floorPos.y) : floorPos.y;
oppFloorPos = new Vector2Int(nextFloorx, nextFloory);
floor = MapManager.inst.currentMap.GetFloorAtPos(floorPos);
if (floor != null)
{ {
//Debug.Log(oppFloorPos); Vector2Int[] floorPoses =
if (floorCountGrid[floor.mapPos] == 0 && IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true)))
{ {
floorCountGrid[floor.mapPos] = 1; new Vector2Int(Mathf.FloorToInt(crossPoint.x), Mathf.FloorToInt(crossPoint.y)),
} new Vector2Int(Mathf.FloorToInt(crossPoint.x), Mathf.CeilToInt(crossPoint.y)),
if (floorCountGrid[floor.mapPos] == 1) new Vector2Int(Mathf.CeilToInt(crossPoint.x), Mathf.FloorToInt(crossPoint.y)),
new Vector2Int(Mathf.CeilToInt(crossPoint.x), Mathf.CeilToInt(crossPoint.y))
};
foreach (var floorPos in floorPoses)
{ {
MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor); int floorCount;
MapManager.inst.currentMap.RemoveObject(oppFloorPos); if (floorCountGrid.TryGetValue(floorPos, out floorCount))
if (floor.objOnFloor != null)
{ {
if (floor.objOnFloor.GetType() == ObjType.Briefcase) if (floorCount == 0) floorCountGrid[floorPos]++; // have floor
MapManager.inst.currentMap.CreateObject(oppFloorPos, ObjType.Briefcase, ((Briefcase)floor.objOnFloor).dropBullet);
else
MapManager.inst.currentMap.CreateObject(oppFloorPos, floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite));
}
if (floor.isPlayerOn)
PlayerController.inst.CreatePlayer(oppFloorPos);
} }
floorCountGrid[floor.mapPos]++; else // no floor on there
}
else if ((floor = MapManager.inst.currentMap.GetFloorAtPos(oppFloorPos)) != null)
{ {
if (floor.isPlayerOn) PlayerController.inst.RemovePlayer(floor); floorCountGrid.Add(floorPos, -1);
if (floor.objOnFloor != null) MapManager.inst.currentMap.RemoveObject(oppFloorPos);
MapManager.inst.currentMap.RemoveFloor(oppFloorPos);
} }
floorPos = new Vector2Int(Mathf.CeilToInt(pointPos.x), Mathf.FloorToInt(pointPos.y));
nextFloorx = dir ? floorPos.x : Mathf.RoundToInt(2 * ldPos.x - floorPos.x);
nextFloory = dir ? Mathf.RoundToInt(2 * ldPos.y - floorPos.y) : floorPos.y;
oppFloorPos = new Vector2Int(nextFloorx, nextFloory);
floor = MapManager.inst.currentMap.GetFloorAtPos(floorPos);
if (floor != null)
{
//Debug.Log(oppFloorPos);
if (floorCountGrid[floor.mapPos] == 0 && IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true)))
{
floorCountGrid[floor.mapPos] = 1;
} }
if (floorCountGrid[floor.mapPos] == 1)
{
MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor);
MapManager.inst.currentMap.RemoveObject(oppFloorPos);
if (floor.objOnFloor != null)
{
if (floor.objOnFloor.GetType() == ObjType.Briefcase)
MapManager.inst.currentMap.CreateObject(oppFloorPos, ObjType.Briefcase, ((Briefcase)floor.objOnFloor).dropBullet);
else
MapManager.inst.currentMap.CreateObject(oppFloorPos, floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite));
} }
if (floor.isPlayerOn)
PlayerController.inst.CreatePlayer(oppFloorPos);
} }
floorCountGrid[floor.mapPos]++; yield return null;
} }
else if ((floor = MapManager.inst.currentMap.GetFloorAtPos(oppFloorPos)) != null) // copy floors
foreach (var floorCount in floorCountGrid)
{ {
if (floor.isPlayerOn) PlayerController.inst.RemovePlayer(floor); Vector2Int oppoPos = GetOpposite(floorCount.Key);
if (floor.objOnFloor != null) MapManager.inst.currentMap.RemoveObject(oppFloorPos); if (floorCount.Value > 0) // copy origin floor to opposite
MapManager.inst.currentMap.RemoveFloor(oppFloorPos);
}
floorPos = new Vector2Int(Mathf.CeilToInt(pointPos.x), Mathf.CeilToInt(pointPos.y));
nextFloorx = dir ? floorPos.x : Mathf.RoundToInt(2 * ldPos.x - floorPos.x);
nextFloory = dir ? Mathf.RoundToInt(2 * ldPos.y - floorPos.y) : floorPos.y;
oppFloorPos = new Vector2Int(nextFloorx, nextFloory);
floor = MapManager.inst.currentMap.GetFloorAtPos(floorPos);
if (floor != null)
{ {
//Debug.Log(oppFloorPos); Floor originFloor = MapManager.inst.currentMap.GetFloorAtPos(floorCount.Key);
if (floorCountGrid[floor.mapPos] == 0 && IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true))) Floor oppoFloor = MapManager.inst.currentMap.GetFloorAtPos(oppoPos);
MapManager.inst.currentMap.CreateFloor(oppoPos, originFloor.isGoalFloor);
if (oppoFloor != null)
{ {
floorCountGrid[floor.mapPos] = 1; if (oppoFloor.isPlayerOn) PlayerController.inst.RemovePlayer(oppoFloor);
if (oppoFloor.objOnFloor != null) MapManager.inst.currentMap.RemoveObject(oppoPos);
} }
if (floorCountGrid[floor.mapPos] == 1)
{
MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor);
MapManager.inst.currentMap.RemoveObject(oppFloorPos);
if (floor.objOnFloor != null)
{
if (floor.objOnFloor.GetType() == ObjType.Briefcase)
MapManager.inst.currentMap.CreateObject(oppFloorPos, ObjType.Briefcase, ((Briefcase)floor.objOnFloor).dropBullet);
else else
MapManager.inst.currentMap.CreateObject(oppFloorPos, floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite)); {
} oppoFloor = MapManager.inst.currentMap.GetFloorAtPos(oppoPos);
if (floor.isPlayerOn)
PlayerController.inst.CreatePlayer(oppFloorPos);
}
floorCountGrid[floor.mapPos]++;
} }
else if ((floor = MapManager.inst.currentMap.GetFloorAtPos(oppFloorPos)) != null) if (originFloor.isPlayerOn && oppoFloor != null) PlayerController.inst.CreatePlayer(oppoFloor);
else if (originFloor.objOnFloor != null)
{ {
if (floor.isPlayerOn) PlayerController.inst.RemovePlayer(floor); IObject obj = originFloor.objOnFloor;
if (floor.objOnFloor != null) MapManager.inst.currentMap.RemoveObject(oppFloorPos); switch (obj.GetType())
MapManager.inst.currentMap.RemoveFloor(oppFloorPos); {
case ObjType.Mannequin:
MapManager.inst.currentMap.CreateObject(oppoPos, ObjType.Mannequin, (obj as Mannequin).isWhite);
break;
case ObjType.Briefcase:
MapManager.inst.currentMap.CreateObject(oppoPos, ObjType.Briefcase, (obj as Briefcase).dropBullet);
break;
default:
MapManager.inst.currentMap.CreateObject(oppoPos, obj.GetType());
break;
} }
} }
} }
while (true) else if (floorCount.Value < 0) // remove opposite floor
{ {
yield return null; Floor oppoFloor = MapManager.inst.currentMap.GetFloorAtPos(oppoPos);
if (Input.GetKeyUp(KeyCode.A)) break; if (oppoFloor != null)
{
PlayerController.inst.RemovePlayer(oppoFloor);
MapManager.inst.currentMap.RemoveObject(oppoPos);
MapManager.inst.currentMap.RemoveFloor(oppoPos);
}
} }
} }
Break(); Break();
...@@ -414,6 +337,20 @@ public class Mirror : Wall, IBulletInteractor, IBreakable ...@@ -414,6 +337,20 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
return false; return false;
} }
Vector2 GetOpposite(Vector2 objPos)
{
Vector2 output = new Vector2(objPos.x, objPos.y);
if (dir) output.y = mapPos.y * 2 - objPos.y;
else output.x = mapPos.x * 2 - objPos.x;
return output;
}
Vector2Int GetOpposite(Vector2Int objPos)
{
Vector2 output = GetOpposite(new Vector2(objPos.x, objPos.y));
return new Vector2Int(Mathf.RoundToInt(output.x), Mathf.RoundToInt(output.y));
}
/// <summary> /// <summary>
/// calculate where _chPos is from _stPos /// calculate where _chPos is from _stPos
/// </summary> /// </summary>
......
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