Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
WidowmakerSimulator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
15박보승
WidowmakerSimulator
Commits
c5f154dc
Commit
c5f154dc
authored
Oct 06, 2019
by
15박보승
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
훅 움직임 개선/맵 밖으로 나가고 10초가 지날시 패배가 되도록 구현
parent
d26f8bbc
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
127 additions
and
57 deletions
+127
-57
Missile.prefab
Grapplers/Assets/Prefabs/Missile.prefab
+2
-1
SampleScene.unity
Grapplers/Assets/Scenes/SampleScene.unity
+45
-29
DistanceJoint3D.cs
Grapplers/Assets/Scripts/DistanceJoint3D.cs
+32
-7
Enemy.cs
Grapplers/Assets/Scripts/Enemy/Enemy.cs
+5
-0
Missile.cs
Grapplers/Assets/Scripts/Enemy/Missile.cs
+1
-1
MapManager.cs
Grapplers/Assets/Scripts/MapManager.cs
+6
-2
PlayerController.cs
Grapplers/Assets/Scripts/PlayerController.cs
+20
-5
WeaponBehaviour.cs
Grapplers/Assets/Scripts/WeaponBehaviour.cs
+16
-12
No files found.
Grapplers/Assets/Prefabs/Missile.prefab
View file @
c5f154dc
...
...
@@ -111,7 +111,7 @@ MonoBehaviour:
curHealth
:
0
attackDamage
:
5
detectRange
:
0
moveSpeed
:
0.5
moveSpeed
:
20
playerMask
:
serializedVersion
:
2
m_Bits
:
256
...
...
@@ -119,6 +119,7 @@ MonoBehaviour:
bloodEffect
:
{
fileID
:
0
}
shotSpeed
:
0
shotTimeInterval
:
0
rb
:
{
fileID
:
0
}
---
!u!54
&13760249356785958
Rigidbody
:
m_ObjectHideFlags
:
0
...
...
Grapplers/Assets/Scenes/SampleScene.unity
View file @
c5f154dc
...
...
@@ -154,7 +154,7 @@ Transform:
m_LocalScale
:
{
x
:
0.1
,
y
:
0.1
,
z
:
0.1
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
4
m_RootOrder
:
3
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!135
&48712144
SphereCollider
:
...
...
@@ -502,7 +502,7 @@ PrefabInstance:
-
target
:
{
fileID
:
808483076966640907
,
guid
:
60f985c4e15827746af49ee480a2d6f9
,
type
:
3
}
propertyPath
:
m_RootOrder
value
:
1
4
value
:
1
3
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
808483076966640907
,
guid
:
60f985c4e15827746af49ee480a2d6f9
,
type
:
3
}
...
...
@@ -558,8 +558,9 @@ Transform:
-
{
fileID
:
60348337
}
-
{
fileID
:
245057451
}
-
{
fileID
:
1077217540
}
-
{
fileID
:
825443685
}
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
10
m_RootOrder
:
9
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!114
&235153516
MonoBehaviour
:
...
...
@@ -1014,7 +1015,7 @@ RectTransform:
-
{
fileID
:
274921780
}
-
{
fileID
:
1972759491
}
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
7
m_RootOrder
:
6
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMax
:
{
x
:
0
,
y
:
0
}
...
...
@@ -1199,7 +1200,7 @@ PrefabInstance:
-
target
:
{
fileID
:
808483076966640907
,
guid
:
60f985c4e15827746af49ee480a2d6f9
,
type
:
3
}
propertyPath
:
m_RootOrder
value
:
1
5
value
:
1
4
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
808483076966640907
,
guid
:
60f985c4e15827746af49ee480a2d6f9
,
type
:
3
}
...
...
@@ -1395,12 +1396,12 @@ Transform:
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
825443681
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
50
,
z
:
19
}
m_LocalScale
:
{
x
:
20
,
y
:
10
,
z
:
20
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
2
m_Father
:
{
fileID
:
235153515
}
m_RootOrder
:
9
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!54
&825443686
Rigidbody
:
...
...
@@ -1599,7 +1600,7 @@ Transform:
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
5
m_RootOrder
:
4
m_LocalEulerAnglesHint
:
{
x
:
30
,
y
:
0
,
z
:
0
}
---
!u!114
&963194229
MonoBehaviour
:
...
...
@@ -1851,7 +1852,7 @@ Transform:
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
9
m_RootOrder
:
8
m_LocalEulerAnglesHint
:
{
x
:
-90
,
y
:
0
,
z
:
0
}
---
!u!199
&1086498342
ParticleSystemRenderer
:
...
...
@@ -2749,7 +2750,7 @@ ParticleSystem:
rateOverTime
:
serializedVersion
:
2
minMaxState
:
0
scalar
:
5
0
scalar
:
1
0
minScalar
:
10
maxCurve
:
serializedVersion
:
2
...
...
@@ -6636,7 +6637,7 @@ PrefabInstance:
-
target
:
{
fileID
:
808483076966640907
,
guid
:
60f985c4e15827746af49ee480a2d6f9
,
type
:
3
}
propertyPath
:
m_RootOrder
value
:
1
1
value
:
1
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
808483076966640907
,
guid
:
60f985c4e15827746af49ee480a2d6f9
,
type
:
3
}
...
...
@@ -6671,6 +6672,7 @@ GameObject:
-
component
:
{
fileID
:
1171556385
}
-
component
:
{
fileID
:
1171556383
}
-
component
:
{
fileID
:
1171556390
}
-
component
:
{
fileID
:
1171556391
}
m_Layer
:
8
m_Name
:
Player
m_TagString
:
Untagged
...
...
@@ -6709,6 +6711,8 @@ MonoBehaviour:
ConnectedRigidbody
:
{
fileID
:
48712147
}
distance
:
0
damper
:
0
moveDelta
:
{
x
:
0
,
y
:
0
,
z
:
0
}
ps
:
20
---
!u!143
&1171556385
CharacterController
:
m_ObjectHideFlags
:
0
...
...
@@ -6787,7 +6791,7 @@ Transform:
-
{
fileID
:
887314839
}
-
{
fileID
:
1266258514
}
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
3
m_RootOrder
:
2
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!114
&1171556389
MonoBehaviour
:
...
...
@@ -6807,18 +6811,6 @@ MonoBehaviour:
groundMask
:
serializedVersion
:
2
m_Bits
:
1
knifeDamage
:
50
gunDamage
:
1
gunRange
:
50
bulletEffect
:
{
fileID
:
1266258516
}
knifeRange
:
3
knifeEffect
:
{
fileID
:
0
}
enemyMask
:
serializedVersion
:
2
m_Bits
:
1024
blockMask
:
serializedVersion
:
2
m_Bits
:
55
---
!u!136
&1171556390
CapsuleCollider
:
m_ObjectHideFlags
:
0
...
...
@@ -6833,6 +6825,30 @@ CapsuleCollider:
m_Height
:
2
m_Direction
:
1
m_Center
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!114
&1171556391
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1171556382
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
d8563877a588e844da7d4f831005a6b4
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
knifeDamage
:
50
gunDamage
:
1
gunRange
:
50
bulletEffect
:
{
fileID
:
1266258516
}
knifeRange
:
10
knifeEffect
:
{
fileID
:
0
}
enemyMask
:
serializedVersion
:
2
m_Bits
:
1024
blockMask
:
serializedVersion
:
2
m_Bits
:
55
---
!u!1
&1266258513
GameObject
:
m_ObjectHideFlags
:
0
...
...
@@ -11759,7 +11775,7 @@ Transform:
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
8
m_RootOrder
:
7
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!1001
&1457301417
PrefabInstance
:
...
...
@@ -11811,7 +11827,7 @@ PrefabInstance:
-
target
:
{
fileID
:
808483076966640907
,
guid
:
60f985c4e15827746af49ee480a2d6f9
,
type
:
3
}
propertyPath
:
m_RootOrder
value
:
1
3
value
:
1
2
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
808483076966640907
,
guid
:
60f985c4e15827746af49ee480a2d6f9
,
type
:
3
}
...
...
@@ -12094,7 +12110,7 @@ Transform:
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
6
m_RootOrder
:
5
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!1
&1873763589
GameObject
:
...
...
@@ -12257,7 +12273,7 @@ PrefabInstance:
-
target
:
{
fileID
:
808483076966640907
,
guid
:
60f985c4e15827746af49ee480a2d6f9
,
type
:
3
}
propertyPath
:
m_RootOrder
value
:
1
2
value
:
1
1
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
808483076966640907
,
guid
:
60f985c4e15827746af49ee480a2d6f9
,
type
:
3
}
...
...
Grapplers/Assets/Scripts/DistanceJoint3D.cs
View file @
c5f154dc
...
...
@@ -8,8 +8,13 @@ public class DistanceJoint3D : MonoBehaviour
public
float
distance
;
public
float
damper
=
5f
;
public
Vector3
moveDelta
;
private
Rigidbody
rb
;
[
SerializeField
]
private
float
ps
=
10
;
private
void
Awake
()
{
rb
=
GetComponent
<
Rigidbody
>();
...
...
@@ -24,8 +29,8 @@ public class DistanceJoint3D : MonoBehaviour
{
if
(
distance
>
0
)
{
distance
=
Mathf
.
Max
(
0
,
distance
-
100
*
Time
.
deltaTime
);
//distance = Mathf.Lerp(distance, 0, 0.
8
f);
distance
=
Mathf
.
Max
(
0
,
distance
-
ps
*
Time
.
deltaTime
);
//distance = Mathf.Lerp(distance, 0, 0.
1
f);
}
}
private
void
FixedUpdate
()
...
...
@@ -35,10 +40,30 @@ public class DistanceJoint3D : MonoBehaviour
var
distanceDiscrepancy
=
distance
-
connection
.
magnitude
;
//rb.position += distanceDiscrepancy * connection.normalized;
rb
.
AddForce
(-
connection
,
ForceMode
.
Acceleration
);
var
velocityTarget
=
connection
+
rb
.
velocity
;
var
projectOnConnect
=
Vector3
.
Project
(
velocityTarget
,
connection
);
rb
.
velocity
=
(
velocityTarget
-
projectOnConnect
+
/*distanceDiscrepancy */
-
ps
*
connection
.
normalized
+
(
projectOnConnect
-
connection
)
*
0.1f
)
/
(
1
+
damper
*
Time
.
fixedDeltaTime
);
rb
.
AddForce
(
moveDelta
);
//rb.position += distanceDiscrepancy * connection.normalized;
/*
float distanceDelta = Vector3.Dot(rb.velocity, connection.normalized);
Debug.Log(distanceDelta);
if (distanceDelta > 0)
{
distance += distanceDelta;
rb.velocity -= connection.normalized;
}
else
{
var velocityTarget = connection + rb.velocity;
var projectOnConnect = Vector3.Project(velocityTarget, connection);
rb.velocity = (velocityTarget - projectOnConnect + distanceDiscrepancy * connection.normalized) / (1 + damper * Time.fixedDeltaTime);
}
*/
}
}
Grapplers/Assets/Scripts/Enemy/Enemy.cs
View file @
c5f154dc
...
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
UnityEngine
;
using
UnityEngine.UI
;
[
RequireComponent
(
typeof
(
Rigidbody
))]
public
abstract
class
Enemy
:
MonoBehaviour
{
[
SerializeField
]
...
...
@@ -38,6 +39,9 @@ public abstract class Enemy : MonoBehaviour
private
float
shotTimeInterval
;
private
float
shotTimer
;
[
SerializeField
]
protected
Rigidbody
rb
;
public
bool
IsDead
{
get
{
return
curHealth
<=
0
;
}
}
#if UNITY_EDITOR
...
...
@@ -51,6 +55,7 @@ public abstract class Enemy : MonoBehaviour
private
void
Start
()
{
col
=
GetComponent
<
Collider
>();
rb
=
GetComponent
<
Rigidbody
>();
curHealth
=
maxHealth
;
InitializeStateMachine
();
}
...
...
Grapplers/Assets/Scripts/Enemy/Missile.cs
View file @
c5f154dc
...
...
@@ -10,7 +10,7 @@ public class Missile : Enemy
idle
.
StateUpdate
+=
delegate
{
transform
.
position
+
=
(
target
.
transform
.
position
-
transform
.
position
).
normalized
*
moveSpeed
;
rb
.
velocity
=
(
target
.
transform
.
position
-
transform
.
position
).
normalized
*
moveSpeed
;
};
stateMachine
.
AddNewState
(
idle
);
...
...
Grapplers/Assets/Scripts/MapManager.cs
View file @
c5f154dc
...
...
@@ -2,7 +2,7 @@
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
MapManager
:
MonoBehaviour
public
class
MapManager
:
SingletonBehaviour
<
MapManager
>
{
private
float
nextMapBlockGenerateDistance
;
private
float
nextEnemyGenerateDistance
;
...
...
@@ -23,10 +23,14 @@ public class MapManager : MonoBehaviour
mapBound
.
center
=
new
Vector3
(
0
,
height
,
0
);
foreach
(
Transform
child
in
transform
)
{
if
(
child
.
position
.
y
<
height
-
500
)
if
(
child
.
position
.
y
<
height
-
mapBound
.
extents
.
y
)
{
child
.
gameObject
.
SetActive
(
false
);
}
}
}
public
bool
IsOutOfMapBounds
(
Vector3
pos
)
{
return
!
mapBound
.
Contains
(
pos
);
}
}
Grapplers/Assets/Scripts/PlayerController.cs
View file @
c5f154dc
...
...
@@ -44,6 +44,9 @@ public class PlayerController : MonoBehaviour
}
}
[
SerializeField
]
private
float
outOfMapTimer
=
10
;
#if UNITY_EDITOR
private
void
OnDrawGizmos
()
{
...
...
@@ -91,8 +94,20 @@ public class PlayerController : MonoBehaviour
}
else
{
rb
.
AddForce
(
horizontal
*
transform
.
right
+
vertical
*
transform
.
forward
*
10.0f
);
if
(
joint
.
enabled
)
joint
.
moveDelta
=
(
horizontal
*
transform
.
right
+
vertical
*
transform
.
forward
).
normalized
*
30.0f
;
else
rb
.
AddForce
(
horizontal
*
Camera
.
main
.
transform
.
right
+
vertical
*
Camera
.
main
.
transform
.
forward
*
10.0f
);
}
if
(
MapManager
.
inst
.
IsOutOfMapBounds
(
transform
.
position
))
{
outOfMapTimer
-=
Time
.
deltaTime
;
if
(
outOfMapTimer
<=
0
)
Health
=
0
;
}
else
outOfMapTimer
=
10
;
}
private
void
LateUpdate
()
...
...
@@ -118,7 +133,7 @@ public class PlayerController : MonoBehaviour
joint
.
enabled
=
false
;
hook
.
DisableHook
();
isWired
=
false
;
rb
.
useGravity
=
true
;
//
rb.useGravity = true;
}
public
void
ActiveWire
()
...
...
@@ -126,7 +141,7 @@ public class PlayerController : MonoBehaviour
joint
.
enabled
=
true
;
joint
.
distance
=
Vector3
.
Distance
(
transform
.
position
,
hook
.
transform
.
position
);
isWired
=
true
;
rb
.
useGravity
=
false
;
//
rb.useGravity = false;
}
public
void
GetDamaged
(
int
damage
)
...
...
Grapplers/Assets/Scripts/WeaponBehaviour.cs
View file @
c5f154dc
...
...
@@ -194,29 +194,33 @@ public class Knife : IWeapon
private
IEnumerator
SkillRoutine
()
{
const
float
dashDistance
=
50
;
const
float
dashTime
=
0.2f
;
Vector3
oriPos
=
player
.
position
;
Ray
ray
=
new
Ray
(
player
.
position
,
Camera
.
main
.
transform
.
forward
);
RaycastHit
hit
;
Physics
.
Raycast
(
ray
,
out
hit
,
30
,
player
.
GetComponent
<
PlayerController
>().
groundMask
);
Vector3
dest
=
hit
.
collider
!=
null
?
hit
.
point
-
Camera
.
main
.
transform
.
forward
*
0.5f
:
player
.
position
+
Camera
.
main
.
transform
.
forward
*
30
;
const
float
skillTime
=
0.2f
;
foreach
(
var
enemyHit
in
Physics
.
RaycastAll
(
ray
,
30
,
1
<<
LayerMask
.
NameToLayer
(
"Enemy"
)))
{
enemyHit
.
collider
.
GetComponent
<
Enemy
>()?.
GetDamaged
(
weaponDamage
);
}
Physics
.
Raycast
(
ray
,
out
hit
,
dashDistance
,
player
.
GetComponent
<
PlayerController
>().
groundMask
);
Vector3
dest
=
hit
.
collider
!=
null
?
hit
.
point
-
Camera
.
main
.
transform
.
forward
*
0.5f
:
player
.
position
+
Camera
.
main
.
transform
.
forward
*
dashDistance
;
player
.
GetComponent
<
MeshRenderer
>().
enabled
=
false
;
for
(
float
t
=
0
;
t
<
skill
Time
;
t
+=
Time
.
fixedDeltaTime
)
for
(
float
t
=
0
;
t
<
dash
Time
;
t
+=
Time
.
fixedDeltaTime
)
{
player
.
position
=
Vector3
.
Lerp
(
oriPos
,
dest
,
t
/
skillTime
);
player
.
position
=
Vector3
.
Lerp
(
oriPos
,
dest
,
1
-
Mathf
.
Pow
(
1
-
(
t
/
dashTime
),
2
)
);
yield
return
new
WaitForFixedUpdate
();
}
player
.
GetComponent
<
Rigidbody
>().
velocity
=
Vector3
.
zero
;
player
.
GetComponent
<
MeshRenderer
>().
enabled
=
true
;
foreach
(
var
enemyHit
in
Physics
.
SphereCastAll
(
ray
,
1
,
Vector3
.
Distance
(
oriPos
,
dest
),
1
<<
LayerMask
.
NameToLayer
(
"Enemy"
)))
{
Enemy
enemy
=
enemyHit
.
collider
.
GetComponent
<
Enemy
>();
Debug
.
Log
(
enemy
);
if
(
enemy
==
null
)
continue
;
enemy
.
GetDamaged
(
weaponDamage
);
if
(
enemy
.
IsDead
)
skillTimer
=
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