Ai 상속 틀 변경
This commit is contained in:
parent
e534106cde
commit
2b846a54e0
@ -34188,7 +34188,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 91032034}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0.019106599, y: 0.4995399, z: 0.011021243, w: 0.86601007}
|
||||
m_LocalRotation: {x: -0.019106599, y: 0.49953982, z: 0.011021242, w: 0.8660101}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@ -37121,37 +37121,6 @@ Transform:
|
||||
- {fileID: 1765855842}
|
||||
m_Father: {fileID: 712552067}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &99817018
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 99817019}
|
||||
m_Layer: 0
|
||||
m_Name: PlayerUnits
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &99817019
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 99817018}
|
||||
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: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &100142392
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -704808,7 +704777,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1871370245}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.67640686, y: 0.00000023841855, z: -0.0000002980232, w: 0.7365282}
|
||||
m_LocalRotation: {x: 0.6764068, y: -0, z: -0, w: 0.7365283}
|
||||
m_LocalPosition: {x: -0.0000002384187, y: 120, z: -10.000001}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@ -794900,7 +794869,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 06c19c0e062e84c169aca3af92060883, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_persistent: 0
|
||||
--- !u!1 &2105554825
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -811519,5 +811487,4 @@ SceneRoots:
|
||||
- {fileID: 222471351}
|
||||
- {fileID: 1994033914}
|
||||
- {fileID: 342641572}
|
||||
- {fileID: 99817019}
|
||||
- {fileID: 1574668128}
|
||||
|
8
BlueWater/Assets/02.Scripts/Ai/Human/Combat.meta
Normal file
8
BlueWater/Assets/02.Scripts/Ai/Human/Combat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c610fa776fedd914683a0ad074480544
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
87
BlueWater/Assets/02.Scripts/Ai/Human/Combat/CombatAi.cs
Normal file
87
BlueWater/Assets/02.Scripts/Ai/Human/Combat/CombatAi.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using UnityEngine.Animations;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
public abstract class CombatAi : HumanAi
|
||||
{
|
||||
#region Properties and variables
|
||||
|
||||
// 일반 변수
|
||||
protected LayerMask targetLayer;
|
||||
protected Vector3 defensePos;
|
||||
|
||||
// 컴포넌트 관련 변수
|
||||
protected Animator humanAnimator;
|
||||
protected NavMeshAgent humanAgent;
|
||||
protected CapsuleCollider myCollider;
|
||||
protected CapsuleCollider hitBoxCollider;
|
||||
protected LookAtConstraint lookAtConstraint;
|
||||
|
||||
// 애니메이션 관련 변수
|
||||
protected static readonly int SpeedHash = Animator.StringToHash("Speed");
|
||||
protected static readonly int AttackHash = Animator.StringToHash("Attack");
|
||||
protected static readonly int DamageHash = Animator.StringToHash("TakeDamage");
|
||||
protected static readonly int DeathTypeHash = Animator.StringToHash("DeathType");
|
||||
protected static readonly int DeathHash = Animator.StringToHash("Death");
|
||||
protected static readonly int ShieldHash = Animator.StringToHash("Shield");
|
||||
protected static readonly int OutlineColorHash = Shader.PropertyToID("_OutlineColor");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Abstract methods
|
||||
|
||||
protected abstract void SetLayer();
|
||||
|
||||
protected abstract void SetCurrentHp(float value);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity built-in methods
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.InitComponent();
|
||||
|
||||
FlagLookAtCamera();
|
||||
SetLayer();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Custom methods
|
||||
|
||||
protected override void InitComponent()
|
||||
{
|
||||
base.InitComponent();
|
||||
|
||||
humanAnimator = Utils.GetComponentAndAssert<Animator>(transform);
|
||||
humanAgent = Utils.GetComponentAndAssert<NavMeshAgent>(transform);
|
||||
myCollider = Utils.GetComponentAndAssert<CapsuleCollider>(transform);
|
||||
hitBoxCollider = Utils.GetComponentAndAssert<CapsuleCollider>(transform.Find("HitBox"));
|
||||
lookAtConstraint = Utils.GetComponentAndAssert<LookAtConstraint>(flagContainer);
|
||||
}
|
||||
|
||||
private void FlagLookAtCamera()
|
||||
{
|
||||
if (Camera.main != null)
|
||||
{
|
||||
var source = new ConstraintSource
|
||||
{
|
||||
sourceTransform = Camera.main.transform,
|
||||
weight = 1f
|
||||
};
|
||||
lookAtConstraint.AddSource(source);
|
||||
}
|
||||
|
||||
lookAtConstraint.constraintActive = true;
|
||||
}
|
||||
|
||||
protected void SetMoveSpeed(float value) => humanAgent.speed = value;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
11
BlueWater/Assets/02.Scripts/Ai/Human/Combat/CombatAi.cs.meta
Normal file
11
BlueWater/Assets/02.Scripts/Ai/Human/Combat/CombatAi.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d395879fb0a0d740910a879261f7383
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -3,7 +3,7 @@ using UnityEngine;
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
public class EnemyAi : HumanAi
|
||||
public class EnemyAi : CombatAi
|
||||
{
|
||||
#region Properties and variables
|
||||
|
@ -6,7 +6,7 @@ using UnityEngine;
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
public class PirateAi : HumanAi
|
||||
public class PirateAi : CombatAi
|
||||
{
|
||||
#region Properties and variables
|
||||
|
@ -1,18 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using UnityEngine.Animations;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
public abstract class HumanAi : BaseAi
|
||||
public class HumanAi : BaseAi
|
||||
{
|
||||
#region Properties and variables
|
||||
|
||||
// 일반 변수
|
||||
protected LayerMask targetLayer;
|
||||
protected Vector3 defensePos;
|
||||
|
||||
// 모델링 관련 변수
|
||||
protected Transform backpackContainer;
|
||||
protected Transform leftWeaponContainer;
|
||||
@ -22,30 +16,6 @@ namespace BlueWaterProject
|
||||
protected Transform bodyContainer;
|
||||
protected Transform flagContainer;
|
||||
|
||||
// 컴포넌트 관련 변수
|
||||
protected Animator humanAnimator;
|
||||
protected NavMeshAgent humanAgent;
|
||||
protected CapsuleCollider myCollider;
|
||||
protected CapsuleCollider hitBoxCollider;
|
||||
protected LookAtConstraint lookAtConstraint;
|
||||
|
||||
// 애니메이션 관련 변수
|
||||
protected static readonly int SpeedHash = Animator.StringToHash("Speed");
|
||||
protected static readonly int AttackHash = Animator.StringToHash("Attack");
|
||||
protected static readonly int DamageHash = Animator.StringToHash("TakeDamage");
|
||||
protected static readonly int DeathTypeHash = Animator.StringToHash("DeathType");
|
||||
protected static readonly int DeathHash = Animator.StringToHash("Death");
|
||||
protected static readonly int ShieldHash = Animator.StringToHash("Shield");
|
||||
protected static readonly int OutlineColorHash = Shader.PropertyToID("_OutlineColor");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Abstract methods
|
||||
|
||||
protected abstract void SetLayer();
|
||||
|
||||
protected abstract void SetCurrentHp(float value);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity built-in methods
|
||||
@ -53,15 +23,13 @@ namespace BlueWaterProject
|
||||
protected virtual void Awake()
|
||||
{
|
||||
InitComponent();
|
||||
FlagLookAtFlag();
|
||||
SetLayer();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Custom methods
|
||||
|
||||
private void InitComponent()
|
||||
protected virtual void InitComponent()
|
||||
{
|
||||
backpackContainer = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Backpack_container"));
|
||||
@ -77,27 +45,6 @@ namespace BlueWaterProject
|
||||
Find("Body_container"));
|
||||
flagContainer = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Flag_container"));
|
||||
|
||||
humanAnimator = Utils.GetComponentAndAssert<Animator>(transform);
|
||||
humanAgent = Utils.GetComponentAndAssert<NavMeshAgent>(transform);
|
||||
myCollider = Utils.GetComponentAndAssert<CapsuleCollider>(transform);
|
||||
hitBoxCollider = Utils.GetComponentAndAssert<CapsuleCollider>(transform.Find("HitBox"));
|
||||
lookAtConstraint = Utils.GetComponentAndAssert<LookAtConstraint>(flagContainer);
|
||||
}
|
||||
|
||||
private void FlagLookAtFlag()
|
||||
{
|
||||
if (Camera.main != null)
|
||||
{
|
||||
var source = new ConstraintSource
|
||||
{
|
||||
sourceTransform = Camera.main.transform,
|
||||
weight = 1f
|
||||
};
|
||||
lookAtConstraint.AddSource(source);
|
||||
}
|
||||
|
||||
lookAtConstraint.constraintActive = true;
|
||||
}
|
||||
|
||||
protected void SetActiveViewModel(Transform container, int model)
|
||||
@ -115,8 +62,6 @@ namespace BlueWaterProject
|
||||
}
|
||||
}
|
||||
|
||||
protected void SetMoveSpeed(float value) => humanAgent.speed = value;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user