489 lines
15 KiB
C#
489 lines
15 KiB
C#
/*
|
||
* @Author: 白哉
|
||
* @Description:
|
||
* @Date: 2025年09月05日 星期五 15:09:36
|
||
* @Modify:
|
||
*/
|
||
|
||
|
||
using System.Collections.Generic;
|
||
using Logic;
|
||
using Logic.CrashSight;
|
||
using MemoryPack;
|
||
using NLog.Targets;
|
||
using RuntimeData;
|
||
using TH1_Logic.Core;
|
||
using UnityEngine;
|
||
|
||
|
||
namespace TH1_Logic.HeroTask
|
||
{
|
||
public enum HeroTaskContentType
|
||
{
|
||
// 累计承受伤害
|
||
AccumulateDamageTaken,
|
||
// 累计造成伤害
|
||
AccumulateDamageDealt,
|
||
// 累计杀人
|
||
AccumulateKills,
|
||
// 累计产生(自身或他人)治疗
|
||
AccumulateHealing,
|
||
// 累计开启遗迹
|
||
AccumulateRelicsOpened,
|
||
// 累计探索新地块
|
||
AccumulateAreasExplored,
|
||
// 累计占领新城市
|
||
AccumulateCitiesCaptured,
|
||
// 单位X 给任何单位增加N次技能A的层数,X的该计数+N
|
||
AddSkillStacks,
|
||
// 单位X 的技能A 生效时(接口,技能自定义),则该计数变化(技能自定义)
|
||
SkillActivation,
|
||
// 累计获得金钱(目前是tewi专用)
|
||
TewiAddCoin,
|
||
// 满足条件的Skill总共掉层X次,Skill 属于 一个特定的List<Skill>
|
||
SkillDropLevels,
|
||
// 遇到X 个其他玩家 (这里X = 50% * N 下取整,N=本局玩家总数)
|
||
MeetOtherPlayers,
|
||
// 施加X次 将一个grid AddSpType(RemiliaGrid)
|
||
AddSpType,
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
[MemoryPackUnion(1, typeof(HeroTaskContentAccumulateDamageTaken))]
|
||
[MemoryPackUnion(2, typeof(HeroTaskContentAccumulateDamageDealt))]
|
||
[MemoryPackUnion(3, typeof(HeroTaskContentAccumulateKills))]
|
||
[MemoryPackUnion(4, typeof(HeroTaskContentAccumulateHealing))]
|
||
[MemoryPackUnion(5, typeof(HeroTaskContentAccumulateRelicsOpened))]
|
||
[MemoryPackUnion(6, typeof(HeroTaskContentAccumulateAreasExplored))]
|
||
[MemoryPackUnion(7, typeof(HeroTaskContentAccumulateCitiesCaptured))]
|
||
[MemoryPackUnion(8, typeof(HeroTaskContentAddSkillStacks))]
|
||
[MemoryPackUnion(9, typeof(HeroTaskContentSkillActivation))]
|
||
[MemoryPackUnion(10, typeof(HeroTaskContentTewiAddCoin))]
|
||
[MemoryPackUnion(11, typeof(HeroTaskContentSkillDropLevels))]
|
||
[MemoryPackUnion(12, typeof(HeroTaskContentMeetOtherPlayers))]
|
||
[MemoryPackUnion(13, typeof(HeroTaskContentAddSpType))]
|
||
public abstract partial class HeroTaskContentBase
|
||
{
|
||
public uint Level;
|
||
public uint TargetLevel;
|
||
public SkillType SkillType;
|
||
public GridSpType SpType;
|
||
public List<SkillType> SkillTypeList;
|
||
public abstract HeroTaskContentType GetContentType();
|
||
|
||
|
||
[MemoryPackConstructor]
|
||
public HeroTaskContentBase()
|
||
{
|
||
Level = 0;
|
||
TargetLevel = 1;
|
||
SkillTypeList = new List<SkillType>();
|
||
;
|
||
}
|
||
|
||
public virtual string LevelShowString()
|
||
{
|
||
return Level.ToString();
|
||
}
|
||
|
||
public virtual string TargetLevelShowString()
|
||
{
|
||
return TargetLevel.ToString();
|
||
}
|
||
|
||
public abstract HeroTaskContentBase GetCopyHeroTaskContent();
|
||
|
||
public virtual bool CheckFinished(MapData map, PlayerData self)
|
||
{
|
||
return Level >= TargetLevel;
|
||
}
|
||
|
||
public virtual void OnCoinAdd(MapData mapData, uint value)
|
||
{
|
||
|
||
}
|
||
|
||
public virtual void OnDamageOther(MapData mapData, SettlementInfo info)
|
||
{
|
||
|
||
}
|
||
|
||
public virtual void OnDamaged(MapData mapData, SettlementInfo info)
|
||
{
|
||
|
||
}
|
||
|
||
public virtual void OnHealthReturn(MapData mapData, int realValue,int value)
|
||
{
|
||
|
||
}
|
||
|
||
public virtual void OnTreasure(MapData mapData)
|
||
{
|
||
|
||
}
|
||
|
||
public virtual void OnCaptureCity(MapData mapData)
|
||
{
|
||
|
||
}
|
||
|
||
public virtual void OnExploredGrids(MapData mapData, int count)
|
||
{
|
||
|
||
}
|
||
|
||
public virtual void OnAddSkillLevels(MapData mapData, SkillType skillType, uint addLevels)
|
||
{
|
||
|
||
}
|
||
|
||
public virtual void OnReduceSkillLevels(MapData mapData, SkillType skillType, uint reduceLevels)
|
||
{
|
||
|
||
}
|
||
|
||
public virtual void OnSkillActivation(MapData mapData, SkillType skillType, uint addLevels)
|
||
{
|
||
|
||
}
|
||
|
||
public virtual int GetFinishCost()
|
||
{
|
||
if (Level >= TargetLevel)
|
||
return 0;
|
||
if (Level == TargetLevel)
|
||
return 20;
|
||
LogSystem.LogInfo($"{TargetLevel } - {Level} / {TargetLevel } / 0.2 = {(int)(1f * (TargetLevel - Level) / TargetLevel /0.2f)}");
|
||
return ((int)(1f * (TargetLevel - Level) / TargetLevel / 0.2f) + 1) * 3 + 5;
|
||
}
|
||
|
||
public virtual void OnAddSpType(MapData mapData, GridSpType spType)
|
||
{
|
||
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentAccumulateDamageTaken : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.AccumulateDamageTaken;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentAccumulateDamageTaken();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
return newContent;
|
||
}
|
||
|
||
public override void OnDamaged(MapData mapData, SettlementInfo info)
|
||
{
|
||
Level += (uint)info.DamageValue;
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentAccumulateDamageDealt : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.AccumulateDamageDealt;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentAccumulateDamageDealt();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
return newContent;
|
||
}
|
||
|
||
public override void OnDamageOther(MapData mapData, SettlementInfo info)
|
||
{
|
||
Level += (uint)info.DamageValue;
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentAccumulateKills : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.AccumulateKills;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentAccumulateKills();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
return newContent;
|
||
}
|
||
|
||
public override void OnDamageOther(MapData mapData, SettlementInfo info)
|
||
{
|
||
if (info.IsKill && info.DamageType != DamageType.KillSelf) Level++;
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentAccumulateHealing : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.AccumulateHealing;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentAccumulateHealing();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
return newContent;
|
||
}
|
||
|
||
public override void OnHealthReturn(MapData mapData, int realValue,int value)
|
||
{
|
||
Level += (uint)value;
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentAccumulateRelicsOpened : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.AccumulateRelicsOpened;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentAccumulateRelicsOpened();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
return newContent;
|
||
}
|
||
|
||
public override void OnTreasure(MapData mapData)
|
||
{
|
||
Level++;
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentAccumulateAreasExplored : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.AccumulateAreasExplored;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentAccumulateAreasExplored();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
return newContent;
|
||
}
|
||
|
||
public override void OnExploredGrids(MapData mapData, int count)
|
||
{
|
||
Level += (uint)count;
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentAccumulateCitiesCaptured : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.AccumulateCitiesCaptured;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentAccumulateCitiesCaptured();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
return newContent;
|
||
}
|
||
|
||
public override void OnCaptureCity(MapData mapData)
|
||
{
|
||
Level++;
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentAddSkillStacks : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.AddSkillStacks;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentAddSkillStacks();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
newContent.SkillType = SkillType;
|
||
return newContent;
|
||
}
|
||
|
||
public override void OnAddSkillLevels(MapData mapData, SkillType skillType, uint addLevels)
|
||
{
|
||
if (skillType != SkillType) return;
|
||
Level += addLevels;
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentSkillActivation : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentSkillActivation();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
newContent.SkillType = SkillType;
|
||
return newContent;
|
||
}
|
||
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.SkillActivation;
|
||
}
|
||
|
||
public override void OnSkillActivation(MapData mapData, SkillType skillType, uint addLevels)
|
||
{
|
||
if (skillType != SkillType) return;
|
||
Level += addLevels;
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentTewiAddCoin : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.TewiAddCoin;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentTewiAddCoin();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
newContent.SkillType = SkillType;
|
||
return newContent;
|
||
}
|
||
|
||
public override void OnCoinAdd(MapData mapData, uint value)
|
||
{
|
||
Level += value;
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentSkillDropLevels : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.SkillDropLevels;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentSkillDropLevels();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
newContent.SkillType = SkillType;
|
||
newContent.SkillTypeList ??= new List<SkillType>();
|
||
newContent.SkillTypeList.Clear();
|
||
foreach (var skillType in SkillTypeList) newContent.SkillTypeList.Add(skillType);
|
||
return newContent;
|
||
}
|
||
|
||
public override void OnReduceSkillLevels(MapData mapData, SkillType skillType, uint reduceLevels)
|
||
{
|
||
if (!SkillTypeList.Contains(skillType)) return;
|
||
Level += reduceLevels;
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentMeetOtherPlayers : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.MeetOtherPlayers;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentMeetOtherPlayers();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
newContent.SkillType = SkillType;
|
||
return newContent;
|
||
}
|
||
|
||
public override bool CheckFinished(MapData map, PlayerData self)
|
||
{
|
||
Level = (uint)(self.MeetPlayers.Count / (float)map.PlayerMap.PlayerDataList.Count * 100);
|
||
return base.CheckFinished(map, self);
|
||
}
|
||
|
||
public override string LevelShowString()
|
||
{
|
||
return ((int)((Main.MapData.MapConfig?.PlayerCount ?? 0) * Level * 0.01f)).ToString();
|
||
}
|
||
|
||
public override string TargetLevelShowString()
|
||
{
|
||
return ((int)((Main.MapData.MapConfig?.PlayerCount ?? 0) * TargetLevel * 0.01f)).ToString();
|
||
}
|
||
}
|
||
|
||
|
||
[MemoryPackable]
|
||
public partial class HeroTaskContentAddSpType : HeroTaskContentBase
|
||
{
|
||
public override HeroTaskContentType GetContentType()
|
||
{
|
||
return HeroTaskContentType.AddSpType;
|
||
}
|
||
|
||
public override HeroTaskContentBase GetCopyHeroTaskContent()
|
||
{
|
||
var newContent = new HeroTaskContentAddSpType();
|
||
newContent.Level = Level;
|
||
newContent.TargetLevel = TargetLevel;
|
||
newContent.SpType = SpType;
|
||
return newContent;
|
||
}
|
||
|
||
public override void OnAddSpType(MapData mapData, GridSpType spType)
|
||
{
|
||
if (SpType == spType) Level++;
|
||
}
|
||
}
|
||
} |