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
613a0acd
Commit
613a0acd
authored
Jun 25, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
거울 뒷부분을 싸그리 날리고 재생성하게 바꿈
parent
af34d9ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
6 deletions
+74
-6
Mirror.cs
Assets/Scripts/Map/Mirror.cs
+74
-6
No files found.
Assets/Scripts/Map/Mirror.cs
View file @
613a0acd
...
...
@@ -33,19 +33,19 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
new
Pair
<
float
,
float
>(
0
,
1
)
};
int
side
,
i
,
i
Reset
,
stCheck
;
int
side
,
i
,
i
Back
,
stCheck
;
if
(
dir
)
// horizontal, parallel with x
{
side
=
(
mapPos
.
y
-
stPos
.
y
>
0
)
?
-
1
:
1
;
i
=
side
>
0
?
Mathf
.
CeilToInt
(
mapPos
.
y
)
:
Mathf
.
FloorToInt
(
mapPos
.
y
);
i
Reset
=
i
;
i
Back
=
side
<
0
?
Mathf
.
CeilToInt
(
mapPos
.
y
)
:
Mathf
.
FloorToInt
(
mapPos
.
y
)
;
stCheck
=
(
int
)
stPos
.
y
;
}
else
// vertical, parallel with y
{
side
=
(
mapPos
.
x
-
stPos
.
x
>
0
)
?
-
1
:
1
;
i
=
side
>
0
?
Mathf
.
CeilToInt
(
mapPos
.
x
)
:
Mathf
.
FloorToInt
(
mapPos
.
x
);
i
Reset
=
i
;
i
Back
=
side
<
0
?
Mathf
.
CeilToInt
(
mapPos
.
x
)
:
Mathf
.
FloorToInt
(
mapPos
.
x
)
;
stCheck
=
(
int
)
stPos
.
x
;
}
yield
return
null
;
...
...
@@ -65,13 +65,81 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
}
}
Debug
.
Log
(
"Start Reflecting."
);
// check after reflect, if obj or floor, copy else if wall or mirror, Subtract
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
);
for
(
i
=
iReset
;
Mathf
.
Abs
(
i
)
<
MapManager
.
inst
.
currentMap
.
maxMapSize
;
i
+=
side
)
// remove backside of mirror
for
(
int
j
=
iBack
;
Mathf
.
Abs
(
j
)
<
MapManager
.
inst
.
currentMap
.
maxMapSize
;
j
-=
side
)
{
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");
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
;
}
}
}
//Debug.Log(i + "th Object End");
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
);
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
(
IsInRay
(
parRay
,
pair
.
l
)
&&
IsInRay
(
parRay
,
pair
.
r
))
{
/*remove wall*/
MapManager
.
inst
.
currentMap
.
RemoveWall
(
wall
.
Key
);
yield
return
null
;
}
}
}
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
<
float
,
float
>
pair
=
new
Pair
<
float
,
float
>(
PointToParRay
(
stPos
,
wall
.
Value
.
ldPos
,
false
),
PointToParRay
(
stPos
,
wall
.
Value
.
rdPos
,
false
));
if
(
IsInRay
(
parRay
,
pair
.
l
)
&&
IsInRay
(
parRay
,
pair
.
r
))
{
/*remove wall*/
MapManager
.
inst
.
currentMap
.
RemoveWall
(
wall
.
Key
);
yield
return
null
;
}
}
}
//Debug.Log(i + "th Wall End");
}
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
);
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
)
{
foreach
(
var
floor
in
copyFloorGrid
)
{
...
...
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