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
125f9cfe
Commit
125f9cfe
authored
Jun 25, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
이제 잭슨도 잘 복사되고 없어지고 한다.
parent
613a0acd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
13 deletions
+107
-13
Mirror.cs
Assets/Scripts/Map/Mirror.cs
+51
-13
PlayerController.cs
Assets/Scripts/PlayerController.cs
+56
-0
No files found.
Assets/Scripts/Map/Mirror.cs
View file @
125f9cfe
...
...
@@ -64,40 +64,59 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
yield
return
null
;
}
}
Dictionary
<
Vector2Int
,
Floor
>
copyFloorGrid
=
new
Dictionary
<
Vector2Int
,
Floor
>(
MapManager
.
inst
.
currentMap
.
floorGrid
);
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
)
{
foreach
(
var
floor
in
copyFloorGrid
)
Debug
.
Log
(
j
);
foreach
(
var
obj
in
copyObjGrid
)
{
if
((
dir
?
floor
.
Key
.
y
:
floor
.
Key
.
x
)
==
j
)
if
((
dir
?
obj
.
Key
.
y
:
obj
.
Key
.
x
)
==
j
)
{
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floor
.
Key
,
false
)))
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
obj
.
Key
,
false
)))
{
/*remove
floor
*/
MapManager
.
inst
.
currentMap
.
Remove
Floor
(
floor
.
Key
);
/*remove
object
*/
MapManager
.
inst
.
currentMap
.
Remove
Object
(
obj
.
Key
);
yield
return
null
;
}
}
}
//Debug.Log(i + "th Floor End");
foreach
(
var
obj
in
copyObjGrid
)
foreach
(
var
ply
in
copyPlayers
)
{
if
(
(
dir
?
obj
.
Key
.
y
:
obj
.
Key
.
x
)
==
j
)
if
(
ply
)
{
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
obj
.
Key
,
false
)))
Floor
plyFloor
=
ply
.
GetComponent
<
Player
>().
currentFloor
;
if
((
dir
?
plyFloor
.
mapPos
.
y
:
plyFloor
.
mapPos
.
x
)
==
j
)
{
/*remove object*/
MapManager
.
inst
.
currentMap
.
RemoveObject
(
obj
.
Key
);
yield
return
null
;
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
plyFloor
.
mapPos
,
false
)))
{
/*remove player*/
PlayerController
.
inst
.
RemovePlayer
(
plyFloor
.
mapPos
);
yield
return
null
;
}
}
}
}
//Debug.Log(i + "th Object End");
foreach
(
var
floor
in
copyFloorGrid
)
{
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
;
}
}
}
//Debug.Log(i + "th Floor End");
float
rangeL
=
j
-
0.25f
*
side
;
float
rangeR
=
j
+
0.25f
*
side
;
foreach
(
var
wall
in
copyWallGrid
)
...
...
@@ -106,6 +125,8 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
if
(
wall
.
Value
.
GetInstanceID
()
!=
GetInstanceID
()
&&
(
side
<
0
?
wallPos
<
rangeL
&&
wallPos
>
rangeR
:
wallPos
>
rangeL
&&
wallPos
<
rangeR
))
{
Pair
<
float
,
float
>
pair
=
new
Pair
<
float
,
float
>(
PointToParRay
(
stPos
,
wall
.
Value
.
ldPos
,
false
),
PointToParRay
(
stPos
,
wall
.
Value
.
rdPos
,
false
));
if
(
pair
.
l
>
pair
.
r
)
pair
.
Swap
();
if
(
IsInRay
(
parRay
,
pair
.
l
)
&&
IsInRay
(
parRay
,
pair
.
r
))
{
/*remove wall*/
...
...
@@ -136,6 +157,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
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
...
...
@@ -172,6 +194,22 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
}
}
}
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*/
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 Object End");
float
rangeL
=
i
-
0.25f
*
side
;
float
rangeR
=
i
+
0.25f
*
side
;
...
...
Assets/Scripts/PlayerController.cs
View file @
125f9cfe
...
...
@@ -29,6 +29,14 @@ public class PlayerController : SingletonBehaviour<PlayerController>
public
void
CreatePlayer
(
Floor
floor
)
{
foreach
(
var
obj
in
MapManager
.
inst
.
players
)
{
if
(
obj
.
GetComponent
<
Player
>().
currentFloor
==
floor
)
{
Debug
.
Log
(
"there are player on that floor."
);
return
;
}
}
GameObject
player
=
Instantiate
(
MapManager
.
inst
.
player
,
floor
.
transform
.
position
+
new
Vector3
(
0
,
0.1f
,
0
),
Quaternion
.
identity
);
player
.
GetComponent
<
Player
>().
currentFloor
=
floor
;
MapManager
.
inst
.
players
.
Add
(
player
);
...
...
@@ -39,6 +47,54 @@ public class PlayerController : SingletonBehaviour<PlayerController>
}
CheckCurrentFloors
();
}
public
void
CreatePlayer
(
Vector2Int
floorPos
)
{
if
(
MapManager
.
inst
.
currentMap
.
floorGrid
.
TryGetValue
(
floorPos
,
out
Floor
floor
))
{
CreatePlayer
(
floor
);
}
else
{
Debug
.
Log
(
"there are no floor"
);
}
}
public
void
RemovePlayer
(
Floor
floor
)
{
if
(!
floor
)
{
Debug
.
Log
(
"there are no floor"
);
return
;
}
List
<
GameObject
>
copyPlayers
=
new
List
<
GameObject
>(
MapManager
.
inst
.
players
);
foreach
(
var
obj
in
copyPlayers
)
{
if
(
obj
.
GetComponent
<
Player
>().
currentFloor
==
floor
)
{
MapManager
.
inst
.
players
.
Remove
(
obj
);
if
(
GameManager
.
nPlayer
>=
0
)
{
MapManager
.
inst
.
currentMap
.
clearConditions
[
GameManager
.
nPlayer
].
count
=
MapManager
.
inst
.
players
.
Count
;
MapManager
.
inst
.
currentMap
.
clearConditions
[
GameManager
.
nPlayer
].
IsDone
();
}
Destroy
(
obj
);
CheckCurrentFloors
();
return
;
}
}
}
public
void
RemovePlayer
(
Vector2Int
floorPos
)
{
if
(
MapManager
.
inst
.
currentMap
.
floorGrid
.
TryGetValue
(
floorPos
,
out
Floor
floor
))
{
RemovePlayer
(
floor
);
}
else
{
Debug
.
Log
(
"there are no floor"
);
}
}
public
void
CheckCurrentFloors
()
{
...
...
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