Commit 22da2ee7 authored by 15박보승's avatar 15박보승

스나이퍼 구현/Weapon Type UI 간단하게 구현

parent c5f154dc
......@@ -132,11 +132,15 @@ MonoBehaviour:
playerMask:
serializedVersion: 2
m_Bits: 256
blockMask:
serializedVersion: 2
m_Bits: 55
projectilePrefab: {fileID: 6757045588236739288, guid: f5523fdf30a86e84ea4d7fd5aa020ca2,
type: 3}
bloodEffect: {fileID: 808483077530519105}
shotSpeed: 0
shotTimeInterval: 5
rb: {fileID: 0}
--- !u!1001 &5714664667939351444
PrefabInstance:
m_ObjectHideFlags: 0
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2105939753196472836
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2105939753196472840}
- component: {fileID: 2105939753196472841}
- component: {fileID: 2105939753196472838}
- component: {fileID: 2105939753196472839}
- component: {fileID: 2105939753196472842}
- component: {fileID: 1585691613636896513}
- component: {fileID: 1585691613636896542}
m_Layer: 10
m_Name: Sniper
m_TagString: Enemy
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2105939753196472840
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2105939753196472836}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 29.6, y: 10.2, z: 30.6}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 2105939753692799296}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &2105939753196472841
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2105939753196472836}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &2105939753196472838
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2105939753196472836}
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: 2100000, guid: b4409bc82ca6b894d96281afa63aa758, type: 2}
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 &2105939753196472839
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2105939753196472836}
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 &2105939753196472842
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2105939753196472836}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!120 &1585691613636896513
LineRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2105939753196472836}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 0
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10306, 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
m_Positions:
- {x: 0, y: 0, z: 0}
- {x: 0, y: 0, z: 1}
m_Parameters:
serializedVersion: 3
widthMultiplier: 0.01
widthCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
colorGradient:
serializedVersion: 2
key0: {r: 1, g: 0.18396229, b: 0.18396229, a: 1}
key1: {r: 1, g: 0.06132078, b: 0.06132078, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
numCornerVertices: 0
numCapVertices: 0
alignment: 0
textureMode: 0
shadowBias: 0.5
generateLightingData: 0
m_UseWorldSpace: 1
m_Loop: 0
--- !u!114 &1585691613636896542
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2105939753196472836}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d3115fa31a567a84799af6a6e052d0a3, type: 3}
m_Name:
m_EditorClassIdentifier:
maxHealth: 10
curHealth: 0
attackDamage: 20
detectRange: 60
moveSpeed: 0
playerMask:
serializedVersion: 2
m_Bits: 256
blockMask:
serializedVersion: 2
m_Bits: 1079
projectilePrefab: {fileID: 0}
bloodEffect: {fileID: 2105939753692799298}
shotSpeed: 0
shotTimeInterval: 5
rb: {fileID: 0}
--- !u!1001 &6435383437559106711
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 2105939753196472840}
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 &2105939753692799296 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4933374738297728471, guid: 59619ab33246ea34496792e427cf9d6e,
type: 3}
m_PrefabInstance: {fileID: 6435383437559106711}
m_PrefabAsset: {fileID: 0}
--- !u!198 &2105939753692799298 stripped
ParticleSystem:
m_CorrespondingSourceObject: {fileID: 4933374738297728469, guid: 59619ab33246ea34496792e427cf9d6e,
type: 3}
m_PrefabInstance: {fileID: 6435383437559106711}
m_PrefabAsset: {fileID: 0}
fileFormatVersion: 2
guid: 49a6d8becec31b34690fd97e6238f57d
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -560,7 +560,7 @@ Transform:
- {fileID: 1077217540}
- {fileID: 825443685}
m_Father: {fileID: 0}
m_RootOrder: 9
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &235153516
MonoBehaviour:
......@@ -1014,6 +1014,7 @@ RectTransform:
- {fileID: 369112311}
- {fileID: 274921780}
- {fileID: 1972759491}
- {fileID: 1169779395}
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -1041,6 +1042,7 @@ MonoBehaviour:
enemyHealthUIPrefab: {fileID: 3062086775062663198, guid: 235a2d94312e86a42bbadc5591dce379,
type: 3}
playerHealthUI: {fileID: 1972759492}
weaponUI: {fileID: 1169779396}
--- !u!1 &519663054
GameObject:
m_ObjectHideFlags: 0
......@@ -6637,7 +6639,7 @@ PrefabInstance:
- target: {fileID: 808483076966640907, guid: 60f985c4e15827746af49ee480a2d6f9,
type: 3}
propertyPath: m_RootOrder
value: 10
value: 9
objectReference: {fileID: 0}
- target: {fileID: 808483076966640907, guid: 60f985c4e15827746af49ee480a2d6f9,
type: 3}
......@@ -6656,6 +6658,81 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 60f985c4e15827746af49ee480a2d6f9, type: 3}
--- !u!1 &1169779394
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1169779395}
- component: {fileID: 1169779397}
- component: {fileID: 1169779396}
m_Layer: 5
m_Name: WeaponTypeUI
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1169779395
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1169779394}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 413298776}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -50, y: 50}
m_SizeDelta: {x: 200, y: 200}
m_Pivot: {x: 1, y: 0}
--- !u!114 &1169779396
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1169779394}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1169779397
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1169779394}
m_CullTransparentMesh: 0
--- !u!1 &1171556382
GameObject:
m_ObjectHideFlags: 0
......@@ -6712,6 +6789,7 @@ MonoBehaviour:
distance: 0
damper: 0
moveDelta: {x: 0, y: 0, z: 0}
maxMagnitude: 100
ps: 20
--- !u!143 &1171556385
CharacterController:
......@@ -6811,6 +6889,7 @@ MonoBehaviour:
groundMask:
serializedVersion: 2
m_Bits: 1
outOfMapTimer: 10
--- !u!136 &1171556390
CapsuleCollider:
m_ObjectHideFlags: 0
......@@ -6849,6 +6928,75 @@ MonoBehaviour:
blockMask:
serializedVersion: 2
m_Bits: 55
--- !u!1001 &1176241554
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2105939753196472836, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_Name
value: Sniper
objectReference: {fileID: 0}
- target: {fileID: 2105939753196472840, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_LocalPosition.x
value: 5.048794
objectReference: {fileID: 0}
- target: {fileID: 2105939753196472840, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_LocalPosition.y
value: 3.4
objectReference: {fileID: 0}
- target: {fileID: 2105939753196472840, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_LocalPosition.z
value: 24.637783
objectReference: {fileID: 0}
- target: {fileID: 2105939753196472840, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2105939753196472840, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2105939753196472840, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2105939753196472840, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2105939753196472840, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_RootOrder
value: 15
objectReference: {fileID: 0}
- target: {fileID: 2105939753196472840, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2105939753196472840, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2105939753196472840, guid: 49a6d8becec31b34690fd97e6238f57d,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 49a6d8becec31b34690fd97e6238f57d, type: 3}
--- !u!1 &1266258513
GameObject:
m_ObjectHideFlags: 0
......@@ -12325,11 +12473,11 @@ RectTransform:
m_Father: {fileID: 413298776}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -749, y: 496}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 50, y: -50}
m_SizeDelta: {x: 320, y: 40}
m_Pivot: {x: 0.5, y: 0.5}
m_Pivot: {x: 0, y: 1}
--- !u!114 &1972759492
MonoBehaviour:
m_ObjectHideFlags: 0
......
......@@ -12,6 +12,8 @@ public class DistanceJoint3D : MonoBehaviour
private Rigidbody rb;
public float maxMagnitude = 30;
[SerializeField]
private float ps= 10;
......@@ -46,6 +48,10 @@ public class DistanceJoint3D : MonoBehaviour
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);
if (rb.velocity.magnitude > maxMagnitude)
{
rb.velocity = rb.velocity.normalized * maxMagnitude;
}
//rb.position += distanceDiscrepancy * connection.normalized;
/*
float distanceDelta = Vector3.Dot(rb.velocity, connection.normalized);
......
......@@ -19,6 +19,8 @@ public abstract class Enemy : MonoBehaviour
[SerializeField]
private LayerMask playerMask;
[SerializeField]
private LayerMask blockMask;
[SerializeField]
private GameObject projectilePrefab;
[SerializeField]
......@@ -36,8 +38,8 @@ public abstract class Enemy : MonoBehaviour
[SerializeField]
private float shotSpeed;
[SerializeField]
private float shotTimeInterval;
private float shotTimer;
protected float shotTimeInterval;
protected float shotTimer;
[SerializeField]
protected Rigidbody rb;
......@@ -52,7 +54,7 @@ public abstract class Enemy : MonoBehaviour
}
#endif
private void Start()
protected virtual void Start()
{
col = GetComponent<Collider>();
rb = GetComponent<Rigidbody>();
......@@ -125,13 +127,16 @@ public abstract class Enemy : MonoBehaviour
var detectResults = Physics.OverlapSphere(transform.position, detectRange, playerMask);
if (detectResults.Length > 0)
{
Ray ray = new Ray(transform.position, detectResults[0].transform.position - transform.position);
if (Physics.Raycast(ray, detectRange, blockMask))
return false;
target = detectResults[0].GetComponent<PlayerController>();
return true;
}
return false;
}
protected void GiveDamageToPlayer()
protected void GiveDamageToTarget()
{
target.GetDamaged(attackDamage);
}
......@@ -148,6 +153,16 @@ public abstract class Enemy : MonoBehaviour
}
}
protected virtual void AttackTarget()
{
shotTimer -= Time.deltaTime;
if (shotTimer <= 0)
{
shotTimer = shotTimeInterval;
GiveDamageToTarget();
}
}
public void SetTarget(PlayerController pc)
{
target = pc;
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class IProjectile : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(LineRenderer))]
public class Sniper : Enemy
{
private LineRenderer lr;
protected override void Start()
{
lr = GetComponent<LineRenderer>();
lr.positionCount = 2;
base.Start();
}
protected override void InitializeStateMachine()
{
State idle = new State("idle");
State detected = new State("detected");
idle.Enter += delegate
{
shotTimer = shotTimeInterval;
lr.enabled = false;
};
idle.StateUpdate += delegate
{
if (DetectPlayer())
{
stateMachine.Transtion("detected");
}
};
detected.Enter += delegate
{
lr.enabled = true;
Debug.Log("Sniper Detect");
};
detected.StateUpdate += AttackTarget;
detected.StateUpdate += delegate
{
lr.SetPosition(0, transform.position);
lr.SetPosition(1, target.transform.position);
if (!DetectPlayer())
{
stateMachine.Transtion("idle");
}
};
State[] states = { idle, detected };
stateMachine.AddNewStates(states);
stateMachine.Transtion("idle");
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: e016a97cde2fae840bf5c5deec5f5565
guid: d3115fa31a567a84799af6a6e052d0a3
MonoImporter:
externalObjects: {}
serializedVersion: 2
......
......@@ -20,6 +20,9 @@ public class IngameUIManager : SingletonBehaviour<IngameUIManager>
[SerializeField]
private Slider playerHealthUI;
[SerializeField]
private Image weaponUI;
public void UpdateTargetLockedUIs(Vector3[] pos)
{
int tmp, i = 0;
......@@ -76,4 +79,17 @@ public class IngameUIManager : SingletonBehaviour<IngameUIManager>
{
playerHealthUI.value = (float)curHealth / maxHealth;
}
public void UpdateWeaponTypeUI(WeaponType type)
{
switch (type)
{
case WeaponType.GUN:
weaponUI.color = Color.blue;
break;
case WeaponType.KNIFE:
weaponUI.color = Color.red;
break;
}
}
}
......@@ -2,6 +2,12 @@
using System.Collections.Generic;
using UnityEngine;
public enum WeaponType
{
GUN,
KNIFE
}
public class WeaponBehaviour : MonoBehaviour
{
[SerializeField]
......@@ -45,9 +51,15 @@ public class WeaponBehaviour : MonoBehaviour
private void SwapWeapon()
{
if (weapon.GetType() == typeof(Gun))
{
weapon = new Knife(knifeDamage, knifeRange, bulletEffect, transform);
IngameUIManager.inst.UpdateWeaponTypeUI(WeaponType.KNIFE);
}
else
{
weapon = new Gun(gunDamage, gunRange, bulletEffect);
IngameUIManager.inst.UpdateWeaponTypeUI(WeaponType.GUN);
}
}
}
......@@ -212,10 +224,9 @@ public class Knife : IWeapon
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")))
foreach (var enemyHit in Physics.SphereCastAll(ray, 3, Vector3.Distance(oriPos,dest), 1 << LayerMask.NameToLayer("Enemy")))
{
Enemy enemy = enemyHit.collider.GetComponent<Enemy>();
Debug.Log(enemy);
if (enemy == null)
continue;
enemy.GetDamaged(weaponDamage);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment