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
fba076cb
Commit
fba076cb
authored
May 04, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
일단 위키 거짓탄로직 문서에 있는대로 다 추가함
parent
060591d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
1 deletion
+93
-1
ModelScene.meta
Assets/Scenes/ModelScene.meta
+8
-0
Mirror.cs
Assets/Scripts/Interactors/Mirror.cs
+85
-1
No files found.
Assets/Scenes/ModelScene.meta
0 → 100644
View file @
fba076cb
fileFormatVersion: 2
guid: a32ca40f7f255ea47ac7ee9d558755ce
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Interactors/Mirror.cs
View file @
fba076cb
...
...
@@ -8,6 +8,11 @@ public class Mirror : MonoBehaviour, IBulletInteractor, IBreakable
private
Camera
camera
;
private
RenderTexture
rt
;
// data about this mirror
private
Vector2Int
pos
;
// position of mirror(left down)
private
int
len
;
// length of mirror
private
bool
dir
;
// false: ver, true: hor
public
void
Break
()
{
Destroy
(
gameObject
);
...
...
@@ -17,7 +22,12 @@ public class Mirror : MonoBehaviour, IBulletInteractor, IBreakable
{
if
(
bullet
is
FakeBullet
)
{
//Break Mirror & Make reflected objects
// Make reflected objects
CopyObject
(
gameObject
.
transform
);
}
else
if
(
bullet
is
TruthBullet
)
{
// Break Mirror
}
}
...
...
@@ -31,4 +41,78 @@ public class Mirror : MonoBehaviour, IBulletInteractor, IBreakable
{
//TODO :Calculate Camera's Position and Rotation
}
/// <summary>
/// copy objects which reflected by this mirror
/// </summary>
/// <param name="_shooter">transform of shooter</param>
private
void
CopyObject
(
Transform
_shooter
)
{
Vector2Int
stPos
;
// position of shooter's cell
Vector2
rstPos
;
// real position of shooter
List
<
Pair
<
float
,
float
>>
parRay
=
new
List
<
Pair
<
float
,
float
>>
{
new
Pair
<
float
,
float
>(
0
,
1
)
};
// TODO: stPos부터 pos까지 검사해 벽이나 거울이 있을경우 SubtractRay
// TODO: pos부터 맵의 끝까지 검사해 맵의 각 요소가 IfInRay면 거울 반대편에 복사, 벽이나 거울이면 SubtractRay
}
/// <summary>
/// subtract _sub from _parRay
/// </summary>
/// <param name="_parRay">ray list to subtracted</param>
/// <param name="_sub">ray to subtract</param>
void
SubtractRay
(
List
<
Pair
<
float
,
float
>>
_parRay
,
Pair
<
float
,
float
>
_sub
)
{
foreach
(
Pair
<
float
,
float
>
pair
in
_parRay
)
{
if
(
pair
.
r
<
_sub
.
l
||
pair
.
l
>
_sub
.
r
)
continue
;
float
[]
arr
=
{
pair
.
l
,
pair
.
r
,
_sub
.
l
,
_sub
.
r
};
// TODO: sort arr
// TODO: _parRay에서 _sub을 뺀다.
}
}
/// <summary>
/// check if _range is included in _parRay
/// </summary>
/// <param name="_parRay">ray list to be checked</param>
/// <param name="_range">range to check</param>
/// <returns>if _range is included in _parRay, return true</returns>
bool
IsInRay
(
List
<
Pair
<
float
,
float
>>
_parRay
,
Pair
<
float
,
float
>
_range
)
{
bool
output
=
false
;
foreach
(
Pair
<
float
,
float
>
pair
in
_parRay
)
{
if
(
pair
.
r
<=
_range
.
l
||
pair
.
l
>=
_range
.
r
)
continue
;
else
{
output
=
true
;
break
;
}
}
return
output
;
}
/// <summary>
/// calculate where _chPos is from _stPos
/// </summary>
/// <param name="stPos">position of shooter</param>
/// <param name="chPos">position of object</param>
/// <param name="isRefl">if we calculate after reflecting, true</param>
/// <returns>float value of _chPos is posed</returns>
float
PointToParRay
(
Vector2
_stPos
,
Vector2
_chPos
,
bool
_isRefl
)
{
if
(
dir
)
// horizontal
{
float
dist
=
_chPos
.
y
-
_stPos
.
y
+
(
_isRefl
?
(
pos
.
y
-
_chPos
.
y
)
*
2
:
0
);
float
spreadLen
=
len
*
dist
/
(
pos
.
y
-
_stPos
.
y
);
float
rayStPos
=
_stPos
.
x
+
(
pos
.
x
-
_stPos
.
x
)
*
dist
/
(
pos
.
y
-
_stPos
.
y
);
return
(
_chPos
.
x
-
rayStPos
)
/
spreadLen
;
}
// TODO: when dir is vertical
return
0
;
}
}
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