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
a6dc40f5
Commit
a6dc40f5
authored
Jun 22, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
이제 거울 거의 정상적으로 돌아가긴 함.
ldPos 폐기 WIP
parent
0f052b1b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
62 deletions
+69
-62
mirror.prefab
Assets/Prefabs/MapObjects/mirror.prefab
+1
-1
wall.prefab
Assets/Prefabs/MapObjects/wall.prefab
+1
-1
Mannequin.cs
Assets/Scripts/Interactors/Mannequin.cs
+2
-0
Mirror.cs
Assets/Scripts/Map/Mirror.cs
+56
-36
Wall.cs
Assets/Scripts/Map/Wall.cs
+4
-16
Player.cs
Assets/Scripts/Player.cs
+1
-5
PlayerController.cs
Assets/Scripts/PlayerController.cs
+4
-3
No files found.
Assets/Prefabs/MapObjects/mirror.prefab
View file @
a6dc40f5
...
...
@@ -92,7 +92,7 @@ BoxCollider:
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1244481854748732982
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
1
m_IsTrigger
:
0
m_Enabled
:
1
serializedVersion
:
2
m_Size
:
{
x
:
1.0000005
,
y
:
1.0000002
,
z
:
0.080003634
}
...
...
Assets/Prefabs/MapObjects/wall.prefab
View file @
a6dc40f5
...
...
@@ -89,7 +89,7 @@ BoxCollider:
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
337530617404887312
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
1
m_IsTrigger
:
0
m_Enabled
:
1
serializedVersion
:
2
m_Size
:
{
x
:
1.0000005
,
y
:
1.0000002
,
z
:
0.080003634
}
...
...
Assets/Scripts/Interactors/Mannequin.cs
View file @
a6dc40f5
...
...
@@ -38,6 +38,7 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor
_color
=
value
;
}
}
public
bool
isWhite
;
public
void
Interact
(
Bullet
bullet
)
{
...
...
@@ -60,6 +61,7 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor
public
void
SetColor
(
bool
isWhite
)
{
Color
=
isWhite
?
Color
.
white
:
Color
.
black
;
this
.
isWhite
=
isWhite
;
}
#
region
IObject
Override
...
...
Assets/Scripts/Map/Mirror.cs
View file @
a6dc40f5
...
...
@@ -14,10 +14,9 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
{
if
(
bullet
is
FakeBullet
)
{
Debug
.
Log
(
"ldPos: "
+
ldPos
+
", rdPos: "
+
rdPos
);
Debug
.
Log
(
"ldPos: "
+
ldPos
+
", rdPos: "
+
rdPos
+
", dir: "
+
dir
);
// Make reflected objects
StartCoroutine
(
CopyObjects
(
PlayerController
.
inst
.
currentPlayer
));
//Destroy(gameObject, 1f);
}
}
...
...
@@ -34,76 +33,97 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
new
Pair
<
float
,
float
>(
0
,
1
)
};
int
side
,
i
,
iReset
,
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
);
iReset
=
i
;
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
);
iReset
=
i
;
stCheck
=
(
int
)
stPos
.
x
;
}
yield
return
null
;
// check before reflect (check walls and mirrors)
for
(;
Mathf
.
Abs
(
i
)
<
MapManager
.
inst
.
currentMap
.
maxMapSize
&&
(
side
>
0
?
i
<
stCheck
:
i
>
stCheck
);
i
+=
side
)
{
foreach
(
var
wall
in
MapManager
.
inst
.
currentMap
.
wallGrid
)
{
if
(
wall
.
Value
.
GetInstanceID
()
!=
GetInstanceID
()
)
if
(
wall
.
Value
.
GetInstanceID
()
!=
GetInstanceID
()
&&
(
dir
?
wall
.
Key
.
y
:
wall
.
Key
.
x
)
==
i
)
{
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
=
pair
.
Swap
();
Debug
.
Log
(
"wall at "
+
wall
.
Key
);
SubtractRay
(
parRay
,
pair
);
yield
return
null
;
}
}
// check after reflect, if obj or floor, copy else if wall or mirror, Subtract
int
side
,
i
;
if
(
dir
)
// horizontal, parallel with x
{
side
=
(
ldPos
.
y
-
stPos
.
y
>
0
)
?
-
1
:
1
;
i
=
ldPos
.
y
;
}
else
// vertical, parallel with y
{
side
=
(
ldPos
.
x
-
stPos
.
x
>
0
)
?
-
1
:
1
;
i
=
ldPos
.
x
;
}
yield
return
null
;
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
(;
Mathf
.
Abs
(
i
)
<
MapManager
.
inst
.
currentMap
.
maxMapSize
;
i
+=
side
)
for
(
i
=
iReset
;
Mathf
.
Abs
(
i
)
<
MapManager
.
inst
.
currentMap
.
maxMapSize
;
i
+=
side
)
{
foreach
(
var
floor
in
MapManager
.
inst
.
currentMap
.
f
loorGrid
)
foreach
(
var
floor
in
copyF
loorGrid
)
{
if
((
dir
?
floor
.
Key
.
y
:
floor
.
Key
.
x
)
==
i
)
{
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
floor
.
Key
,
true
)))
{
/*copy floor*/
int
nextx
=
dir
?
floor
.
Key
.
x
:
2
*
ldPos
.
x
-
floor
.
Key
.
x
;
int
nexty
=
dir
?
2
*
ldPos
.
y
-
floor
.
Key
.
y
:
floor
.
Key
.
y
;
int
nextx
=
dir
?
floor
.
Key
.
x
:
Mathf
.
RoundToInt
(
2
*
ldPos
.
x
-
floor
.
Key
.
x
)
;
int
nexty
=
dir
?
Mathf
.
RoundToInt
(
2
*
ldPos
.
y
-
floor
.
Key
.
y
)
:
floor
.
Key
.
y
;
MapManager
.
inst
.
currentMap
.
CreateFloor
(
new
Vector2Int
(
nextx
,
nexty
));
yield
return
null
;
}
}
}
foreach
(
var
obj
in
MapManager
.
inst
.
currentMap
.
object
Grid
)
foreach
(
var
obj
in
copyObj
Grid
)
{
if
((
dir
?
obj
.
Key
.
y
:
obj
.
Key
.
x
)
==
i
)
{
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
obj
.
Value
.
GetPos
()
,
true
)))
if
(
IsInRay
(
parRay
,
PointToParRay
(
stPos
,
obj
.
Key
,
true
)))
{
/*copy object*/
int
nextx
=
dir
?
obj
.
Key
.
x
:
Mathf
.
RoundToInt
(
2
*
ldPos
.
x
-
obj
.
Key
.
x
);
int
nexty
=
dir
?
Mathf
.
RoundToInt
(
2
*
ldPos
.
y
-
obj
.
Key
.
y
)
:
obj
.
Key
.
y
;
ObjType
type
=
obj
.
Value
.
GetType
();
MapManager
.
inst
.
currentMap
.
CreateObject
(
new
Vector2Int
(
nextx
,
nexty
),
type
,
(
type
==
ObjType
.
Mannequin
?
((
Mannequin
)(
obj
.
Value
)).
isWhite
:
true
));
yield
return
null
;
}
}
}
Dictionary
<
Vector2
,
Wall
>
copyGrid
=
new
Dictionary
<
Vector2
,
Wall
>(
MapManager
.
inst
.
currentMap
.
wallGrid
);
foreach
(
var
wall
in
copyGrid
)
foreach
(
var
wall
in
copyWallGrid
)
{
if
((
dir
?
wall
.
Key
.
y
:
wall
.
Key
.
x
)
==
i
)
{
Pair
<
float
,
float
>
pair
=
new
Pair
<
float
,
float
>(
PointToParRay
(
stPos
,
wall
.
Value
.
ldPos
,
true
),
PointToParRay
(
stPos
,
wall
.
Value
.
rdPos
,
true
));
if
(
pair
.
l
>
pair
.
r
)
pair
=
pair
.
Swap
();
if
(
IsInRay
(
parRay
,
pair
.
l
)
||
IsInRay
(
parRay
,
pair
.
r
))
{
/*copy wall*/
float
nextx
=
dir
?
wall
.
Key
.
x
:
2
*
ld
Pos
.
x
-
wall
.
Key
.
x
;
float
nexty
=
dir
?
2
*
ld
Pos
.
y
-
wall
.
Key
.
y
:
wall
.
Key
.
y
;
float
nextx
=
dir
?
wall
.
Key
.
x
:
2
*
map
Pos
.
x
-
wall
.
Key
.
x
;
float
nexty
=
dir
?
2
*
map
Pos
.
y
-
wall
.
Key
.
y
:
wall
.
Key
.
y
;
MapManager
.
inst
.
currentMap
.
CreateWall
(
new
Vector2
(
nextx
,
nexty
),
wall
.
Value
.
type
);
Debug
.
Log
(
"created at "
+
nextx
+
", "
+
nexty
);
SubtractRay
(
parRay
,
pair
);
yield
return
null
;
}
}
}
}
MapManager
.
inst
.
currentMap
.
RemoveWall
(
mapPos
);
}
/// <summary>
...
...
@@ -153,7 +173,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
if
(
_parRay
[
i
].
r
-
_parRay
[
i
].
l
<
0.001f
)
_parRay
.
Remove
(
_parRay
[
i
]);
}
Debug
.
Log
(
"Ray count: "
+
_parRay
.
Count
);
Debug
.
Log
(
"
ray to subtract: "
+
_sub
.
l
+
"~"
+
_sub
.
r
+
"\n
Ray count: "
+
_parRay
.
Count
);
foreach
(
var
ray
in
_parRay
)
{
Debug
.
Log
(
"Ray: "
+
ray
.
l
+
"~"
+
ray
.
r
);
...
...
Assets/Scripts/Map/Wall.cs
View file @
a6dc40f5
...
...
@@ -15,13 +15,13 @@ public class Wall : MonoBehaviour
/// Position of this floor at the map.
/// </summary>
public
Vector2
mapPos
;
public
Vector2
Int
ldPos
// left down pos
public
Vector2
ldPos
// left down pos
{
get
{
return
new
Vector2
Int
((
int
)(
mapPos
.
x
+
0.5f
),
(
int
)(
mapPos
.
y
+
0.5f
)
);
}
get
{
return
new
Vector2
(
dir
?
mapPos
.
x
-
0.5f
:
mapPos
.
x
,
!
dir
?
mapPos
.
y
-
0.5f
:
mapPos
.
y
);
}
}
public
Vector2
Int
rdPos
// right down pos
public
Vector2
rdPos
// right down pos
{
get
{
return
ldPos
+
(
dir
?
new
Vector2
Int
(
len
,
0
)
:
new
Vector2Int
(
0
,
len
));
}
get
{
return
ldPos
+
(
dir
?
new
Vector2
(
len
,
0
)
:
new
Vector2
(
0
,
len
));
}
}
public
bool
dir
// false: ver, true: hor
{
...
...
@@ -29,16 +29,4 @@ public class Wall : MonoBehaviour
}
public
int
len
=
1
;
// length of wall
public
WallType
type
;
// Start is called before the first frame update
void
Start
()
{
}
// Update is called once per frame
void
Update
()
{
}
}
Assets/Scripts/Player.cs
View file @
a6dc40f5
...
...
@@ -5,13 +5,9 @@ using UnityEngine.AI;
public
class
Player
:
MonoBehaviour
{
public
Vector2Int
ldPos
{
get
{
return
new
Vector2Int
(
currentFloor
.
mapPos
.
x
,
currentFloor
.
mapPos
.
y
);
}
}
public
Vector2
pos
{
get
{
return
ldPos
+
new
Vector2
(
0.5f
,
0.5f
);
}
get
{
return
new
Vector2
(
currentFloor
.
mapPos
.
x
,
currentFloor
.
mapPos
.
y
);
}
}
Coroutine
playerArrivalCheck
;
...
...
Assets/Scripts/PlayerController.cs
View file @
a6dc40f5
...
...
@@ -71,13 +71,14 @@ public class PlayerController : SingletonBehaviour<PlayerController>
{
prePos
=
MapPos
;
bulletList
.
Add
(
BulletCode
.
Mirror
);
bulletList
.
Add
(
BulletCode
.
Mirror
);
bulletList
.
Add
(
BulletCode
.
False
);
bulletList
.
Add
(
BulletCode
.
False
);
bulletList
.
Add
(
BulletCode
.
False
);
bulletList
.
Add
(
BulletCode
.
Mirror
);
bulletList
.
Add
(
BulletCode
.
False
);
bulletList
.
Add
(
BulletCode
.
Mirror
);
bulletList
.
Add
(
BulletCode
.
False
);
bulletList
.
Add
(
BulletCode
.
Mirror
);
bulletList
.
Add
(
BulletCode
.
False
);
bulletList
.
Add
(
BulletCode
.
Mirror
);
bulletList
.
Add
(
BulletCode
.
False
);
}
...
...
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