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
a60d01e7
Commit
a60d01e7
authored
Aug 08, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
거울 로직 변경 및 거울로 사라지면 파괴로 카운트 안하게 만듬
parent
aed576ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
197 deletions
+140
-197
Pair.cs
Assets/Scripts/Generals/Pair.cs
+5
-2
Map.cs
Assets/Scripts/Map/Map.cs
+9
-6
Mirror.cs
Assets/Scripts/Map/Mirror.cs
+126
-189
No files found.
Assets/Scripts/Generals/Pair.cs
View file @
a60d01e7
...
...
@@ -11,11 +11,14 @@ public class Pair
{
this
.
l
=
_l
;
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
)
...
...
Assets/Scripts/Map/Map.cs
View file @
a60d01e7
...
...
@@ -126,7 +126,7 @@ public class Map : MonoBehaviour
/// </summary>
/// <param name="pos">Position 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
)))
{
...
...
@@ -157,7 +157,12 @@ public class Map : MonoBehaviour
Debug
.
Log
(
"Wall already exists at : "
+
pos
);
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
/// Change normal wall at position to mirror.
/// </summary>
/// <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
)))
{
...
...
@@ -195,7 +200,7 @@ public class Map : MonoBehaviour
}
if
(
wallGrid
.
ContainsKey
(
pos
))
{
(
wallGrid
[
pos
]
as
NormalWall
).
Break
();
if
(
isBreak
)
(
wallGrid
[
pos
]
as
NormalWall
).
Break
();
RemoveWall
(
pos
);
wallGrid
.
Add
(
pos
,
Instantiate
(
MapManager
.
inst
.
mirror
,
new
Vector3
(
pos
.
x
,
0
,
pos
.
y
),
Quaternion
.
identity
,
walls
.
transform
).
GetComponent
<
Wall
>());
wallGrid
[
pos
].
mapPos
=
pos
;
...
...
@@ -278,8 +283,6 @@ public class Map : MonoBehaviour
case
ObjType
.
Camera
:
if
(
GameManager
.
aTurret
>=
0
)
clearConditions
[
GameManager
.
aTurret
].
IsDone
(
0
,
-
1
);
if
(
GameManager
.
nTurret
>=
0
)
clearConditions
[
GameManager
.
nTurret
].
IsDone
(
1
);
PlayerController
.
inst
.
OnPlayerMove
-=
objectGrid
[
pos
].
GetObject
().
GetComponent
<
IPlayerInteractor
>().
Interact
;
break
;
case
ObjType
.
Mannequin
:
...
...
Assets/Scripts/Map/Mirror.cs
View file @
a60d01e7
...
...
@@ -60,241 +60,164 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
foreach
(
var
wall
in
MapManager
.
inst
.
currentMap
.
wallGrid
)
{
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
));
if
(
pair
.
l
>
pair
.
r
)
pair
=
pair
.
Swap
();
if
(
IsInRay
(
parRay
,
pair
))
SubtractRay
(
parRay
,
pair
);
yield
return
null
;
}
}
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
>();
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
);
float
minMap
=
-
1
*
MapManager
.
inst
.
currentMap
.
maxMapSize
-
1.5f
;
float
maxMap
=
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1.5f
;
int
minMapRange
=
-
1
*
MapManager
.
inst
.
currentMap
.
maxMapSize
-
1
;
int
maxMapRange
=
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1
;
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
)
for
(;
Mathf
.
Abs
(
i
)
<
maxMapRange
;
i
+=
side
)
{
while
(
true
)
{
yield
return
null
;
if
(
Input
.
GetKeyUp
(
KeyCode
.
A
))
break
;
}
for
(
float
j
=
minMap
;
j
<
maxMap
;
j
++)
// check walls and copy
for
(
float
j
=
minMapRange
+
0.5f
;
j
<
maxMapRange
+
0.5f
;
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
Vector2
oppoPos
=
GetOpposite
(
wallPos
)
;
Pair
wallPair
=
dir
?
(
new
Pair
(
PointToParRay
(
stPos
,
wallPos
+
new
Vector2
(
0
,
-
0.5f
),
true
),
PointToParRay
(
stPos
,
wallPos
+
new
Vector2
(
0
,
0.5f
),
true
)))
:
(
new
Pair
(
PointToParRay
(
stPos
,
wallPos
+
new
Vector2
(-
0.5f
,
0
),
true
),
PointToParRay
(
stPos
,
wallPos
+
new
Vector2
(
0.5f
,
0
),
true
))
);
if
(
IsInRay
(
parRay
,
wallPair
))
{
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
(
copyWallGrid
.
ContainsKey
(
wallPos
))
{
MapManager
.
inst
.
currentMap
.
CreateWall
(
oppWallPos
,
wallAtPos
.
type
);
Wall
originWall
=
copyWallGrid
[
wallPos
];
MapManager
.
inst
.
currentMap
.
CreateWall
(
oppoPos
,
originWall
.
type
,
false
);
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
);
}
}
while
(
true
)
{
yield
return
null
;
if
(
Input
.
GetKeyUp
(
KeyCode
.
A
))
break
;
}
float
iMid
=
i
+
0.5f
*
side
;
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
))
else
{
MapManager
.
inst
.
currentMap
.
CreateWall
(
oppWallPos
,
wallAtPos
.
type
);
SubtractRay
(
parRay
,
wallPair
);
if
(
copyWallGrid
.
ContainsKey
(
oppoPos
))
MapManager
.
inst
.
currentMap
.
RemoveWall
(
oppoPos
);
}
}
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
Vector2
pointPos
=
dir
?
new
Vector2
(
j
,
iMid
)
:
new
Vector2
(
iMid
,
j
);
if
(
IsInRayWeak
(
parRay
,
PointToParRay
(
stPos
,
pointPos
,
true
)))
}
for
(
int
j
=
minMapRange
+
1
;
j
<
maxMapRange
;
j
++)
{
// check floors
Vector2Int
floorPos
=
dir
?
new
Vector2Int
(
j
,
i
)
:
new
Vector2Int
(
i
,
j
);
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floorPos
,
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
)
{
//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
]++;
}
else
if
((
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
oppFloorPos
))
!=
null
)
int
floorCount
;
if
(
floorCountGrid
.
TryGetValue
(
floorPos
,
out
floorCount
))
{
if
(
floor
.
isPlayerOn
)
PlayerController
.
inst
.
RemovePlayer
(
floor
);
if
(
floor
.
objOnFloor
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
oppFloorPos
);
MapManager
.
inst
.
currentMap
.
RemoveFloor
(
oppFloorPos
);
if
(
floorCount
==
0
)
floorCountGrid
[
floorPos
]++;
// have floor
}
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
)
else
// no floor on there
{
//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
]++;
floorCountGrid
.
Add
(
floorPos
,
-
1
);
}
else
if
((
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
oppFloorPos
))
!=
null
)
}
}
yield
return
null
;
float
iMid
=
i
+
0.5f
*
side
;
// check walls and copy
for
(
int
j
=
minMapRange
;
j
<
maxMapRange
;
j
++)
{
Vector2
wallPos
=
dir
?
new
Vector2
(
j
,
iMid
)
:
new
Vector2
(
iMid
,
j
);
Vector2
oppoPos
=
GetOpposite
(
wallPos
);
Pair
wallPair
=
!
dir
?
(
new
Pair
(
PointToParRay
(
stPos
,
wallPos
+
new
Vector2
(
0
,
-
0.5f
),
true
),
PointToParRay
(
stPos
,
wallPos
+
new
Vector2
(
0
,
0.5f
),
true
)))
:
(
new
Pair
(
PointToParRay
(
stPos
,
wallPos
+
new
Vector2
(-
0.5f
,
0
),
true
),
PointToParRay
(
stPos
,
wallPos
+
new
Vector2
(
0.5f
,
0
),
true
)));
if
(
IsInRay
(
parRay
,
wallPair
))
{
if
(
copyWallGrid
.
ContainsKey
(
wallPos
))
{
if
(
floor
.
isPlayerOn
)
PlayerController
.
inst
.
RemovePlayer
(
floor
)
;
if
(
floor
.
objOnFloor
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
oppFloorPos
);
MapManager
.
inst
.
currentMap
.
RemoveFloor
(
oppFloorPos
);
Wall
originWall
=
copyWallGrid
[
wallPos
]
;
MapManager
.
inst
.
currentMap
.
CreateWall
(
oppoPos
,
originWall
.
type
,
false
);
SubtractRay
(
parRay
,
wallPair
);
}
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
)
else
{
//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
]++;
if
(
copyWallGrid
.
ContainsKey
(
oppoPos
))
MapManager
.
inst
.
currentMap
.
RemoveWall
(
oppoPos
);
}
else
if
((
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
oppFloorPos
))
!=
null
)
}
}
// check floors
for
(
int
j
=
minMapRange
;
j
<
maxMapRange
;
j
++)
{
Vector2
crossPoint
=
dir
?
new
Vector2
(
j
+
0.5f
,
iMid
)
:
new
Vector2
(
iMid
,
j
+
0.5f
);
if
(
IsInRayWeak
(
parRay
,
PointToParRay
(
stPos
,
crossPoint
,
true
)))
{
Vector2Int
[]
floorPoses
=
{
if
(
floor
.
isPlayerOn
)
PlayerController
.
inst
.
RemovePlayer
(
floor
);
if
(
floor
.
objOnFloor
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
oppFloorPos
);
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
)
new
Vector2Int
(
Mathf
.
FloorToInt
(
crossPoint
.
x
),
Mathf
.
FloorToInt
(
crossPoint
.
y
)),
new
Vector2Int
(
Mathf
.
FloorToInt
(
crossPoint
.
x
),
Mathf
.
CeilToInt
(
crossPoint
.
y
)),
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
)
{
//Debug.Log(oppFloorPos)
;
if
(
floorCountGrid
[
floor
.
mapPos
]
==
0
&&
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floor
.
mapPos
,
true
)
))
int
floorCount
;
if
(
floorCountGrid
.
TryGetValue
(
floorPos
,
out
floorCount
))
{
floorCountGrid
[
floor
.
mapPos
]
=
1
;
if
(
floorCount
==
0
)
floorCountGrid
[
floorPos
]++;
// have floor
}
if
(
floorCountGrid
[
floor
.
mapPos
]
==
1
)
else
// no floor on there
{
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
.
Add
(
floorPos
,
-
1
);
}
floorCountGrid
[
floor
.
mapPos
]++;
}
else
if
((
floor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
oppFloorPos
))
!=
null
)
}
}
yield
return
null
;
}
// copy floors
foreach
(
var
floorCount
in
floorCountGrid
)
{
Vector2Int
oppoPos
=
GetOpposite
(
floorCount
.
Key
);
if
(
floorCount
.
Value
>
0
)
// copy origin floor to opposite
{
Floor
originFloor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
floorCount
.
Key
);
Floor
oppoFloor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
oppoPos
);
MapManager
.
inst
.
currentMap
.
CreateFloor
(
oppoPos
,
originFloor
.
isGoalFloor
);
if
(
oppoFloor
!=
null
)
{
if
(
oppoFloor
.
isPlayerOn
)
PlayerController
.
inst
.
RemovePlayer
(
oppoFloor
);
if
(
oppoFloor
.
objOnFloor
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
oppoPos
);
}
else
{
oppoFloor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
oppoPos
);
}
if
(
originFloor
.
isPlayerOn
&&
oppoFloor
!=
null
)
PlayerController
.
inst
.
CreatePlayer
(
oppoFloor
);
else
if
(
originFloor
.
objOnFloor
!=
null
)
{
IObject
obj
=
originFloor
.
objOnFloor
;
switch
(
obj
.
GetType
())
{
if
(
floor
.
isPlayerOn
)
PlayerController
.
inst
.
RemovePlayer
(
floor
);
if
(
floor
.
objOnFloor
!=
null
)
MapManager
.
inst
.
currentMap
.
RemoveObject
(
oppFloorPos
);
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
;
if
(
Input
.
GetKeyUp
(
KeyCode
.
A
))
break
;
Floor
oppoFloor
=
MapManager
.
inst
.
currentMap
.
GetFloorAtPos
(
oppoPos
);
if
(
oppoFloor
!=
null
)
{
PlayerController
.
inst
.
RemovePlayer
(
oppoFloor
);
MapManager
.
inst
.
currentMap
.
RemoveObject
(
oppoPos
);
MapManager
.
inst
.
currentMap
.
RemoveFloor
(
oppoPos
);
}
}
}
Break
();
...
...
@@ -414,6 +337,20 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
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>
/// calculate where _chPos is from _stPos
/// </summary>
...
...
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