using System; using System.Collections.Generic; using Sirenix.OdinInspector; using UnityEngine; // ReSharper disable once CheckNamespace namespace BlueWaterProject { [Serializable] public class Unit { #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("부대의 이름 또는 선장의 이름")] [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; } //[field: ShowIf("AttackerType", AttackerType.DEFENSE)] [field: SerializeField] public DefenseType DefenseType { get; set; } [field: Tooltip("부대 병력 리스트")] public List UnitList { get; set; } #endregion #region Constructor public Unit() { Idx = null; CaptainStatIdx = null; SailorStatIdx = null; UnitName = null; UnitType = GlobalValue.UnitType.NONE; SailorCount = 0; AttackerType = AttackerType.NONE; OffenseType = OffenseType.NONE; DefenseType = DefenseType.NONE; UnitList = new List(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 unitList) { Idx = idx; CaptainStatIdx = captainIdx; SailorStatIdx = sailorIdx; UnitName = unitName; UnitType = unitType; SailorCount = sailorCount; AttackerType = attackerType; OffenseType = offenseType; DefenseType = defenseType; UnitList = unitList; } public Unit(Unit unit) { 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; } #endregion #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; #endregion } }