231 lines
6.0 KiB
C#
231 lines
6.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Logic.Action;
|
|
using UnityEngine;
|
|
using RuntimeData;
|
|
using Logic.Multilingual;
|
|
|
|
public enum CivEnum
|
|
{
|
|
Common,
|
|
Egyptian,
|
|
French,
|
|
Germany,
|
|
Indian,
|
|
Norway,
|
|
Britain,
|
|
Persian,
|
|
Byzantine,
|
|
Max
|
|
}
|
|
|
|
public enum LandformType
|
|
{
|
|
Terrain,
|
|
Mountain,
|
|
Tree,
|
|
Road,
|
|
Resource,
|
|
Max
|
|
}
|
|
|
|
[Serializable]
|
|
[CreateAssetMenu(fileName = "PlayerDataAssets", menuName = "TH1 Game Data/Player Data Asset")]
|
|
public class PlayerDataAssets : ScriptableObject
|
|
{
|
|
public List<PlayerInfo> PlayerDataList = new List<PlayerInfo>();
|
|
public List<CivLandformPack> CivLandformList = new List<CivLandformPack>();
|
|
public CommonLandformPack CommonLandform;
|
|
public Color CommonColor;
|
|
public Sprite CommonPlayerAvatar;
|
|
private Dictionary<UnitType,UnitTypeInfo> _unitTypeDict = new Dictionary<UnitType, UnitTypeInfo>();
|
|
private Dictionary<GiantType,UnitTypeInfo> _giantTypeDict = new Dictionary<GiantType, UnitTypeInfo>();
|
|
|
|
[NonSerialized]
|
|
private bool _initialized = false;
|
|
|
|
public bool GetPlayerInfo(PlayerData player,out PlayerInfo info)
|
|
{
|
|
info = null;
|
|
if (player == null)
|
|
return false;
|
|
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;
|
|
}
|
|
|
|
//判断一个action是否在一个玩家的techPool里面
|
|
public bool CheckActionInTechPool(CommonActionId actionId,PlayerData player)
|
|
{
|
|
if (!GetPlayerInfo(player, out var info)) return false;
|
|
foreach (var t in info.TechPool)
|
|
{
|
|
if(!Table.Instance.TechDataAssets.GetTechInfo(t,out var techInfo))continue;
|
|
foreach(var a in techInfo.techActions)
|
|
if (a == actionId)
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
// --------------------------------------------- 处理初始资源参数的模块 -------------------------------------
|
|
|
|
public bool GetCivLandformPack(CivEnum civ, out CivLandformPack info)
|
|
{
|
|
foreach(var t in CivLandformList)
|
|
if (t.civ == civ)
|
|
{
|
|
info = t;
|
|
return true;
|
|
}
|
|
|
|
info = null;
|
|
return false;
|
|
}
|
|
//terrain重载
|
|
public float GetLandformRate(TerrainType terrain, CivEnum civ)
|
|
{
|
|
var ret = 1f;
|
|
//if (tree != Vegetation.Trees) return 0;
|
|
return ret;
|
|
}
|
|
|
|
//tree重载(树占平地的比例)
|
|
public float GetLandformRate(Vegetation tree, CivEnum civ = CivEnum.Common,InnerOuterCity innerOuterCity = InnerOuterCity.All)
|
|
{
|
|
var ret = 1f;
|
|
if (tree != Vegetation.Trees) return ret;
|
|
//return CommonLandform.
|
|
return ret;
|
|
}
|
|
|
|
//mountain重载 (山占所有陆地的比例)
|
|
public float GetLandformRate(TerrainFeature mountain, CivEnum civ = CivEnum.Common,InnerOuterCity innerOuterCity = InnerOuterCity.All)
|
|
{
|
|
var ret = 1f;
|
|
if (mountain != TerrainFeature.Mountain) return ret;
|
|
return ret;
|
|
}
|
|
|
|
//animal/fruit/crop/metal重载(animal占森林的比例)
|
|
public float GetLandformRate(ResourceType resource, CivEnum civ = CivEnum.Common,InnerOuterCity innerOuterCity = InnerOuterCity.All)
|
|
{
|
|
var ret = 1f;
|
|
if (!(resource is ResourceType.Metal or ResourceType.Crop or ResourceType.Farm or ResourceType.Fruit)) return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
[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";
|
|
|
|
}
|
|
}
|
|
|
|
|
|
[Serializable]
|
|
public class CivLandformPack
|
|
{
|
|
public CivEnum civ;
|
|
public List<LandformParamItem> LandformParamList;
|
|
}
|
|
|
|
[Serializable]
|
|
public class CommonLandformPack
|
|
{
|
|
public CivEnum civ;
|
|
public List<LandformParamItem> LandformParamList;
|
|
}
|
|
|
|
|
|
|
|
public enum InnerOuterCity
|
|
{
|
|
All,
|
|
InnerCity,
|
|
OuterCity,
|
|
Max
|
|
}
|
|
|
|
//单个的地貌数据参数,例如“少山的”“多山的”“多海的”之类的
|
|
[Serializable]
|
|
public class LandformParamItem
|
|
{
|
|
|
|
public LandformType LandformType;
|
|
public string ParamPackDesc;//这个parampack的描述信息
|
|
public TerrainType TerrainType;
|
|
public ResourceType ResourceType;
|
|
public float Rate;
|
|
public InnerOuterCity InnerOuterCity;
|
|
|
|
} |