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

73 lines
2.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
[Serializable]
public class Unit
{
[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: SerializeField] public int SoliderCount { get; set; }
[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<AiController> soldierList;
public Unit()
{
UnitName = null;
UnitType = GlobalValue.UnitType.NONE;
SoliderCount = 0;
soldierList = new List<AiController>();
}
public Unit(string unitName, GlobalValue.UnitType unitType, int soliderCount, List<AiController> soldierList)
{
this.UnitName = unitName;
this.UnitType = unitType;
this.SoliderCount = soliderCount;
this.soldierList = new List<AiController>(this.SoliderCount);
this.soldierList = soldierList;
}
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;
}
}