200 lines
5.4 KiB
C#
200 lines
5.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Logic.Multilingual;
|
|
using UnityEngine;
|
|
using RuntimeData;
|
|
|
|
|
|
public enum WonderLibrary
|
|
{
|
|
EgyptianRemiliaPEACE,
|
|
EgyptianRemiliaKNOWLEDGE,
|
|
EgyptianRemiliaTRADE,
|
|
EgyptianRemiliaWEALTH,
|
|
EgyptianRemiliaPOWER,
|
|
EgyptianRemiliaPARK,
|
|
EgyptianRemiliaEYE,
|
|
RrenchKaguyaPEACE,
|
|
RrenchKaguyaKNOWLEDGE,
|
|
RrenchKaguyaTRADE,
|
|
RrenchKaguyaWEALTH,
|
|
RrenchKaguyaPOWER,
|
|
RrenchKaguyaPARK,
|
|
RrenchKaguyaEYE,
|
|
GermanyKanakoPEACE,
|
|
GermanyKanakoKNOWLEDGE,
|
|
GermanyKanakoTRADE,
|
|
GermanyKanakoWEALTH,
|
|
GermanyKanakoPOWER,
|
|
GermanyKanakoPARK,
|
|
GermanyKanakoEYE,
|
|
IndianSatoriPEACE,
|
|
IndianSatoriKNOWLEDGE,
|
|
IndianSatoriTRADE,
|
|
IndianSatoriWEALTH,
|
|
IndianSatoriPOWER,
|
|
IndianSatoriPARK,
|
|
IndianSatoriEYE,
|
|
NorwayReimuPEACE,
|
|
NorwayReimuKNOWLEDGE,
|
|
NorwayReimuTRADE,
|
|
NorwayReimuWEALTH,
|
|
NorwayReimuPOWER,
|
|
NorwayReimuPARK,
|
|
NorwayReimuEYE,
|
|
BritishByakurenPEACE,
|
|
BritishByakurenKNOWLEDGE,
|
|
BritishByakurenTRADE,
|
|
BritishByakurenWEALTH,
|
|
BritishByakurenPOWER,
|
|
BritishByakurenPARK,
|
|
BritishByakurenEYE,
|
|
PersianMikoPEACE,
|
|
PersianMikoKNOWLEDGE,
|
|
PersianMikoTRADE,
|
|
PersianMikoWEALTH,
|
|
PersianMikoPOWER,
|
|
PersianMikoPARK,
|
|
PersianMikoEYE,
|
|
ByzantineZanmuPEACE,
|
|
ByzantineZanmuKNOWLEDGE,
|
|
ByzantineZanmuTRADE,
|
|
ByzantineZanmuWEALTH,
|
|
ByzantineZanmuPOWER,
|
|
ByzantineZanmuPARK,
|
|
ByzantineZanmuEYE
|
|
}
|
|
|
|
|
|
[Serializable]
|
|
[CreateAssetMenu(fileName = "GridAndResourceDataAssets", menuName = "TH1 Game Data/GridAndResource Data Asset")]
|
|
public class GridAndResourceDataAssets : ScriptableObject
|
|
{
|
|
public List<TerrainInfo> TerrainInfoList;
|
|
public List<ResourceInfo> ResourceInfoList;
|
|
public List<WonderInfo> WonderInfoList;
|
|
public MountainInfo MountainInfo;
|
|
public VegetationInfo VegetationInfo;
|
|
|
|
private Dictionary<ResourceType,ResourceInfo> _resourceInfoDict = new Dictionary<ResourceType, ResourceInfo>();
|
|
|
|
[NonSerialized]
|
|
private bool _initialized = false;
|
|
|
|
private void Init()
|
|
{
|
|
if (_initialized)
|
|
return;
|
|
foreach(var t in ResourceInfoList)
|
|
_resourceInfoDict[t.Resource] = t;
|
|
|
|
_initialized = true;
|
|
}
|
|
public bool GetResourceInfo(ResourceType resource, out ResourceInfo resourceInfo)
|
|
{
|
|
Init();
|
|
return _resourceInfoDict.TryGetValue(resource, out resourceInfo);
|
|
}
|
|
|
|
public bool GetWonderInfo(WonderLibrary wonder, out WonderInfo wonderInfo)
|
|
{
|
|
wonderInfo = null;
|
|
foreach(var t in WonderInfoList)
|
|
if (t.Wonder == wonder)
|
|
{
|
|
wonderInfo = t;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public bool GetWonderInfoByType(WonderTypeEnum wonder,PlayerData player, out WonderInfo wonderInfo)
|
|
{
|
|
wonderInfo = null;
|
|
foreach(var t in WonderInfoList)
|
|
if (t.WonderType == wonder && t.CivId == player.PlayerCivId && t.ForceId == player.PlayerForceId)
|
|
{
|
|
wonderInfo = t;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
public Sprite GetWonderSprite(WonderLibrary wonder,PlayerData playerData)
|
|
{
|
|
if (!GetWonderInfo(wonder, out var wonderInfo))
|
|
return null;
|
|
return wonderInfo.Sprite;
|
|
}
|
|
|
|
public string GetWonderName(WonderLibrary wonder,PlayerData playerData)
|
|
{
|
|
if (!GetWonderInfo(wonder, out var wonderInfo))
|
|
return "";
|
|
return wonderInfo.Name;
|
|
}
|
|
|
|
public ResourceType GetMillLikeRelative(ResourceType resource)
|
|
{
|
|
if (resource == ResourceType.Sawmill)
|
|
return ResourceType.LumberHut;
|
|
if (resource == ResourceType.Windmill)
|
|
return ResourceType.Farm;
|
|
if (resource == ResourceType.Forge)
|
|
return ResourceType.Mine;
|
|
if (resource == ResourceType.Mine)
|
|
return ResourceType.Forge;
|
|
if (resource == ResourceType.Farm)
|
|
return ResourceType.Windmill;
|
|
if (resource == ResourceType.LumberHut)
|
|
return ResourceType.Sawmill;
|
|
return ResourceType.None;
|
|
}
|
|
}
|
|
|
|
|
|
[Serializable]
|
|
public class TerrainInfo
|
|
{
|
|
public TerrainType TerrainType;
|
|
public Sprite Sprite;
|
|
public bool VarientSprite;
|
|
public List<CivForceToSprite> SpriteList;
|
|
}
|
|
|
|
[Serializable]
|
|
public class MountainInfo
|
|
{
|
|
public List<CivForceToSprite> SpriteList;
|
|
}
|
|
|
|
[Serializable]
|
|
public class VegetationInfo
|
|
{
|
|
public List<CivForceToSprite> SpriteList;
|
|
}
|
|
|
|
[Serializable]
|
|
public class ResourceInfo
|
|
{
|
|
public ResourceType Resource;
|
|
public Sprite Sprite;
|
|
public bool VarientSprite;
|
|
public int Exp;
|
|
public List<CivForceToSprite> SpriteList;
|
|
}
|
|
|
|
[Serializable]
|
|
public class WonderInfo
|
|
{
|
|
public WonderLibrary Wonder;
|
|
public WonderTypeEnum WonderType;
|
|
public uint CivId;
|
|
public uint ForceId;
|
|
public Sprite Sprite;
|
|
[MultilingualField]
|
|
public string Name;
|
|
public int Exp;
|
|
|
|
} |