closed #39 오브젝트 형식의 원거리 공격(ObjectWeapon) 구현

+ 파티클, 오브젝트 형식의 공격에서 autoDestory추가
  ㄴ 자동으로 autoDestoryTime이 지난 후 파괴
+ TenTen(원거리 무기) Dagger 추가
This commit is contained in:
NTG_Lenovo 2023-10-23 11:48:27 +09:00
parent 56eb1d5f34
commit 3c2e8d68bd
10 changed files with 403 additions and 4 deletions

View File

@ -1160,6 +1160,37 @@ RectTransform:
type: 3}
m_PrefabInstance: {fileID: 2135365439}
m_PrefabAsset: {fileID: 0}
--- !u!1 &214533789
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 214533790}
m_Layer: 0
m_Name: ShootLocation
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &214533790
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 214533789}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0, y: 0.186, z: -0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1523920201}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &231861242
PrefabInstance:
m_ObjectHideFlags: 0
@ -3155,7 +3186,7 @@ MonoBehaviour:
isDrawViewRange: 1
isDrawDefenseRange: 1
isDrawTargetRange: 1
<MaxHp>k__BackingField: 250
<MaxHp>k__BackingField: 50
<CurrentHp>k__BackingField: 0
<MoveSpd>k__BackingField: 5
<Atk>k__BackingField: 10
@ -9618,7 +9649,11 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedGameObjects:
- targetCorrespondingSourceObject: {fileID: 9033924121474021245, guid: f231da17ce5b9c84f91bf8ed73c2868e,
type: 3}
insertIndex: -1
addedObject: {fileID: 214533790}
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 7216996033527228451, guid: f231da17ce5b9c84f91bf8ed73c2868e,
type: 3}
@ -9751,6 +9786,10 @@ MonoBehaviour:
<TargetLayer>k__BackingField:
serializedVersion: 2
m_Bits: 0
projectileObj: {fileID: 6365080210048648475, guid: d101d38de657e0b42aa2aea84f8590c7,
type: 3}
shootLocation: {fileID: 214533790}
speed: 500
--- !u!114 &1362034960
MonoBehaviour:
m_ObjectHideFlags: 0
@ -10896,6 +10935,12 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e1c4cc5b9a7d0d7479734ea4167d417e, type: 3}
--- !u!4 &1523920201 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 9033924121474021245, guid: f231da17ce5b9c84f91bf8ed73c2868e,
type: 3}
m_PrefabInstance: {fileID: 1362034954}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1533915118 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2718910014188824470, guid: 14871bcccb7cf4e1d81bb38ec7a3a4e0,

View File

@ -1,5 +1,6 @@
using System;
using System.Collections;
using Sirenix.OdinInspector;
using UnityEngine;
// ReSharper disable once CheckNamespace
@ -8,6 +9,50 @@ namespace BlueWaterProject
[Serializable]
public class TenTen : Crewmate
{
#region Properties and variables
[Title("Weapon")]
[Required]
[SerializeField] private GameObject projectileObj;
[Required]
[SerializeField] private Transform shootLocation;
[SerializeField] private float speed = 500f;
private Transform objectPoolLocation;
#endregion
#region Unity built-in methods
protected override void Start()
{
base.Start();
var objectPoolData = FindAnyObjectByType<ObjectPoolData>();
objectPoolLocation = objectPoolData.transform.Find("Objects/Daggers");
}
#endregion
#region Interface
// IAnimatorBridge
public override void AttackTiming()
{
if (!Target) return;
var myCenterPos = MyCollider.bounds.center;
var weapon = Instantiate(projectileObj, shootLocation.transform.position, Quaternion.identity, objectPoolLocation).GetComponent<ObjectWeapon>();
weapon.transform.LookAt(Target.bounds.center);
weapon.SetPower(Atk);
weapon.GetComponent<Rigidbody>().AddForce(weapon.transform.forward * speed);
}
#endregion
#region Custom methods
protected override IEnumerator NormalAttackCoroutine()
{
usedNormalAttackCoroutine = true;
@ -29,5 +74,7 @@ namespace BlueWaterProject
yield return waitAtkCooldown;
usedNormalAttackCoroutine = false;
}
#endregion
}
}

View File

@ -1,9 +1,7 @@
using System;
using System.Collections;
using EpicToonFX;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.Pool;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
@ -14,7 +12,9 @@ namespace BlueWaterProject
#region Properties and variables
[Title("Weapon")]
[Required]
[SerializeField] private GameObject projectileObj;
[Required]
[SerializeField] private Transform shootLocation;
[SerializeField] private float speed = 500f;

View File

