Commit d37db3d0 authored by 15박보승's avatar 15박보승

Merge branch 'mirror'

# Conflicts:
#	Assets/2019-07-02-13-21-35.json.meta
parents 7c754168 ea184ec5
{"objects":[{"tag":0,"xPos":20.0,"yPos":0.0},{"tag":2,"xPos":-2.0,"yPos":-0.5},{"tag":2,"xPos":-1.0,"yPos":-0.5},{"tag":2,"xPos":0.5,"yPos":-1.0},{"tag":3,"xPos":0.0,"yPos":-0.5},{"tag":3,"xPos":1.0,"yPos":-0.5},{"tag":1,"xPos":-2.0,"yPos":1.0},{"tag":1,"xPos":-1.0,"yPos":1.0},{"tag":1,"xPos":0.0,"yPos":1.0},{"tag":1,"xPos":1.0,"yPos":1.0},{"tag":1,"xPos":1.0,"yPos":0.0},{"tag":1,"xPos":0.0,"yPos":0.0},{"tag":1,"xPos":-1.0,"yPos":0.0},{"tag":1,"xPos":-2.0,"yPos":0.0},{"tag":1,"xPos":-2.0,"yPos":-1.0},{"tag":1,"xPos":-1.0,"yPos":-1.0},{"tag":1,"xPos":0.0,"yPos":-1.0},{"tag":1,"xPos":1.0,"yPos":-1.0},{"tag":1,"xPos":1.0,"yPos":-2.0},{"tag":1,"xPos":0.0,"yPos":-2.0},{"tag":1,"xPos":-1.0,"yPos":-2.0},{"tag":1,"xPos":-2.0,"yPos":-2.0},{"tag":4,"xPos":-2.0,"yPos":-2.0},{"tag":5,"xPos":1.0,"yPos":-2.0},{"tag":6,"xPos":1.0,"yPos":-1.0}],"clears":[{"type":6,"goal":1}],"bullets":[1,1]}
\ No newline at end of file
...@@ -48,6 +48,7 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor ...@@ -48,6 +48,7 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone(1); MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone(1);
if (GameManager.nCase >= 0) if (GameManager.nCase >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.nCase].IsDone(1); MapManager.inst.currentMap.clearConditions[GameManager.nCase].IsDone(1);
floor.objOnFloor = null;
Destroy(gameObject); Destroy(gameObject);
} }
} }
......
...@@ -10,8 +10,7 @@ public class Floor : MonoBehaviour ...@@ -10,8 +10,7 @@ public class Floor : MonoBehaviour
public Vector2Int mapPos; public Vector2Int mapPos;
public bool isGoalFloor = false; public bool isGoalFloor = false;
public IObject objOnFloor = null; public IObject objOnFloor = null;
public bool isPlayerOn = false;
public int copyCounter = 0; // count for mirror copy
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
......
...@@ -66,223 +66,198 @@ public class Mirror : Wall, IBulletInteractor, IBreakable ...@@ -66,223 +66,198 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
} }
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<Vector2Int, int> floorCountGrid = new Dictionary<Vector2Int, int>();
foreach (var floor in copyFloorGrid)
{
floorCountGrid.Add(floor.Key, 0);
}
Dictionary<Vector2Int, IObject> copyObjGrid = new Dictionary<Vector2Int, IObject>(MapManager.inst.currentMap.objectGrid); Dictionary<Vector2Int, IObject> copyObjGrid = new Dictionary<Vector2Int, IObject>(MapManager.inst.currentMap.objectGrid);
Dictionary<Vector2, Wall> copyWallGrid = new Dictionary<Vector2, Wall>(MapManager.inst.currentMap.wallGrid); Dictionary<Vector2, Wall> copyWallGrid = new Dictionary<Vector2, Wall>(MapManager.inst.currentMap.wallGrid);
List<GameObject> copyPlayers = new List<GameObject>(MapManager.inst.players); List<GameObject> copyPlayers = new List<GameObject>(MapManager.inst.players);
// remove backside of mirror float minMap = -1 * MapManager.inst.currentMap.maxMapSize - 1.5f;
for (int j = iBack; Mathf.Abs(j) < MapManager.inst.currentMap.maxMapSize; j -= side) float maxMap = MapManager.inst.currentMap.maxMapSize + 1.5f;
{
//Debug.Log(j); Debug.Log("Start Reflecting.");
foreach (var obj in copyObjGrid) // check after reflect, if obj or floor, copy else if wall or mirror, Subtract
{ for (; Mathf.Abs(i) < MapManager.inst.currentMap.maxMapSize; i += side)
if ((dir ? obj.Key.y : obj.Key.x) == j)
{
if (IsInRay(parRay, PointToParRay(stPos, obj.Key, false)))
{
/*remove object*/
MapManager.inst.currentMap.RemoveObject(obj.Key);
yield return null;
}
}
}
foreach (var ply in copyPlayers)
{ {
if (ply) for (float j = minMap; j < maxMap; j++)
{ {
Floor plyFloor = ply.GetComponent<Player>().currentFloor; // copy / remove wall
if ((dir ? plyFloor.mapPos.y : plyFloor.mapPos.x) == j) Vector2 wallPos = dir ? new Vector2(j, i) : new Vector2(i, j);
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
{ {
// create wall
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, PointToParRay(stPos, plyFloor.mapPos, false))) if (IsInRay(parRay, wallPair))
{ {
/*remove player*/ MapManager.inst.currentMap.CreateWall(oppWallPos, wallAtPos.type);
PlayerController.inst.RemovePlayer(plyFloor.mapPos); SubtractRay(parRay, wallPair);
yield return null;
}
} }
} }
} else if (MapManager.inst.currentMap.GetWallAtPos(oppWallPos) != null) // no wall at wallPos but have at opposite
//Debug.Log(i + "th Object End");
foreach (var floor in copyFloorGrid)
{ {
if ((dir ? floor.Key.y : floor.Key.x) == j) // remove wall
{ MapManager.inst.currentMap.RemoveWall(oppWallPos);
if (IsInRay(parRay, PointToParRay(stPos, floor.Key, false)))
{
/*remove floor*/
MapManager.inst.currentMap.RemoveFloor(floor.Key);
yield return null;
} }
} }
} float iMid = i + 0.5f * side;
//Debug.Log(i + "th Floor End"); for (float j = minMap; j < maxMap; j++)
float rangeL = j - 0.25f * side;
float rangeR = j + 0.25f * side;
foreach (var wall in copyWallGrid)
{ {
float wallPos = (dir ? wall.Key.y : wall.Key.x); //Debug.Log("iMid:" + iMid + " j:" + j);
if (wall.Value.GetInstanceID() != GetInstanceID() && (side < 0 ? wallPos < rangeL && wallPos > rangeR : wallPos > rangeL && wallPos < rangeR)) // copy / remove wall
Vector2 wallPos = dir ? new Vector2(j - 0.5f, iMid) : new Vector2(iMid, j - 0.5f);
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 pair = new Pair (PointToParRay(stPos, wall.Value.ldPos, false), PointToParRay(stPos, wall.Value.rdPos, false)); // create wall
if (pair.l > pair.r) pair.Swap(); Pair wallPair = new Pair(PointToParRay(stPos, wallAtPos.ldPos, true), PointToParRay(stPos, wallAtPos.rdPos, true));
if (IsInRay(parRay, pair)) if (wallPair.l > wallPair.r) wallPair = wallPair.Swap();
if (IsInRay(parRay, wallPair))
{ {
/*remove wall*/ MapManager.inst.currentMap.CreateWall(oppWallPos, wallAtPos.type);
MapManager.inst.currentMap.RemoveWall(wall.Key); SubtractRay(parRay, wallPair);
yield return null;
}
} }
} }
rangeL = j - 0.25f * side + 0.5f; else if (MapManager.inst.currentMap.GetWallAtPos(oppWallPos) != null) // no wall at wallPos but have at opposite
rangeR = j + 0.25f * side + 0.5f;
foreach (var wall in copyWallGrid)
{
float wallPos = (dir ? wall.Key.y : wall.Key.x);
if (wall.Value.GetInstanceID() != GetInstanceID() && (side < 0 ? wallPos < rangeL && wallPos > rangeR : wallPos > rangeL && wallPos < rangeR))
{ {
Pair pair = new Pair (PointToParRay(stPos, wall.Value.ldPos, false), PointToParRay(stPos, wall.Value.rdPos, false)); // remove wall
if (pair.l > pair.r) pair.Swap(); MapManager.inst.currentMap.RemoveWall(oppWallPos);
if (IsInRay(parRay, pair))
{
/*remove wall*/
MapManager.inst.currentMap.RemoveWall(wall.Key);
yield return null;
}
}
}
//Debug.Log(i + "th Wall End");
} }
// copy / remove floor and object
yield return new WaitForSeconds(3f); Vector2 pointPos = dir ? new Vector2(j, iMid) : new Vector2(iMid, j);
if (IsInRay(parRay, PointToParRay(stPos, pointPos, true)))
copyFloorGrid = new Dictionary<Vector2Int, Floor>(MapManager.inst.currentMap.floorGrid);
copyObjGrid = new Dictionary<Vector2Int, IObject>(MapManager.inst.currentMap.objectGrid);
copyWallGrid = new Dictionary<Vector2, Wall>(MapManager.inst.currentMap.wallGrid);
copyPlayers = new List<GameObject>(MapManager.inst.players);
Debug.Log("Start Reflecting.");
// check after reflect, if obj or floor, copy else if wall or mirror, Subtract
for (; Mathf.Abs(i) < MapManager.inst.currentMap.maxMapSize; i += side)
{ {
float rangeL = i - 0.25f * side; //Debug.Log("inside " + pointPos);
float rangeR = i + 0.25f * side; Vector2Int floorPos = new Vector2Int(Mathf.FloorToInt(pointPos.x), Mathf.FloorToInt(pointPos.y));
foreach (var wall in copyWallGrid) int nextFloorx = dir ? floorPos.x : Mathf.RoundToInt(2 * ldPos.x - floorPos.x);
int nextFloory = dir ? Mathf.RoundToInt(2 * ldPos.y - floorPos.y) : floorPos.y;
Vector2Int oppFloorPos = new Vector2Int(nextFloorx, nextFloory);
Floor floor = MapManager.inst.currentMap.GetFloorAtPos(floorPos);
if (floor != null)
{ {
float wallPos = (dir ? wall.Key.y : wall.Key.x); //Debug.Log(oppFloorPos);
if (wall.Value.GetInstanceID() != GetInstanceID() && (side < 0 ? wallPos < rangeL && wallPos > rangeR : wallPos > rangeL && wallPos < rangeR)) if (IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true)))
{ {
Pair pair = new Pair(PointToParRay(stPos, wall.Value.ldPos, true), PointToParRay(stPos, wall.Value.rdPos, true)); floorCountGrid[floor.mapPos] = 1;
if (pair.l > pair.r) pair = pair.Swap(); }
if (IsInRay(parRay, pair)) if (floorCountGrid[floor.mapPos] == 1)
{ {
/*copy wall*/ MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor);
float nextx = dir ? wall.Key.x : 2 * mapPos.x - wall.Key.x; MapManager.inst.currentMap.RemoveObject(oppFloorPos);
float nexty = dir ? 2 * mapPos.y - wall.Key.y : wall.Key.y; if (floor.objOnFloor != null)
MapManager.inst.currentMap.CreateWall(new Vector2(nextx, nexty), wall.Value.type); MapManager.inst.currentMap.CreateObject(oppFloorPos, floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite));
if (floor.isPlayerOn)
SubtractRay(parRay, pair); PlayerController.inst.CreatePlayer(oppFloorPos);
yield return null;
} }
floorCountGrid[floor.mapPos]++;
} }
else if ((floor = MapManager.inst.currentMap.GetFloorAtPos(oppFloorPos)) != null)
{
if (floor.isPlayerOn) PlayerController.inst.RemovePlayer(floor);
if (floor.objOnFloor != null) MapManager.inst.currentMap.RemoveObject(oppFloorPos);
MapManager.inst.currentMap.RemoveFloor(oppFloorPos);
} }
rangeL = i - 0.25f * side + 0.5f; floorPos = new Vector2Int(Mathf.FloorToInt(pointPos.x), Mathf.CeilToInt(pointPos.y));
rangeR = i + 0.25f * side + 0.5f; nextFloorx = dir ? floorPos.x : Mathf.RoundToInt(2 * ldPos.x - floorPos.x);
foreach (var wall in copyWallGrid) 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)
{ {
float wallPos = (dir ? wall.Key.y : wall.Key.x); //Debug.Log(oppFloorPos);
if (wall.Value.GetInstanceID() != GetInstanceID() && (side < 0 ? wallPos < rangeL && wallPos > rangeR : wallPos > rangeL && wallPos < rangeR)) if (IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true)))
{ {
Pair pair = new Pair(PointToParRay(stPos, wall.Value.ldPos, true), PointToParRay(stPos, wall.Value.rdPos, true)); floorCountGrid[floor.mapPos] = 1;
if (pair.l > pair.r) pair = pair.Swap(); }
if (IsInRay(parRay, pair)) if (floorCountGrid[floor.mapPos] == 1)
{ {
/*copy wall*/ MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor);
float nextx = dir ? wall.Key.x : 2 * mapPos.x - wall.Key.x; MapManager.inst.currentMap.RemoveObject(oppFloorPos);
float nexty = dir ? 2 * mapPos.y - wall.Key.y : wall.Key.y; if (floor.objOnFloor != null)
MapManager.inst.currentMap.CreateWall(new Vector2(nextx, nexty), wall.Value.type); MapManager.inst.currentMap.CreateObject(oppFloorPos, floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite));
if (floor.isPlayerOn)
SubtractRay(parRay, pair); PlayerController.inst.CreatePlayer(oppFloorPos);
yield return null;
} }
floorCountGrid[floor.mapPos]++;
} }
else if ((floor = MapManager.inst.currentMap.GetFloorAtPos(oppFloorPos)) != null)
{
if (floor.isPlayerOn) PlayerController.inst.RemovePlayer(floor);
if (floor.objOnFloor != null) MapManager.inst.currentMap.RemoveObject(oppFloorPos);
MapManager.inst.currentMap.RemoveFloor(oppFloorPos);
} }
Debug.Log(i + "th Wall End"); floorPos = new Vector2Int(Mathf.CeilToInt(pointPos.x), Mathf.FloorToInt(pointPos.y));
float range = i + 0.5f * side; nextFloorx = dir ? floorPos.x : Mathf.RoundToInt(2 * ldPos.x - floorPos.x);
float minMap = -1 * MapManager.inst.currentMap.maxMapSize / 2 - 1.5f; nextFloory = dir ? Mathf.RoundToInt(2 * ldPos.y - floorPos.y) : floorPos.y;
float maxMap = MapManager.inst.currentMap.maxMapSize / 2 + 1.5f; oppFloorPos = new Vector2Int(nextFloorx, nextFloory);
//Debug.Log("value: " + minMap + ", " + maxMap); floor = MapManager.inst.currentMap.GetFloorAtPos(floorPos);
for (float j = minMap; j < maxMap; j += 1) if (floor != null)
{ {
Vector2 point = dir ? new Vector2(j, range) : new Vector2(range, j); //Debug.Log(oppFloorPos);
if (IsInRay(parRay, PointToParRay(stPos, point, true))) if (IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true)))
{ {
Debug.Log("inside " + point); floorCountGrid[floor.mapPos] = 1;
// 사방의 바닥 카피, 그 위의 오브젝트도 카피 }
Floor floor = MapManager.inst.currentMap.GetFloorAtPos(Mathf.FloorToInt(point.x), Mathf.FloorToInt(point.y)); if (floorCountGrid[floor.mapPos] == 1)
Debug.Log(floor);
if (floor != null)
{ {
int nextx = dir ? floor.mapPos.x : Mathf.RoundToInt(2 * ldPos.x - floor.mapPos.x); MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor);
int nexty = dir ? Mathf.RoundToInt(2 * ldPos.y - floor.mapPos.y) : floor.mapPos.y; MapManager.inst.currentMap.RemoveObject(oppFloorPos);
MapManager.inst.currentMap.CreateFloor(new Vector2Int(nextx, nexty), floor.isGoalFloor);
if (floor.objOnFloor != null) if (floor.objOnFloor != null)
MapManager.inst.currentMap.CreateObject(new Vector2Int(nextx, nexty), floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite)); MapManager.inst.currentMap.CreateObject(oppFloorPos, floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite));
yield return null; if (floor.isPlayerOn)
PlayerController.inst.CreatePlayer(oppFloorPos);
} }
floor = MapManager.inst.currentMap.GetFloorAtPos(Mathf.FloorToInt(point.x), Mathf.CeilToInt(point.y)); floorCountGrid[floor.mapPos]++;
Debug.Log(floor); }
if (floor != null) else if ((floor = MapManager.inst.currentMap.GetFloorAtPos(oppFloorPos)) != null)
{ {
int nextx = dir ? floor.mapPos.x : Mathf.RoundToInt(2 * ldPos.x - floor.mapPos.x); if (floor.isPlayerOn) PlayerController.inst.RemovePlayer(floor);
int nexty = dir ? Mathf.RoundToInt(2 * ldPos.y - floor.mapPos.y) : floor.mapPos.y; if (floor.objOnFloor != null) MapManager.inst.currentMap.RemoveObject(oppFloorPos);
MapManager.inst.currentMap.CreateFloor(new Vector2Int(nextx, nexty), floor.isGoalFloor); MapManager.inst.currentMap.RemoveFloor(oppFloorPos);
if (floor.objOnFloor != null)
MapManager.inst.currentMap.CreateObject(new Vector2Int(nextx, nexty), floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite));
yield return null;
} }
floor = MapManager.inst.currentMap.GetFloorAtPos(Mathf.CeilToInt(point.x), Mathf.FloorToInt(point.y)); floorPos = new Vector2Int(Mathf.CeilToInt(pointPos.x), Mathf.CeilToInt(pointPos.y));
Debug.Log(floor); 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) if (floor != null)
{ {
int nextx = dir ? floor.mapPos.x : Mathf.RoundToInt(2 * ldPos.x - floor.mapPos.x); //Debug.Log(oppFloorPos);
int nexty = dir ? Mathf.RoundToInt(2 * ldPos.y - floor.mapPos.y) : floor.mapPos.y; if (IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true)))
MapManager.inst.currentMap.CreateFloor(new Vector2Int(nextx, nexty), floor.isGoalFloor); {
if (floor.objOnFloor != null) floorCountGrid[floor.mapPos] = 1;
MapManager.inst.currentMap.CreateObject(new Vector2Int(nextx, nexty), floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite));
yield return null;
} }
floor = MapManager.inst.currentMap.GetFloorAtPos(Mathf.CeilToInt(point.x), Mathf.CeilToInt(point.y)); if (floorCountGrid[floor.mapPos] == 1)
Debug.Log(floor);
if (floor != null)
{ {
int nextx = dir ? floor.mapPos.x : Mathf.RoundToInt(2 * ldPos.x - floor.mapPos.x); MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor);
int nexty = dir ? Mathf.RoundToInt(2 * ldPos.y - floor.mapPos.y) : floor.mapPos.y; MapManager.inst.currentMap.RemoveObject(oppFloorPos);
MapManager.inst.currentMap.CreateFloor(new Vector2Int(nextx, nexty), floor.isGoalFloor);
if (floor.objOnFloor != null) if (floor.objOnFloor != null)
MapManager.inst.currentMap.CreateObject(new Vector2Int(nextx, nexty), floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite)); MapManager.inst.currentMap.CreateObject(oppFloorPos, floor.objOnFloor.GetType(), (floor.objOnFloor.GetType() != ObjType.Mannequin ? true : ((Mannequin)floor.objOnFloor).isWhite));
yield return null; if (floor.isPlayerOn)
} PlayerController.inst.CreatePlayer(oppFloorPos);
} }
floorCountGrid[floor.mapPos]++;
} }
Debug.Log(i + "th Floor End"); else if ((floor = MapManager.inst.currentMap.GetFloorAtPos(oppFloorPos)) != null)
foreach (var ply in copyPlayers)
{ {
Floor plyFloor = ply.GetComponent<Player>().currentFloor; if (floor.isPlayerOn) PlayerController.inst.RemovePlayer(floor);
if ((dir ? plyFloor.mapPos.y : plyFloor.mapPos.x) == i) if (floor.objOnFloor != null) MapManager.inst.currentMap.RemoveObject(oppFloorPos);
{ MapManager.inst.currentMap.RemoveFloor(oppFloorPos);
if (IsInRay(parRay, PointToParRay(stPos, plyFloor.mapPos, true)))
{
/*copy player*/
int nextx = dir ? plyFloor.mapPos.x : Mathf.RoundToInt(2 * ldPos.x - plyFloor.mapPos.x);
int nexty = dir ? Mathf.RoundToInt(2 * ldPos.y - plyFloor.mapPos.y) : plyFloor.mapPos.y;
PlayerController.inst.CreatePlayer(new Vector2Int(nextx, nexty));
yield return null;
} }
} }
} }
//Debug.Log(i + "th Player End");
} }
MapManager.inst.currentMap.RemoveWall(mapPos); MapManager.inst.currentMap.RemoveWall(mapPos);
} }
...@@ -354,7 +329,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable ...@@ -354,7 +329,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
bool output = false; bool output = false;
foreach (Pair pair in _parRay) foreach (Pair pair in _parRay)
{ {
Debug.Log("IsinRay (" + pair.l + ", " + pair.r + ") " + _range.l + ", " + _range.r); //Debug.Log("IsinRay (" + pair.l + ", " + pair.r + ") " + _range.l + ", " + _range.r);
if (pair.r <= _range.l || pair.l >= _range.r) continue; if (pair.r <= _range.l || pair.l >= _range.r) continue;
else else
{ {
...@@ -369,7 +344,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable ...@@ -369,7 +344,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
{ {
foreach (Pair pair in _parRay) foreach (Pair pair in _parRay)
{ {
Debug.Log("IsinRay (" + pair.l + ", " + pair.r + ") " + _obj); //Debug.Log("IsinRay (" + pair.l + ", " + pair.r + ") " + _obj);
if (pair.l <= _obj && pair.r >= _obj) return true; if (pair.l <= _obj && pair.r >= _obj) return true;
} }
return false; return false;
......
...@@ -72,7 +72,9 @@ public class Player : MonoBehaviour ...@@ -72,7 +72,9 @@ public class Player : MonoBehaviour
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);
currentFloor.isPlayerOn = false;
currentFloor = MapManager.inst.currentMap.GetFloorAtPos(new Vector2Int((int)destination.x, (int)destination.z)); currentFloor = MapManager.inst.currentMap.GetFloorAtPos(new Vector2Int((int)destination.x, (int)destination.z));
currentFloor.isPlayerOn = true;
PlayerController.inst.CheckCurrentFloors(); PlayerController.inst.CheckCurrentFloors();
anim.SetBool("isWalking", false); anim.SetBool("isWalking", false);
PlayerController.inst.isPlayerMoving = false; PlayerController.inst.isPlayerMoving = false;
......
...@@ -38,6 +38,7 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -38,6 +38,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
} }
GameObject player = Instantiate(MapManager.inst.player, floor.transform.position + new Vector3(0, 0.1f, 0), Quaternion.identity); GameObject player = Instantiate(MapManager.inst.player, floor.transform.position + new Vector3(0, 0.1f, 0), Quaternion.identity);
player.GetComponent<Player>().currentFloor = floor; player.GetComponent<Player>().currentFloor = floor;
floor.isPlayerOn = true;
MapManager.inst.players.Add(player); MapManager.inst.players.Add(player);
if (GameManager.nPlayer >= 0) if (GameManager.nPlayer >= 0)
{ {
...@@ -67,6 +68,7 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -67,6 +68,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
{ {
if (obj.GetComponent<Player>().currentFloor == floor) if (obj.GetComponent<Player>().currentFloor == floor)
{ {
floor.isPlayerOn = false;
MapManager.inst.players.Remove(obj); MapManager.inst.players.Remove(obj);
if (GameManager.nPlayer >= 0) if (GameManager.nPlayer >= 0)
{ {
......
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