Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
man-in-the-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MIM
man-in-the-mirror
Commits
ea184ec5
Commit
ea184ec5
authored
Jul 02, 2019
by
18신대성
Committed by
18손재민
Jul 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
드디어 신대성 거울에게 승리
floor에도 플레이어 정보와 오브젝트 정보를 넣음 모든 오브젝트 init시 floor에 정보 들어가게
parent
79f1cca0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
243 deletions
+118
-243
Briefcase.cs
Assets/Scripts/Interactors/Briefcase.cs
+1
-0
Floor.cs
Assets/Scripts/Map/Floor.cs
+1
-0
Mirror.cs
Assets/Scripts/Map/Mirror.cs
+112
-243
Player.cs
Assets/Scripts/Player.cs
+2
-0
PlayerController.cs
Assets/Scripts/PlayerController.cs
+2
-0
No files found.
Assets/Scripts/Interactors/Briefcase.cs
View file @
ea184ec5
...
@@ -35,6 +35,7 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
...
@@ -35,6 +35,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
);
}
}
}
}
...
...
Assets/Scripts/Map/Floor.cs
View file @
ea184ec5
...
@@ -10,6 +10,7 @@ public class Floor : MonoBehaviour
...
@@ -10,6 +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
;
// Start is called before the first frame update
// Start is called before the first frame update
void
Start
()
void
Start
()
...
...
Assets/Scripts/Map/Mirror.cs
View file @
ea184ec5
...
@@ -74,321 +74,190 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
...
@@ -74,321 +74,190 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
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
);
List
<
Pair
>
copyParRay
=
new
List
<
Pair
>(
parRay
);
// 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
(
"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
)
{
{
//Debug.Log(j);
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
);
// copy / remove wall
if
(
wall
.
Value
.
GetInstanceID
()
!=
GetInstanceID
()
&&
(
side
<
0
?
wallPos
<
rangeL
&&
wallPos
>
rangeR
:
wallPos
>
rangeL
&&
wallPos
<
rangeR
))
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
{
{
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
(
copyParRay
,
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
);
SubtractRay
(
copyParRay
,
pair
);
yield
return
null
;
}
}
}
}
}
else
if
(
MapManager
.
inst
.
currentMap
.
GetWallAtPos
(
oppWallPos
)
!=
null
)
// no wall at wallPos but have at opposite
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
))
{
{
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
(
copyParRay
,
pair
))
{
/*remove wall*/
MapManager
.
inst
.
currentMap
.
RemoveWall
(
wall
.
Key
);
SubtractRay
(
copyParRay
,
pair
);
yield
return
null
;
}
}
}
}
}
//Debug.Log(i + "th Wall End")
;
float
iMid
=
i
+
0.5f
*
side
;
for
each
(
var
ply
in
copyPlayers
)
for
(
float
j
=
minMap
;
j
<
maxMap
;
j
++
)
{
{
if
(
ply
)
//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
{
{
Floor
plyFloor
=
ply
.
GetComponent
<
Player
>().
currentFloor
;
// create wall
if
((
dir
?
plyFloor
.
mapPos
.
y
:
plyFloor
.
mapPos
.
x
)
==
j
)
Pair
wallPair
=
new
Pair
(
PointToParRay
(
stPos
,
wallAtPos
.
ldPos
,
true
),
PointToParRay
(
stPos
,
wallAtPos
.
rdPos
,
true
));
{
if
(
wallPair
.
l
>
wallPair
.
r
)
wallPair
=
wallPair
.
Swap
();
if
(
IsInRay
(
copyParRay
,
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");
float
range
=
j
-
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
k
=
minMap
;
k
<
maxMap
;
k
+=
1
)
{
Vector2
point
=
dir
?
new
Vector2
(
k
,
range
)
:
new
Vector2
(
range
,
k
);
if
(
IsInRay
(
copyParRay
,
PointToParRay
(
stPos
,
point
,
false
)))
{
{
Debug
.
Log
(
"inside "
+
point
+
", "
);
// remove wall
// 사방의 바닥 카피, 그 위의 오브젝트도 카피
MapManager
.
inst
.
currentMap
.
RemoveWall
(
oppWallPos
);
Floor
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
Mathf
.
FloorToInt
(
point
.
x
),
Mathf
.
FloorToInt
(
point
.
y
));
}
// copy / remove floor and object
Vector2
pointPos
=
dir
?
new
Vector2
(
j
,
iMid
)
:
new
Vector2
(
iMid
,
j
);
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
pointPos
,
true
)))
{
//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
)
if
(
floor
!=
null
)
{
{
Debug
.
Log
(
floor
.
map
Pos
);
//Debug.Log(oppFloor
Pos);
if
(
IsInRay
(
copyParRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
fals
e
)))
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
tru
e
)))
{
{
floorCountGrid
[
floor
.
mapPos
]
=
1
;
floorCountGrid
[
floor
.
mapPos
]
=
1
;
}
}
if
(
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
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
floor
.
mapPos
);
MapManager
.
inst
.
currentMap
.
CreateObject
(
oppFloorPos
,
floor
.
objOnFloor
.
GetType
(),
(
floor
.
objOnFloor
.
GetType
()
!=
ObjType
.
Mannequin
?
true
:
((
Mannequin
)
floor
.
objOnFloor
).
isWhite
));
Debug
.
Log
(
"remove "
+
floor
.
mapPos
);
if
(
floor
.
isPlayerOn
)
MapManager
.
inst
.
currentMap
.
RemoveFloor
(
floor
.
mapPos
);
PlayerController
.
inst
.
CreatePlayer
(
oppFloorPos
);
yield
return
null
;
}
}
floorCountGrid
[
floor
.
mapPos
]++;
floorCountGrid
[
floor
.
mapPos
]++;
}
}
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
Mathf
.
FloorToInt
(
point
.
x
),
Mathf
.
CeilToInt
(
point
.
y
));
else
if
((
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
oppFloorPos
))
!=
null
)
if
(
floor
!=
null
)
{
{
Debug
.
Log
(
floor
.
mapPos
);
if
(
floor
.
isPlayerOn
)
PlayerController
.
inst
.
RemovePlayer
(
floor
);
if
(
IsInRay
(
copyParRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
false
)))
if
(
floor
.
objOnFloor
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
oppFloorPos
);
{
MapManager
.
inst
.
currentMap
.
RemoveFloor
(
oppFloorPos
);
floorCountGrid
[
floor
.
mapPos
]
=
1
;
}
if
(
floorCountGrid
[
floor
.
mapPos
]
==
1
)
{
if
(
floor
.
objOnFloor
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
floor
.
mapPos
);
Debug
.
Log
(
"remove "
+
floor
.
mapPos
);
MapManager
.
inst
.
currentMap
.
RemoveFloor
(
floor
.
mapPos
);
yield
return
null
;
}
floorCountGrid
[
floor
.
mapPos
]++;
}
}
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
Mathf
.
CeilToInt
(
point
.
x
),
Mathf
.
FloorToInt
(
point
.
y
));
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
)
if
(
floor
!=
null
)
{
{
Debug
.
Log
(
floor
.
map
Pos
);
//Debug.Log(oppFloor
Pos);
if
(
IsInRay
(
copyParRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
fals
e
)))
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
tru
e
)))
{
{
floorCountGrid
[
floor
.
mapPos
]
=
1
;
floorCountGrid
[
floor
.
mapPos
]
=
1
;
}
}
if
(
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
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
floor
.
mapPos
);
MapManager
.
inst
.
currentMap
.
CreateObject
(
oppFloorPos
,
floor
.
objOnFloor
.
GetType
(),
(
floor
.
objOnFloor
.
GetType
()
!=
ObjType
.
Mannequin
?
true
:
((
Mannequin
)
floor
.
objOnFloor
).
isWhite
));
Debug
.
Log
(
"remove "
+
floor
.
mapPos
);
if
(
floor
.
isPlayerOn
)
MapManager
.
inst
.
currentMap
.
RemoveFloor
(
floor
.
mapPos
);
PlayerController
.
inst
.
CreatePlayer
(
oppFloorPos
);
yield
return
null
;
}
}
floorCountGrid
[
floor
.
mapPos
]++;
floorCountGrid
[
floor
.
mapPos
]++;
}
}
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
Mathf
.
CeilToInt
(
point
.
x
),
Mathf
.
CeilToInt
(
point
.
y
));
else
if
((
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
oppFloorPos
))
!=
null
)
if
(
floor
!=
null
)
{
{
Debug
.
Log
(
floor
.
mapPos
);
if
(
floor
.
isPlayerOn
)
PlayerController
.
inst
.
RemovePlayer
(
floor
);
if
(
IsInRay
(
copyParRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
false
)))
if
(
floor
.
objOnFloor
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
oppFloorPos
);
{
MapManager
.
inst
.
currentMap
.
RemoveFloor
(
oppFloorPos
);
floorCountGrid
[
floor
.
mapPos
]
=
1
;
}
if
(
floorCountGrid
[
floor
.
mapPos
]
==
1
)
{
if
(
floor
.
objOnFloor
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
floor
.
mapPos
);
Debug
.
Log
(
"remove "
+
floor
.
mapPos
);
MapManager
.
inst
.
currentMap
.
RemoveFloor
(
floor
.
mapPos
);
yield
return
null
;
}
floorCountGrid
[
floor
.
mapPos
]++;
}
}
}
floorPos
=
new
Vector2Int
(
Mathf
.
CeilToInt
(
pointPos
.
x
),
Mathf
.
FloorToInt
(
pointPos
.
y
));
}
nextFloorx
=
dir
?
floorPos
.
x
:
Mathf
.
RoundToInt
(
2
*
ldPos
.
x
-
floorPos
.
x
);
//Debug.Log(i + "th Floor End");
nextFloory
=
dir
?
Mathf
.
RoundToInt
(
2
*
ldPos
.
y
-
floorPos
.
y
)
:
floorPos
.
y
;
}
oppFloorPos
=
new
Vector2Int
(
nextFloorx
,
nextFloory
);
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
floorPos
);
yield
return
new
WaitForSeconds
(
3f
);
copyFloorGrid
=
new
Dictionary
<
Vector2Int
,
Floor
>(
MapManager
.
inst
.
currentMap
.
floorGrid
);
floorCountGrid
=
new
Dictionary
<
Vector2Int
,
int
>();
foreach
(
var
floor
in
copyFloorGrid
)
{
floorCountGrid
.
Add
(
floor
.
Key
,
0
);
}
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
;
float
rangeR
=
i
+
0.25f
*
side
;
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
,
true
),
PointToParRay
(
stPos
,
wall
.
Value
.
rdPos
,
true
));
if
(
pair
.
l
>
pair
.
r
)
pair
=
pair
.
Swap
();
if
(
IsInRay
(
parRay
,
pair
))
{
/*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
;
}
}
}
rangeL
=
i
-
0.25f
*
side
+
0.5f
;
rangeR
=
i
+
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
,
true
),
PointToParRay
(
stPos
,
wall
.
Value
.
rdPos
,
true
));
if
(
pair
.
l
>
pair
.
r
)
pair
=
pair
.
Swap
();
if
(
IsInRay
(
parRay
,
pair
))
{
/*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
;
}
}
}
//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
)
{
Vector2
point
=
dir
?
new
Vector2
(
j
,
range
)
:
new
Vector2
(
range
,
j
);
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
point
,
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
)
{
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
true
)))
{
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
);
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
;
}
floorCountGrid
[
floor
.
mapPos
]++;
}
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
Mathf
.
FloorToInt
(
point
.
x
),
Mathf
.
CeilToInt
(
point
.
y
));
//Debug.Log(floor);
if
(
floor
!=
null
)
if
(
floor
!=
null
)
{
{
//Debug.Log(oppFloorPos);
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
true
)))
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
true
)))
{
{
floorCountGrid
[
floor
.
mapPos
]
=
1
;
floorCountGrid
[
floor
.
mapPos
]
=
1
;
}
}
if
(
floorCountGrid
[
floor
.
mapPos
]
==
1
)
if
(
floorCountGrid
[
floor
.
mapPos
]
==
1
)
{
{
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
]++;
floorCountGrid
[
floor
.
mapPos
]++;
}
}
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
Mathf
.
CeilToInt
(
point
.
x
),
Mathf
.
FloorToInt
(
point
.
y
));
else
if
((
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
oppFloorPos
))
!=
null
)
//Debug.Log(floor);
if
(
floor
!=
null
)
{
{
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
true
)))
if
(
floor
.
isPlayerOn
)
PlayerController
.
inst
.
RemovePlayer
(
floor
);
{
if
(
floor
.
objOnFloor
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
oppFloorPos
);
floorCountGrid
[
floor
.
mapPos
]
=
1
;
MapManager
.
inst
.
currentMap
.
RemoveFloor
(
oppFloorPos
);
}
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
);
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
;
}
floorCountGrid
[
floor
.
mapPos
]++;
}
}
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
Mathf
.
CeilToInt
(
point
.
x
),
Mathf
.
CeilToInt
(
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
)
{
{
//Debug.Log(oppFloorPos);
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
true
)))
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
true
)))
{
{
floorCountGrid
[
floor
.
mapPos
]
=
1
;
floorCountGrid
[
floor
.
mapPos
]
=
1
;
}
}
if
(
floorCountGrid
[
floor
.
mapPos
]
==
1
)
if
(
floorCountGrid
[
floor
.
mapPos
]
==
1
)
{
{
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
]++;
floorCountGrid
[
floor
.
mapPos
]++;
}
}
}
else
if
((
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
oppFloorPos
))
!=
null
)
}
//Debug.Log(i + "th Floor End");
foreach
(
var
ply
in
copyPlayers
)
{
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*/
if
(
floor
.
isPlayerOn
)
PlayerController
.
inst
.
RemovePlayer
(
floor
);
int
nextx
=
dir
?
plyFloor
.
mapPos
.
x
:
Mathf
.
RoundToInt
(
2
*
ldPos
.
x
-
plyFloor
.
mapPos
.
x
);
if
(
floor
.
objOnFloor
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
oppFloorPos
);
int
nexty
=
dir
?
Mathf
.
RoundToInt
(
2
*
ldPos
.
y
-
plyFloor
.
mapPos
.
y
)
:
plyFloor
.
mapPos
.
y
;
MapManager
.
inst
.
currentMap
.
RemoveFloor
(
oppFloorPos
);
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
);
}
}
...
...
Assets/Scripts/Player.cs
View file @
ea184ec5
...
@@ -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
;
...
...
Assets/Scripts/PlayerController.cs
View file @
ea184ec5
...
@@ -39,6 +39,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
...
@@ -39,6 +39,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
)
{
{
...
@@ -68,6 +69,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
...
@@ -68,6 +69,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
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment