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
d26f8bbc
Commit
d26f8bbc
authored
Oct 06, 2019
by
15박보승
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Playercontroller에서 무기관련 로직 WeaponBehaviour로 분리/검 스킬 구현
parent
c184c282
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
901 additions
and
430 deletions
+901
-430
AirplaneEnemy.prefab
Grapplers/Assets/Prefabs/AirplaneEnemy.prefab
+220
-0
AirplaneEnemy.prefab.meta
Grapplers/Assets/Prefabs/AirplaneEnemy.prefab.meta
+7
-0
Missile.prefab
Grapplers/Assets/Prefabs/Missile.prefab
+1
-1
SampleScene.unity
Grapplers/Assets/Scenes/SampleScene.unity
+436
-362
AirplaneEnemy.cs
Grapplers/Assets/Scripts/Enemy/AirplaneEnemy.cs
+0
-2
Enemy.cs
Grapplers/Assets/Scripts/Enemy/Enemy.cs
+2
-0
Missile.cs
Grapplers/Assets/Scripts/Enemy/Missile.cs
+0
-1
GameManager.cs
Grapplers/Assets/Scripts/GameManager.cs
+0
-1
PlayerController.cs
Grapplers/Assets/Scripts/PlayerController.cs
+2
-63
WeaponBehaviour.cs
Grapplers/Assets/Scripts/WeaponBehaviour.cs
+222
-0
WeaponBehaviour.cs.meta
Grapplers/Assets/Scripts/WeaponBehaviour.cs.meta
+11
-0
No files found.
Grapplers/Assets/Prefabs/AirplaneEnemy.prefab
0 → 100644
View file @
d26f8bbc
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!1
&808483076966640903
GameObject
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
808483076966640907
}
-
component
:
{
fileID
:
808483076966640906
}
-
component
:
{
fileID
:
808483076966640901
}
-
component
:
{
fileID
:
808483076966640900
}
-
component
:
{
fileID
:
808483076966640905
}
-
component
:
{
fileID
:
808483076966640904
}
m_Layer
:
10
m_Name
:
AirplaneEnemy
m_TagString
:
Enemy
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!4
&808483076966640907
Transform
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
808483076966640903
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
-0.01939517
,
y
:
1.97188
,
z
:
15.06
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
-
{
fileID
:
808483077530519107
}
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!33
&808483076966640906
MeshFilter
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
808483076966640903
}
m_Mesh
:
{
fileID
:
10206
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
---
!u!23
&808483076966640901
MeshRenderer
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
808483076966640903
}
m_Enabled
:
1
m_CastShadows
:
1
m_ReceiveShadows
:
1
m_DynamicOccludee
:
1
m_MotionVectors
:
1
m_LightProbeUsage
:
1
m_ReflectionProbeUsage
:
1
m_RenderingLayerMask
:
1
m_RendererPriority
:
0
m_Materials
:
-
{
fileID
:
10303
,
guid
:
0000000000000000f000000000000000
,
type
:
0
}
m_StaticBatchInfo
:
firstSubMesh
:
0
subMeshCount
:
0
m_StaticBatchRoot
:
{
fileID
:
0
}
m_ProbeAnchor
:
{
fileID
:
0
}
m_LightProbeVolumeOverride
:
{
fileID
:
0
}
m_ScaleInLightmap
:
1
m_ReceiveGI
:
1
m_PreserveUVs
:
0
m_IgnoreNormalsForChartDetection
:
0
m_ImportantGI
:
0
m_StitchLightmapSeams
:
1
m_SelectedEditorRenderState
:
3
m_MinimumChartSize
:
4
m_AutoUVMaxDistance
:
0.5
m_AutoUVMaxAngle
:
89
m_LightmapParameters
:
{
fileID
:
0
}
m_SortingLayerID
:
0
m_SortingLayer
:
0
m_SortingOrder
:
0
---
!u!136
&808483076966640900
CapsuleCollider
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
808483076966640903
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_Enabled
:
1
m_Radius
:
0.5000001
m_Height
:
2
m_Direction
:
1
m_Center
:
{
x
:
0.000000059604645
,
y
:
0
,
z
:
-0.00000008940697
}
---
!u!54
&808483076966640905
Rigidbody
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
808483076966640903
}
serializedVersion
:
2
m_Mass
:
1
m_Drag
:
5
m_AngularDrag
:
0.05
m_UseGravity
:
0
m_IsKinematic
:
0
m_Interpolate
:
0
m_Constraints
:
0
m_CollisionDetection
:
0
---
!u!114
&808483076966640904
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
808483076966640903
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
c85a502201043ea4585ced1c522431cb
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
maxHealth
:
50
curHealth
:
0
attackDamage
:
0
detectRange
:
50
moveSpeed
:
0
playerMask
:
serializedVersion
:
2
m_Bits
:
256
projectilePrefab
:
{
fileID
:
6757045588236739288
,
guid
:
f5523fdf30a86e84ea4d7fd5aa020ca2
,
type
:
3
}
bloodEffect
:
{
fileID
:
808483077530519105
}
shotSpeed
:
0
shotTimeInterval
:
5
---
!u!1001
&5714664667939351444
PrefabInstance
:
m_ObjectHideFlags
:
0
serializedVersion
:
2
m_Modification
:
m_TransformParent
:
{
fileID
:
808483076966640907
}
m_Modifications
:
-
target
:
{
fileID
:
4933374738297728470
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_Name
value
:
BloodEffect
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_LocalPosition.x
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_LocalPosition.y
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_LocalPosition.z
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_LocalRotation.x
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_LocalRotation.y
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_LocalRotation.z
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_LocalRotation.w
value
:
1
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_RootOrder
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_LocalEulerAnglesHint.x
value
:
-90
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_LocalEulerAnglesHint.y
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
propertyPath
:
m_LocalEulerAnglesHint.z
value
:
0
objectReference
:
{
fileID
:
0
}
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
---
!u!4
&808483077530519107
stripped
Transform
:
m_CorrespondingSourceObject
:
{
fileID
:
4933374738297728471
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
m_PrefabInstance
:
{
fileID
:
5714664667939351444
}
m_PrefabAsset
:
{
fileID
:
0
}
---
!u!198
&808483077530519105
stripped
ParticleSystem
:
m_CorrespondingSourceObject
:
{
fileID
:
4933374738297728469
,
guid
:
59619ab33246ea34496792e427cf9d6e
,
type
:
3
}
m_PrefabInstance
:
{
fileID
:
5714664667939351444
}
m_PrefabAsset
:
{
fileID
:
0
}
Grapplers/Assets/Prefabs/AirplaneEnemy.prefab.meta
0 → 100644
View file @
d26f8bbc
fileFormatVersion: 2
guid: 60f985c4e15827746af49ee480a2d6f9
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Grapplers/Assets/Prefabs/Missile.prefab
View file @
d26f8bbc
...
...
@@ -111,7 +111,7 @@ MonoBehaviour:
curHealth
:
0
attackDamage
:
5
detectRange
:
0
moveSpeed
:
0.
1
moveSpeed
:
0.
5
playerMask
:
serializedVersion
:
2
m_Bits
:
256
...
...
Grapplers/Assets/Scenes/SampleScene.unity
View file @
d26f8bbc
This diff is collapsed.
Click to expand it.
Grapplers/Assets/Scripts/Enemy/AirplaneEnemy.cs
View file @
d26f8bbc
...
...
@@ -4,8 +4,6 @@ using UnityEngine;
public
class
AirplaneEnemy
:
Enemy
{
private
float
shotTimer
=
5
;
protected
override
void
InitializeStateMachine
()
{
State
idle
=
new
State
(
"idle"
);
...
...
Grapplers/Assets/Scripts/Enemy/Enemy.cs
View file @
d26f8bbc
...
...
@@ -38,6 +38,8 @@ public abstract class Enemy : MonoBehaviour
private
float
shotTimeInterval
;
private
float
shotTimer
;
public
bool
IsDead
{
get
{
return
curHealth
<=
0
;
}
}
#if UNITY_EDITOR
private
void
OnDrawGizmos
()
{
...
...
Grapplers/Assets/Scripts/Enemy/Missile.cs
View file @
d26f8bbc
...
...
@@ -19,7 +19,6 @@ public class Missile : Enemy
private
void
OnTriggerEnter
(
Collider
other
)
{
Debug
.
Log
(
other
);
if
(
other
.
tag
.
Contains
(
"Enemy"
))
return
;
other
.
GetComponent
<
PlayerController
>()?.
GetDamaged
(
attackDamage
);
...
...
Grapplers/Assets/Scripts/GameManager.cs
View file @
d26f8bbc
...
...
@@ -13,7 +13,6 @@ public class GameManager : SingletonBehaviour<GameManager>
}
set
{
Debug
.
Log
(
value
);
_maxHeight
=
value
;
OnMaxHeightChanged
?.
Invoke
(
value
);
}
...
...
Grapplers/Assets/Scripts/PlayerController.cs
View file @
d26f8bbc
...
...
@@ -22,8 +22,7 @@ public class PlayerController : MonoBehaviour
[
SerializeField
]
private
Transform
groundChecker
;
[
SerializeField
]
private
LayerMask
groundMask
;
public
LayerMask
groundMask
;
private
bool
IsGrounded
{
get
{
...
...
@@ -31,15 +30,6 @@ public class PlayerController : MonoBehaviour
}
}
[
SerializeField
]
private
float
bulletMaxDistance
;
[
SerializeField
]
private
ParticleSystem
bulletEffect
;
[
SerializeField
]
private
LayerMask
enemyMask
;
[
SerializeField
]
private
LayerMask
bulletBlockMask
;
public
int
MaxHealth
{
get
;
private
set
;
}
private
int
_health
;
public
int
Health
{
...
...
@@ -83,35 +73,6 @@ public class PlayerController : MonoBehaviour
float
vertical
=
Input
.
GetAxis
(
"Vertical"
);
float
horizontal
=
Input
.
GetAxis
(
"Horizontal"
);
RaycastHit
[]
enemyHits
=
Physics
.
SphereCastAll
(
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
),
3
,
bulletMaxDistance
,
enemyMask
);
List
<
Enemy
>
hitEnemies
=
new
List
<
Enemy
>();
List
<
Vector3
>
hitEnemyPositions
=
new
List
<
Vector3
>();
foreach
(
var
enemyHit
in
enemyHits
)
{
Ray
ray
=
new
Ray
(
Camera
.
main
.
transform
.
position
,
(
enemyHit
.
point
-
Camera
.
main
.
transform
.
position
).
normalized
);
if
(!
Physics
.
Raycast
(
ray
,
Vector3
.
Distance
(
Camera
.
main
.
transform
.
position
,
enemyHit
.
point
),
bulletBlockMask
))
{
hitEnemies
.
Add
(
enemyHit
.
collider
.
GetComponent
<
Enemy
>());
hitEnemyPositions
.
Add
(
enemyHit
.
transform
.
position
);
}
}
IngameUIManager
.
inst
.
UpdateTargetLockedUIs
(
hitEnemyPositions
.
ToArray
());
if
(
Input
.
GetMouseButton
(
0
))
{
bulletEffect
.
transform
.
rotation
=
Camera
.
main
.
transform
.
rotation
;
bulletEffect
.
Play
();
foreach
(
var
enemy
in
hitEnemies
)
{
enemy
?.
GetDamaged
(
1
);
}
}
if
(
Input
.
GetMouseButtonDown
(
1
))
{
if
(!
hook
.
gameObject
.
activeSelf
)
...
...
@@ -172,26 +133,4 @@ public class PlayerController : MonoBehaviour
{
Health
=
Mathf
.
Max
(
0
,
Health
-
damage
);
}
}
public
interface
IWeapon
{
void
UseWeapon
();
}
public
class
Gun
:
IWeapon
{
public
void
UseWeapon
()
{
throw
new
System
.
NotImplementedException
();
}
}
public
class
Weapon
:
IWeapon
{
public
void
UseWeapon
()
{
throw
new
System
.
NotImplementedException
();
}
}
}
\ No newline at end of file
Grapplers/Assets/Scripts/WeaponBehaviour.cs
0 → 100644
View file @
d26f8bbc
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
WeaponBehaviour
:
MonoBehaviour
{
[
SerializeField
]
private
int
knifeDamage
=
50
;
[
SerializeField
]
private
int
gunDamage
=
1
;
[
SerializeField
]
private
float
gunRange
=
50
;
[
SerializeField
]
private
ParticleSystem
bulletEffect
;
[
SerializeField
]
private
float
knifeRange
;
[
SerializeField
]
private
ParticleSystem
knifeEffect
;
[
SerializeField
]
private
LayerMask
enemyMask
,
blockMask
;
private
IWeapon
weapon
;
private
void
Start
()
{
weapon
=
new
Gun
(
gunDamage
,
gunRange
,
bulletEffect
);
weapon
=
new
Knife
(
knifeDamage
,
knifeRange
,
bulletEffect
,
transform
);
}
private
void
Update
()
{
weapon
.
UpdateWeapon
();
Enemy
[]
hitEnemies
=
weapon
.
WeaponLockOn
(
enemyMask
,
blockMask
);
weapon
.
UseWeapon
(
hitEnemies
);
if
(
Input
.
GetKeyDown
(
KeyCode
.
Tab
))
{
SwapWeapon
();
}
if
(
Input
.
GetKeyDown
(
KeyCode
.
LeftShift
))
{
weapon
.
UseSkill
();
}
}
private
void
SwapWeapon
()
{
if
(
weapon
.
GetType
()
==
typeof
(
Gun
))
weapon
=
new
Knife
(
knifeDamage
,
knifeRange
,
bulletEffect
,
transform
);
else
weapon
=
new
Gun
(
gunDamage
,
gunRange
,
bulletEffect
);
}
}
public
interface
IWeapon
{
void
UseWeapon
(
Enemy
[]
hitEnemies
);
void
UseSkill
();
Enemy
[]
WeaponLockOn
(
LayerMask
enemyMask
,
LayerMask
blockMask
);
void
UpdateWeapon
();
}
public
class
Gun
:
IWeapon
{
protected
int
weaponDamage
;
protected
float
weaponRange
;
private
ParticleSystem
effect
;
private
const
float
gunShotInterval
=
0.02f
;
private
float
timer
;
public
Gun
(
int
dmg
,
float
range
,
ParticleSystem
effect
)
{
weaponDamage
=
dmg
;
weaponRange
=
range
;
this
.
effect
=
effect
;
}
public
void
UseWeapon
(
Enemy
[]
hitEnemies
)
{
if
(
timer
>
0
)
return
;
if
(
Input
.
GetMouseButton
(
0
))
{
effect
.
transform
.
rotation
=
Camera
.
main
.
transform
.
rotation
;
effect
.
Play
();
foreach
(
var
enemy
in
hitEnemies
)
{
enemy
?.
GetDamaged
(
weaponDamage
);
}
timer
=
gunShotInterval
;
}
}
public
Enemy
[]
WeaponLockOn
(
LayerMask
enemyMask
,
LayerMask
blockMask
)
{
RaycastHit
[]
enemyHits
=
Physics
.
SphereCastAll
(
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
),
3
,
weaponRange
,
enemyMask
);
List
<
Enemy
>
hitEnemies
=
new
List
<
Enemy
>();
List
<
Vector3
>
hitEnemyPositions
=
new
List
<
Vector3
>();
foreach
(
var
enemyHit
in
enemyHits
)
{
Ray
ray
=
new
Ray
(
Camera
.
main
.
transform
.
position
,
(
enemyHit
.
point
-
Camera
.
main
.
transform
.
position
).
normalized
);
if
(!
Physics
.
Raycast
(
ray
,
Vector3
.
Distance
(
Camera
.
main
.
transform
.
position
,
enemyHit
.
point
),
blockMask
))
{
hitEnemies
.
Add
(
enemyHit
.
collider
.
GetComponent
<
Enemy
>());
hitEnemyPositions
.
Add
(
enemyHit
.
transform
.
position
);
}
}
IngameUIManager
.
inst
.
UpdateTargetLockedUIs
(
hitEnemyPositions
.
ToArray
());
return
hitEnemies
.
ToArray
();
}
public
void
UseSkill
()
{
}
public
void
UpdateWeapon
()
{
timer
-=
Time
.
deltaTime
;
}
}
public
class
Knife
:
IWeapon
{
protected
int
weaponDamage
;
protected
float
weaponRange
;
ParticleSystem
effect
;
Transform
player
;
private
const
float
skillTimeInterval
=
5
;
private
float
skillTimer
=
0
;
public
Knife
(
int
dmg
,
float
range
,
ParticleSystem
effect
,
Transform
player
)
{
weaponDamage
=
dmg
;
weaponRange
=
range
;
this
.
effect
=
effect
;
this
.
player
=
player
;
}
public
void
UseWeapon
(
Enemy
[]
hitEnemies
)
{
if
(
Input
.
GetMouseButtonDown
(
0
))
{
effect
.
transform
.
rotation
=
Camera
.
main
.
transform
.
rotation
;
effect
.
Play
();
foreach
(
var
enemy
in
hitEnemies
)
{
enemy
.
GetDamaged
(
weaponDamage
);
if
(
enemy
.
IsDead
)
skillTimer
=
0
;
}
}
}
public
Enemy
[]
WeaponLockOn
(
LayerMask
enemyMask
,
LayerMask
blockMask
)
{
RaycastHit
[]
enemyHits
=
Physics
.
SphereCastAll
(
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
),
3
,
weaponRange
,
enemyMask
);
List
<
Enemy
>
hitEnemies
=
new
List
<
Enemy
>();
List
<
Vector3
>
hitEnemyPositions
=
new
List
<
Vector3
>();
foreach
(
var
enemyHit
in
enemyHits
)
{
Ray
ray
=
new
Ray
(
Camera
.
main
.
transform
.
position
,
(
enemyHit
.
point
-
Camera
.
main
.
transform
.
position
).
normalized
);
if
(!
Physics
.
Raycast
(
ray
,
Vector3
.
Distance
(
Camera
.
main
.
transform
.
position
,
enemyHit
.
point
),
blockMask
))
{
hitEnemies
.
Add
(
enemyHit
.
collider
.
GetComponent
<
Enemy
>());
hitEnemyPositions
.
Add
(
enemyHit
.
transform
.
position
);
}
}
IngameUIManager
.
inst
.
UpdateTargetLockedUIs
(
hitEnemyPositions
.
ToArray
());
return
hitEnemies
.
ToArray
();
}
public
void
UseSkill
()
{
if
(
skillTimer
>
0
)
return
;
GameManager
.
inst
.
StartCoroutine
(
SkillRoutine
());
skillTimer
=
skillTimeInterval
;
}
public
void
UpdateWeapon
()
{
skillTimer
-=
Time
.
deltaTime
;
}
private
IEnumerator
SkillRoutine
()
{
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
);
}
player
.
GetComponent
<
MeshRenderer
>().
enabled
=
false
;
for
(
float
t
=
0
;
t
<
skillTime
;
t
+=
Time
.
fixedDeltaTime
)
{
player
.
position
=
Vector3
.
Lerp
(
oriPos
,
dest
,
t
/
skillTime
);
yield
return
new
WaitForFixedUpdate
();
}
player
.
GetComponent
<
Rigidbody
>().
velocity
=
Vector3
.
zero
;
player
.
GetComponent
<
MeshRenderer
>().
enabled
=
true
;
}
}
Grapplers/Assets/Scripts/WeaponBehaviour.cs.meta
0 → 100644
View file @
d26f8bbc
fileFormatVersion: 2
guid: d8563877a588e844da7d4f831005a6b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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