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
487461c5
Commit
487461c5
authored
Jul 23, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/map' into polish
parents
083a5304
1731374a
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
53 additions
and
46 deletions
+53
-46
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
CameraTurret.cs
Assets/Scripts/Interactors/CameraTurret.cs
+1
-2
Mannequin.cs
Assets/Scripts/Interactors/Mannequin.cs
+3
-6
GameManager.cs
Assets/Scripts/Managers/GameManager.cs
+1
-0
MapManager.cs
Assets/Scripts/Managers/MapManager.cs
+1
-3
ClearCondition.cs
Assets/Scripts/Map/ClearCondition.cs
+3
-2
Map.cs
Assets/Scripts/Map/Map.cs
+2
-2
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 @
487461c5
...
...
@@ -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 @
487461c5
...
...
@@ -10,6 +10,6 @@ public class FakeBullet : Bullet
{
other
.
GetComponent
<
IBulletInteractor
>().
Interact
(
this
);
}
Destroy
(
gameObject
);
Destroy
(
gameObject
);
}
}
Assets/Scripts/CameraController.cs
View file @
487461c5
...
...
@@ -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/Interactors/CameraTurret.cs
View file @
487461c5
...
...
@@ -27,14 +27,13 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto
public
void
Interact
(
Vector2Int
pos
)
{
if
(!
GameManager
.
inst
.
isGameOver
)
if
(!
GameManager
.
inst
.
isGameOver
&&
PlayerController
.
inst
.
currentPlayer
!=
null
)
{
if
(
Position
.
IsInAdjacentArea
(
pos
,
1
)
&&
MapManager
.
inst
.
currentMap
.
GetWallAtPos
((
Vector2
)(
Position
+
pos
)
/
2
)
==
null
)
{
GameManager
.
inst
.
isGameOver
=
true
;
StartCoroutine
(
GameManager
.
inst
.
RestartStage
());
GameManager
.
inst
.
uiGenerator
.
ResetAllClearUIs
();
//TODO : Restart Level
}
}
...
...
Assets/Scripts/Interactors/Mannequin.cs
View file @
487461c5
...
...
@@ -70,18 +70,15 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor
transform
.
Rotate
(
new
Vector3
(
0
,
Random
.
Range
(
0
,
4
)
*
90
,
0
));
isWhite
=
true
;
Color
=
Color
.
white
;
if
(
GameManager
.
white
>=
0
)
MapManager
.
inst
.
currentMap
.
clearConditions
[
GameManager
.
white
].
IsDone
(
1
);
//
if (GameManager.white >= 0) MapManager.inst.currentMap.clearConditions[GameManager.white].IsDone(1);
}
public
void
SetColor
(
bool
isWhite
)
{
Color
=
isWhite
?
Color
.
white
:
Color
.
black
;
this
.
isWhite
=
isWhite
;
if
(
GameManager
.
black
>=
0
&&
!
isWhite
)
{
MapManager
.
inst
.
currentMap
.
clearConditions
[
GameManager
.
black
].
count
++;
if
(
GameManager
.
white
>=
0
)
MapManager
.
inst
.
currentMap
.
clearConditions
[
GameManager
.
white
].
count
--;
}
if
(
GameManager
.
black
>=
0
&&
!
isWhite
)
MapManager
.
inst
.
currentMap
.
clearConditions
[
GameManager
.
black
].
count
++;
if
(
GameManager
.
white
>=
0
&&
isWhite
)
MapManager
.
inst
.
currentMap
.
clearConditions
[
GameManager
.
white
].
count
++;
}
#
region
IObject
Override
...
...
Assets/Scripts/Managers/GameManager.cs
View file @
487461c5
...
...
@@ -13,6 +13,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/Managers/MapManager.cs
View file @
487461c5
...
...
@@ -91,15 +91,13 @@ public class MapManager : SingletonBehaviour<MapManager>
if
(!
child
.
GetComponent
<
Mannequin
>().
isWhite
&&
GameManager
.
black
>=
0
)
currentMap
.
clearConditions
[
GameManager
.
black
].
IsDone
(
1
);
}
}
for
(
int
i
=
0
;
i
<
currentMap
.
startFloors
.
Count
;
i
++)
PlayerController
.
inst
.
CreatePlayer
(
currentMap
.
startFloors
[
i
]);
for
(
int
i
=
0
;
i
<
loadedMapData
.
bullets
.
Count
;
i
++)
PlayerController
.
inst
.
AddBullet
(
loadedMapData
.
bullets
[
i
]);
}
public
IEnumerator
Rebaker
()
{
yield
return
null
;
...
...
Assets/Scripts/Map/ClearCondition.cs
View file @
487461c5
...
...
@@ -25,14 +25,15 @@ public class ClearCondition
count
+=
_count
;
goal
+=
_goal
;
assignedClearUI
.
RefreshClearCondition
();
if
(
goal
<=
count
&&
!
isDone
)
if
(
(
type
==
ClearType
.
White
||
type
==
ClearType
.
Black
)
?
goal
==
count
:
goal
<=
count
&&
!
isDone
)
{
GameManager
.
inst
.
clearCounter
--;
isDone
=
true
;
Debug
.
Log
(
GameManager
.
inst
.
clearCounter
);
if
(
GameManager
.
inst
.
clearCounter
==
0
)
GameManager
.
inst
.
StartCoroutine
(
GameManager
.
inst
.
ClearStage
());
}
else
if
(
goal
>
count
)
else
if
(
(
type
==
ClearType
.
White
||
type
==
ClearType
.
Black
)
?
goal
!=
count
:
goal
>
count
&&
isDone
)
{
GameManager
.
inst
.
clearCounter
++;
isDone
=
false
;
...
...
Assets/Scripts/Map/Map.cs
View file @
487461c5
...
...
@@ -266,9 +266,9 @@ public class Map : MonoBehaviour
else
if
(
objectGrid
[
pos
].
GetType
()
==
ObjType
.
Mannequin
)
{
if
(
objectGrid
[
pos
].
GetObject
().
GetComponent
<
Mannequin
>().
isWhite
&&
GameManager
.
white
>=
0
)
clearConditions
[
GameManager
.
white
].
IsDone
(
0
,
-
1
);
clearConditions
[
GameManager
.
white
].
IsDone
(-
1
);
else
if
(!
objectGrid
[
pos
].
GetObject
().
GetComponent
<
Mannequin
>().
isWhite
&&
GameManager
.
black
>=
0
)
clearConditions
[
GameManager
.
black
].
IsDone
(
0
,
-
1
);
clearConditions
[
GameManager
.
black
].
IsDone
(-
1
);
}
if
(
objectGrid
[
pos
].
GetType
()
!=
ObjType
.
Mannequin
)
PlayerController
.
inst
.
OnPlayerMove
-=
objectGrid
[
pos
].
GetObject
().
GetComponent
<
IPlayerInteractor
>().
Interact
;
...
...
Assets/Scripts/Player.cs
View file @
487461c5
...
...
@@ -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 @
487461c5
...
...
@@ -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
...
...
@@ -144,12 +143,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
;
...
...
@@ -174,7 +173,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
currentPlayer
.
ResetCurrentPlayer
();
}
}
else
if
(
isPlayerShooting
)
else
if
(
GameManager
.
inst
.
isPlayerShooting
)
{
if
(
bulletList
.
Count
>
0
)
{
...
...
@@ -182,7 +181,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
;
...
...
@@ -197,7 +196,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