79 lines
2.1 KiB
C#
79 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using RuntimeData;
|
|
|
|
[Serializable]
|
|
[CreateAssetMenu(fileName = "PlayerDataAssets", menuName = "TH1 Game Data/Player Data Asset")]
|
|
public class PlayerDataAssets : ScriptableObject
|
|
{
|
|
public List<PlayerInfo> PlayerDataList = new List<PlayerInfo>();
|
|
|
|
private Dictionary<UnitType,UnitTypeInfo> _unitTypeDict = new Dictionary<UnitType, UnitTypeInfo>();
|
|
private Dictionary<GiantType,UnitTypeInfo> _giantTypeDict = new Dictionary<GiantType, UnitTypeInfo>();
|
|
|
|
[NonSerialized]
|
|
private bool _initialized = false;
|
|
|
|
/*private void Init()
|
|
{
|
|
if (_initialized)
|
|
return;
|
|
foreach(var t in UnitTypeList)
|
|
if (t.UnitType != UnitType.Giant)
|
|
_unitTypeDict[t.UnitType] = t;
|
|
else
|
|
_giantTypeDict[t.GiantType] = t;
|
|
|
|
_initialized = true;
|
|
}*/
|
|
|
|
public bool GetPlayerInfo(PlayerData player,out PlayerInfo info)
|
|
{
|
|
info = null;
|
|
foreach (var t in PlayerDataList)
|
|
{
|
|
if (t.CivId == player.PlayerCivId && t.ForceId == player.PlayerForceId)
|
|
{
|
|
info = t;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool GetPlayerInfo(uint cid,uint forceid,out PlayerInfo info)
|
|
{
|
|
info = null;
|
|
foreach (var t in PlayerDataList)
|
|
{
|
|
if (t.CivId == cid && t.ForceId == forceid)
|
|
{
|
|
info = t;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
[Serializable]
|
|
public class PlayerInfo
|
|
{
|
|
public uint ForceId;
|
|
public uint CivId;
|
|
public string CivName;
|
|
public string ForceName;
|
|
public string LeaderName;
|
|
public Sprite LeaderIllustration;
|
|
public List<TechType> TechPool = new List<TechType>();
|
|
public List<TechType> TechStart = new List<TechType>();
|
|
|
|
PlayerInfo()
|
|
{
|
|
foreach (TechType t in System.Enum.GetValues(typeof(TechType)))
|
|
TechPool.Add(t);
|
|
TechStart.Add(TechType.None);
|
|
}
|
|
} |