217 lines
5.9 KiB
C#
217 lines
5.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Logic.CrashSight;
|
|
using UnityEngine;
|
|
using RuntimeData;
|
|
using Logic.Multilingual;
|
|
using Logic.Skill;
|
|
using TH1_Logic.Core;
|
|
using TH1Renderer;
|
|
using TH1Resource;
|
|
using Unity.VisualScripting;
|
|
|
|
//单位类型
|
|
|
|
public enum MomentMainType
|
|
{
|
|
DarkestMoment,
|
|
AdversityMoment,
|
|
KeyMoment,
|
|
GloriousMoment,
|
|
}
|
|
|
|
public enum MomentSubType
|
|
{
|
|
None = 0,
|
|
BattleHeroDie = 101001,
|
|
BattleCaptainLost = 101002,
|
|
BattleCityLost = 101003,
|
|
BattleCityFire = 201004,
|
|
BattleCityBesieged = 201005,
|
|
BattleSacrify = 201006,
|
|
BattleTreasure = 201007,
|
|
BattleLevelup = 301008,
|
|
BattleNarrowVictory = 301009,
|
|
BattleCounterKill = 301010,
|
|
BattleLastStand = 301011,
|
|
BattleKillGiant = 301012,
|
|
BattleKillTreasure = 301013,
|
|
BattleCaptureVillage = 301014,
|
|
BattleOccupyFirstCity = 301015,
|
|
BattleOccupyCity = 301016,
|
|
Battle3Kill = 301017,
|
|
Battle4Kill = 301018,
|
|
BattleKillFullHealth = 301019,
|
|
BattleKillOfficer = 301020,
|
|
BattleHeroLevelup = 301021,
|
|
BattleKillVillage = 301022,
|
|
BattleKillOnOurCity = 301023,
|
|
BattleKillOnOtherCity = 301024,
|
|
BattleHasTwoHero = 301025,
|
|
BattleHasThreeHero = 301026,
|
|
ExploitBigCity = 302001,
|
|
ExploitWealth10 = 302002,
|
|
ExploitWealth20 = 302003,
|
|
ExploitWealth30 = 302004,
|
|
ExploitTech5 = 302005,
|
|
ExploitTech10 = 302006,
|
|
ExploitFirstBattleShip = 302007,
|
|
ExploitFirstSwordsman = 302008,
|
|
ExploitFirstKnight = 302009,
|
|
ExploitFirstCatapult = 302010,
|
|
ExploitFirstGiant = 302011,
|
|
ExploitFirstPreserve = 302012,
|
|
ExploitFirstAcademy = 302013,
|
|
ExploitFirstWindmill = 302014,
|
|
ExploitFirstMarket = 302015,
|
|
ExploitFirstForge = 302016,
|
|
ExploitFirstSawmill = 302017,
|
|
ExploitFirstNavalBase = 302018,
|
|
ExploitTreasure = 302019,
|
|
DiplomacyBreak = 303001,
|
|
Battle5Kill = 401001,
|
|
Battle6PlusKill = 401002,
|
|
BattleOccupyCaptain = 401003,
|
|
BattleKillHero = 401004,
|
|
BattleOccupyOurCity = 401005,
|
|
BattleOccupyOurCaptain = 401006,
|
|
BattleOccupyBigCity = 401007,
|
|
ExploitWonder = 402001,
|
|
ExploitWealth50 = 402002,
|
|
ExploitWealth100 = 402003,
|
|
ExploitTech20 = 402004,
|
|
ExploitFirstSuperCity = 402005,
|
|
ExploitFirstBigPreserve = 402006,
|
|
ExploitFirstBigAcademy = 402007,
|
|
ExploitFirstBigWindmill = 402008,
|
|
ExploitFirstBigMarket = 402009,
|
|
ExploitFirstBigForge = 402010,
|
|
ExploitFirstBigSawmill = 402011,
|
|
ExploitWonderPEACE = 402012,
|
|
ExploitWonderKNOWLEDGE = 402013,
|
|
ExploitWonderTRADE = 402014,
|
|
ExploitWonderWEALTH = 402015,
|
|
ExploitWonderPOWER = 402016,
|
|
ExploitWonderPARK = 402017,
|
|
ExploitWonderEYE = 402018,
|
|
}
|
|
|
|
[Serializable]
|
|
[CreateAssetMenu(fileName = "MomentDataAssets", menuName = "TH1 Game Data/Moment Data Asset")]
|
|
public class MomentDataAssets : ScriptableObject
|
|
{
|
|
|
|
public List<MomentMainData> MomentMainDataList = new List<MomentMainData>();
|
|
public List<MomentSubData> MomentSubDataList = new List<MomentSubData>();
|
|
|
|
[NonSerialized]
|
|
private bool _subInitialized = false;
|
|
private Dictionary<MomentSubType, MomentSubData> _momentSubDataDict = new Dictionary<MomentSubType, MomentSubData>();
|
|
|
|
private void InitSub()
|
|
{
|
|
if (_subInitialized)
|
|
return;
|
|
foreach (var data in MomentSubDataList)
|
|
_momentSubDataDict[data.SubType] = data;
|
|
_subInitialized = true;
|
|
}
|
|
|
|
public bool GetMomentMainData(MomentMainType momentType, out MomentMainData data)
|
|
{
|
|
data = null;
|
|
foreach (var mainData in MomentMainDataList)
|
|
{
|
|
if (mainData.MomentType == momentType)
|
|
{
|
|
data = mainData;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool GetMomentSubData(MomentSubType subType, out MomentSubData data)
|
|
{
|
|
InitSub();
|
|
return _momentSubDataDict.TryGetValue(subType, out data);
|
|
}
|
|
}
|
|
|
|
//每一种xx时刻大类的参数
|
|
[Serializable]
|
|
public class MomentMainData
|
|
{
|
|
public MomentMainType MomentType;
|
|
public Color TitleBG;
|
|
public Color DescBG;
|
|
public Color TitleTextBG;
|
|
public Color BigTitleTextColor;
|
|
[MultilingualField]
|
|
public string Title;
|
|
public List<MomentImagePack> ImagePacks = new List<MomentImagePack>();
|
|
public Sprite GetImage(Empire empire)
|
|
{
|
|
// 收集所有匹配的候选
|
|
Sprite[] candidates = new Sprite[ImagePacks.Count];
|
|
int count = 0;
|
|
foreach (var pack in ImagePacks)
|
|
{
|
|
if (pack.Empire == empire)
|
|
candidates[count++] = pack.Image;
|
|
}
|
|
|
|
// 如果没有候选,返回 null
|
|
if (count == 0) return null;
|
|
|
|
// 返回随机选择的图片
|
|
return candidates[UnityEngine.Random.Range(0, count)];
|
|
}
|
|
}
|
|
|
|
|
|
//每一种xx时刻小类的参数
|
|
[Serializable]
|
|
public class MomentSubData
|
|
{
|
|
public MomentMainType MomentType;
|
|
public MomentSubType SubType;
|
|
[MultilingualField]
|
|
public string Title;
|
|
[MultilingualField]
|
|
public string Desc;
|
|
public Sprite Icon;
|
|
public List<MomentImagePack> ImagePacks = new List<MomentImagePack>();
|
|
public bool EveryTime;
|
|
public int MaxTime;
|
|
public Sprite GetImage(Empire empire)
|
|
{
|
|
var t = Table.Instance.MomentDataAssets.GetMomentMainData(MomentType,out var mainData);
|
|
return mainData.GetImage(empire);
|
|
|
|
// 收集所有匹配的候选
|
|
Sprite[] candidates = new Sprite[ImagePacks.Count];
|
|
int count = 0;
|
|
foreach (var pack in ImagePacks)
|
|
{
|
|
if (pack.Empire == empire)
|
|
candidates[count++] = pack.Image;
|
|
}
|
|
|
|
// 如果没有候选,返回 null
|
|
if (count == 0) return null;
|
|
|
|
// 返回随机选择的图片
|
|
return candidates[UnityEngine.Random.Range(0, count)];
|
|
}
|
|
|
|
}
|
|
|
|
[Serializable]
|
|
public struct MomentImagePack
|
|
{
|
|
public Sprite Image;
|
|
public Empire Empire;
|
|
|
|
}
|