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
1731374a
Commit
1731374a
authored
Jul 16, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
발사 모드로 들어갈 때 클릭하면 애니메이션 스킵 됨, 총알이 날아가는 도중에는 조작 불가
parent
b06be162
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
31 deletions
+43
-31
Bullet.cs
Assets/Scripts/Bullets/Bullet.cs
+6
-0
FakeBullet.cs
Assets/Scripts/Bullets/FakeBullet.cs
+1
-1
CameraController.cs
Assets/Scripts/CameraController.cs
+27
-21
GameManager.cs
Assets/Scripts/Managers/GameManager.cs
+1
-0
Player.cs
Assets/Scripts/Player.cs
+3
-3
PlayerController.cs
Assets/Scripts/PlayerController.cs
+5
-6
No files found.
Assets/Scripts/Bullets/Bullet.cs
View file @
1731374a
...
...
@@ -12,8 +12,14 @@ public abstract class Bullet : MonoBehaviour
rb
=
GetComponent
<
Rigidbody
>();
}
private
void
OnDestroy
()
{
GameManager
.
inst
.
isBulletFlying
=
false
;
}
public
void
Init
(
Vector3
velocity
)
{
GameManager
.
inst
.
isBulletFlying
=
true
;
GetComponent
<
Rigidbody
>().
velocity
=
velocity
;
Destroy
(
gameObject
,
MapManager
.
inst
.
currentMap
.
maxMapSize
/
velocity
.
magnitude
);
}
...
...
Assets/Scripts/Bullets/FakeBullet.cs
View file @
1731374a
...
...
@@ -10,6 +10,6 @@ public class FakeBullet : Bullet
{
other
.
GetComponent
<
IBulletInteractor
>().
Interact
(
this
);
}
Destroy
(
gameObject
);
Destroy
(
gameObject
);
}
}
Assets/Scripts/CameraController.cs
View file @
1731374a
...
...
@@ -80,23 +80,32 @@ public class CameraController : MonoBehaviour
Vector3
posDiff
=
(
player
.
head
.
transform
.
position
-
transform
.
position
)
/
40
;
float
fovDiff
=
(
shootingFov
-
mapFov
)
/
40f
;
float
angleDiff
=
-
30f
/
40f
;
PlayerControll
er
.
inst
.
isZooming
=
true
;
GameManag
er
.
inst
.
isZooming
=
true
;
previousPos
=
transform
.
position
;
previousAngle
=
new
Vector3
(
transform
.
eulerAngles
.
x
>
180
?
transform
.
eulerAngles
.
x
-
360
:
transform
.
eulerAngles
.
x
,
transform
.
eulerAngles
.
y
>
180
?
transform
.
eulerAngles
.
y
-
360
:
transform
.
eulerAngles
.
y
,
transform
.
eulerAngles
.
z
>
180
?
transform
.
eulerAngles
.
z
-
360
:
transform
.
eulerAngles
.
z
);
for
(
int
i
=
0
;
i
<
40
;
i
++)
int
i
;
for
(
i
=
0
;
i
<
40
;
i
++)
{
yield
return
null
;
if
(
Input
.
GetMouseButtonDown
(
0
))
break
;
transform
.
position
+=
posDiff
;
transform
.
eulerAngles
+=
new
Vector3
(
angleDiff
,
0
,
0
);
Camera
.
main
.
fieldOfView
+=
fovDiff
;
}
if
(
i
<
40
)
{
transform
.
position
+=
posDiff
*
(
40
-
i
);
transform
.
eulerAngles
+=
new
Vector3
(
angleDiff
*
(
40
-
i
),
0
,
0
);
Camera
.
main
.
fieldOfView
+=
fovDiff
*
(
40
-
i
);
}
player
.
transform
.
eulerAngles
=
new
Vector3
(
player
.
transform
.
eulerAngles
.
x
,
transform
.
eulerAngles
.
y
,
player
.
transform
.
eulerAngles
.
z
);
transform
.
position
=
player
.
head
.
transform
.
position
;
rotationX
=
transform
.
eulerAngles
.
y
;
rotationY
=
transform
.
eulerAngles
.
x
;
PlayerControll
er
.
inst
.
isZooming
=
false
;
GameManag
er
.
inst
.
isZooming
=
false
;
player
.
laser
.
SetActive
(
true
);
player
.
anim
.
SetBool
(
"isShooting"
,
true
);
player
.
head
.
transform
.
Find
(
"Head 19"
).
gameObject
.
layer
=
LayerMask
.
NameToLayer
(
"Head"
);
...
...
@@ -115,7 +124,7 @@ public class CameraController : MonoBehaviour
Vector3
posDiff
=
(
previousPos
-
transform
.
position
)
/
40
;
float
fovDiff
=
(
mapFov
-
shootingFov
)
/
40f
;
player
.
laser
.
SetActive
(
false
);
PlayerControll
er
.
inst
.
isZooming
=
true
;
GameManag
er
.
inst
.
isZooming
=
true
;
player
.
anim
.
SetBool
(
"isShooting"
,
false
);
player
.
head
.
transform
.
Find
(
"Head 19"
).
gameObject
.
layer
=
LayerMask
.
NameToLayer
(
"Player"
);
player
.
head
.
SetActive
(
true
);
...
...
@@ -126,16 +135,25 @@ public class CameraController : MonoBehaviour
angleDiff
=
new
Vector3
(
angleDiff
.
x
>
180
?
360
-
angleDiff
.
x
:
angleDiff
.
x
,
angleDiff
.
y
>
180
?
360
-
angleDiff
.
y
:
angleDiff
.
y
,
angleDiff
.
z
>
180
?
360
-
angleDiff
.
z
:
angleDiff
.
z
);
for
(
int
i
=
0
;
i
<
40
;
i
++)
int
i
;
for
(
i
=
0
;
i
<
40
;
i
++)
{
yield
return
null
;
if
(
Input
.
GetMouseButtonDown
(
0
))
break
;
transform
.
position
+=
posDiff
;
transform
.
eulerAngles
+=
angleDiff
;
Camera
.
main
.
fieldOfView
+=
fovDiff
;
}
if
(
i
<
40
)
{
transform
.
position
+=
posDiff
*
(
40
-
i
);
transform
.
eulerAngles
+=
angleDiff
*
(
40
-
i
);
Camera
.
main
.
fieldOfView
+=
fovDiff
*
(
40
-
i
);
}
transform
.
position
=
previousPos
;
PlayerControll
er
.
inst
.
isPlayerShooting
=
false
;
PlayerControll
er
.
inst
.
isZooming
=
false
;
GameManag
er
.
inst
.
isPlayerShooting
=
false
;
GameManag
er
.
inst
.
isZooming
=
false
;
// Visible mouse cursor
Cursor
.
visible
=
true
;
...
...
@@ -153,22 +171,10 @@ public class CameraController : MonoBehaviour
// Update is called once per frame
void
Update
()
{
if
(!
PlayerControll
er
.
inst
.
isZooming
)
if
(!
GameManag
er
.
inst
.
isZooming
)
{
if
(!
PlayerControll
er
.
inst
.
isPlayerShooting
)
if
(!
GameManag
er
.
inst
.
isPlayerShooting
)
{
CameraMove
();
CameraDrag
();
}
...
...
Assets/Scripts/Managers/GameManager.cs
View file @
1731374a
...
...
@@ -12,6 +12,7 @@ public class GameManager : SingletonBehaviour<GameManager>
[
Space
(
10
)]
public
bool
isGameOver
=
false
;
public
bool
isPlayerMoving
,
isPlayerShooting
,
isZooming
,
isBulletFlying
;
public
int
[]
clearIndex
=
new
int
[
9
];
public
int
clearCounter
=
0
;
...
...
Assets/Scripts/Player.cs
View file @
1731374a
...
...
@@ -59,7 +59,7 @@ public class Player : MonoBehaviour
agent
.
CalculatePath
(
destination
,
path
);
if
(
path
.
status
==
NavMeshPathStatus
.
PathComplete
)
{
PlayerControll
er
.
inst
.
isPlayerMoving
=
true
;
GameManag
er
.
inst
.
isPlayerMoving
=
true
;
playerArrivalCheck
=
StartCoroutine
(
CheckIfPlayerArrived
(
destination
));
GetComponent
<
NavMeshAgent
>().
SetDestination
(
destination
);
}
...
...
@@ -82,7 +82,7 @@ public class Player : MonoBehaviour
currentFloor
.
isPlayerOn
=
true
;
PlayerController
.
inst
.
CheckCurrentFloors
();
anim
.
SetBool
(
"isWalking"
,
false
);
PlayerControll
er
.
inst
.
isPlayerMoving
=
false
;
GameManag
er
.
inst
.
isPlayerMoving
=
false
;
}
/// <summary>
/// Count 2 second to make player in shooting mode.
...
...
@@ -102,7 +102,7 @@ public class Player : MonoBehaviour
}
if
(
time
>
endTime
)
{
PlayerControll
er
.
inst
.
isPlayerShooting
=
true
;
GameManag
er
.
inst
.
isPlayerShooting
=
true
;
StartCoroutine
(
Camera
.
main
.
GetComponent
<
CameraController
>().
ZoomInAtPlayer
(
this
));
}
}
...
...
Assets/Scripts/PlayerController.cs
View file @
1731374a
...
...
@@ -7,7 +7,6 @@ using UnityEngine.AI;
public
class
PlayerController
:
SingletonBehaviour
<
PlayerController
>
{
public
Player
currentPlayer
;
public
bool
isPlayerMoving
,
isPlayerShooting
,
isZooming
;
public
List
<
BulletCode
>
bulletList
=
new
List
<
BulletCode
>();
private
Vector2Int
prePos
;
public
Vector2Int
MapPos
...
...
@@ -143,12 +142,12 @@ public class PlayerController : SingletonBehaviour<PlayerController>
}
//Control player only if camera is not zooming in to or out from the current player
if
(!
isZoom
ing
)
if
(!
GameManager
.
inst
.
isZooming
&&
!
GameManager
.
inst
.
isBulletFly
ing
)
{
if
(
Input
.
GetMouseButtonDown
(
0
))
{
//Move the current player.
if
(!
isPlayerMoving
&&
!
isPlayerShooting
)
if
(!
GameManager
.
inst
.
isPlayerMoving
&&
!
GameManager
.
inst
.
isPlayerShooting
)
{
Ray
mouseRay
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
RaycastHit
hit
;
...
...
@@ -173,7 +172,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
currentPlayer
.
ResetCurrentPlayer
();
}
}
else
if
(
isPlayerShooting
)
else
if
(
GameManager
.
inst
.
isPlayerShooting
)
{
if
(
bulletList
.
Count
>
0
)
{
...
...
@@ -181,7 +180,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
}
}
}
else
if
(
Input
.
GetMouseButtonDown
(
1
)
&&
isPlayerShooting
)
else
if
(
Input
.
GetMouseButtonDown
(
1
)
&&
GameManager
.
inst
.
isPlayerShooting
)
{
StartCoroutine
(
Camera
.
main
.
GetComponent
<
CameraController
>().
ZoomOutFromPlayer
(
currentPlayer
));
currentPlayer
.
shootingArm
.
rotation
=
currentPlayer
.
armRotation
;
...
...
@@ -196,7 +195,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
{
if
(
currentPlayer
.
GetComponent
<
NavMeshAgent
>().
velocity
.
magnitude
>
0
)
transform
.
rotation
=
Quaternion
.
LookRotation
(
currentPlayer
.
GetComponent
<
NavMeshAgent
>().
velocity
.
normalized
);
if
(
isPlayerShooting
)
if
(
GameManager
.
inst
.
isPlayerShooting
)
{
Quaternion
destinationRotation
=
Quaternion
.
Euler
(
new
Vector3
(
transform
.
eulerAngles
.
x
,
Camera
.
main
.
transform
.
eulerAngles
.
y
,
currentPlayer
.
transform
.
eulerAngles
.
z
));
currentPlayer
.
transform
.
rotation
=
Quaternion
.
Lerp
(
currentPlayer
.
transform
.
rotation
,
destinationRotation
,
Time
.
deltaTime
*
10
);
...
...
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