OldBlueWater/BlueWater/Assets/02.Scripts/Ai/Unit/Unit.cs

110 lines
3.6 KiB
C#

using System;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
[Serializable]
public class Unit : IIdx
{
#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: 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: SerializeField] public AttackerType AttackerType { get; set; }
[field: SerializeField] public OffenseType OffenseType { get; set; }
[field: SerializeField] public DefenseType DefenseType { get; set; }
[field: Tooltip("부대 병력 리스트")]
[field: SerializeField] public List<AiController> 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<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;
//SetAttackerTypeUnitAll();
}
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;
//SetAttackerTypeUnitAll();
}
#endregion
#region Custrom method
// private void SetAttackerTypeUnitAll()
// {
// foreach (var item in UnitList)
// {
// item.SetAttackerType(AttackerType);
// }
// }
public void SetOffenseType(OffenseType type) => OffenseType = type;
public void SetDefenseType(DefenseType type) => DefenseType = type;
#endregion
}
}