#28 유닛 생성 방식 변경 중
This commit is contained in:
parent
6438ca89a0
commit
ea170ca058
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using Random = UnityEngine.Random;
|
||||
@ -10,6 +11,14 @@ using Random = UnityEngine.Random;
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
public enum AiType
|
||||
{
|
||||
NONE = -1,
|
||||
PLAYER,
|
||||
PIRATE,
|
||||
ENEMY
|
||||
}
|
||||
|
||||
public enum AttackerType
|
||||
{
|
||||
NONE = -1,
|
||||
@ -27,7 +36,7 @@ namespace BlueWaterProject
|
||||
public enum DefenseType
|
||||
{
|
||||
NONE = -1,
|
||||
NORMAL,
|
||||
NORMAL
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@ -65,6 +74,14 @@ namespace BlueWaterProject
|
||||
protected bool isAttacking;
|
||||
private Vector3 commandedPos;
|
||||
|
||||
protected Transform backpackContainer;
|
||||
protected Transform leftWeaponContainer;
|
||||
protected Transform leftShieldContainer;
|
||||
protected Transform headContainer;
|
||||
protected Transform rightWeaponContainer;
|
||||
protected Transform bodyContainer;
|
||||
protected Transform flagContainer;
|
||||
|
||||
public IslandInfo IslandInfo { get; set; }
|
||||
protected Animator aiAnimator;
|
||||
protected NavMeshAgent navMeshAgent;
|
||||
@ -73,7 +90,6 @@ namespace BlueWaterProject
|
||||
private UnitSelection unitSelection;
|
||||
private CapsuleCollider myCollider;
|
||||
private CapsuleCollider hitBoxCollider;
|
||||
protected Transform weaponLocation;
|
||||
protected CloseWeapon closeWeapon;
|
||||
|
||||
private static readonly int SpeedHash = Animator.StringToHash("Speed");
|
||||
@ -100,19 +116,52 @@ namespace BlueWaterProject
|
||||
protected virtual void Awake()
|
||||
{
|
||||
FindMaterial();
|
||||
|
||||
backpackContainer = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Backpack_container"));
|
||||
leftWeaponContainer = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 L Clavicle/Bip001 L UpperArm/Bip001 L Forearm/Bip001 L Hand/L_hand_container"));
|
||||
leftShieldContainer = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 L Clavicle/Bip001 L UpperArm/Bip001 L Forearm/Bip001 L Hand/L_shield_container"));
|
||||
headContainer = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Neck/Bip001 Head/Head_container"));
|
||||
rightWeaponContainer = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand/R_hand_container"));
|
||||
bodyContainer = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Body_container"));
|
||||
flagContainer = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Flag_container"));
|
||||
|
||||
aiAnimator = Utils.GetComponentAndAssert<Animator>(transform);
|
||||
navMeshAgent = Utils.GetComponentAndAssert<NavMeshAgent>(transform);
|
||||
myUnitController = Utils.GetComponentAndAssert<UnitController>(transform.parent);
|
||||
myCollider = Utils.GetComponentAndAssert<CapsuleCollider>(transform);
|
||||
hitBoxCollider = Utils.GetComponentAndAssert<CapsuleCollider>(transform.Find("HitBox"));
|
||||
|
||||
unitSelection = FindObjectOfType<UnitSelection>();
|
||||
|
||||
SetAttackerType();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
switch (AiStat.AiType)
|
||||
{
|
||||
case AiType.NONE:
|
||||
break;
|
||||
case AiType.PLAYER:
|
||||
gameObject.layer = LayerMask.NameToLayer("Player");
|
||||
hitBoxCollider.gameObject.layer = LayerMask.NameToLayer("Player");
|
||||
break;
|
||||
case AiType.PIRATE:
|
||||
gameObject.layer = LayerMask.NameToLayer("Pirate");
|
||||
hitBoxCollider.gameObject.layer = LayerMask.NameToLayer("Pirate");
|
||||
break;
|
||||
case AiType.ENEMY:
|
||||
gameObject.layer = LayerMask.NameToLayer("Enemy");
|
||||
hitBoxCollider.gameObject.layer = LayerMask.NameToLayer("Enemy");
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
InitViewModel();
|
||||
SetCurrentHp(AiStat.MaxHp);
|
||||
SetMoveSpeed(AiStat.MoveSpd);
|
||||
|
||||
@ -460,6 +509,38 @@ namespace BlueWaterProject
|
||||
|
||||
#region Custom function
|
||||
|
||||
public void InitViewModel()
|
||||
{
|
||||
SetActiveViewModel(backpackContainer, DataManager.Inst.GetAiViewDictionaryKey(AiStat.ViewIdx).Backpack);
|
||||
SetActiveViewModel(leftWeaponContainer, DataManager.Inst.GetAiViewDictionaryKey(AiStat.ViewIdx).LeftWeapon);
|
||||
SetActiveViewModel(leftShieldContainer, DataManager.Inst.GetAiViewDictionaryKey(AiStat.ViewIdx).LeftShield);
|
||||
SetActiveViewModel(headContainer, DataManager.Inst.GetAiViewDictionaryKey(AiStat.ViewIdx).Head);
|
||||
SetActiveViewModel(rightWeaponContainer, DataManager.Inst.GetAiViewDictionaryKey(AiStat.ViewIdx).RightWeapon);
|
||||
SetActiveViewModel(bodyContainer, DataManager.Inst.GetAiViewDictionaryKey(AiStat.ViewIdx).Body);
|
||||
SetActiveViewModel(flagContainer, DataManager.Inst.GetAiViewDictionaryKey(AiStat.ViewIdx).Flag);
|
||||
|
||||
if (DataManager.Inst.GetAiViewDictionaryKey(AiStat.ViewIdx).RightWeapon == -1) return;
|
||||
|
||||
closeWeapon = rightWeaponContainer.GetChild(DataManager.Inst.GetAiViewDictionaryKey(AiStat.ViewIdx).RightWeapon).AddComponent<CloseWeapon>();
|
||||
closeWeapon.gameObject.layer = LayerMask.NameToLayer("Weapon");
|
||||
closeWeapon.SetAttackerType(attackerType);
|
||||
}
|
||||
|
||||
private void SetActiveViewModel(Transform container, int model)
|
||||
{
|
||||
foreach (Transform item in container)
|
||||
{
|
||||
if (!item.gameObject.activeSelf) continue;
|
||||
|
||||
item.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if (model != -1)
|
||||
{
|
||||
container.GetChild(model).gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Attack()
|
||||
{
|
||||
StartCoroutine(nameof(AttackAnimation));
|
||||
@ -542,22 +623,6 @@ namespace BlueWaterProject
|
||||
IslandInfo.RemoveListElement(IslandInfo.EnemyList, transform);
|
||||
}
|
||||
|
||||
private void SetAttackerType()
|
||||
{
|
||||
if (gameObject.layer == LayerMask.NameToLayer("Player"))
|
||||
{
|
||||
attackerType = AttackerType.OFFENSE;
|
||||
}
|
||||
else if (gameObject.layer == LayerMask.NameToLayer("Pirate"))
|
||||
{
|
||||
attackerType = AttackerType.OFFENSE;
|
||||
}
|
||||
else if (gameObject.layer == LayerMask.NameToLayer("Enemy"))
|
||||
{
|
||||
attackerType = AttackerType.DEFENSE;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetAgentIsStopped(bool value)
|
||||
{
|
||||
if (navMeshAgent.enabled)
|
||||
|
@ -6,7 +6,7 @@ using UnityEngine;
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
[Serializable]
|
||||
public class AiStat
|
||||
public class AiStat : IIdx
|
||||
{
|
||||
#region Property and variable
|
||||
|
||||
@ -16,6 +16,10 @@ namespace BlueWaterProject
|
||||
[field: Tooltip("캐릭터 모델 인덱스")]
|
||||
[field: SerializeField] public string ViewIdx { get; set; }
|
||||
|
||||
[field: Tooltip("Ai 종류")]
|
||||
[field: EnumToggleButtons]
|
||||
[field: SerializeField] public AiType AiType { get; set; }
|
||||
|
||||
[field: Tooltip("캐릭터 최대 체력")]
|
||||
[field: SerializeField] public float MaxHp { get; set; }
|
||||
|
||||
@ -52,6 +56,14 @@ namespace BlueWaterProject
|
||||
[field: ShowIf("@UsingShield == true")]
|
||||
[field: Range(0, 100)]
|
||||
[field: SerializeField] public int PenetrationResistivity { get; set; }
|
||||
|
||||
[field: Tooltip("캐릭터의 활 사용 유무")]
|
||||
[field: SerializeField] public bool UsingBow { get; set; }
|
||||
|
||||
[field: Tooltip("화살이 타겟에 도달하는 오차 범위(부정확함)")]
|
||||
[field: ShowIf("@UsingBow == true")]
|
||||
[field: Range(0, 2f)]
|
||||
[field: SerializeField] public float Inaccuracy { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -64,6 +76,7 @@ namespace BlueWaterProject
|
||||
{
|
||||
Idx = null;
|
||||
ViewIdx = null;
|
||||
AiType = AiType.NONE;
|
||||
MaxHp = 0f;
|
||||
CurrentHp = 0f;
|
||||
Atk = 0f;
|
||||
@ -75,16 +88,20 @@ namespace BlueWaterProject
|
||||
AvoidanceRate = 0;
|
||||
UsingShield = false;
|
||||
PenetrationResistivity = 0;
|
||||
UsingBow = false;
|
||||
Inaccuracy = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 일반 생성자
|
||||
/// </summary>
|
||||
public AiStat(string idx, string viewIdx, float maxHp, float currentHp, float atk, float def, float moveSpd,
|
||||
float atkCooldown, float atkRange, int shieldPenetrationRate, int avoidanceRate, bool usingShield, int penetrationResistivity)
|
||||
public AiStat(string idx, string viewIdx, AiType aiType, float maxHp, float currentHp, float atk, float def,
|
||||
float moveSpd, float atkCooldown, float atkRange, int shieldPenetrationRate, int avoidanceRate,
|
||||
bool usingShield, int penetrationResistivity, bool usingBow, float inaccuracy)
|
||||
{
|
||||
Idx = idx;
|
||||
ViewIdx = viewIdx;
|
||||
AiType = aiType;
|
||||
MaxHp = maxHp;
|
||||
CurrentHp = currentHp;
|
||||
Atk = atk;
|
||||
@ -96,6 +113,8 @@ namespace BlueWaterProject
|
||||
AvoidanceRate = avoidanceRate;
|
||||
UsingShield = usingShield;
|
||||
PenetrationResistivity = penetrationResistivity;
|
||||
UsingBow = usingBow;
|
||||
Inaccuracy = inaccuracy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -105,6 +124,7 @@ namespace BlueWaterProject
|
||||
{
|
||||
Idx = aiStat.Idx;
|
||||
ViewIdx = aiStat.ViewIdx;
|
||||
AiType = aiStat.AiType;
|
||||
MaxHp = aiStat.MaxHp;
|
||||
CurrentHp = aiStat.CurrentHp;
|
||||
Atk = aiStat.Atk;
|
||||
@ -116,6 +136,8 @@ namespace BlueWaterProject
|
||||
AvoidanceRate = aiStat.AvoidanceRate;
|
||||
UsingShield = aiStat.UsingShield;
|
||||
PenetrationResistivity = aiStat.PenetrationResistivity;
|
||||
UsingBow = aiStat.UsingBow;
|
||||
Inaccuracy = aiStat.Inaccuracy;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
[Serializable]
|
||||
public class AiView
|
||||
public class AiView : IIdx
|
||||
{
|
||||
#region Property and variable
|
||||
|
||||
@ -14,7 +13,7 @@ namespace BlueWaterProject
|
||||
[field: SerializeField] public string Idx { get; set; }
|
||||
|
||||
[field: Tooltip("등에 메고 다닐 모델\n화살통 등")]
|
||||
[field: SerializeField] public int BackPack { get; set; }
|
||||
[field: SerializeField] public int Backpack { get; set; }
|
||||
|
||||
[field: Tooltip("왼손 무기 모델\n활, 스태프 등")]
|
||||
[field: SerializeField] public int LeftWeapon { get; set; }
|
||||
@ -44,7 +43,7 @@ namespace BlueWaterProject
|
||||
public AiView()
|
||||
{
|
||||
Idx = null;
|
||||
BackPack = -1;
|
||||
Backpack = -1;
|
||||
LeftWeapon = -1;
|
||||
LeftShield = -1;
|
||||
Head = -1;
|
||||
@ -56,10 +55,10 @@ namespace BlueWaterProject
|
||||
/// <summary>
|
||||
/// 일반 생성자
|
||||
/// </summary>
|
||||
public AiView(string idx, int backPack, int leftWeapon, int leftShield, int head, int rightWeapon, int body, int flag)
|
||||
public AiView(string idx, int backpack, int leftWeapon, int leftShield, int head, int rightWeapon, int body, int flag)
|
||||
{
|
||||
Idx = idx;
|
||||
BackPack = backPack;
|
||||
Backpack = backpack;
|
||||
LeftWeapon = leftWeapon;
|
||||
LeftShield = leftShield;
|
||||
Head = head;
|
||||
@ -74,7 +73,7 @@ namespace BlueWaterProject
|
||||
public AiView(AiView aiView)
|
||||
{
|
||||
Idx = aiView.Idx;
|
||||
BackPack = aiView.BackPack;
|
||||
Backpack = aiView.Backpack;
|
||||
LeftWeapon = aiView.LeftWeapon;
|
||||
LeftShield = aiView.LeftShield;
|
||||
Head = aiView.Head;
|
||||
|
@ -11,14 +11,8 @@ namespace BlueWaterProject
|
||||
#region Property and variable
|
||||
|
||||
[Header("화살 오브젝트 관리")]
|
||||
[Tooltip("화살 오브젝트 프리팹")]
|
||||
[SerializeField] private GameObject arrowPrefab;
|
||||
|
||||
[Tooltip("화살 오브젝트 풀링할 최대 갯수")]
|
||||
[SerializeField] private int arrowMaxSize;
|
||||
|
||||
[Tooltip("화살 발사 위치")]
|
||||
[SerializeField] private Transform shootLocation;
|
||||
[SerializeField] private int arrowMaxSize = 100;
|
||||
|
||||
[Tooltip("화살 발사 후 오브젝트 저장될 위치")]
|
||||
[SerializeField] private Transform arrowsPoolLocation;
|
||||
@ -55,9 +49,22 @@ namespace BlueWaterProject
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
shootLocation = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 L Clavicle/Bip001 L UpperArm/Bip001 L Forearm/Bip001 L Hand/L_hand_container"));
|
||||
|
||||
var animatorControllerList = UnitManager.Inst.AIAnimatorControllerList;
|
||||
if (animatorControllerList == null)
|
||||
{
|
||||
Debug.LogError("Animator Controller List is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
var archerController = animatorControllerList.Find(obj => obj.name == "Archer");
|
||||
if (archerController == null)
|
||||
{
|
||||
Debug.LogError("No AnimatorController named 'Archer' was found in the list.");
|
||||
return;
|
||||
}
|
||||
|
||||
aiAnimator.runtimeAnimatorController = archerController;
|
||||
arrowsPoolLocation = GameObject.Find("ObjectPoolManager/Arrows").transform;
|
||||
arrowPool = new ObjectPool<Arrow>(CreateArrow, OnGetArrow, OnReleaseArrow, OnDestroyArrow, maxSize:arrowMaxSize);
|
||||
}
|
||||
@ -130,7 +137,7 @@ namespace BlueWaterProject
|
||||
public void OnShootArrow()
|
||||
{
|
||||
var arrow = arrowPool.Get();
|
||||
arrow.SetShootingArrow(shootLocation.position, transform.position,
|
||||
arrow.SetShootingArrow(leftWeaponContainer.position, transform.position,
|
||||
TargetTransform.position + rayOffset, AiStat, attackerType, inaccuracy);
|
||||
arrow.ShootArrowCoroutine();
|
||||
}
|
||||
@ -161,7 +168,7 @@ namespace BlueWaterProject
|
||||
|
||||
private Arrow CreateArrow()
|
||||
{
|
||||
var arrow = Instantiate(arrowPrefab, shootLocation.position, Quaternion.identity, arrowsPoolLocation).GetComponent<Arrow>();
|
||||
var arrow = Instantiate(UnitManager.Inst.ArrowPrefab, leftWeaponContainer.position, Quaternion.identity, arrowsPoolLocation).GetComponent<Arrow>();
|
||||
arrow.SetManagedPool(arrowPool);
|
||||
return arrow;
|
||||
}
|
||||
|
@ -9,17 +9,7 @@ namespace BlueWaterProject
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
weaponLocation = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand/R_hand_container"));
|
||||
|
||||
foreach (Transform weapon in weaponLocation)
|
||||
{
|
||||
if (!weapon.gameObject.activeSelf) continue;
|
||||
|
||||
closeWeapon = weapon.GetComponent<CloseWeapon>();
|
||||
break;
|
||||
}
|
||||
closeWeapon.SetAttackerType(attackerType);
|
||||
aiAnimator.runtimeAnimatorController = UnitManager.Inst.AIAnimatorControllerList.Find(obj => obj.name == "Axeman");
|
||||
}
|
||||
}
|
||||
}
|
@ -9,17 +9,7 @@ namespace BlueWaterProject
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
weaponLocation = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand/R_hand_container"));
|
||||
|
||||
foreach (Transform weapon in weaponLocation)
|
||||
{
|
||||
if (!weapon.gameObject.activeSelf) continue;
|
||||
|
||||
closeWeapon = weapon.GetComponent<CloseWeapon>();
|
||||
break;
|
||||
}
|
||||
closeWeapon.SetAttackerType(attackerType);
|
||||
aiAnimator.runtimeAnimatorController = UnitManager.Inst.AIAnimatorControllerList.Find(obj => obj.name == "SpearKnight");
|
||||
}
|
||||
}
|
||||
}
|
@ -9,17 +9,7 @@ namespace BlueWaterProject
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
weaponLocation = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand/R_hand_container"));
|
||||
|
||||
foreach (Transform weapon in weaponLocation)
|
||||
{
|
||||
if (!weapon.gameObject.activeSelf) continue;
|
||||
|
||||
closeWeapon = weapon.GetComponent<CloseWeapon>();
|
||||
break;
|
||||
}
|
||||
closeWeapon.SetAttackerType(attackerType);
|
||||
aiAnimator.runtimeAnimatorController = UnitManager.Inst.AIAnimatorControllerList.Find(obj => obj.name == "Spearman");
|
||||
}
|
||||
}
|
||||
}
|
@ -9,17 +9,7 @@ namespace BlueWaterProject
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
weaponLocation = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand/R_hand_container"));
|
||||
|
||||
foreach (Transform weapon in weaponLocation)
|
||||
{
|
||||
if (!weapon.gameObject.activeSelf) continue;
|
||||
|
||||
closeWeapon = weapon.GetComponent<CloseWeapon>();
|
||||
break;
|
||||
}
|
||||
closeWeapon.SetAttackerType(attackerType);
|
||||
aiAnimator.runtimeAnimatorController = UnitManager.Inst.AIAnimatorControllerList.Find(obj => obj.name == "SwordKnight");
|
||||
}
|
||||
}
|
||||
}
|
@ -9,17 +9,7 @@ namespace BlueWaterProject
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
weaponLocation = Utils.GetComponentAndAssert<Transform>(transform.
|
||||
Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 R Clavicle/Bip001 R UpperArm/Bip001 R Forearm/Bip001 R Hand/R_hand_container"));
|
||||
|
||||
foreach (Transform weapon in weaponLocation)
|
||||
{
|
||||
if (!weapon.gameObject.activeSelf) continue;
|
||||
|
||||
closeWeapon = weapon.GetComponent<CloseWeapon>();
|
||||
break;
|
||||
}
|
||||
closeWeapon.SetAttackerType(attackerType);
|
||||
aiAnimator.runtimeAnimatorController = UnitManager.Inst.AIAnimatorControllerList.Find(obj => obj.name == "Swordman");
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ using UnityEngine;
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
[Serializable]
|
||||
public class Unit
|
||||
public class Unit : IIdx
|
||||
{
|
||||
#region Property and variable
|
||||
|
||||
@ -24,18 +24,12 @@ namespace BlueWaterProject
|
||||
[field: SerializeField] public string UnitName { get; set; }
|
||||
|
||||
[field: Tooltip("부대의 종류")]
|
||||
[field: OnValueChanged("AttackerTypeAutoSetting")]
|
||||
[field: SerializeField] public GlobalValue.UnitType UnitType { get; set; }
|
||||
|
||||
[field: Tooltip("선원의 수")]
|
||||
[field: Range(0, GlobalValue.ONE_UNIT_CAPACITY - 1)]
|
||||
[field: SerializeField] public int SailorCount { get; set; }
|
||||
|
||||
[field: Tooltip("공격 타입 UnitType에 맞게 자동 설정")]
|
||||
[field: DisableInEditorMode]
|
||||
[field: EnumToggleButtons]
|
||||
[field: SerializeField] public AttackerType AttackerType { get; set; }
|
||||
|
||||
//[field: ShowIf("AttackerType", AttackerType.OFFENSE)]
|
||||
[field: SerializeField] public OffenseType OffenseType { get; set; }
|
||||
|
||||
@ -43,7 +37,7 @@ namespace BlueWaterProject
|
||||
[field: SerializeField] public DefenseType DefenseType { get; set; }
|
||||
|
||||
[field: Tooltip("부대 병력 리스트")]
|
||||
public List<AiController> UnitList { get; set; }
|
||||
[field: SerializeField] public List<AiController> UnitList { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -57,14 +51,13 @@ namespace BlueWaterProject
|
||||
UnitName = null;
|
||||
UnitType = GlobalValue.UnitType.NONE;
|
||||
SailorCount = 0;
|
||||
AttackerType = AttackerType.NONE;
|
||||
OffenseType = OffenseType.NONE;
|
||||
DefenseType = DefenseType.NONE;
|
||||
UnitList = new List<AiController>(GlobalValue.ONE_UNIT_CAPACITY);
|
||||
}
|
||||
|
||||
public Unit(string idx, string captainIdx, string sailorIdx, string unitName, GlobalValue.UnitType unitType,
|
||||
int sailorCount, AttackerType attackerType, OffenseType offenseType, DefenseType defenseType, List<AiController> unitList)
|
||||
int sailorCount, OffenseType offenseType, DefenseType defenseType, List<AiController> unitList)
|
||||
{
|
||||
Idx = idx;
|
||||
CaptainStatIdx = captainIdx;
|
||||
@ -72,7 +65,6 @@ namespace BlueWaterProject
|
||||
UnitName = unitName;
|
||||
UnitType = unitType;
|
||||
SailorCount = sailorCount;
|
||||
AttackerType = attackerType;
|
||||
OffenseType = offenseType;
|
||||
DefenseType = defenseType;
|
||||
UnitList = unitList;
|
||||
@ -86,7 +78,6 @@ namespace BlueWaterProject
|
||||
UnitName = unit.UnitName;
|
||||
UnitType = unit.UnitType;
|
||||
SailorCount = unit.SailorCount;
|
||||
AttackerType = unit.AttackerType;
|
||||
OffenseType = unit.OffenseType;
|
||||
DefenseType = unit.DefenseType;
|
||||
UnitList = unit.UnitList;
|
||||
@ -96,23 +87,6 @@ namespace BlueWaterProject
|
||||
|
||||
#region Custrom method
|
||||
|
||||
public void AttackerTypeAutoSetting()
|
||||
{
|
||||
if (UnitType.ToString().Contains("_E"))
|
||||
{
|
||||
AttackerType = AttackerType.DEFENSE;
|
||||
}
|
||||
else if (UnitType.ToString().Contains("_P"))
|
||||
{
|
||||
AttackerType = AttackerType.OFFENSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
AttackerType = AttackerType.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAttackerType(AttackerType type) => AttackerType = type;
|
||||
public void SetOffenseType(OffenseType type) => OffenseType = type;
|
||||
public void SetDefenseType(DefenseType type) => DefenseType = type;
|
||||
|
||||
|
@ -10,8 +10,8 @@ namespace BlueWaterProject
|
||||
#region Property and variable
|
||||
|
||||
[PropertyOrder(-11)]
|
||||
[EnableIf("@unit.AttackerType == AttackerType.OFFENSE")]
|
||||
[InlineButton("SetIslandInfoTest", "테스트 설정")]
|
||||
//[EnableIf("@unit.AttackerType == AttackerType.OFFENSE")]
|
||||
//[InlineButton("SetIslandInfoTest", "테스트 설정")]
|
||||
[SerializeField] private IslandInfo attackIslandInfo;
|
||||
|
||||
[PropertyOrder(-10)]
|
||||
@ -28,7 +28,7 @@ namespace BlueWaterProject
|
||||
if (unit == null || unit.SailorCount <= 0) return;
|
||||
|
||||
var unitManager = UnitManager.Inst != null ? UnitManager.Inst : FindObjectOfType<UnitManager>();
|
||||
var matrix = unitManager.UnitMatrices.Find(um => um.soldiers == unit.SailorCount);
|
||||
var matrix = unitManager.UnitMatrices.Find(um => um.units == unit.SailorCount);
|
||||
if (matrix == null) return;
|
||||
|
||||
for (var i = 0; i < unit.SailorCount; i++)
|
||||
@ -36,8 +36,8 @@ namespace BlueWaterProject
|
||||
var row = i / matrix.columns;
|
||||
var column = i % matrix.columns;
|
||||
|
||||
var xOffset = (column - (matrix.columns - 1) / 2.0f) * unitManager.SoldierSpacing;
|
||||
var zOffset = (row - (matrix.rows - 1) / 2.0f) * unitManager.SoldierSpacing;
|
||||
var xOffset = (column - (matrix.columns - 1) / 2.0f) * unitManager.UnitSpacing;
|
||||
var zOffset = (row - (matrix.rows - 1) / 2.0f) * unitManager.UnitSpacing;
|
||||
var spawnPosition = transform.position + new Vector3(xOffset, 0, zOffset);
|
||||
|
||||
var ray = new Ray(spawnPosition, Vector3.down);
|
||||
@ -46,10 +46,10 @@ namespace BlueWaterProject
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
SetIslandInfoTest();
|
||||
}
|
||||
// private void Start()
|
||||
// {
|
||||
// SetIslandInfoTest();
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -107,13 +107,12 @@ namespace BlueWaterProject
|
||||
|
||||
[PropertyOrder(1)]
|
||||
[GUIColor("GetTypeAllButtonColor")]
|
||||
[ShowIf("ShowTypeAllButton")]
|
||||
//[ShowIf("ShowTypeAllButton")]
|
||||
[Button("타입 모두 적용")]
|
||||
private void SetTypeAll()
|
||||
{
|
||||
foreach (var soldier in unit.UnitList)
|
||||
{
|
||||
soldier.SetAttackerType(unit.AttackerType);
|
||||
soldier.SetOffenseType(unit.OffenseType);
|
||||
soldier.SetDefenseType(unit.DefenseType);
|
||||
}
|
||||
@ -129,56 +128,56 @@ namespace BlueWaterProject
|
||||
}
|
||||
}
|
||||
|
||||
private void SetIslandInfoTest()
|
||||
{
|
||||
if (unit.AttackerType != AttackerType.OFFENSE) return;
|
||||
|
||||
var islandInfo = FindObjectOfType<IslandInfo>();
|
||||
attackIslandInfo = islandInfo;
|
||||
|
||||
foreach (var soldier in unit.UnitList)
|
||||
{
|
||||
soldier.IslandInfo = attackIslandInfo;
|
||||
}
|
||||
}
|
||||
// private void SetIslandInfoTest()
|
||||
// {
|
||||
// if (unit.AttackerType != AttackerType.OFFENSE) return;
|
||||
//
|
||||
// var islandInfo = FindObjectOfType<IslandInfo>();
|
||||
// attackIslandInfo = islandInfo;
|
||||
//
|
||||
// foreach (var soldier in unit.UnitList)
|
||||
// {
|
||||
// soldier.IslandInfo = attackIslandInfo;
|
||||
// }
|
||||
// }
|
||||
|
||||
private bool ShowTypeAllButton()
|
||||
{
|
||||
switch (unit.AttackerType)
|
||||
{
|
||||
case AttackerType.NONE:
|
||||
return false;
|
||||
case AttackerType.OFFENSE:
|
||||
if (unit.OffenseType == OffenseType.NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case AttackerType.DEFENSE:
|
||||
if (unit.DefenseType == DefenseType.NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// private bool ShowTypeAllButton()
|
||||
// {
|
||||
// switch (unit.AttackerType)
|
||||
// {
|
||||
// case AttackerType.NONE:
|
||||
// return false;
|
||||
// case AttackerType.OFFENSE:
|
||||
// if (unit.OffenseType == OffenseType.NONE)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// break;
|
||||
// case AttackerType.DEFENSE:
|
||||
// if (unit.DefenseType == DefenseType.NONE)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// throw new ArgumentOutOfRangeException();
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
private Color GetCreateUnitButtonColor() => unit.UnitList.Count > 0 ? Color.white : Color.green;
|
||||
private Color GetAttackerTypeButtonColor()
|
||||
{
|
||||
if (unit.UnitList.Count > 0)
|
||||
{
|
||||
return unit.AttackerType == AttackerType.NONE ? Color.green : Color.white;
|
||||
}
|
||||
|
||||
return Color.white;
|
||||
}
|
||||
// private Color GetAttackerTypeButtonColor()
|
||||
// {
|
||||
// if (unit.UnitList.Count > 0)
|
||||
// {
|
||||
// return unit.AttackerType == AttackerType.NONE ? Color.green : Color.white;
|
||||
// }
|
||||
//
|
||||
// return Color.white;
|
||||
// }
|
||||
private Color GetTypeAllButtonColor() => isClickedTypeAllButton ? Color.white : Color.green;
|
||||
private void OnTypeChanged() => isClickedTypeAllButton = false;
|
||||
public void SetAttackerType(AttackerType value) => unit.AttackerType = value;
|
||||
//public void SetAttackerType(AttackerType value) => unit.AttackerType = value;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEditor.Animations;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
@ -9,14 +11,14 @@ namespace BlueWaterProject
|
||||
[Serializable]
|
||||
public class UnitMatrix
|
||||
{
|
||||
public int soldiers; // 부대 안의 병사 수
|
||||
public int units; // 부대 안의 병사 수
|
||||
public int rows; // 배치될 행의 갯수
|
||||
public int columns; // 배치될 열의 갯수
|
||||
//public int centerNum; // 부대의 중심 번호
|
||||
|
||||
public UnitMatrix(int soldiers, int rows, int columns)
|
||||
public UnitMatrix(int units, int rows, int columns)
|
||||
{
|
||||
this.soldiers = soldiers;
|
||||
this.units = units;
|
||||
this.rows = rows;
|
||||
this.columns = columns;
|
||||
}
|
||||
@ -25,6 +27,15 @@ namespace BlueWaterProject
|
||||
public class UnitManager : Singleton<UnitManager>
|
||||
{
|
||||
#region Property and variable
|
||||
|
||||
[Tooltip("유닛 프리팹")]
|
||||
[field: SerializeField] public GameObject UnitPrefab { get; private set; }
|
||||
|
||||
[Tooltip("캐릭터 기초 프리팹")]
|
||||
[field: SerializeField] public GameObject BaseCharacterPrefab { get; private set; }
|
||||
|
||||
[Tooltip("화살 프리팹")]
|
||||
[field: SerializeField] public GameObject ArrowPrefab { get; private set; }
|
||||
|
||||
[Tooltip("바닥 레이어")]
|
||||
[field: SerializeField] public LayerMask GroundLayer { get; private set; }
|
||||
@ -33,13 +44,17 @@ namespace BlueWaterProject
|
||||
[field: SerializeField] public float MaxGroundDistance { get; private set; } = 0.5f;
|
||||
|
||||
[Tooltip("병력 간의 간격")]
|
||||
[field: SerializeField] public float SoldierSpacing { get; private set; } = 0.5f;
|
||||
[field: SerializeField] public float UnitSpacing { get; private set; } = 0.5f;
|
||||
|
||||
[Tooltip("부대 배치 행렬")]
|
||||
[field: SerializeField] public List<UnitMatrix> UnitMatrices { get; private set; } = new(MATRICES_CAPACITY);
|
||||
|
||||
[FormerlySerializedAs("soldierPrefabList")]
|
||||
[Tooltip("병력들의 프리팹 리스트(순서 중요)")]
|
||||
[SerializeField] private List<GameObject> soldierPrefabList = new(SOLDIER_PREFAB_CAPACITY);
|
||||
[SerializeField] private List<GameObject> characterPrefabList = new(SOLDIER_PREFAB_CAPACITY);
|
||||
|
||||
[field: Tooltip("병력들의 애니메이터 컨트롤러 리스트")]
|
||||
[field: SerializeField] public List<AnimatorController> AIAnimatorControllerList { get; private set; } = new(GlobalValue.AI_ANIMATOR_CAPACITY);
|
||||
|
||||
[Tooltip("플레이어가 가지고 있는 부대리스트")]
|
||||
[SerializeField] private List<UnitController> playerUnitList = new(PLAYER_UNIT_CAPACITY);
|
||||
@ -67,10 +82,10 @@ namespace BlueWaterProject
|
||||
{
|
||||
GroundLayer = LayerMask.GetMask("Ground");
|
||||
MaxGroundDistance = 0.5f;
|
||||
SoldierSpacing = 0.5f;
|
||||
soldierPrefabList = new List<GameObject>(SOLDIER_PREFAB_CAPACITY); // TODO : 프리팹 자동 리셋화 필요
|
||||
UnitSpacing = 0.5f;
|
||||
characterPrefabList = new List<GameObject>(SOLDIER_PREFAB_CAPACITY); // TODO : 프리팹 자동 리셋화 필요
|
||||
InitUnitMatrices();
|
||||
InitSoldierPrefabList();
|
||||
InitCharacterPrefabList();
|
||||
InitPlayerUnitList();
|
||||
}
|
||||
|
||||
@ -105,11 +120,15 @@ namespace BlueWaterProject
|
||||
/// 프리팹 초기화 함수
|
||||
/// </summary>
|
||||
[GUIColor(0, 1, 0)]
|
||||
[ShowIf("@soldierPrefabList.Count != SOLDIER_PREFAB_CAPACITY")]
|
||||
[ShowIf("@BaseCharacterPrefab == null || UnitPrefab == null || ArrowPrefab == null")]
|
||||
[Button("프리팹 초기화")]
|
||||
private void InitSoldierPrefabList()
|
||||
private void InitCharacterPrefabList()
|
||||
{
|
||||
soldierPrefabList = new List<GameObject>(SOLDIER_PREFAB_CAPACITY)
|
||||
UnitPrefab = Utils.LoadPrefabFromFolder("Assets/05.Prefabs/Character", "Unit");
|
||||
BaseCharacterPrefab = Utils.LoadPrefabFromFolder("Assets/05.Prefabs/Character", "BaseCharacter");
|
||||
ArrowPrefab = Utils.LoadPrefabFromFolder("Assets/05.Prefabs", "Arrow_01");
|
||||
|
||||
characterPrefabList = new List<GameObject>(SOLDIER_PREFAB_CAPACITY)
|
||||
{
|
||||
Utils.LoadPrefabFromFolder("Assets/05.Prefabs/Character/Enemy", "Archer_E"),
|
||||
Utils.LoadPrefabFromFolder("Assets/05.Prefabs/Character/Enemy", "SpearKnight_E"),
|
||||
@ -132,17 +151,7 @@ namespace BlueWaterProject
|
||||
[Button("플레이어 유닛 가져오기")]
|
||||
private void InitPlayerUnitList()
|
||||
{
|
||||
var playerUnitsObj = GameObject.Find("PlayerUnits");
|
||||
if (playerUnitsObj)
|
||||
{
|
||||
playerUnits = playerUnitsObj.transform;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerUnitsObj = new GameObject("PlayerUnits");
|
||||
playerUnitsObj.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
|
||||
playerUnits = playerUnitsObj.transform;
|
||||
}
|
||||
SetPlayerUnits();
|
||||
|
||||
playerUnitList = new List<UnitController>(PLAYER_UNIT_CAPACITY);
|
||||
|
||||
@ -154,15 +163,23 @@ namespace BlueWaterProject
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 부대 생성 함수
|
||||
/// </summary>
|
||||
public void CreateUnit(UnitController unitController)
|
||||
private void SetPlayerUnits()
|
||||
{
|
||||
DestroyDeployedSoldiers(unitController);
|
||||
|
||||
var baseName = soldierPrefabList[(int)unitController.unit.UnitType].name;
|
||||
var playerUnitsObj = GameObject.Find("PlayerUnits");
|
||||
if (playerUnitsObj)
|
||||
{
|
||||
playerUnits = playerUnitsObj.transform;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerUnitsObj = new GameObject("PlayerUnits");
|
||||
playerUnitsObj.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
|
||||
playerUnits = playerUnitsObj.transform;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetUnitName(UnitController unitController, string baseName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(unitController.unit.UnitName))
|
||||
{
|
||||
const int maxIterations = 100;
|
||||
@ -187,11 +204,153 @@ namespace BlueWaterProject
|
||||
{
|
||||
unitController.gameObject.name = unitController.unit.UnitName;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateUnit(string cardIdx, AttackerType attackerType)
|
||||
{
|
||||
var card = DataManager.Inst.GetCardDictionaryKey(cardIdx);
|
||||
var unit = DataManager.Inst.GetUnitDictionaryKey(card.UnitIdx);
|
||||
var captainStat = DataManager.Inst.GetAiStatDictionaryKey(unit.CaptainStatIdx);
|
||||
var sailorStat = DataManager.Inst.GetAiStatDictionaryKey(unit.SailorStatIdx);
|
||||
|
||||
// 비활성화 생성 및 정렬
|
||||
SetPlayerUnits();
|
||||
|
||||
var newUnitController = Instantiate(UnitPrefab, Vector3.zero, Quaternion.identity, playerUnits).GetComponent<UnitController>();
|
||||
newUnitController.unit = new Unit(unit);
|
||||
|
||||
DestroyDeployedUnits(newUnitController);
|
||||
|
||||
var baseName = characterPrefabList[(int)newUnitController.unit.UnitType].name;
|
||||
SetUnitName(newUnitController, baseName);
|
||||
|
||||
newUnitController.unit.UnitList = new List<AiController>(newUnitController.unit.SailorCount + 1);
|
||||
|
||||
var unitControllerTransform = newUnitController.transform;
|
||||
var unitControllerRotation = unitControllerTransform.rotation;
|
||||
unitControllerTransform.rotation = Quaternion.identity;
|
||||
|
||||
var gridSize = 0;
|
||||
|
||||
switch (newUnitController.unit.SailorCount)
|
||||
{
|
||||
case 0:
|
||||
gridSize = 1;
|
||||
break;
|
||||
case <= 3:
|
||||
gridSize = 2;
|
||||
break;
|
||||
case <= 8:
|
||||
gridSize = 3;
|
||||
break;
|
||||
case <= 15:
|
||||
gridSize = 4;
|
||||
break;
|
||||
default:
|
||||
print("유닛의 병사 숫자 설정 에러");
|
||||
break;
|
||||
}
|
||||
|
||||
var heroPosition = (gridSize * gridSize) / 2;
|
||||
|
||||
for (var i = 0; i < gridSize; i++)
|
||||
{
|
||||
for (var j = 0; j < gridSize; j++)
|
||||
{
|
||||
var currentPos = i * gridSize + j;
|
||||
|
||||
if (currentPos > newUnitController.unit.SailorCount) break;
|
||||
|
||||
var xOffset = (i - (gridSize - 1) / 2.0f) * UnitSpacing;
|
||||
var zOffset = (j - (gridSize - 1) / 2.0f) * UnitSpacing;
|
||||
var spawnPosition = unitControllerTransform.position + new Vector3(xOffset, 0, zOffset);
|
||||
|
||||
var baseObj = Instantiate(BaseCharacterPrefab, spawnPosition,
|
||||
Quaternion.identity, newUnitController.transform);
|
||||
|
||||
var newSoldierName = $"{baseName}_{currentPos + 1:00}";
|
||||
|
||||
baseObj.name = newSoldierName;
|
||||
baseObj.gameObject.SetActive(false);
|
||||
|
||||
AiController aiController;
|
||||
if (currentPos == heroPosition)
|
||||
{
|
||||
aiController = GetAiController(baseObj, newUnitController.unit.UnitType, captainStat);
|
||||
}
|
||||
else
|
||||
{
|
||||
aiController = GetAiController(baseObj, newUnitController.unit.UnitType, sailorStat);
|
||||
}
|
||||
|
||||
aiController.SetAttackerType(attackerType);
|
||||
newUnitController.unit.UnitList.Add(aiController);
|
||||
}
|
||||
}
|
||||
newUnitController.transform.rotation *= unitControllerRotation;
|
||||
}
|
||||
|
||||
private AiController GetAiController(GameObject baseObj, GlobalValue.UnitType unitType, AiStat aiStat)
|
||||
{
|
||||
AiController temp = null;
|
||||
switch (unitType)
|
||||
{
|
||||
case GlobalValue.UnitType.NONE:
|
||||
break;
|
||||
case GlobalValue.UnitType.ARCHER_E:
|
||||
temp = baseObj.AddComponent<Archer>();
|
||||
break;
|
||||
case GlobalValue.UnitType.SPEAR_KNIGHT_E:
|
||||
temp = baseObj.AddComponent<SpearKnight>();
|
||||
break;
|
||||
case GlobalValue.UnitType.SPEARMAN_E:
|
||||
temp = baseObj.AddComponent<Spearman>();
|
||||
break;
|
||||
case GlobalValue.UnitType.SWORD_KNIGHT_E:
|
||||
temp = baseObj.AddComponent<SwordKnight>();
|
||||
break;
|
||||
case GlobalValue.UnitType.SWORDMAN_E:
|
||||
temp = baseObj.AddComponent<Swordman>();
|
||||
break;
|
||||
case GlobalValue.UnitType.ARCHER_P:
|
||||
temp = baseObj.AddComponent<Archer>();
|
||||
break;
|
||||
case GlobalValue.UnitType.AXEMAN_P:
|
||||
temp = baseObj.AddComponent<Axeman>();
|
||||
break;
|
||||
case GlobalValue.UnitType.SPEARMAN_P:
|
||||
temp = baseObj.AddComponent<Spearman>();
|
||||
break;
|
||||
case GlobalValue.UnitType.SWORD_KNIGHT_P:
|
||||
temp = baseObj.AddComponent<SwordKnight>();
|
||||
break;
|
||||
case GlobalValue.UnitType.SWORDMAN_P:
|
||||
temp = baseObj.AddComponent<Swordman>();
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(unitType), unitType, null);
|
||||
}
|
||||
|
||||
if (temp == null) return null;
|
||||
|
||||
temp.AiStat = new AiStat(aiStat);
|
||||
return temp;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 부대 생성 함수
|
||||
/// </summary>
|
||||
public void CreateUnit(UnitController unitController)
|
||||
{
|
||||
DestroyDeployedUnits(unitController);
|
||||
|
||||
var baseName = characterPrefabList[(int)unitController.unit.UnitType].name;
|
||||
SetUnitName(unitController, baseName);
|
||||
|
||||
unitController.gameObject.layer = LayerMask.NameToLayer("Unit");
|
||||
unitController.unit.UnitList = new List<AiController>(unitController.unit.SailorCount);
|
||||
|
||||
var matrix = UnitMatrices.Find(um => um.soldiers == unitController.unit.SailorCount);
|
||||
var matrix = UnitMatrices.Find(um => um.units == unitController.unit.SailorCount);
|
||||
if (matrix == null)
|
||||
{
|
||||
Debug.LogError("사용할 수 없는 병력의 숫자입니다. UnitManager의 UnitMatrices를 확인해주세요.");
|
||||
@ -207,11 +366,11 @@ namespace BlueWaterProject
|
||||
var row = i / matrix.columns;
|
||||
var column = i % matrix.columns;
|
||||
|
||||
var xOffset = (column - (matrix.columns - 1) / 2.0f) * SoldierSpacing;
|
||||
var zOffset = (row - (matrix.rows - 1) / 2.0f) * SoldierSpacing;
|
||||
var xOffset = (column - (matrix.columns - 1) / 2.0f) * UnitSpacing;
|
||||
var zOffset = (row - (matrix.rows - 1) / 2.0f) * UnitSpacing;
|
||||
var spawnPosition = unitControllerTransform.position + new Vector3(xOffset, 0, zOffset);
|
||||
|
||||
var soldierObject = Instantiate(soldierPrefabList[(int)unitController.unit.UnitType], spawnPosition,
|
||||
var soldierObject = Instantiate(characterPrefabList[(int)unitController.unit.UnitType], spawnPosition,
|
||||
Quaternion.identity, unitController.transform).GetComponent<AiController>();
|
||||
|
||||
var newSoldierName = $"{baseName}_{i + 1:00}";
|
||||
@ -222,22 +381,22 @@ namespace BlueWaterProject
|
||||
}
|
||||
unitController.transform.rotation *= unitControllerRotation;
|
||||
|
||||
if (unitController.unit.UnitType.ToString().Contains("_E"))
|
||||
{
|
||||
unitController.SetAttackerType(AttackerType.DEFENSE);
|
||||
foreach (var soldier in unitController.unit.UnitList)
|
||||
{
|
||||
soldier.SetAttackerType(AttackerType.DEFENSE);
|
||||
}
|
||||
}
|
||||
else if (unitController.unit.UnitType.ToString().Contains("_P"))
|
||||
{
|
||||
unitController.SetAttackerType(AttackerType.OFFENSE);
|
||||
foreach (var soldier in unitController.unit.UnitList)
|
||||
{
|
||||
soldier.SetAttackerType(AttackerType.DEFENSE);
|
||||
}
|
||||
}
|
||||
// if (unitController.unit.UnitType.ToString().Contains("_E"))
|
||||
// {
|
||||
// unitController.SetAttackerType(AttackerType.DEFENSE);
|
||||
// foreach (var soldier in unitController.unit.UnitList)
|
||||
// {
|
||||
// soldier.SetAttackerType(AttackerType.DEFENSE);
|
||||
// }
|
||||
// }
|
||||
// else if (unitController.unit.UnitType.ToString().Contains("_P"))
|
||||
// {
|
||||
// unitController.SetAttackerType(AttackerType.OFFENSE);
|
||||
// foreach (var soldier in unitController.unit.UnitList)
|
||||
// {
|
||||
// soldier.SetAttackerType(AttackerType.DEFENSE);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -278,7 +437,7 @@ namespace BlueWaterProject
|
||||
/// <summary>
|
||||
/// 기존에 생성된 부대 병력들이 있으면 확인해서 삭제해주는 함수
|
||||
/// </summary>
|
||||
private void DestroyDeployedSoldiers(UnitController unitController)
|
||||
private void DestroyDeployedUnits(UnitController unitController)
|
||||
{
|
||||
if (unitController.transform.childCount <= 0) return;
|
||||
|
||||
|
@ -15,6 +15,7 @@ MonoBehaviour:
|
||||
aiStatDataList:
|
||||
- <Idx>k__BackingField: ai_stat_sailor_e_001
|
||||
<ViewIdx>k__BackingField: ai_view_sailor_e_001
|
||||
<AiType>k__BackingField: 2
|
||||
<MaxHp>k__BackingField: 30
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 50
|
||||
@ -26,8 +27,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 20
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 1
|
||||
<Inaccuracy>k__BackingField: 0.5
|
||||
- <Idx>k__BackingField: ai_stat_sailor_e_002
|
||||
<ViewIdx>k__BackingField: ai_view_sailor_e_002
|
||||
<AiType>k__BackingField: 2
|
||||
<MaxHp>k__BackingField: 60
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 40
|
||||
@ -39,8 +43,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 10
|
||||
<UsingShield>k__BackingField: 1
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_sailor_e_003
|
||||
<ViewIdx>k__BackingField: ai_view_sailor_e_003
|
||||
<AiType>k__BackingField: 2
|
||||
<MaxHp>k__BackingField: 40
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 50
|
||||
@ -52,8 +59,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 20
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_sailor_e_004
|
||||
<ViewIdx>k__BackingField: ai_view_sailor_e_004
|
||||
<AiType>k__BackingField: 2
|
||||
<MaxHp>k__BackingField: 60
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 30
|
||||
@ -65,8 +75,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 10
|
||||
<UsingShield>k__BackingField: 1
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_sailor_e_005
|
||||
<ViewIdx>k__BackingField: ai_view_sailor_e_005
|
||||
<AiType>k__BackingField: 2
|
||||
<MaxHp>k__BackingField: 45
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 35
|
||||
@ -78,8 +91,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 30
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_sailor_p_001
|
||||
<ViewIdx>k__BackingField: ai_view_sailor_p_001
|
||||
<AiType>k__BackingField: 1
|
||||
<MaxHp>k__BackingField: 30
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 50
|
||||
@ -91,8 +107,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 20
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 1
|
||||
<Inaccuracy>k__BackingField: 0.5
|
||||
- <Idx>k__BackingField: ai_stat_sailor_p_002
|
||||
<ViewIdx>k__BackingField: ai_view_sailor_p_002
|
||||
<AiType>k__BackingField: 1
|
||||
<MaxHp>k__BackingField: 50
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 50
|
||||
@ -104,8 +123,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 10
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_sailor_p_003
|
||||
<ViewIdx>k__BackingField: ai_view_sailor_p_003
|
||||
<AiType>k__BackingField: 1
|
||||
<MaxHp>k__BackingField: 40
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 50
|
||||
@ -117,8 +139,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 20
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_sailor_p_004
|
||||
<ViewIdx>k__BackingField: ai_view_sailor_p_004
|
||||
<AiType>k__BackingField: 1
|
||||
<MaxHp>k__BackingField: 60
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 30
|
||||
@ -130,8 +155,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 10
|
||||
<UsingShield>k__BackingField: 1
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_sailor_p_005
|
||||
<ViewIdx>k__BackingField: ai_view_sailor_p_005
|
||||
<AiType>k__BackingField: 1
|
||||
<MaxHp>k__BackingField: 45
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 35
|
||||
@ -143,8 +171,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 30
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_captain_e_001
|
||||
<ViewIdx>k__BackingField: ai_view_captain_e_001
|
||||
<AiType>k__BackingField: 2
|
||||
<MaxHp>k__BackingField: 150
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 50
|
||||
@ -156,8 +187,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 20
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 1
|
||||
<Inaccuracy>k__BackingField: 0.5
|
||||
- <Idx>k__BackingField: ai_stat_captain_e_002
|
||||
<ViewIdx>k__BackingField: ai_view_captain_e_002
|
||||
<AiType>k__BackingField: 2
|
||||
<MaxHp>k__BackingField: 300
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 40
|
||||
@ -169,8 +203,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 10
|
||||
<UsingShield>k__BackingField: 1
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_captain_e_003
|
||||
<ViewIdx>k__BackingField: ai_view_captain_e_003
|
||||
<AiType>k__BackingField: 2
|
||||
<MaxHp>k__BackingField: 200
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 50
|
||||
@ -182,8 +219,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 20
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_captain_e_004
|
||||
<ViewIdx>k__BackingField: ai_view_captain_e_004
|
||||
<AiType>k__BackingField: 2
|
||||
<MaxHp>k__BackingField: 300
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 30
|
||||
@ -195,8 +235,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 10
|
||||
<UsingShield>k__BackingField: 1
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_captain_e_005
|
||||
<ViewIdx>k__BackingField: ai_view_captain_e_005
|
||||
<AiType>k__BackingField: 2
|
||||
<MaxHp>k__BackingField: 225
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 35
|
||||
@ -208,8 +251,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 30
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_captain_p_001
|
||||
<ViewIdx>k__BackingField: ai_view_captain_p_001
|
||||
<AiType>k__BackingField: 1
|
||||
<MaxHp>k__BackingField: 150
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 50
|
||||
@ -221,8 +267,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 20
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 1
|
||||
<Inaccuracy>k__BackingField: 0.5
|
||||
- <Idx>k__BackingField: ai_stat_captain_p_002
|
||||
<ViewIdx>k__BackingField: ai_view_captain_p_002
|
||||
<AiType>k__BackingField: 1
|
||||
<MaxHp>k__BackingField: 250
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 50
|
||||
@ -234,8 +283,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 10
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_captain_p_003
|
||||
<ViewIdx>k__BackingField: ai_view_captain_p_003
|
||||
<AiType>k__BackingField: 1
|
||||
<MaxHp>k__BackingField: 200
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 50
|
||||
@ -247,8 +299,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 20
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_captain_p_004
|
||||
<ViewIdx>k__BackingField: ai_view_captain_p_004
|
||||
<AiType>k__BackingField: 1
|
||||
<MaxHp>k__BackingField: 300
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 30
|
||||
@ -260,8 +315,11 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 10
|
||||
<UsingShield>k__BackingField: 1
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_stat_captain_p_005
|
||||
<ViewIdx>k__BackingField: ai_view_captain_p_005
|
||||
<AiType>k__BackingField: 1
|
||||
<MaxHp>k__BackingField: 225
|
||||
<CurrentHp>k__BackingField: 0
|
||||
<Atk>k__BackingField: 35
|
||||
@ -273,3 +331,5 @@ MonoBehaviour:
|
||||
<AvoidanceRate>k__BackingField: 30
|
||||
<UsingShield>k__BackingField: 0
|
||||
<PenetrationResistivity>k__BackingField: 0
|
||||
<UsingBow>k__BackingField: 0
|
||||
<Inaccuracy>k__BackingField: 0
|
||||
|
@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
aiViewDataList:
|
||||
- <Idx>k__BackingField: ai_view_sailor_e_001
|
||||
<BackPack>k__BackingField: 1
|
||||
<Backpack>k__BackingField: 1
|
||||
<LeftWeapon>k__BackingField: 2
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 16
|
||||
@ -22,7 +22,7 @@ MonoBehaviour:
|
||||
<Body>k__BackingField: 11
|
||||
<Flag>k__BackingField: -1
|
||||
- <Idx>k__BackingField: ai_view_sailor_e_002
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: 1
|
||||
<Head>k__BackingField: 46
|
||||
@ -30,7 +30,7 @@ MonoBehaviour:
|
||||
<Body>k__BackingField: 18
|
||||
<Flag>k__BackingField: -1
|
||||
- <Idx>k__BackingField: ai_view_sailor_e_003
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 35
|
||||
@ -38,7 +38,7 @@ MonoBehaviour:
|
||||
<Body>k__BackingField: 17
|
||||
<Flag>k__BackingField: -1
|
||||
- <Idx>k__BackingField: ai_view_sailor_e_004
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: 9
|
||||
<Head>k__BackingField: 33
|
||||
@ -46,7 +46,7 @@ MonoBehaviour:
|
||||
<Body>k__BackingField: 39
|
||||
<Flag>k__BackingField: -1
|
||||
- <Idx>k__BackingField: ai_view_sailor_e_005
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 25
|
||||
@ -54,7 +54,7 @@ MonoBehaviour:
|
||||
<Body>k__BackingField: 29
|
||||
<Flag>k__BackingField: -1
|
||||
- <Idx>k__BackingField: ai_view_sailor_p_001
|
||||
<BackPack>k__BackingField: 0
|
||||
<Backpack>k__BackingField: 0
|
||||
<LeftWeapon>k__BackingField: 1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 11
|
||||
@ -62,7 +62,7 @@ MonoBehaviour:
|
||||
<Body>k__BackingField: 1
|
||||
<Flag>k__BackingField: -1
|
||||
- <Idx>k__BackingField: ai_view_sailor_p_002
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 50
|
||||
@ -70,7 +70,7 @@ MonoBehaviour:
|
||||
<Body>k__BackingField: 58
|
||||
<Flag>k__BackingField: -1
|
||||
- <Idx>k__BackingField: ai_view_sailor_p_003
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 36
|
||||
@ -78,7 +78,7 @@ MonoBehaviour:
|
||||
<Body>k__BackingField: 60
|
||||
<Flag>k__BackingField: -1
|
||||
- <Idx>k__BackingField: ai_view_sailor_p_004
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: 2
|
||||
<Head>k__BackingField: 22
|
||||
@ -86,7 +86,7 @@ MonoBehaviour:
|
||||
<Body>k__BackingField: 58
|
||||
<Flag>k__BackingField: -1
|
||||
- <Idx>k__BackingField: ai_view_sailor_p_005
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 5
|
||||
@ -94,82 +94,82 @@ MonoBehaviour:
|
||||
<Body>k__BackingField: 0
|
||||
<Flag>k__BackingField: -1
|
||||
- <Idx>k__BackingField: ai_view_captain_e_001
|
||||
<BackPack>k__BackingField: 1
|
||||
<Backpack>k__BackingField: 1
|
||||
<LeftWeapon>k__BackingField: 2
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 16
|
||||
<RightWeapon>k__BackingField: -1
|
||||
<Body>k__BackingField: 11
|
||||
<Flag>k__BackingField: 1
|
||||
<Flag>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_view_captain_e_002
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: 1
|
||||
<Head>k__BackingField: 46
|
||||
<RightWeapon>k__BackingField: 27
|
||||
<Body>k__BackingField: 18
|
||||
<Flag>k__BackingField: 1
|
||||
<Flag>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_view_captain_e_003
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 35
|
||||
<RightWeapon>k__BackingField: 27
|
||||
<Body>k__BackingField: 17
|
||||
<Flag>k__BackingField: 1
|
||||
<Flag>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_view_captain_e_004
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: 9
|
||||
<Head>k__BackingField: 33
|
||||
<RightWeapon>k__BackingField: 6
|
||||
<Body>k__BackingField: 39
|
||||
<Flag>k__BackingField: 1
|
||||
<Flag>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_view_captain_e_005
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 25
|
||||
<RightWeapon>k__BackingField: 28
|
||||
<Body>k__BackingField: 29
|
||||
<Flag>k__BackingField: 1
|
||||
<Flag>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_view_captain_p_001
|
||||
<BackPack>k__BackingField: 0
|
||||
<Backpack>k__BackingField: 0
|
||||
<LeftWeapon>k__BackingField: 1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 11
|
||||
<RightWeapon>k__BackingField: -1
|
||||
<Body>k__BackingField: 1
|
||||
<Flag>k__BackingField: 1
|
||||
<Flag>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_view_captain_p_002
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 50
|
||||
<RightWeapon>k__BackingField: 31
|
||||
<Body>k__BackingField: 58
|
||||
<Flag>k__BackingField: 1
|
||||
<Flag>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_view_captain_p_003
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 36
|
||||
<RightWeapon>k__BackingField: 27
|
||||
<Body>k__BackingField: 60
|
||||
<Flag>k__BackingField: 1
|
||||
<Flag>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_view_captain_p_004
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: 2
|
||||
<Head>k__BackingField: 22
|
||||
<RightWeapon>k__BackingField: 24
|
||||
<Body>k__BackingField: 58
|
||||
<Flag>k__BackingField: 1
|
||||
<Flag>k__BackingField: 0
|
||||
- <Idx>k__BackingField: ai_view_captain_p_005
|
||||
<BackPack>k__BackingField: -1
|
||||
<Backpack>k__BackingField: -1
|
||||
<LeftWeapon>k__BackingField: -1
|
||||
<LeftShield>k__BackingField: -1
|
||||
<Head>k__BackingField: 5
|
||||
<RightWeapon>k__BackingField: 12
|
||||
<Body>k__BackingField: 0
|
||||
<Flag>k__BackingField: 1
|
||||
<Flag>k__BackingField: 0
|
||||
|
@ -1,15 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using _02.Scripts.WaterAndShip;
|
||||
using BlueWaterProject;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class DataManager : Singleton<DataManager>
|
||||
{
|
||||
[Title("Scriptable Object")]
|
||||
[field: SerializeField] public AiViewDataSo AiViewDataSo { get; private set; }
|
||||
private Dictionary<string, AiView> aiViewDictionary;
|
||||
|
||||
[field: SerializeField] public AiStatDataSo AiStatDataSo { get; private set; }
|
||||
private Dictionary<string, AiStat> aiStatDictionary;
|
||||
|
||||
[field: SerializeField] public UnitDataSo UnitDataSo { get; private set; }
|
||||
private Dictionary<string, Unit> unitDictionary;
|
||||
|
||||
[field: SerializeField] public CardDataSo CardDataSo { get; private set; }
|
||||
private Dictionary<string, Card> cardDictionary;
|
||||
|
||||
[Title("DataBase")]
|
||||
public List<string> CardList { get; private set; } = new(MAX_CARD_NUM);
|
||||
private const int MAX_CARD_NUM = 100;
|
||||
[field: SerializeField] public List<string> CardList { get; private set; } = new(GlobalValue.CARD_DATA_CAPACITY);
|
||||
|
||||
[Title("DataBase", "GameObject")]
|
||||
public GameObject mouseSpot;
|
||||
@ -18,4 +29,47 @@ public class DataManager : Singleton<DataManager>
|
||||
|
||||
[Title("DataBase", "Sprites")]
|
||||
public Sprite[] cardType;
|
||||
|
||||
protected override void OnAwake()
|
||||
{
|
||||
InitDictionary();
|
||||
|
||||
InitCard();
|
||||
}
|
||||
|
||||
private void InitDictionary()
|
||||
{
|
||||
aiViewDictionary = CreateDictionaryFromList(AiViewDataSo.aiViewDataList, GlobalValue.AI_VIEW_DATA_CAPACITY);
|
||||
aiStatDictionary = CreateDictionaryFromList(AiStatDataSo.aiStatDataList, GlobalValue.AI_STAT_DATA_CAPACITY);
|
||||
unitDictionary = CreateDictionaryFromList(UnitDataSo.unitDataList, GlobalValue.UNIT_CAPACITY);
|
||||
cardDictionary = CreateDictionaryFromList(CardDataSo.cardDataList, GlobalValue.CARD_DATA_CAPACITY);
|
||||
}
|
||||
|
||||
private void InitCard()
|
||||
{
|
||||
foreach (var item in CardList)
|
||||
{
|
||||
UnitManager.Inst.CreateUnit(item, AttackerType.OFFENSE);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary 초기화 함수
|
||||
/// </summary>
|
||||
private Dictionary<string, T> CreateDictionaryFromList<T>(List<T> list, int capacity) where T : IIdx
|
||||
{
|
||||
var newDictionary = new Dictionary<string, T>(capacity);
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
newDictionary.Add(item.Idx, item);
|
||||
}
|
||||
|
||||
return newDictionary;
|
||||
}
|
||||
|
||||
public AiView GetAiViewDictionaryKey(string idx) => aiViewDictionary[idx] != null ? aiViewDictionary[idx] : null;
|
||||
public AiStat GetAiStatDictionaryKey(string idx) => aiStatDictionary[idx] != null ? aiStatDictionary[idx] : null;
|
||||
public Unit GetUnitDictionaryKey(string idx) => unitDictionary[idx] != null ? unitDictionary[idx] : null;
|
||||
public Card GetCardDictionaryKey(string idx) => cardDictionary[idx] != null ? cardDictionary[idx] : null;
|
||||
}
|
8
BlueWater/Assets/02.Scripts/Interface/IIdx.cs
Normal file
8
BlueWater/Assets/02.Scripts/Interface/IIdx.cs
Normal file
@ -0,0 +1,8 @@
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
public interface IIdx
|
||||
{
|
||||
string Idx { get; set; }
|
||||
}
|
||||
}
|
11
BlueWater/Assets/02.Scripts/Interface/IIdx.cs.meta
Normal file
11
BlueWater/Assets/02.Scripts/Interface/IIdx.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be694fa6d5f5acb43ab22f0903338902
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using BlueWaterProject;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _02.Scripts.WaterAndShip
|
||||
{
|
||||
[Serializable]
|
||||
public class Card
|
||||
public class Card : IIdx
|
||||
{
|
||||
[field: Tooltip("고유 인덱스")]
|
||||
[field: SerializeField] public string Idx { get; set; }
|
||||
|
@ -5,6 +5,7 @@ public class GlobalValue
|
||||
public const int AI_STAT_DATA_CAPACITY = 50;
|
||||
public const int UNIT_CAPACITY = 50;
|
||||
public const int ONE_UNIT_CAPACITY = 16;
|
||||
public const int AI_ANIMATOR_CAPACITY = 10;
|
||||
|
||||
public enum UnitType
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -112,6 +112,10 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
|
||||
type: 3}
|
||||
screenSpaceLensFlare: {fileID: 4800000, guid: 701880fecb344ea4c9cd0db3407ab287,
|
||||
type: 3}
|
||||
dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
|
||||
type: 3}
|
||||
m_AssetVersion: 2
|
||||
m_OpaqueLayerMask:
|
||||
serializedVersion: 2
|
||||
|
@ -56,6 +56,10 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
|
||||
type: 3}
|
||||
screenSpaceLensFlare: {fileID: 4800000, guid: 701880fecb344ea4c9cd0db3407ab287,
|
||||
type: 3}
|
||||
dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
|
||||
type: 3}
|
||||
m_AssetVersion: 2
|
||||
m_OpaqueLayerMask:
|
||||
serializedVersion: 2
|
||||
|
@ -112,6 +112,10 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
|
||||
type: 3}
|
||||
screenSpaceLensFlare: {fileID: 4800000, guid: 701880fecb344ea4c9cd0db3407ab287,
|
||||
type: 3}
|
||||
dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
|
||||
type: 3}
|
||||
m_AssetVersion: 2
|
||||
m_OpaqueLayerMask:
|
||||
serializedVersion: 2
|
||||
|
@ -76,6 +76,10 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
|
||||
type: 3}
|
||||
screenSpaceLensFlare: {fileID: 4800000, guid: 701880fecb344ea4c9cd0db3407ab287,
|
||||
type: 3}
|
||||
dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
|
||||
type: 3}
|
||||
m_AssetVersion: 2
|
||||
m_OpaqueLayerMask:
|
||||
serializedVersion: 2
|
||||
|
@ -11,9 +11,7 @@ Material:
|
||||
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _GLOSSINESS_FROM_BASE_ALPHA
|
||||
- _SPECULAR_COLOR
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
@ -51,7 +49,7 @@ Material:
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Texture: {fileID: 2800000, guid: 5d02c3b2981f49649a75c528311a25d6, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
|
@ -24,9 +24,7 @@ Material:
|
||||
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _GLOSSINESS_FROM_BASE_ALPHA
|
||||
- _SPECULAR_COLOR
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
@ -64,7 +62,7 @@ Material:
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Texture: {fileID: 2800000, guid: bdb6851450208a64c80959e7c7c2b2f8, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
|
@ -11,9 +11,7 @@ Material:
|
||||
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _GLOSSINESS_FROM_BASE_ALPHA
|
||||
- _SPECULAR_COLOR
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
@ -51,7 +49,7 @@ Material:
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Texture: {fileID: 2800000, guid: cb3746379ea1a2e4da656b7c06430d9a, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
|
@ -24,9 +24,7 @@ Material:
|
||||
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _GLOSSINESS_FROM_BASE_ALPHA
|
||||
- _SPECULAR_COLOR
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
@ -64,7 +62,7 @@ Material:
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Texture: {fileID: 2800000, guid: a788e0d8b03c71443ac9fddbac8608fd, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
|
@ -11,9 +11,7 @@ Material:
|
||||
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _GLOSSINESS_FROM_BASE_ALPHA
|
||||
- _SPECULAR_COLOR
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
@ -51,7 +49,7 @@ Material:
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Texture: {fileID: 2800000, guid: bb82ed32eeaa27549970117665015344, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
|
Loading…
Reference in New Issue
Block a user