You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

270 lines
11 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using ProtoCSStruct;
using Sog;
namespace Battle
{
public static class BattleInitSvc
{
public static void InitBattle(BattleObj battle)
{
battle.Trace("BattleInitSvc.InitBattle battle {0} mainland {1}"
, battle.BattleId, battle.battleInfo.MainlandId);
battle.round = 0;
// 战斗中的用到的配置参数
//BattleControl.InitBattleParamCfg();
InitAllHero(battle, ref battle.battleInfo.HerosA, BattleSide.SideA);
InitMonster(battle);
}
public static int InitHero(BattleObj battle, BattleSide side, long nowSec, ref HeroInfo heroInfo, ref int posCount, ref int posStep)
{
BattleHero hero = new BattleHero(battle);
hero.DescId = 101;
hero.heroType = HeroType.Hero;
hero.objId = battle.GenObjId();
heroInfo.Dbhero.SerialNum = hero.objId;
hero.initSide = side;
hero.pos = posCount;
posCount += posStep;
//heroInfo.LineupPos = hero.pos;
//HeroPropUtils.CalcHeroProp(ref heroInfo, hero.prop, nowSec, (MainlandType)battle.battleInfo.MainlandType);
InitHeroCommProp(battle, side, ref heroInfo, ref hero);
// 机器人要根据面板值进行弱化
if (side == BattleSide.SideB && battle.battleInfo.RoleB.RoleBase.Uid < 100000)
{
//ProcessWeakRobot(ref hero.prop, battle.battleInfo.RoleB.RoleBase.Level);
}
// 填充英雄表现信息
MakeHeroShowInfo(hero, ref heroInfo);
//battle.Trace("BattleInitSvc.InitHero hero {0}-{1} hp {2} atk {3} def {4} speed {5} side {6}"
// , hero.objId, hero.DescId, heroInfo.ShowInfo.MaxHp, hero.prop.GetValueNoCheck(CSPropIDType.Atk)
// , hero.prop.GetValueNoCheck(CSPropIDType.Def), hero.prop.GetValueNoCheck(CSPropIDType.Speed), side);
if (side == BattleSide.SideA)
battle.herosA.Add(hero);
else
{
battle.herosB.Add(hero);
}
battle.allCreatures.Add(hero);
return 0;
}
public static int InitAllHero(BattleObj battle, ref BattleSideInfo sideInfo, BattleSide side)
{
long nowSec = BattleServerUtils.GetTimeSecond();
int posCount = 1; //pos从1开始
int posStep = 1; //pos步长
for (int i = 0; i < sideInfo.List.Count; i++)
{
ref HeroInfo heroInfo = ref sideInfo.List[i];
posStep = 1;//恢复pos步长
InitHero(battle, side, nowSec, ref heroInfo, ref posCount, ref posStep);
}
return battle.allCreatures.Count;
}
public static int InitHeroCommProp(BattleObj battle, BattleSide side, ref HeroInfo heroInfo, ref BattleHero hero)
{
// gm测试战斗
if (battle.battleInfo.Smash == 1 || battle.battleInfo.Invincible == 1)
{
GMAddHeroProp(hero);
}
// 计算完所有属性后设置hp
//hero.prop.SetValueNoCheck(CSPropIDType.Hp, hero.prop.GetValueNoCheck(CSPropIDType.HpMax), false);
// 设置战场上的泥泞, 禁疗属性值
//SetBattleUnSpeed(battle, (int)side, hero.prop.GetValueNoCheck(CSPropIDType.UnSpeed));
//SetBattleUnHeal(battle, (int)side, hero.prop.GetValueNoCheck(CSPropIDType.UnHeal));
return 0;
}
// gm测试战斗
private static void GMAddHeroProp(BattleHero hero)
{
if (hero.initSide != BattleSide.SideA)
{
return;
}
//hero.prop.AddValueNoCheck(CSPropIDType.BaseSpeed, 10000000000);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseHpMax, 10000000000);
//if (hero.Battle.battleInfo.Smash == 1)
//{
// hero.prop.AddValueNoCheck(CSPropIDType.BaseAtk, 10000000000);
// hero.prop.AddValueNoCheck(CSPropIDType.BaseUnDodge, 10000000000);
//}
//if (hero.Battle.battleInfo.Invincible == 1)
//{
// hero.prop.AddValueNoCheck(CSPropIDType.BaseDef, 10000000000);
// hero.prop.AddValueNoCheck(CSPropIDType.BaseUnStun, 10000000000);
// hero.prop.AddValueNoCheck(CSPropIDType.BaseUnCombo, 10000000000);
//}
}
public static int InitMonsterHero(BattleObj battle, int monsterID, long unbeatableHp, int pos, HeroInfo petHeroInfo, int genId = 0)
{
//var propDesc = MonsterPropDescMgr.Instance.GetConfig(monsterID);
//if (propDesc == null)
//{
// battle.Error("BattleInitSvc.InitMonster invalid monster prop {0}", monsterID);
// return -1;
//}
//BattleHero hero = new BattleHero(battle);
//hero.DescId = monsterID;
//hero.objId = genId > 0 ? genId : battle.GenObjId();
//hero.initSide = BattleSide.SideB;
//hero.heroType = HeroType.Monster;
//hero.pos = 1;
//hero.prop.BeginChange();
//hero.prop.AddValueNoCheck(CSPropIDType.BaseHpMax, unbeatableHp > 0 ? unbeatableHp : propDesc.hp, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseAtk, propDesc.atk, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseDef, propDesc.def, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseSpeed, propDesc.speed, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseUnSpeed, propDesc.unSpeed, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseCombo, propDesc.combo, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseUnCombo, propDesc.unCombo, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseAtkBack, propDesc.atkBack, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseUnAtkBack, propDesc.unAtkBack, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseDodge, propDesc.dodge, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseUnDodge, propDesc.unDodge, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseLifeSteal, propDesc.steal, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseUnLifeSteal, propDesc.unSteal, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseStun, propDesc.stun, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseUnStun, propDesc.unStun, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseCriRate, propDesc.criRate, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseUnCriRate, propDesc.unCriRate, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseCriPower, propDesc.criPower, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseUnCriPower, propDesc.unCriPower, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseUnHeal, propDesc.unHeal, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseHeal5, propDesc.heal5, false);
//hero.prop.AddValueNoCheck(CSPropIDType.BaseBully, propDesc.bully, false);
//hero.prop.EndChange();
//hero.prop.SetValueNoCheck(CSPropIDType.Hp, hero.prop.GetValueNoCheck(CSPropIDType.HpMax), false);
//// 设置战场上的泥泞, 禁疗属性值
//SetBattleUnSpeed(battle, (int)BattleSide.SideB, hero.prop.GetValueNoCheck(CSPropIDType.UnSpeed));
//SetBattleUnHeal(battle, (int)BattleSide.SideB, hero.prop.GetValueNoCheck(CSPropIDType.UnHeal));
//var heroInfo = new HeroInfo();
//heroInfo.Dbhero.DescId = hero.DescId;
//heroInfo.Dbhero.Level = hero.level;
//heroInfo.LineupPos = hero.pos;
//heroInfo.Dbhero.SerialNum = hero.objId;
//MakeHeroShowInfo(hero, ref heroInfo);
//battle.Trace("BattleInitSvc.InitMonsterHero hero {0}-{1} hp {2} atk {3} def {4} speed {5}"
// , hero.objId, hero.DescId, hero.prop.GetValueNoCheck(CSPropIDType.Hp), hero.prop.GetValueNoCheck(CSPropIDType.Atk)
// , hero.prop.GetValueNoCheck(CSPropIDType.Def), hero.prop.GetValueNoCheck(CSPropIDType.Speed));
//// battlesvr负责生成monster在BattleInfo中的HeroB数据
//battle.battleInfo.HerosB.List.Add(ref heroInfo);
//battle.herosB.Add(hero);
//battle.allCreatures.Add(hero);
return 0;
}
public static int InitMonster(BattleObj battle, int genId = 0)
{
int monsterID = 0;
long unbeatableHp = 0;
var desc = ChapterBattleDescMgr.Instance.GetConfig(battle.MainlandId);
if (desc == null)
{
battle.Error("BattleInitSvc.InitMonster invalid mainlandId {0}", battle.battleInfo.MainlandId);
return -1;
}
// monsterID = desc.monsterID;
int posCount = 1;
HeroInfo petHeroInfo = new HeroInfo();
//TODO 临时测试用:拷贝对方宠物
/*
int posStep = 1;
petHeroInfo.CopyFrom(ref battle.battleInfo.HerosA.List[0]);
InitHeroPet(battle, BattleSide.SideB, ref petHeroInfo, ref posCount, ref posStep);
*/
InitMonsterHero(battle, monsterID, unbeatableHp, posCount, petHeroInfo, genId);
return 0;
}
private static void MakeHeroShowInfo(BattleHero hero, ref HeroInfo heroInfo)
{
//heroInfo.ShowInfo.ObjId = hero.objId;
//heroInfo.ShowInfo.DescId = hero.DescId;
//heroInfo.ShowInfo.MaxHp = hero.prop.GetValueNoCheck(CSPropIDType.Hp);
//heroInfo.ShowInfo.Pos = heroInfo.LineupPos;
//heroInfo.ShowInfo.EquipShowIds.Clear();
//ref var equipList = ref heroInfo.Dbhero.WearEquip;
//for (int i = 0; i < equipList.Count; i++)
//{
// if (HeroPropUtils.IsShowEquip(equipList[i].Pos))
// {
// heroInfo.ShowInfo.EquipShowIds.Add(equipList[i].DescId);
// }
//}
}
//private static void ProcessWeakRobot(ref HeroProp prop, int level)
//{
// int baseRate = 0;
// prop.BeginChange();
// prop.SetValueNoCheck(CSPropIDType.HpMax, prop.GetValueNoCheck(CSPropIDType.HpMax) * baseRate / 10000);
// prop.SetValueNoCheck(CSPropIDType.Hp, prop.GetValueNoCheck(CSPropIDType.Hp) * baseRate / 10000);
// prop.SetValueNoCheck(CSPropIDType.Atk, prop.GetValueNoCheck(CSPropIDType.Atk) * baseRate / 10000);
// prop.SetValueNoCheck(CSPropIDType.Def, prop.GetValueNoCheck(CSPropIDType.Def) * baseRate / 10000);
// prop.SetValueNoCheck(CSPropIDType.Speed, prop.GetValueNoCheck(CSPropIDType.Speed) * baseRate / 10000);
// prop.EndChange();
//}
}
}