@ -14,13 +14,23 @@ namespace BlueWaterProject
[Button("기본 설정")]
private void CreateDefaultSetting()
{
// Objects
var objects = transform.Find("Objects");
if (!objects)
{
objects = new GameObject("Objects").transform;
objects.transform.parent = transform;
}
var daggers = transform.Find("Daggers");
if (!daggers)
{
daggers = new GameObject("Daggers").transform;
daggers.transform.parent = objects;
}
// Particles
var particles = transform.Find("Particles");
if (!particles)
{

View File

@ -0,0 +1,70 @@
using System.Collections;
using UnityEngine;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public class ObjectWeapon : MonoBehaviour
{
[SerializeField] private LayerMask targetLayer;
[SerializeField] private float power;
[SerializeField] private float autoDestroyTime = 3f;
private Rigidbody rb;
private SphereCollider sphereCollider;
private WaitForSeconds waitForSeconds;
private void Awake()
{
rb = GetComponent<Rigidbody>();
sphereCollider = GetComponent<SphereCollider>();
waitForSeconds = new WaitForSeconds(autoDestroyTime);
}
private void OnDestroy()
{
StopAllCoroutines();
}
private void Start()
{
StartCoroutine(nameof(AutoDestroy));
}
private void FixedUpdate()
{
// if (rb.velocity.magnitude != 0)
// {
// transform.rotation = Quaternion.LookRotation(rb.velocity); // Sets rotation to look at direction of movement
// }
var direction = rb.velocity; // Gets the direction of the projectile, used for collision detection
if (rb.useGravity)
direction += Physics.gravity * Time.deltaTime; // Accounts for gravity if enabled
direction = direction.normalized;
var detectionDistance = rb.velocity.magnitude * Time.deltaTime; // Distance of collision detection for this frame
if (Physics.SphereCast(transform.position, sphereCollider.radius, direction, out var hit, detectionDistance, targetLayer)) // Checks if collision will happen
{
transform.position = hit.point + (hit.normal); // Move projectile to point of collision
Destroy(gameObject); // Removes the projectile
hit.transform.GetComponent<IDamageable>()?.TakeDamage(power);
}
}
private IEnumerator AutoDestroy()
{
yield return waitForSeconds;
if (gameObject != null)
{
Destroy(gameObject);
}
}
public void SetPower(float value) => power = value;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce67f7a5af7e8364182e3563a56ad079
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,3 +1,5 @@
using System;
using System.Collections;
using UnityEngine;
// ReSharper disable once CheckNamespace
@ -15,18 +17,28 @@ namespace BlueWaterProject
[SerializeField] private LayerMask targetLayer;
[SerializeField] private float power;
[SerializeField] private float autoDestroyTime = 5f;
private Rigidbody rb;
private SphereCollider sphereCollider;
private WaitForSeconds waitForSeconds;
private void Awake()
{
rb = GetComponent<Rigidbody>();
sphereCollider = GetComponent<SphereCollider>();
waitForSeconds = new WaitForSeconds(autoDestroyTime);
}
private void OnDestroy()
{
StopAllCoroutines();
}
private void Start()
{
StartCoroutine(nameof(AutoDestroy));
projectileParticle = Instantiate(projectileParticle, transform.position, transform.rotation, transform) as GameObject;
projectileParticle.transform.parent = transform;
if (muzzleParticle)
@ -83,6 +95,16 @@ namespace BlueWaterProject
}
}
private IEnumerator AutoDestroy()
{
yield return waitForSeconds;
if (gameObject != null)
{
Destroy(gameObject);
}
}
public void SetPower(float value) => power = value;
}
}

View File

@ -0,0 +1,186 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4974917693782220124
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4687260148761221251}
- component: {fileID: 2067129615080396003}
m_Layer: 0
m_Name: VisualLook
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4687260148761221251
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4974917693782220124}
serializedVersion: 2
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 2, y: 2, z: 2}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 2677528810302803348}
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!212 &2067129615080396003
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4974917693782220124}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, 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: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 522cef2ef8d6a4da395354c0f0e34690, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.1875, y: 0.46875}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &6365080210048648475
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2677528810302803348}
- component: {fileID: 1253731450221583048}
- component: {fileID: 1659185759454902698}
- component: {fileID: 5784756153569027963}
m_Layer: 0
m_Name: Dagger
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2677528810302803348
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6365080210048648475}
serializedVersion: 2
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_ConstrainProportionsScale: 1
m_Children:
- {fileID: 4687260148761221251}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!135 &1253731450221583048
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6365080210048648475}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Radius: 0.3
m_Center: {x: 0.02, y: 0, z: 0.25}
--- !u!54 &1659185759454902698
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6365080210048648475}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &5784756153569027963
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6365080210048648475}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ce67f7a5af7e8364182e3563a56ad079, type: 3}
m_Name:
m_EditorClassIdentifier:
targetLayer:
serializedVersion: 2
m_Bits: 8192
power: 0
autoDestroyTime: 3

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d101d38de657e0b42aa2aea84f8590c7
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -106,3 +106,4 @@ MonoBehaviour:
serializedVersion: 2
m_Bits: 1536
power: 0
autoDestroyTime: 3