CTT/Server/Hotfix/Game/Helper/MonsterFactoryHelper.cs

409 lines
26 KiB
C#
Executable File

using Cal;
using Cal.DataTable;
using System;
using System.Collections.Generic;
using System.Text;
namespace ET
{
public static class MonsterFactoryHelper
{
//0.50f, 0.46f, 0.41f, 0.35f
private static readonly float[] HpDifficultyArr = { 0, 0.50f, 0.96f, 1.37f, 1.72f };
// 0.18f, 0.16f, 0.12f, 0.08f
private static readonly float[] AtkDefDifficultyArr = { 0, 0.18f, 0.34f, 0.46f, 0.53f };
public static MonsterBase MainstoryGenerate(CopyBattle self, MainStory mainStory)
{
Team team = self.team;
int len = mainStory.Monster_1Arr.Length;
Team targetTeam = EntityFactory.Create<Team>(Game.Scene);
targetTeam.LeaderId = team.LeaderId;
//!+怪物队伍的总怪物数量
MainStory.Monster_1 _monsters = mainStory.Monster_1Arr[0];
MonsterBase _monsterBase = DataTableHelper.Get<MonsterBase>(_monsters.Monster_1_Id);
for (int i = 0; i < len; i++)
{
//!获取怪物队伍的数量信息
MainStory.Monster_1 monsters = mainStory.Monster_1Arr[i];
MonsterBase monsterBase = DataTableHelper.Get<MonsterBase>(monsters.Monster_1_Id);
int monsterCount = monsters.Monster_1_Count;
//monsterCount = 10;
for (int j = 0; j < monsterCount; j++)
{
//!创建怪物,加入队伍
Unit unitMonster = EntityFactory.CreateWithParent<Unit, UnitType>(targetTeam, UnitType.Monster);
//!设置基础属性
int difficultIndex = team.MemberCount - 1;
float hpDifficult = 1 + HpDifficultyArr[difficultIndex];
float atkDefDifficult = 1 + AtkDefDifficultyArr[difficultIndex];
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, monsterBase.Level);
Character character = unitMonster.AddComponent<Character>();
unitMonster.AddComponent<Combat>();
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Hp * hpDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiDef * atkDefDifficult));
MonsterInit(team.GetLeader().GetMap(), unitMonster, team.LeaderId, targetTeam, (int) mainStory.Id, (int) monsterBase.Id,
monsterBase.Level, monsterBase.SkillGroupId);
}
}
self.targetTeam = targetTeam;
return _monsterBase;
}
public static MonsterBase TrialCopyGenerate(CopyBattle self, TrialCopy trialCopy)
{
Team team = self.team;
Team targetTeam = EntityFactory.Create<Team>(Game.Scene);
targetTeam.LeaderId = team.LeaderId;
MonsterBase monsterBase = DataTableHelper.Get<MonsterBase>(trialCopy.MonsterId);
for (int i = 0; i < trialCopy.MonsterCount; i++)
{
Unit unitMonster = EntityFactory.CreateWithParent<Unit, UnitType>(targetTeam, UnitType.Monster);
//!设置基础属性
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, monsterBase.Level);
Character character = unitMonster.AddComponent<Character>();
unitMonster.AddComponent<Combat>();
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Hp));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyAtk));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiAtk));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyDef));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiDef));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Str));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Wim));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Quk));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Spi));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Phy));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Sta));
character.Set(AttributeType., monsterBase.Pcrir);
character.Set(AttributeType., monsterBase.Pcri);
character.Set(AttributeType., monsterBase.Mcrir);
character.Set(AttributeType., monsterBase.Mcri);
character.Set(AttributeType., monsterBase.Rpcrir);
character.Set(AttributeType., monsterBase.Rpcri);
character.Set(AttributeType., monsterBase.Rmcrir);
character.Set(AttributeType., monsterBase.Rmcri);
character.Set(AttributeType., monsterBase.Dvo);
character.Set(AttributeType., monsterBase.Nphyi);
character.Set(AttributeType., monsterBase.Nmeni);
MonsterInit(team.GetLeader().GetMap(), unitMonster, team.LeaderId, targetTeam, (int) trialCopy.Id, trialCopy.MonsterId,
monsterBase.Level, monsterBase.SkillGroupId);
}
self.targetTeam = targetTeam;
return monsterBase;
}
public static void ManulEquipGenerate(CopyBattle self, ManulEquipMonsterConfig config)
{
Team team = self.team;
Team targetTeam = EntityFactory.Create<Team>(Game.Scene);
targetTeam.LeaderId = team.LeaderId;
long id = config.Id;
for (int i = 0; i < 3; i++)
{
ManulEquipMonsterConfig monsterConfig = ManulEquipMonsterConfigCategory.Instance.Get(id++);
MonsterBase monsterBase = MonsterBaseCategory.Instance.Get(monsterConfig.MonsterId);
Unit unitMonster = EntityFactory.CreateWithParent<Unit, UnitType>(targetTeam, UnitType.Monster);
//!设置基础属性
int difficultIndex = team.MemberCount - 1;
float hpDifficult = 1 + ConstDefine.HpDifficultyArr[difficultIndex];
float atkDefDifficult = 1 + ConstDefine.AtkDefDifficultyArr[difficultIndex];
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, monsterBase.Level);
Character character = unitMonster.AddComponent<Character>();
unitMonster.AddComponent<Combat>();
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Hp * hpDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Str * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Wim * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Quk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Spi * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Phy * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Sta * atkDefDifficult));
character.Set(AttributeType., monsterBase.Pcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Pcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Mcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Mcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rpcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rpcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rmcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rmcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Dvo * atkDefDifficult);
character.Set(AttributeType., monsterBase.Nphyi);
character.Set(AttributeType., monsterBase.Nmeni);
MonsterInit(team.GetLeader().GetMap(), unitMonster, team.LeaderId, targetTeam, (int) config.Id, (int) monsterBase.Id,
monsterBase.Level, monsterBase.SkillGroupId);
}
self.targetTeam = targetTeam;
}
public static void SpaceTravelGenerate(CopyBattle self, SpaceTravelConfig config)
{
Team team = self.team;
Team targetTeam = EntityFactory.Create<Team>(Game.Scene);
targetTeam.LeaderId = team.LeaderId;
int difficultIndex = team.MemberCount - 1;
float hpDifficult = 1 + ConstDefine.HpDifficultyArr[difficultIndex];
float atkDefDifficult = 1 + ConstDefine.AtkDefDifficultyArr[difficultIndex];
foreach (int monsterId in config.MonsterIdArr)
{
MonsterBase monsterBase = MonsterBaseCategory.Instance.Get(monsterId);
Unit unitMonster = EntityFactory.CreateWithParent<Unit, UnitType>(targetTeam, UnitType.Monster);
//!设置基础属性
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, monsterBase.Level);
Character character = unitMonster.AddComponent<Character>();
unitMonster.AddComponent<Combat>();
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Hp * hpDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Str * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Wim * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Quk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Spi * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Phy * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Sta * atkDefDifficult));
character.Set(AttributeType., monsterBase.Pcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Pcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Mcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Mcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rpcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rpcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rmcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rmcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Dvo * atkDefDifficult);
character.Set(AttributeType., monsterBase.Nphyi);
character.Set(AttributeType., monsterBase.Nmeni);
MonsterInit(team.GetLeader().GetMap(), unitMonster, team.LeaderId, targetTeam, (int) config.Id, (int) monsterBase.Id,
monsterBase.Level, monsterBase.SkillGroupId);
}
self.targetTeam = targetTeam;
}
public static MonsterBase BossGenerate(CopyBattle self, int mapId, BossBase bossBase)
{
Team team = self.team;
Team targetTeam = EntityFactory.Create<Team>(Game.Scene);
targetTeam.LeaderId = team.LeaderId;
MonsterBase monsterBase = MonsterBaseCategory.Instance.Get(bossBase.MonsterId);
Unit unitMonster = EntityFactory.CreateWithParent<Unit, UnitType>(targetTeam, UnitType.Monster);
//!设置基础属性
int difficultIndex = team.MemberCount - 1;
float hpDifficult = 1 + ConstDefine.HpDifficultyArr[difficultIndex];
float atkDefDifficult = 1 + ConstDefine.AtkDefDifficultyArr[difficultIndex];
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, monsterBase.Level);
Character character = unitMonster.AddComponent<Character>();
unitMonster.AddComponent<Combat>();
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Hp * hpDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Str * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Wim * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Quk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Spi * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Phy * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Sta * atkDefDifficult));
character.Set(AttributeType., monsterBase.Pcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Pcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Mcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Mcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rpcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rpcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rmcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rmcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Dvo * atkDefDifficult);
character.Set(AttributeType., monsterBase.Nphyi);
character.Set(AttributeType., monsterBase.Nmeni);
//!保存bossUnitId
BossComponent.Instance.bossIdDic[mapId % 100] = unitMonster.Id;
unitMonster.AddComponent<UnitScene>().MapId = mapId;
MonsterInit(team.GetLeader().GetMap(), unitMonster, team.LeaderId, targetTeam, (int) bossBase.Id, bossBase.MonsterId, monsterBase.Level,
monsterBase.SkillGroupId);
self.targetTeam = targetTeam;
return monsterBase;
}
public static FamilyBossConfig FamilyBossGenerate(CopyBattle self, FamilyBossConfig familyBossConfig, FamilyBoss family)
{
Team team = self.team;
Team targetTeam = EntityFactory.Create<Team>(Game.Scene);
targetTeam.LeaderId = team.LeaderId;
MonsterBase monsterBase = MonsterBaseCategory.Instance.Get(familyBossConfig.MonsterId);
Unit unitMonster = EntityFactory.CreateWithParent<Unit, UnitType>(targetTeam, UnitType.Monster);
//!设置基础属性
int difficultIndex = team.MemberCount - 1;
float hpDifficult = 1 + ConstDefine.HpDifficultyArr[difficultIndex];
float atkDefDifficult = 1 + ConstDefine.AtkDefDifficultyArr[difficultIndex];
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, monsterBase.Level);
Character character = unitMonster.AddComponent<Character>();
unitMonster.AddComponent<Combat>();
int hp = family.GetBossHp((int) familyBossConfig.Id);
character.Set(AttributeType., hp);
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiDef * atkDefDifficult));
character.Set(AttributeType., monsterBase.Pcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Pcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Mcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Mcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rpcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rpcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rmcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rmcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Dvo * atkDefDifficult);
character.Set(AttributeType., monsterBase.Nphyi);
character.Set(AttributeType., monsterBase.Nmeni);
MonsterInit(team.GetLeader().GetMap(), unitMonster, team.LeaderId, targetTeam, (int) familyBossConfig.Id, familyBossConfig.MonsterId,
monsterBase.Level, monsterBase.SkillGroupId);
self.targetTeam = targetTeam;
return familyBossConfig;
}
public static void StarSoulGenerate(CopyBattle self, StarSoulCopyConfig config)
{
Team team = self.team;
Team targetTeam = EntityFactory.Create<Team>(Game.Scene);
targetTeam.LeaderId = team.LeaderId;
int difficultIndex = team.MemberCount - 1;
float hpDifficult = 1 + ConstDefine.HpDifficultyArr[difficultIndex];
float atkDefDifficult = 1 + ConstDefine.AtkDefDifficultyArr[difficultIndex];
foreach (int monsterId in config.MonsterIdArr)
{
MonsterBase monsterBase = MonsterBaseCategory.Instance.Get(monsterId);
Unit unitMonster = EntityFactory.CreateWithParent<Unit, UnitType>(targetTeam, UnitType.Monster);
//!设置基础属性
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, monsterBase.Level);
Character character = unitMonster.AddComponent<Character>();
unitMonster.AddComponent<Combat>();
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Hp * hpDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.PhyDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.SpiDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Str * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Wim * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Quk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Spi * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Phy * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterBase.Sta * atkDefDifficult));
character.Set(AttributeType., monsterBase.Pcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Pcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Mcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Mcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rpcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rpcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rmcrir * atkDefDifficult);
character.Set(AttributeType., monsterBase.Rmcri * atkDefDifficult);
character.Set(AttributeType., monsterBase.Dvo * atkDefDifficult);
character.Set(AttributeType., monsterBase.Nphyi);
character.Set(AttributeType., monsterBase.Nmeni);
MonsterInit(team.GetLeader().GetMap(), unitMonster, team.LeaderId, targetTeam, (int) config.Id, (int) monsterBase.Id,
monsterBase.Level, monsterBase.SkillGroupId);
}
self.targetTeam = targetTeam;
}
/// <summary>
/// 3处需要改动
/// </summary>
/// <param name="unitMonster"></param>
/// <param name="learderId"></param>
/// <param name="targetTeam"></param>
/// <param name="monsterId"></param>
/// <param name="level"></param>
/// <param name="skillGroupId"></param>
private static void MonsterInit(MapScene mapScene, Unit unitMonster, long learderId, Team targetTeam, int configId, int monsterId, int level,
int skillGroupId)
{
mapScene.Enter(unitMonster).Coroutine();
unitMonster.AddComponent<BattleComponent>();
unitMonster.AddComponent<AttackComponent>();
unitMonster.AddComponent<TargetableUnitComponent>();
var monsterInfo = unitMonster.AddComponent<MonsterInfo>();
monsterInfo.configId = configId;
monsterInfo.monsterId = monsterId;
unitMonster.AddComponent<BrocastComponent, bool>(false);
//!用TeamLeaderId保存玩家Id
unitMonster.TeamLeaderId = learderId;
//!初始化怪物技能
unitMonster.AddComponent<SkillMgrComponent>();
unitMonster.AddComponent<ModifierContainerComponent>();
UnitSkillComponent skillComponent = unitMonster.AddComponent<UnitSkillComponent>();
SkillAI ai = unitMonster.AddComponent<SkillAI>();
SkillGroupBase skillGroupBase = DataTableHelper.Get<SkillGroupBase>(skillGroupId);
for (int i = skillGroupBase.SkillsArr.Length - 1; i >= 0; i--)
{
int skillId = skillGroupBase.SkillsArr[i].Skills_Id;
if (skillComponent.InitMonsterSkill(skillId))
skillComponent.LearnMonsterSkill(skillId);
ai.AutoSkillList.AddFirst(skillId);
}
//添加技能
SkillMgrComponent skillMgr = unitMonster.GetComponent<SkillMgrComponent>();
foreach (UnitSkill unitSkill in skillComponent.GetLearnedSkills())
{
skillMgr.AddSkill(unitMonster, unitSkill);
}
int lv = level;
float spd = CharacterHelper.GetSpeed(lv);
ai.roundCD = CharacterHelper.GetSkillCD(spd);
//!增加记录玩家的组件
unitMonster.AddComponent<UnitEnermy>().MonsterId = monsterId;
//!加入怪物队伍
targetTeam.Add(unitMonster);
}
}
}