2023-08-23 07:24:31 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
|
|
namespace BlueWaterProject
|
|
|
|
{
|
|
|
|
[Serializable]
|
|
|
|
public class Unit
|
|
|
|
{
|
2023-08-28 19:52:23 +00:00
|
|
|
#region Property and variable
|
|
|
|
|
|
|
|
[field: Tooltip("고유 인덱스")]
|
|
|
|
[field: SerializeField] public string Idx { get; set; }
|
|
|
|
|
|
|
|
[field: Tooltip("선장의 인덱스")]
|
|
|
|
[field: SerializeField] public string CaptainStatIdx { get; set; }
|
|
|
|
|
|
|
|
[field: Tooltip("선원의 인덱스")]
|
|
|
|
[field: SerializeField] public string SailorStatIdx { get; set; }
|
|
|
|
|
|
|
|
[field: Tooltip("부대의 이름 또는 선장의 이름")]
|
2023-08-23 07:24:31 +00:00
|
|
|
[field: SerializeField] public string UnitName { get; set; }
|
|
|
|
|
|
|
|
[field: Tooltip("부대의 종류")]
|
|
|
|
[field: OnValueChanged("AttackerTypeAutoSetting")]
|
|
|
|
[field: SerializeField] public GlobalValue.UnitType UnitType { get; set; }
|
|
|
|
|
2023-08-28 19:52:23 +00:00
|
|
|
[field: Tooltip("선원의 수")]
|
|
|
|
[field: Range(0, GlobalValue.ONE_UNIT_CAPACITY - 1)]
|
|
|
|
[field: SerializeField] public int SailorCount { get; set; }
|
2023-08-23 07:24:31 +00:00
|
|
|
|
2023-08-28 19:52:23 +00:00
|
|
|
[field: Tooltip("공격 타입 UnitType에 맞게 자동 설정")]
|
2023-08-23 07:24:31 +00:00
|
|
|
[field: DisableInEditorMode]
|
|
|
|
[field: EnumToggleButtons]
|
|
|
|
[field: SerializeField] public AttackerType AttackerType { get; set; }
|
|
|
|
|
2023-08-28 19:52:23 +00:00
|
|
|
//[field: ShowIf("AttackerType", AttackerType.OFFENSE)]
|
2023-08-23 07:24:31 +00:00
|
|
|
[field: SerializeField] public OffenseType OffenseType { get; set; }
|
|
|
|
|
2023-08-28 19:52:23 +00:00
|
|
|
//[field: ShowIf("AttackerType", AttackerType.DEFENSE)]
|
2023-08-23 07:24:31 +00:00
|
|
|
[field: SerializeField] public DefenseType DefenseType { get; set; }
|
|
|
|
|
|
|
|
[field: Tooltip("부대 병력 리스트")]
|
2023-08-28 19:52:23 +00:00
|
|
|
public List<AiController> UnitList { get; set; }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Constructor
|
2023-08-23 07:24:31 +00:00
|
|
|
|
|
|
|
public Unit()
|
|
|
|
{
|
2023-08-28 19:52:23 +00:00
|
|
|
Idx = null;
|
|
|
|
CaptainStatIdx = null;
|
|
|
|
SailorStatIdx = null;
|
2023-08-23 07:24:31 +00:00
|
|
|
UnitName = null;
|
|
|
|
UnitType = GlobalValue.UnitType.NONE;
|
2023-08-28 19:52:23 +00:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
Idx = idx;
|
|
|
|
CaptainStatIdx = captainIdx;
|
|
|
|
SailorStatIdx = sailorIdx;
|
|
|
|
UnitName = unitName;
|
|
|
|
UnitType = unitType;
|
|
|
|
SailorCount = sailorCount;
|
|
|
|
AttackerType = attackerType;
|
|
|
|
OffenseType = offenseType;
|
|
|
|
DefenseType = defenseType;
|
|
|
|
UnitList = unitList;
|
2023-08-23 07:24:31 +00:00
|
|
|
}
|
|
|
|
|
2023-08-28 19:52:23 +00:00
|
|
|
public Unit(Unit unit)
|
2023-08-23 07:24:31 +00:00
|
|
|
{
|
2023-08-28 19:52:23 +00:00
|
|
|
Idx = unit.Idx;
|
|
|
|
CaptainStatIdx = unit.CaptainStatIdx;
|
|
|
|
SailorStatIdx = unit.SailorStatIdx;
|
|
|
|
UnitName = unit.UnitName;
|
|
|
|
UnitType = unit.UnitType;
|
|
|
|
SailorCount = unit.SailorCount;
|
|
|
|
AttackerType = unit.AttackerType;
|
|
|
|
OffenseType = unit.OffenseType;
|
|
|
|
DefenseType = unit.DefenseType;
|
|
|
|
UnitList = unit.UnitList;
|
2023-08-23 07:24:31 +00:00
|
|
|
}
|
|
|
|
|
2023-08-28 19:52:23 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Custrom method
|
|
|
|
|
2023-08-23 07:24:31 +00:00
|
|
|
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;
|
2023-08-28 19:52:23 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2023-08-23 07:24:31 +00:00
|
|
|
}
|
|
|
|
}
|