115 lines
3.2 KiB
C#
115 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using RuntimeData;
|
|
using Logic.Multilingual;
|
|
|
|
[Serializable]
|
|
[CreateAssetMenu(fileName = "PlayerDataAssets", menuName = "TH1 Game Data/Player Data Asset")]
|
|
public class PlayerDataAssets : ScriptableObject
|
|
{
|
|
public List<PlayerInfo> PlayerDataList = new List<PlayerInfo>();
|
|
public Color CommonColor;
|
|
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 GetPlayerInfoByCivId(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;
|
|
[MultilingualField]
|
|
public string CivName;
|
|
[MultilingualField]
|
|
public string ForceName;
|
|
[MultilingualField]
|
|
public string LeaderName;
|
|
public Sprite LeaderIllustration;
|
|
public List<TechType> TechPool = new List<TechType>();
|
|
public List<TechType> TechStart = new List<TechType>();
|
|
public Color Color;
|
|
public Sprite FlagIcon;
|
|
[MultilingualField]
|
|
public List<string> StartChatBubble;
|
|
[MultilingualField]
|
|
public List<string> MeetChatBubble;
|
|
[MultilingualField]
|
|
public List<string> LoseChatBubble;
|
|
PlayerInfo()
|
|
{
|
|
foreach (TechType t in System.Enum.GetValues(typeof(TechType)))
|
|
TechPool.Add(t);
|
|
TechStart.Add(TechType.None);
|
|
}
|
|
|
|
public string GetRandomMeetChat()
|
|
{
|
|
if (MeetChatBubble.Count > 0)
|
|
return MeetChatBubble[UnityEngine.Random.Range(0, MeetChatBubble.Count)];
|
|
else return "0";
|
|
|
|
}
|
|
|
|
public string GetRandomStartChat()
|
|
{
|
|
if (StartChatBubble.Count > 0)
|
|
return StartChatBubble[UnityEngine.Random.Range(0, StartChatBubble.Count)];
|
|
else return "0";
|
|
|
|
}
|
|
public string GetRandomLoseChat()
|
|
{
|
|
if (LoseChatBubble.Count > 0)
|
|
return LoseChatBubble[UnityEngine.Random.Range(0, LoseChatBubble.Count)];
|
|
else return "0";
|
|
|
|
}
|
|
} |