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

290 lines
18 KiB
C#

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
public readonly static float[] HpDifficultyArr = { 0, 0.50f, 0.96f, 1.37f, 1.72f };
// 0.18f, 0.16f, 0.12f, 0.08f
public readonly static float[] AtkDefDifficultyArr = { 0, 0.18f, 0.34f, 0.46f, 0.53f };
public static MonsterBase MainstoryGenerate(BattleBase self, MainStory mainStory)
{
Team team = self.team;
int len = mainStory.Monster_1Arr.Length;
var targetTeam = EntityFactory.Create<Team>(Game.Scene);
targetTeam.LeaderId = team.LeaderId;
//!+怪物队伍的总怪物数量
var _monsters = mainStory.Monster_1Arr[0];
MonsterBase _monsterBase = DataTableHelper.Get<MonsterBase>(_monsters.Monster_1_Id);
for (int i = 0; i < len; i++)
{
//!获取怪物队伍的数量信息
var 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.MainStoryMonster);
//!设置基础属性
int difficultIndex = team.MemberCount - 1;
float hpDifficult = 1 + HpDifficultyArr[difficultIndex];
float atkDefDifficult = 1 + AtkDefDifficultyArr[difficultIndex];
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, monsterBase.Level);
var 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)monsterBase.Id, monsterBase.Level, monsterBase.SkillGroupId);
}
}
self.targetTeam = targetTeam;
return _monsterBase;
}
public static MonsterBase TrialCopyGenerate(BattleBase self, TrialCopy trialCopy)
{
Team team = self.team;
var targetTeam = EntityFactory.Create<Team>(Game.Scene);
targetTeam.LeaderId = team.LeaderId;
var monsterBase = DataTableHelper.Get<MonsterBase>(trialCopy.MonsterId);
for (int i = 0; i < trialCopy.MonsterCount; i++)
{
Unit unitMonster = EntityFactory.CreateWithParent<Unit, UnitType>(targetTeam, UnitType.TrialCopyMonster);
//!设置基础属性
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, monsterBase.Level);
var 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)monsterBase.Id, monsterBase.Level, monsterBase.SkillGroupId);
}
self.targetTeam = targetTeam;
return monsterBase;
}
public static void ManulEquipGenerate(ManulEquipBattle self, ManulEquipMonsterConfig config)
{
Team team = self.team;
var 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++);
Unit unitMonster = EntityFactory.CreateWithParent<Unit, UnitType>(targetTeam, UnitType.ManulEquipMonster);
//!设置基础属性
int difficultIndex = team.MemberCount - 1;
float hpDifficult = 1 + C2M_StartMainStoryFightHandler.HpDifficultyArr[difficultIndex];
float atkDefDifficult = 1 + C2M_StartMainStoryFightHandler.AtkDefDifficultyArr[difficultIndex];
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, monsterConfig.Level);
var character = unitMonster.AddComponent<Character>();
unitMonster.AddComponent<Combat>();
character.Set(AttributeType., MathHelper.RoundToInt(monsterConfig.Hp * hpDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterConfig.PhyAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterConfig.SpiAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterConfig.PhyDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterConfig.SpiDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterConfig.Str * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterConfig.Wim * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterConfig.Quk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterConfig.Spi * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterConfig.Phy * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(monsterConfig.Sta * atkDefDifficult));
character.Set(AttributeType., monsterConfig.Pcrir * atkDefDifficult);
character.Set(AttributeType., monsterConfig.Pcri * atkDefDifficult);
character.Set(AttributeType., monsterConfig.Mcrir * atkDefDifficult);
character.Set(AttributeType., monsterConfig.Mcri * atkDefDifficult);
character.Set(AttributeType., monsterConfig.Rpcrir * atkDefDifficult);
character.Set(AttributeType., monsterConfig.Rpcri * atkDefDifficult);
character.Set(AttributeType., monsterConfig.Rmcrir * atkDefDifficult);
character.Set(AttributeType., monsterConfig.Rmcri * atkDefDifficult);
character.Set(AttributeType., monsterConfig.Dvo * atkDefDifficult);
character.Set(AttributeType., monsterConfig.Nphyi);
character.Set(AttributeType., monsterConfig.Nmeni);
MonsterInit(team.GetLeader().GetMap(),unitMonster, team.LeaderId, targetTeam, (int)monsterConfig.Id, monsterConfig.Level, monsterConfig.SkillGroupId);
}
self.targetTeam = targetTeam;
}
public static MonsterBase BossGenerate(BattleBase self, int mapId)
{
Team team = self.team;
var targetTeam = EntityFactory.Create<Team>(Game.Scene);
targetTeam.LeaderId = team.LeaderId;
int mapLayer = mapId % 100;
var bossBase = DataTableHelper.Get<BossBase>(BossComponent.Instance.GetBossId(mapLayer));
MonsterBase monsterBase = MonsterBaseCategory.Instance.Get(bossBase.PrefabId);
Unit unitMonster = EntityFactory.CreateWithParent<Unit, UnitType>(targetTeam, UnitType.BossMonster);
//!设置基础属性
int difficultIndex = team.MemberCount - 1;
float hpDifficult = 1 + C2M_StartMainStoryFightHandler.HpDifficultyArr[difficultIndex];
float atkDefDifficult = 1 + C2M_StartMainStoryFightHandler.AtkDefDifficultyArr[difficultIndex];
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, monsterBase.Level);
var 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[mapLayer] = unitMonster.Id;
unitMonster.AddComponent<UnitScene>().MapId = mapId;
MonsterInit(team.GetLeader().GetMap(),unitMonster, team.LeaderId, targetTeam, (int)monsterBase.Id, monsterBase.Level, monsterBase.SkillGroupId);
self.targetTeam = targetTeam;
return monsterBase;
}
public static FamilyBossConfig FamilyBossGenerate(BattleBase self, int bossId, FamilyBoss family)
{
Team team = self.team;
var targetTeam = EntityFactory.Create<Team>(Game.Scene);
targetTeam.LeaderId = team.LeaderId;
FamilyBossConfig bossBase = DataTableHelper.Get<FamilyBossConfig>(bossId);
Unit unitMonster = EntityFactory.CreateWithParent<Unit, UnitType>(targetTeam, UnitType.FamilyBossMonster);
//!设置基础属性
int difficultIndex = team.MemberCount - 1;
float hpDifficult = 1 + C2M_StartMainStoryFightHandler.HpDifficultyArr[difficultIndex];
float atkDefDifficult = 1 + C2M_StartMainStoryFightHandler.AtkDefDifficultyArr[difficultIndex];
unitMonster.AddComponent<NumericComponent>().Set(NumericType.Level, bossBase.Level);
var character = unitMonster.AddComponent<Character>();
unitMonster.AddComponent<Combat>();
int hp = family.GetBossHp(bossId);
character.Set(AttributeType., hp);
character.Set(AttributeType., MathHelper.RoundToInt(bossBase.PhyAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(bossBase.SpiAtk * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(bossBase.PhyDef * atkDefDifficult));
character.Set(AttributeType., MathHelper.RoundToInt(bossBase.SpiDef * atkDefDifficult));
character.Set(AttributeType., bossBase.Pcrir * atkDefDifficult);
character.Set(AttributeType., bossBase.Pcri * atkDefDifficult);
character.Set(AttributeType., bossBase.Mcrir * atkDefDifficult);
character.Set(AttributeType., bossBase.Mcri * atkDefDifficult);
character.Set(AttributeType., bossBase.Rpcrir * atkDefDifficult);
character.Set(AttributeType., bossBase.Rpcri * atkDefDifficult);
character.Set(AttributeType., bossBase.Rmcrir * atkDefDifficult);
character.Set(AttributeType., bossBase.Rmcri * atkDefDifficult);
character.Set(AttributeType., bossBase.Dvo * atkDefDifficult);
character.Set(AttributeType., bossBase.Nphyi);
character.Set(AttributeType., bossBase.Nmeni);
MonsterInit(team.GetLeader().GetMap(),unitMonster, team.LeaderId, targetTeam, (int)bossBase.Id, bossBase.Level, bossBase.SkillGroupId);
self.targetTeam = targetTeam;
return bossBase;
}
/// <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 monsterId, int level, int skillGroupId)
{
mapScene.Enter(unitMonster).Coroutine();
unitMonster.AddComponent<BattleComponent>();
unitMonster.AddComponent<MonsterInfo>().monsterId = monsterId;
unitMonster.AddComponent<BrocastComponent, bool>(false);
//!用TeamLeaderId保存玩家Id
unitMonster.TeamLeaderId = learderId;
//!初始化怪物技能
unitMonster.AddComponent<SkillMgrComponent>();
unitMonster.AddComponent<ModifierContainerComponent>();
var skillComponent = unitMonster.AddComponent<UnitSkillComponent>();
var ai = unitMonster.AddComponent<SkillAI>();
SkillGroupBase skillGroupBase = DataTableHelper.Get<SkillGroupBase>(skillGroupId);
for (int i = skillGroupBase.SkillsArr.Length - 1; i >= 0; i--)
{
var skillId = skillGroupBase.SkillsArr[i].Skills_Id;
if (skillComponent.InitMonsterSkill(skillId))
skillComponent.LearnMonsterSkill(skillId);
ai.AutoSkillList.AddFirst(skillId);
}
int lv = level;
var spd = CharacterHelper.GetSpeed(lv);
ai.roundCD = CharacterHelper.GetSkillCD(spd);
//!增加记录玩家的组件
unitMonster.AddComponent<UnitEnermy>().MonsterId = monsterId;
//!加入怪物队伍
targetTeam.Add(unitMonster);
}
}
}