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
e901a5c2
Commit
e901a5c2
authored
5 years ago
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
거울 알고리즘 수정 및 마네킹 트리거 위치조정
parent
1be4a515
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
72 deletions
+96
-72
mannequin (4).prefab
Assets/Prefabs/Objects/Mannequin/mannequin (4).prefab
+14
-44
Mirror.cs
Assets/Scripts/Map/Mirror.cs
+82
-28
No files found.
Assets/Prefabs/Objects/Mannequin/mannequin (4).prefab
View file @
e901a5c2
...
...
@@ -11,7 +11,6 @@ GameObject:
-
component
:
{
fileID
:
7532712444690926276
}
-
component
:
{
fileID
:
2757119551192804292
}
-
component
:
{
fileID
:
1737342363823857601
}
-
component
:
{
fileID
:
7820135686568696358
}
m_Layer
:
0
m_Name
:
Cylinder (1)
m_TagString
:
Untagged
...
...
@@ -79,20 +78,6 @@ MeshRenderer:
m_SortingLayerID
:
0
m_SortingLayer
:
0
m_SortingOrder
:
0
---
!u!136
&7820135686568696358
CapsuleCollider
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
4214528635841560197
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_Enabled
:
1
m_Radius
:
0.5000001
m_Height
:
1.9999998
m_Direction
:
1
m_Center
:
{
x
:
0.000000059604634
,
y
:
0
,
z
:
-0.00000008940695
}
---
!u!1
&6169104080419908224
GameObject
:
m_ObjectHideFlags
:
0
...
...
@@ -1091,7 +1076,7 @@ CapsuleCollider:
m_Radius
:
0.14
m_Height
:
0.67
m_Direction
:
1
m_Center
:
{
x
:
-0.03
,
y
:
1.07
,
z
:
0.06
}
m_Center
:
{
x
:
0.06
,
y
:
1.28
,
z
:
0.02
}
---
!u!136
&7520578024426790809
CapsuleCollider
:
m_ObjectHideFlags
:
0
...
...
@@ -1105,7 +1090,7 @@ CapsuleCollider:
m_Radius
:
0.06
m_Height
:
0.82
m_Direction
:
1
m_Center
:
{
x
:
-0.
12
,
y
:
0.34
,
z
:
0.06
}
m_Center
:
{
x
:
-0.
02
,
y
:
0.64
,
z
:
0.09
}
---
!u!135
&8665308411572536972
SphereCollider
:
m_ObjectHideFlags
:
0
...
...
@@ -1118,7 +1103,7 @@ SphereCollider:
m_Enabled
:
1
serializedVersion
:
2
m_Radius
:
0.09
m_Center
:
{
x
:
0.
27
,
y
:
0.59
,
z
:
0.11
}
m_Center
:
{
x
:
0.
16
,
y
:
1.68
,
z
:
0.03
}
---
!u!135
&3177627456582659259
SphereCollider
:
m_ObjectHideFlags
:
0
...
...
@@ -1131,7 +1116,7 @@ SphereCollider:
m_Enabled
:
1
serializedVersion
:
2
m_Radius
:
0.09
m_Center
:
{
x
:
0.2
4
,
y
:
0.23
,
z
:
0.07
}
m_Center
:
{
x
:
0.2
,
y
:
0.36
,
z
:
-0.13
}
---
!u!135
&6611904422136213405
SphereCollider
:
m_ObjectHideFlags
:
0
...
...
@@ -1144,7 +1129,7 @@ SphereCollider:
m_Enabled
:
1
serializedVersion
:
2
m_Radius
:
0.09
m_Center
:
{
x
:
0.
32
,
y
:
0.45
,
z
:
0.13
}
m_Center
:
{
x
:
0.
27
,
y
:
0.53
,
z
:
-0.11
}
---
!u!136
&547261276454492544
CapsuleCollider
:
m_ObjectHideFlags
:
0
...
...
@@ -1156,9 +1141,9 @@ CapsuleCollider:
m_IsTrigger
:
1
m_Enabled
:
1
m_Radius
:
0.08
m_Height
:
0.
4
m_Height
:
0.
27
m_Direction
:
1
m_Center
:
{
x
:
0.24
,
y
:
1.32
,
z
:
0.11
}
m_Center
:
{
x
:
-0.1
,
y
:
1.31
,
z
:
0.12
}
---
!u!135
&1057832123483110392
SphereCollider
:
m_ObjectHideFlags
:
0
...
...
@@ -1171,7 +1156,7 @@ SphereCollider:
m_Enabled
:
1
serializedVersion
:
2
m_Radius
:
0.11
m_Center
:
{
x
:
0.1
3
,
y
:
1.29
,
z
:
0.06
}
m_Center
:
{
x
:
0.1
9
,
y
:
0.89
,
z
:
-0.09
}
---
!u!135
&2060313653279296710
SphereCollider
:
m_ObjectHideFlags
:
0
...
...
@@ -1183,8 +1168,8 @@ SphereCollider:
m_IsTrigger
:
1
m_Enabled
:
1
serializedVersion
:
2
m_Radius
:
0.0
6
m_Center
:
{
x
:
0.
1
,
y
:
1.47
,
z
:
0.15
}
m_Radius
:
0.0
8
m_Center
:
{
x
:
0.
26
,
y
:
1.47
,
z
:
-0.1
}
---
!u!135
&5008880329460952899
SphereCollider
:
m_ObjectHideFlags
:
0
...
...
@@ -1197,7 +1182,7 @@ SphereCollider:
m_Enabled
:
1
serializedVersion
:
2
m_Radius
:
0.09
m_Center
:
{
x
:
0.
15
,
y
:
0.74
,
z
:
0.07
}
m_Center
:
{
x
:
0.
27
,
y
:
0.69
,
z
:
-0.11
}
---
!u!1
&6169104080419908268
GameObject
:
m_ObjectHideFlags
:
0
...
...
@@ -2677,7 +2662,7 @@ GameObject:
-
component
:
{
fileID
:
5778541329035756108
}
m_Layer
:
0
m_Name
:
Cube
m_TagString
:
Untagged
m_TagString
:
Mannequin
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
...
...
@@ -2750,10 +2735,10 @@ BoxCollider:
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
7055982119285520526
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_IsTrigger
:
1
m_Enabled
:
1
serializedVersion
:
2
m_Size
:
{
x
:
0.99999994
,
y
:
0.9999999
,
z
:
0.99999994
}
m_Size
:
{
x
:
2.02
,
y
:
0.9999999
,
z
:
0.99999994
}
m_Center
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!1
&9160474912727509970
GameObject
:
...
...
@@ -2766,7 +2751,6 @@ GameObject:
-
component
:
{
fileID
:
2174992776252301311
}
-
component
:
{
fileID
:
8219032022057428283
}
-
component
:
{
fileID
:
1080991707287384770
}
-
component
:
{
fileID
:
8246746603589846495
}
m_Layer
:
0
m_Name
:
Cylinder (2)
m_TagString
:
Untagged
...
...
@@ -2834,17 +2818,3 @@ MeshRenderer:
m_SortingLayerID
:
0
m_SortingLayer
:
0
m_SortingOrder
:
0
---
!u!136
&8246746603589846495
CapsuleCollider
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
9160474912727509970
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_Enabled
:
1
m_Radius
:
0.5000001
m_Height
:
1.9999998
m_Direction
:
1
m_Center
:
{
x
:
0.000000059604634
,
y
:
0
,
z
:
-0.00000008940695
}
This diff is collapsed.
Click to expand it.
Assets/Scripts/Map/Mirror.cs
View file @
e901a5c2
...
...
@@ -37,21 +37,27 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
new
Pair
(
0
,
1
)
};
int
side
,
i
,
iBack
,
stCheck
;
int
side
,
i
,
reflectSide
,
mapRange
;
bool
isSameRSide
;
if
(
dir
)
// horizontal, parallel with x
{
side
=
(
mapPos
.
y
-
stPos
.
y
>
0
)
?
-
1
:
1
;
reflectSide
=
(
mapPos
.
x
-
stPos
.
x
>
0
)
?
1
:
-
1
;
if
(
isSameRSide
=
mapPos
.
x
==
stPos
.
x
)
mapRange
=
Mathf
.
RoundToInt
(
mapPos
.
x
);
else
mapRange
=
-
reflectSide
*
(
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1
);
i
=
side
>
0
?
Mathf
.
CeilToInt
(
mapPos
.
y
)
:
Mathf
.
FloorToInt
(
mapPos
.
y
);
iBack
=
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
;
reflectSide
=
(
mapPos
.
y
-
stPos
.
y
>
0
)
?
1
:
-
1
;
if
(
isSameRSide
=
mapPos
.
y
==
stPos
.
y
)
mapRange
=
Mathf
.
RoundToInt
(
mapPos
.
y
);
else
mapRange
=
-
reflectSide
*
(
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1
);
i
=
side
>
0
?
Mathf
.
CeilToInt
(
mapPos
.
x
)
:
Mathf
.
FloorToInt
(
mapPos
.
x
);
iBack
=
side
<
0
?
Mathf
.
CeilToInt
(
mapPos
.
x
)
:
Mathf
.
FloorToInt
(
mapPos
.
x
);
stCheck
=
(
int
)
stPos
.
x
;
}
//Debug.Log("side: " + side + ", reflectSide: " + reflectSide + ", i: " + i + ", isSameRSide: " + isSameRSide);
//Debug.Log("minRange: " + mapRange);
yield
return
null
;
// check before reflect (check walls and mirrors)
...
...
@@ -76,15 +82,11 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
floorCountGrid
.
Add
(
floor
.
Key
,
0
);
}
int
minMapRange
=
-
1
*
MapManager
.
inst
.
currentMap
.
maxMapSize
-
1
;
int
maxMapRange
=
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1
;
// start reflection
Vector2Int
frontFloorPos
=
dir
?
new
Vector2Int
(
Mathf
.
RoundToInt
(
mapPos
.
x
),
Mathf
.
RoundToInt
(
mapPos
.
y
+
0.5f
*
side
))
:
new
Vector2Int
(
Mathf
.
RoundToInt
(
mapPos
.
x
+
0.5f
*
side
),
Mathf
.
RoundToInt
(
mapPos
.
y
));
int
frontFloorCount
=
0
;
if
(
floorCountGrid
.
TryGetValue
(
frontFloorPos
,
out
frontFloorCount
))
if
(
floorCountGrid
.
TryGetValue
(
frontFloorPos
,
out
int
frontFloorCount
))
{
if
(
frontFloorCount
==
0
)
floorCountGrid
[
frontFloorPos
]++;
// have floor
}
...
...
@@ -92,12 +94,32 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
{
floorCountGrid
.
Add
(
frontFloorPos
,
-
1
);
}
for
(;
Mathf
.
Abs
(
i
)
<
maxMapRange
;
i
+=
side
)
for
(;
Mathf
.
Abs
(
i
)
<
(
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1
)
;
i
+=
side
)
{
// check walls and copy
for
(
float
j
=
minMapRange
+
0.5f
;
j
<
maxMapRange
+
0.5f
;
j
++
)
bool
anotherSide
=
false
;
for
(
int
j
=
mapRange
;
Mathf
.
Abs
(
j
)
<=
(
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1
);
j
+=
reflectSide
)
{
Vector2
wallPos
=
dir
?
new
Vector2
(
j
,
i
)
:
new
Vector2
(
i
,
j
);
// check floors
Vector2Int
floorPos
=
dir
?
new
Vector2Int
(
j
,
i
)
:
new
Vector2Int
(
i
,
j
);
Pair
floorPair
=
new
Pair
(
PointToParRay
(
stPos
,
floorPos
+
0.5f
*
(
dir
?
new
Vector2
(
reflectSide
,
-
side
)
:
new
Vector2
(-
side
,
reflectSide
)),
true
),
PointToParRay
(
stPos
,
floorPos
+
0.5f
*
(
dir
?
new
Vector2
(-
reflectSide
,
side
)
:
new
Vector2
(
side
,
-
reflectSide
)),
true
));
if
(
IsInRay
(
parRay
,
floorPair
))
{
int
floorCount
;
if
(
floorCountGrid
.
TryGetValue
(
floorPos
,
out
floorCount
))
{
if
(
floorCount
==
0
)
floorCountGrid
[
floorPos
]++;
// have floor
}
else
// no floor on there
{
floorCountGrid
.
Add
(
floorPos
,
-
1
);
}
}
// check walls and copy
Vector2
wallPos
=
dir
?
new
Vector2
(
j
+
0.5f
*
reflectSide
,
i
)
:
new
Vector2
(
i
,
j
+
0.5f
*
reflectSide
);
//Debug.Log(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
)))
:
...
...
@@ -115,29 +137,29 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
if
(
copyWallGrid
.
ContainsKey
(
oppoPos
))
MapManager
.
inst
.
currentMap
.
RemoveWall
(
oppoPos
);
}
}
}
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
)))
if
(
isSameRSide
&&
Mathf
.
Abs
(
j
)
==
(
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1
))
{
int
floorCount
;
if
(
floorCountGrid
.
TryGetValue
(
floorPos
,
out
floorCount
))
if
(
anotherSide
)
{
if
(
floorCount
==
0
)
floorCountGrid
[
floorPos
]++;
// have floor
reflectSide
*=
-
1
;
anotherSide
=
false
;
break
;
}
else
// no floor on there
else
{
floorCountGrid
.
Add
(
floorPos
,
-
1
);
anotherSide
=
true
;
reflectSide
*=
-
1
;
j
=
mapRange
-
reflectSide
;
}
}
}
float
iMid
=
i
+
0.5f
*
side
;
// check walls and copy
for
(
int
j
=
m
inMapRange
;
j
<
maxMapRange
;
j
++
)
for
(
int
j
=
m
apRange
;
Mathf
.
Abs
(
j
)
<=
(
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1
);
j
+=
reflectSide
)
{
Vector2
wallPos
=
dir
?
new
Vector2
(
j
,
iMid
)
:
new
Vector2
(
iMid
,
j
);
//Debug.Log(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
)))
:
...
...
@@ -155,11 +177,27 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
if
(
copyWallGrid
.
ContainsKey
(
oppoPos
))
MapManager
.
inst
.
currentMap
.
RemoveWall
(
oppoPos
);
}
}
if
(
isSameRSide
&&
Mathf
.
Abs
(
j
)
==
(
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1
))
{
if
(
anotherSide
)
{
reflectSide
*=
-
1
;
anotherSide
=
false
;
break
;
}
else
{
anotherSide
=
true
;
reflectSide
*=
-
1
;
j
=
mapRange
-
reflectSide
;
}
}
}
// check floors
for
(
int
j
=
m
inMapRange
;
j
<
maxMapRange
;
j
++
)
for
(
int
j
=
m
apRange
;
Mathf
.
Abs
(
j
)
<=
(
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1
);
j
+=
reflectSide
)
{
Vector2
crossPoint
=
dir
?
new
Vector2
(
j
+
0.5f
,
iMid
)
:
new
Vector2
(
iMid
,
j
+
0.5f
);
Vector2
crossPoint
=
dir
?
new
Vector2
(
j
+
0.5f
*
reflectSide
,
iMid
)
:
new
Vector2
(
iMid
,
j
+
0.5f
*
reflectSide
);
if
(
IsInRayWeak
(
parRay
,
PointToParRay
(
stPos
,
crossPoint
,
true
)))
{
Vector2Int
[]
floorPoses
=
...
...
@@ -182,6 +220,22 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
}
}
}
if
(
isSameRSide
&&
Mathf
.
Abs
(
j
)
==
(
MapManager
.
inst
.
currentMap
.
maxMapSize
+
1
))
{
if
(
anotherSide
)
{
reflectSide
*=
-
1
;
anotherSide
=
false
;
break
;
}
else
{
anotherSide
=
true
;
reflectSide
*=
-
1
;
j
=
mapRange
-
reflectSide
;
}
}
}
}
yield
return
null
;
...
...
This diff is collapsed.
Click to expand it.
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