#25 카드 시스템 작업 중 유니티 버전 변경
This commit is contained in:
parent
bd2803b002
commit
daa0c9f06e
73
BlueWater/Assets/02.Scripts/Ai/Unit/Unit.cs
Normal file
73
BlueWater/Assets/02.Scripts/Ai/Unit/Unit.cs
Normal file
@ -0,0 +1,73 @@
|
||||
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;
|
||||
}
|
||||
}
|
11
BlueWater/Assets/02.Scripts/Ai/Unit/Unit.cs.meta
Normal file
11
BlueWater/Assets/02.Scripts/Ai/Unit/Unit.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d1e5af44c71b4443885b72e1b19ddd2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,72 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
[Serializable]
|
||||
public class Unit
|
||||
{
|
||||
[Tooltip("부대의 이름")]
|
||||
public string unitName;
|
||||
|
||||
[Tooltip("부대의 종류")]
|
||||
public GlobalValue.UnitType unitType;
|
||||
|
||||
[Tooltip("부대의 병력 수")]
|
||||
public int soliderCount;
|
||||
|
||||
[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 class UnitController : MonoBehaviour
|
||||
{
|
||||
#region Property and variable
|
||||
|
||||
[PropertyOrder(-11)]
|
||||
[EnableIf("@attackerType == AttackerType.OFFENSE")]
|
||||
[EnableIf("@unit.AttackerType == AttackerType.OFFENSE")]
|
||||
[InlineButton("SetIslandInfoTest", "테스트 설정")]
|
||||
[SerializeField] private IslandInfo attackIslandInfo;
|
||||
|
||||
[PropertyOrder(-10)]
|
||||
public Unit unit;
|
||||
|
||||
private bool alwaysFalse;
|
||||
|
||||
[EnableIf("alwaysFalse")]
|
||||
[EnumToggleButtons]
|
||||
[OnValueChanged("OnTypeChanged")]
|
||||
[SerializeField] private AttackerType attackerType;
|
||||
|
||||
[ShowIf("attackerType", AttackerType.OFFENSE)]
|
||||
[OnValueChanged("OnTypeChanged")]
|
||||
[SerializeField] private OffenseType offenseType;
|
||||
|
||||
[ShowIf("attackerType", AttackerType.DEFENSE)]
|
||||
[OnValueChanged("OnTypeChanged")]
|
||||
[SerializeField] private DefenseType defenseType;
|
||||
|
||||
private bool isClickedTypeAllButton;
|
||||
|
||||
#endregion
|
||||
@ -75,13 +25,13 @@ namespace BlueWaterProject
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
if (unit == null || unit.soliderCount <= 0) return;
|
||||
if (unit == null || unit.SoliderCount <= 0) return;
|
||||
|
||||
var unitManager = UnitManager.Inst != null ? UnitManager.Inst : FindObjectOfType<UnitManager>();
|
||||
var matrix = unitManager.UnitMatrices.Find(um => um.soldiers == unit.soliderCount);
|
||||
var matrix = unitManager.UnitMatrices.Find(um => um.soldiers == unit.SoliderCount);
|
||||
if (matrix == null) return;
|
||||
|
||||
for (var i = 0; i < unit.soliderCount; i++)
|
||||
for (var i = 0; i < unit.SoliderCount; i++)
|
||||
{
|
||||
var row = i / matrix.columns;
|
||||
var column = i % matrix.columns;
|
||||
@ -111,16 +61,7 @@ namespace BlueWaterProject
|
||||
[Button("유닛 생성")]
|
||||
public void CreateUnit()
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
var unitManager = FindObjectOfType<UnitManager>();
|
||||
unitManager.CreateUnit(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
UnitManager.Inst.CreateUnit(this);
|
||||
}
|
||||
|
||||
UnitManager.Inst.CreateUnit(this);
|
||||
}
|
||||
|
||||
[PropertyOrder(-8)]
|
||||
@ -161,9 +102,6 @@ namespace BlueWaterProject
|
||||
{
|
||||
unit = new Unit();
|
||||
attackIslandInfo = null;
|
||||
attackerType = AttackerType.NONE;
|
||||
offenseType = OffenseType.NONE;
|
||||
defenseType = DefenseType.NONE;
|
||||
isClickedTypeAllButton = false;
|
||||
}
|
||||
|
||||
@ -175,9 +113,9 @@ namespace BlueWaterProject
|
||||
{
|
||||
foreach (var soldier in unit.soldierList)
|
||||
{
|
||||
soldier.SetAttackerType(attackerType);
|
||||
soldier.SetOffenseType(offenseType);
|
||||
soldier.SetDefenseType(defenseType);
|
||||
soldier.SetAttackerType(unit.AttackerType);
|
||||
soldier.SetOffenseType(unit.OffenseType);
|
||||
soldier.SetDefenseType(unit.DefenseType);
|
||||
}
|
||||
|
||||
isClickedTypeAllButton = true;
|
||||
@ -193,7 +131,7 @@ namespace BlueWaterProject
|
||||
|
||||
private void SetIslandInfoTest()
|
||||
{
|
||||
if (attackerType != AttackerType.OFFENSE) return;
|
||||
if (unit.AttackerType != AttackerType.OFFENSE) return;
|
||||
|
||||
var islandInfo = FindObjectOfType<IslandInfo>();
|
||||
attackIslandInfo = islandInfo;
|
||||
@ -206,18 +144,18 @@ namespace BlueWaterProject
|
||||
|
||||
private bool ShowTypeAllButton()
|
||||
{
|
||||
switch (attackerType)
|
||||
switch (unit.AttackerType)
|
||||
{
|
||||
case AttackerType.NONE:
|
||||
return false;
|
||||
case AttackerType.OFFENSE:
|
||||
if (offenseType == OffenseType.NONE)
|
||||
if (unit.OffenseType == OffenseType.NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case AttackerType.DEFENSE:
|
||||
if (defenseType == DefenseType.NONE)
|
||||
if (unit.DefenseType == DefenseType.NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -233,14 +171,14 @@ namespace BlueWaterProject
|
||||
{
|
||||
if (unit.soldierList.Count > 0)
|
||||
{
|
||||
return attackerType == AttackerType.NONE ? Color.green : Color.white;
|
||||
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) => attackerType = value;
|
||||
public void SetAttackerType(AttackerType value) => unit.AttackerType = value;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
@ -162,9 +161,9 @@ namespace BlueWaterProject
|
||||
{
|
||||
DestroyDeployedSoldiers(unitController);
|
||||
|
||||
var baseName = soldierPrefabList[(int)unitController.unit.unitType - 1].name;
|
||||
var baseName = soldierPrefabList[(int)unitController.unit.UnitType - 1].name;
|
||||
|
||||
if (string.IsNullOrEmpty(unitController.unit.unitName))
|
||||
if (string.IsNullOrEmpty(unitController.unit.UnitName))
|
||||
{
|
||||
const int maxIterations = 100;
|
||||
var namingNum = 0;
|
||||
@ -186,13 +185,13 @@ namespace BlueWaterProject
|
||||
}
|
||||
else
|
||||
{
|
||||
unitController.gameObject.name = unitController.unit.unitName;
|
||||
unitController.gameObject.name = unitController.unit.UnitName;
|
||||
}
|
||||
|
||||
unitController.gameObject.layer = LayerMask.NameToLayer("Unit");
|
||||
unitController.unit.soldierList = new List<AiController>(unitController.unit.soliderCount);
|
||||
unitController.unit.soldierList = new List<AiController>(unitController.unit.SoliderCount);
|
||||
|
||||
var matrix = UnitMatrices.Find(um => um.soldiers == unitController.unit.soliderCount);
|
||||
var matrix = UnitMatrices.Find(um => um.soldiers == unitController.unit.SoliderCount);
|
||||
if (matrix == null)
|
||||
{
|
||||
Debug.LogError("사용할 수 없는 병력의 숫자입니다. UnitManager의 UnitMatrices를 확인해주세요.");
|
||||
@ -203,7 +202,7 @@ namespace BlueWaterProject
|
||||
var unitControllerRotation = unitControllerTransform.rotation;
|
||||
unitControllerTransform.rotation = Quaternion.identity;
|
||||
|
||||
for (var i = 0; i < unitController.unit.soliderCount; i++)
|
||||
for (var i = 0; i < unitController.unit.SoliderCount; i++)
|
||||
{
|
||||
var row = i / matrix.columns;
|
||||
var column = i % matrix.columns;
|
||||
@ -212,7 +211,7 @@ namespace BlueWaterProject
|
||||
var zOffset = (row - (matrix.rows - 1) / 2.0f) * SoldierSpacing;
|
||||
var spawnPosition = unitControllerTransform.position + new Vector3(xOffset, 0, zOffset);
|
||||
|
||||
var soldierObject = Instantiate(soldierPrefabList[(int)unitController.unit.unitType - 1], spawnPosition,
|
||||
var soldierObject = Instantiate(soldierPrefabList[(int)unitController.unit.UnitType - 1], spawnPosition,
|
||||
Quaternion.identity, unitController.transform).GetComponent<AiController>();
|
||||
|
||||
var newSoldierName = $"{baseName}_{i + 1:00}";
|
||||
@ -223,7 +222,7 @@ namespace BlueWaterProject
|
||||
}
|
||||
unitController.transform.rotation *= unitControllerRotation;
|
||||
|
||||
if (unitController.unit.unitType.ToString().Contains("_E"))
|
||||
if (unitController.unit.UnitType.ToString().Contains("_E"))
|
||||
{
|
||||
unitController.SetAttackerType(AttackerType.DEFENSE);
|
||||
foreach (var soldier in unitController.unit.soldierList)
|
||||
@ -231,7 +230,7 @@ namespace BlueWaterProject
|
||||
soldier.SetAttackerType(AttackerType.DEFENSE);
|
||||
}
|
||||
}
|
||||
else if (unitController.unit.unitType.ToString().Contains("_P"))
|
||||
else if (unitController.unit.UnitType.ToString().Contains("_P"))
|
||||
{
|
||||
unitController.SetAttackerType(AttackerType.OFFENSE);
|
||||
foreach (var soldier in unitController.unit.soldierList)
|
||||
@ -250,7 +249,7 @@ namespace BlueWaterProject
|
||||
|
||||
unitController.transform.position = assignPos;
|
||||
|
||||
for (var i = 0; i < unitController.unit.soliderCount; i++)
|
||||
for (var i = 0; i < unitController.unit.SoliderCount; i++)
|
||||
{
|
||||
var soldierPos = unitController.unit.soldierList[i].transform.position;
|
||||
var ray = new Ray(soldierPos, Vector3.down);
|
||||
|
8
BlueWater/Assets/02.Scripts/Data.meta
Normal file
8
BlueWater/Assets/02.Scripts/Data.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7fff6957b3e19f4e8877add5442e28f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
BlueWater/Assets/02.Scripts/Data/CardDataSo.cs
Normal file
14
BlueWater/Assets/02.Scripts/Data/CardDataSo.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using _02.Scripts.WaterAndShip;
|
||||
using UnityEngine;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace BlueWaterProject
|
||||
{
|
||||
[CreateAssetMenu(fileName = "CardDataSo", menuName = "ScriptableObjects/CardData", order = 0)]
|
||||
public class CardDataSo : ScriptableObject
|
||||
{
|
||||
public List<Card> cardDataList = new(GlobalValue.CARD_DATA_CAPACITY);
|
||||
}
|
||||
}
|
11
BlueWater/Assets/02.Scripts/Data/CardDataSo.cs.meta
Normal file
11
BlueWater/Assets/02.Scripts/Data/CardDataSo.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 420d288b4d553b64ca505f318acd0c60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
BlueWater/Assets/02.Scripts/Data/So.meta
Normal file
8
BlueWater/Assets/02.Scripts/Data/So.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e46d3012f59195a469a056244872da07
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
78
BlueWater/Assets/02.Scripts/Data/So/CardDataSo.asset
Normal file
78
BlueWater/Assets/02.Scripts/Data/So/CardDataSo.asset
Normal file
@ -0,0 +1,78 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 420d288b4d553b64ca505f318acd0c60, type: 3}
|
||||
m_Name: CardDataSo
|
||||
m_EditorClassIdentifier:
|
||||
cardDataList:
|
||||
- <Idx>k__BackingField: card_001
|
||||
<Unit>k__BackingField:
|
||||
<UnitName>k__BackingField: Legolas
|
||||
<UnitType>k__BackingField: 6
|
||||
<SoliderCount>k__BackingField: 6
|
||||
<AttackerType>k__BackingField: 1
|
||||
<OffenseType>k__BackingField: 1
|
||||
<DefenseType>k__BackingField: 0
|
||||
soldierList: []
|
||||
- <Idx>k__BackingField: card_002
|
||||
<Unit>k__BackingField:
|
||||
<UnitName>k__BackingField: Robin Hood
|
||||
<UnitType>k__BackingField: 6
|
||||
<SoliderCount>k__BackingField: 4
|
||||
<AttackerType>k__BackingField: 1
|
||||
<OffenseType>k__BackingField: 1
|
||||
<DefenseType>k__BackingField: 0
|
||||
soldierList: []
|
||||
- <Idx>k__BackingField: card_003
|
||||
<Unit>k__BackingField:
|
||||
<UnitName>k__BackingField: Olaf
|
||||
<UnitType>k__BackingField: 7
|
||||
<SoliderCount>k__BackingField: 6
|
||||
<AttackerType>k__BackingField: 1
|
||||
<OffenseType>k__BackingField: 1
|
||||
<DefenseType>k__BackingField: 0
|
||||
soldierList: []
|
||||
- <Idx>k__BackingField: card_004
|
||||
<Unit>k__BackingField:
|
||||
<UnitName>k__BackingField: Lancer
|
||||
<UnitType>k__BackingField: 8
|
||||
<SoliderCount>k__BackingField: 8
|
||||
<AttackerType>k__BackingField: 1
|
||||
<OffenseType>k__BackingField: 1
|
||||
<DefenseType>k__BackingField: 0
|
||||
soldierList: []
|
||||
- <Idx>k__BackingField: card_005
|
||||
<Unit>k__BackingField:
|
||||
<UnitName>k__BackingField:
|
||||
<UnitType>k__BackingField: 9
|
||||
<SoliderCount>k__BackingField: 0
|
||||
<AttackerType>k__BackingField: 1
|
||||
<OffenseType>k__BackingField: 1
|
||||
<DefenseType>k__BackingField: 0
|
||||
soldierList: []
|
||||
- <Idx>k__BackingField: card_006
|
||||
<Unit>k__BackingField:
|
||||
<UnitName>k__BackingField: Aragorn
|
||||
<UnitType>k__BackingField: 10
|
||||
<SoliderCount>k__BackingField: 9
|
||||
<AttackerType>k__BackingField: 1
|
||||
<OffenseType>k__BackingField: 1
|
||||
<DefenseType>k__BackingField: 0
|
||||
soldierList: []
|
||||
- <Idx>k__BackingField: card_007
|
||||
<Unit>k__BackingField:
|
||||
<UnitName>k__BackingField: King Arthur
|
||||
<UnitType>k__BackingField: 10
|
||||
<SoliderCount>k__BackingField: 6
|
||||
<AttackerType>k__BackingField: 1
|
||||
<OffenseType>k__BackingField: 2
|
||||
<DefenseType>k__BackingField: 0
|
||||
soldierList: []
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0db3b35c9121e9e4bbe8559a0922145f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -7,6 +7,8 @@ using UnityEngine;
|
||||
|
||||
public class DataManager : Singleton<DataManager>
|
||||
{
|
||||
[field: SerializeField] public CardDataSo CardDataSo { get; private set; }
|
||||
|
||||
public List<Card> CardList = new List<Card>(10);
|
||||
|
||||
public GameObject mouseSpot;
|
||||
|
@ -1,9 +1,13 @@
|
||||
using System;
|
||||
using BlueWaterProject;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _02.Scripts.WaterAndShip
|
||||
{
|
||||
[Serializable]
|
||||
public class Card
|
||||
{
|
||||
public Unit Unit { get; set; }
|
||||
[field: SerializeField] public string Idx { get; set; }
|
||||
[field: SerializeField] public Unit Unit { get; set; }
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
public class GlobalValue
|
||||
{
|
||||
public const int CARD_DATA_CAPACITY = 50;
|
||||
|
||||
public enum UnitType
|
||||
{
|
||||
NONE = 0,
|
||||
|
Loading…
Reference in New Issue
Block a user