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
MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone(1);
if (GameManager.nCase >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.nCase].IsDone(1);
floor.objOnFloor = null;
Destroy(gameObject);
}
}
......
......@@ -10,8 +10,7 @@ public class Floor : MonoBehaviour
public Vector2Int mapPos;
public bool isGoalFloor = false;
public IObject objOnFloor = null;
public int copyCounter = 0; // count for mirror copy
public bool isPlayerOn = false;
// Start is called before the first frame update
void Start()
......
......@@ -66,223 +66,198 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
}
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<Vector2, Wall> copyWallGrid = new Dictionary<Vector2, Wall>(MapManager.inst.currentMap.wallGrid);
List<GameObject> copyPlayers = new List<GameObject>(MapManager.inst.players);
// remove backside of mirror
for (int j = iBack; Mathf.Abs(j) < MapManager.inst.currentMap.maxMapSize; j -= side)
{
//Debug.Log(j);
foreach (var obj in copyObjGrid)
{
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)
float minMap = -1 * MapManager.inst.currentMap.maxMapSize - 1.5f;
float maxMap = MapManager.inst.currentMap.maxMapSize + 1.5f;
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)
{
if (ply)
for (float j = minMap; j < maxMap; j++)
{
Floor plyFloor = ply.GetComponent<Player>().currentFloor;
if ((dir ? plyFloor.mapPos.y : plyFloor.mapPos.x) == j)
// copy / remove wall
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*/
PlayerController.inst.RemovePlayer(plyFloor.mapPos);
yield return null;
}
MapManager.inst.currentMap.CreateWall(oppWallPos, wallAtPos.type);
SubtractRay(parRay, wallPair);
}
}
}
//Debug.Log(i + "th Object End");
foreach (var floor in copyFloorGrid)
else if (MapManager.inst.currentMap.GetWallAtPos(oppWallPos) != null) // no wall at wallPos but have at opposite
{
if ((dir ? floor.Key.y : floor.Key.x) == j)
{
if (IsInRay(parRay, PointToParRay(stPos, floor.Key, false)))
{
/*remove floor*/
MapManager.inst.currentMap.RemoveFloor(floor.Key);
yield return null;
// remove wall
MapManager.inst.currentMap.RemoveWall(oppWallPos);
}
}
}
//Debug.Log(i + "th Floor End");
float rangeL = j - 0.25f * side;
float rangeR = j + 0.25f * side;
foreach (var wall in copyWallGrid)
float iMid = i + 0.5f * side;
for (float j = minMap; j < maxMap; j++)
{
float wallPos = (dir ? wall.Key.y : wall.Key.x);
if (wall.Value.GetInstanceID() != GetInstanceID() && (side < 0 ? wallPos < rangeL && wallPos > rangeR : wallPos > rangeL && wallPos < rangeR))
//Debug.Log("iMid:" + iMid + " j:" + j);
// 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));
if (pair.l > pair.r) pair.Swap();
if (IsInRay(parRay, pair))
// 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, wallPair))
{
/*remove wall*/
MapManager.inst.currentMap.RemoveWall(wall.Key);
yield return null;
}
MapManager.inst.currentMap.CreateWall(oppWallPos, wallAtPos.type);
SubtractRay(parRay, wallPair);
}
}
rangeL = j - 0.25f * side + 0.5f;
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))
else if (MapManager.inst.currentMap.GetWallAtPos(oppWallPos) != null) // no wall at wallPos but have at opposite
{
Pair pair = new Pair (PointToParRay(stPos, wall.Value.ldPos, false), PointToParRay(stPos, wall.Value.rdPos, false));
if (pair.l > pair.r) pair.Swap();
if (IsInRay(parRay, pair))
{
/*remove wall*/
MapManager.inst.currentMap.RemoveWall(wall.Key);
yield return null;
}
}
}
//Debug.Log(i + "th Wall End");
// remove wall
MapManager.inst.currentMap.RemoveWall(oppWallPos);
}
yield return new WaitForSeconds(3f);
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)
// copy / remove floor and object
Vector2 pointPos = dir ? new Vector2(j, iMid) : new Vector2(iMid, j);
if (IsInRay(parRay, PointToParRay(stPos, pointPos, true)))
{
float rangeL = i - 0.25f * side;
float rangeR = i + 0.25f * side;
foreach (var wall in copyWallGrid)
//Debug.Log("inside " + pointPos);
Vector2Int floorPos = new Vector2Int(Mathf.FloorToInt(pointPos.x), Mathf.FloorToInt(pointPos.y));
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);
if (wall.Value.GetInstanceID() != GetInstanceID() && (side < 0 ? wallPos < rangeL && wallPos > rangeR : wallPos > rangeL && wallPos < rangeR))
//Debug.Log(oppFloorPos);
if (IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true)))
{
Pair pair = new Pair(PointToParRay(stPos, wall.Value.ldPos, true), PointToParRay(stPos, wall.Value.rdPos, true));
if (pair.l > pair.r) pair = pair.Swap();
if (IsInRay(parRay, pair))
floorCountGrid[floor.mapPos] = 1;
}
if (floorCountGrid[floor.mapPos] == 1)
{
/*copy wall*/
float nextx = dir ? wall.Key.x : 2 * mapPos.x - wall.Key.x;
float nexty = dir ? 2 * mapPos.y - wall.Key.y : wall.Key.y;
MapManager.inst.currentMap.CreateWall(new Vector2(nextx, nexty), wall.Value.type);
SubtractRay(parRay, pair);
yield return null;
MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor);
MapManager.inst.currentMap.RemoveObject(oppFloorPos);
if (floor.objOnFloor != null)
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 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;
rangeR = i + 0.25f * side + 0.5f;
foreach (var wall in copyWallGrid)
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)
{
float wallPos = (dir ? wall.Key.y : wall.Key.x);
if (wall.Value.GetInstanceID() != GetInstanceID() && (side < 0 ? wallPos < rangeL && wallPos > rangeR : wallPos > rangeL && wallPos < rangeR))
//Debug.Log(oppFloorPos);
if (IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true)))
{
Pair pair = new Pair(PointToParRay(stPos, wall.Value.ldPos, true), PointToParRay(stPos, wall.Value.rdPos, true));
if (pair.l > pair.r) pair = pair.Swap();
if (IsInRay(parRay, pair))
floorCountGrid[floor.mapPos] = 1;
}
if (floorCountGrid[floor.mapPos] == 1)
{
/*copy wall*/
float nextx = dir ? wall.Key.x : 2 * mapPos.x - wall.Key.x;
float nexty = dir ? 2 * mapPos.y - wall.Key.y : wall.Key.y;
MapManager.inst.currentMap.CreateWall(new Vector2(nextx, nexty), wall.Value.type);
SubtractRay(parRay, pair);
yield return null;
MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor);
MapManager.inst.currentMap.RemoveObject(oppFloorPos);
if (floor.objOnFloor != null)
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 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");
float range = i + 0.5f * side;
float minMap = -1 * MapManager.inst.currentMap.maxMapSize / 2 - 1.5f;
float maxMap = MapManager.inst.currentMap.maxMapSize / 2 + 1.5f;
//Debug.Log("value: " + minMap + ", " + maxMap);
for (float j = minMap; j < maxMap; j += 1)
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)
{
Vector2 point = dir ? new Vector2(j, range) : new Vector2(range, j);
if (IsInRay(parRay, PointToParRay(stPos, point, true)))
//Debug.Log(oppFloorPos);
if (IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true)))
{
Debug.Log("inside " + point);
// 사방의 바닥 카피, 그 위의 오브젝트도 카피
Floor floor = MapManager.inst.currentMap.GetFloorAtPos(Mathf.FloorToInt(point.x), Mathf.FloorToInt(point.y));
Debug.Log(floor);
if (floor != null)
floorCountGrid[floor.mapPos] = 1;
}
if (floorCountGrid[floor.mapPos] == 1)
{
int nextx = dir ? floor.mapPos.x : Mathf.RoundToInt(2 * ldPos.x - floor.mapPos.x);
int nexty = dir ? Mathf.RoundToInt(2 * ldPos.y - floor.mapPos.y) : floor.mapPos.y;
MapManager.inst.currentMap.CreateFloor(new Vector2Int(nextx, nexty), floor.isGoalFloor);
MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor);
MapManager.inst.currentMap.RemoveObject(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;
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);
}
floor = MapManager.inst.currentMap.GetFloorAtPos(Mathf.FloorToInt(point.x), Mathf.CeilToInt(point.y));
Debug.Log(floor);
if (floor != null)
floorCountGrid[floor.mapPos]++;
}
else if ((floor = MapManager.inst.currentMap.GetFloorAtPos(oppFloorPos)) != null)
{
int nextx = dir ? floor.mapPos.x : Mathf.RoundToInt(2 * ldPos.x - floor.mapPos.x);
int nexty = dir ? Mathf.RoundToInt(2 * ldPos.y - floor.mapPos.y) : floor.mapPos.y;
MapManager.inst.currentMap.CreateFloor(new Vector2Int(nextx, nexty), floor.isGoalFloor);
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;
if (floor.isPlayerOn) PlayerController.inst.RemovePlayer(floor);
if (floor.objOnFloor != null) MapManager.inst.currentMap.RemoveObject(oppFloorPos);
MapManager.inst.currentMap.RemoveFloor(oppFloorPos);
}
floor = MapManager.inst.currentMap.GetFloorAtPos(Mathf.CeilToInt(point.x), Mathf.FloorToInt(point.y));
Debug.Log(floor);
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)
{
int nextx = dir ? floor.mapPos.x : Mathf.RoundToInt(2 * ldPos.x - floor.mapPos.x);
int nexty = dir ? Mathf.RoundToInt(2 * ldPos.y - floor.mapPos.y) : floor.mapPos.y;
MapManager.inst.currentMap.CreateFloor(new Vector2Int(nextx, nexty), floor.isGoalFloor);
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;
//Debug.Log(oppFloorPos);
if (IsInRay(parRay, PointToParRay(stPos, floor.mapPos, true)))
{
floorCountGrid[floor.mapPos] = 1;
}
floor = MapManager.inst.currentMap.GetFloorAtPos(Mathf.CeilToInt(point.x), Mathf.CeilToInt(point.y));
Debug.Log(floor);
if (floor != null)
if (floorCountGrid[floor.mapPos] == 1)
{
int nextx = dir ? floor.mapPos.x : Mathf.RoundToInt(2 * ldPos.x - floor.mapPos.x);
int nexty = dir ? Mathf.RoundToInt(2 * ldPos.y - floor.mapPos.y) : floor.mapPos.y;
MapManager.inst.currentMap.CreateFloor(new Vector2Int(nextx, nexty), floor.isGoalFloor);
MapManager.inst.currentMap.CreateFloor(oppFloorPos, floor.isGoalFloor);
MapManager.inst.currentMap.RemoveObject(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;
}
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]++;
}
Debug.Log(i + "th Floor End");
foreach (var ply in copyPlayers)
else if ((floor = MapManager.inst.currentMap.GetFloorAtPos(oppFloorPos)) != null)
{
Floor plyFloor = ply.GetComponent<Player>().currentFloor;
if ((dir ? plyFloor.mapPos.y : plyFloor.mapPos.x) == i)
{
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;
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 Player End");
}
MapManager.inst.currentMap.RemoveWall(mapPos);
}
......@@ -354,7 +329,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
bool output = false;
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;
else
{
......@@ -369,7 +344,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
{
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;
}
return false;
......
......@@ -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)
yield return null;
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.isPlayerOn = true;
PlayerController.inst.CheckCurrentFloors();
anim.SetBool("isWalking", false);
PlayerController.inst.isPlayerMoving = false;
......
......@@ -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);
player.GetComponent<Player>().currentFloor = floor;
floor.isPlayerOn = true;
MapManager.inst.players.Add(player);
if (GameManager.nPlayer >= 0)
{
......@@ -67,6 +68,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
{
if (obj.GetComponent<Player>().currentFloor == floor)
{
floor.isPlayerOn = false;
MapManager.inst.players.Remove(obj);
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