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.
 
 
 
 
 
 

179 lines
6.2 KiB

using System;
using CoreGame;
using ProtoCSClass;
using Proto;
using Sog;
using ChapterOption = ProtoCSClass.ChapterOption;
namespace CoreGame.Render
{
public static class RPCCaller
{
// 暂停之类的操作
public static void Call_BattleOption(ChapterOption state)
{
if (Contexts.IsValid == false)
return;
var onBattleOptionReq = new OnBattleOptionReq
{
Option = state
};
// NetMsgGateway.Instance.SendMsgReq(msgId, msg);
NetMsgGateway.Instance?.SendMsgReqCoreGame(ClientMsgId.CS_GAMEMSGID_BATTLE_OPTION_REQ, onBattleOptionReq);
}
// 击杀怪物击杀
public static void Call_OnKillEntity(CombatEntity ent)
{
if (Contexts.IsValid == false)
return;
if (ent.hasEquips) // 有装备丢了
{
GunSrv.ClearEquips(ent);
}
if (ent.isHero || ent.hasSummon)
{
ent.isDestroyEnt = true;
return;
}
if (RPCConfig.UseLocalRPC == false)
{
// Boss 连战
var combatPRcRetry = Contexts.Combat.rPCRetry;
var onKilledMonsterReq = new OnKilledMonsterReq
{
MonsterId = ent.blackboard.unitCfgId,
StageId = ent.blackboard.largeWaveID,
Seq = ent.creationIndex,
MsgSeq = combatPRcRetry.seq
};
NetMsgGateway.Instance?.SendMsgReqCoreGame(ClientMsgId.CS_GAMEMSGID_KILLED_MONSTER_REQ, onKilledMonsterReq);
combatPRcRetry.AddCache((int)ClientMsgId.CS_GAMEMSGID_KILLED_MONSTER_REQ, onKilledMonsterReq);
Call_OnBossBattleChangeLayer(ent, false);
}
else
{
var res = new OnKilledMonsterRes
{
Ret = 0,
DropInfo = new MonsterDrop
{
Seq = ent.creationIndex
}
};
CallFromRPC.Call(ent.creationIndex, RpcType.KilledMonster, res);
}
}
private static Fixed64 s_LevelWaveAppendPauseTime =
CommParamDescMgr.Instance.ContBttlDelay.int_val * BattleConst.TenThousandReverse;
public static void Call_OnBossBattleChangeLayer(CombatEntity entity, bool forceLeave)
{
if (BattleModule.Instance.worldType != WorldType.BossContinueBattle)
return;
var levelWaveEnt = Contexts.Combat.LevelWave;
// if (forceLeave && levelWaveEnt.hasLevelWaveAppend && levelWaveEnt.levelWaveAppend.pauseTime > 0)
// {
// BattleLogger.LogInfoByEntity(levelWaveEnt,
// "forceLeave, levelWaveAppend.pauseTime > 0, 不能执行 Call_OnBossBattleChangeLayer");
// return;
// }
var layer = CoreUIBridge.s_BossBattleParams.bossBattleLayer;
var hpRemain = 0;
if (entity == null || entity.hasBorn) // 还未加载出来
{
hpRemain = 100;
}
else if (!entity.isDead)
{
var prop = entity.property;
var curHp = prop.GetProperty_Long(PropertyDef.CurHp);
var maxHp = prop.TotalHp;
hpRemain = (int)Math.Ceiling((double)curHp / maxHp * 100);
}
var combatPRcRetry = Contexts.Combat.rPCRetry;
var data = new CSCBFinishLayerReq
{
HpReamin = hpRemain,
Layer = layer,
ForceLeave = forceLeave ? 1 : 0,
MsgSeq = combatPRcRetry.seq
};
// levelWaveEnt?.ReplaceLevelWaveAppend(s_LevelWaveAppendPauseTime.AsFloat);
NetMsgGateway.Instance?.SendMsgReqCoreGame(ClientMsgId.CS_GAMEMSGID_CB_FINISH_REQ, data);
combatPRcRetry.AddCache((int)ClientMsgId.CS_GAMEMSGID_CB_FINISH_REQ, data);
}
public static void Call_OnBossBattleLeave()
{
var combatPRcRetry = Contexts.Combat.rPCRetry;
var data = new CSCBLeaveReq()
{
Layer = CoreUIBridge.s_BossBattleParams.bossBattleLayer,
MsgSeq = combatPRcRetry.seq
};
NetMsgGateway.Instance?.SendMsgReqCoreGame(ClientMsgId.CS_GAMEMSGID_CB_LEAVE_REQ, data);
combatPRcRetry.AddCache((int)ClientMsgId.CS_GAMEMSGID_CB_LEAVE_REQ, data);
}
// 生成怪物
public static void Call_SpawnEntity(CombatEntity ent)
{
if (Contexts.IsValid == false)
return;
if (RPCConfig.UseLocalRPC)
{
var res = new OnTickBattleEntityRes
{
Ret = 0,
Seq = ent.creationIndex
};
CallFromRPC.Call(ent.creationIndex, RpcType.OnBronEntity, res);
return;
}
var blackboard = ent.blackboard;
if (blackboard.cfgType == CfgType.MonsterCfg)
{
var tbMonster = MonsterPropDescMgr.Instance.GetConfig(blackboard.unitCfgId);
if (tbMonster.type == MonsterType.Intruder)
{
var res = new OnTickBattleEntityRes
{
Ret = 0,
Seq = ent.creationIndex
};
CallFromRPC.Call(ent.creationIndex, RpcType.OnBronEntity, res);
return;
}
}
var combatPRcRetry = Contexts.Combat.rPCRetry;
var onTickBattleEntityReq = new OnTickBattleEntityReq
{
EntityId = ent.blackboard.unitCfgId,
Seq = ent.creationIndex,
Type = 0,
MsgSeq = combatPRcRetry.seq
};
combatPRcRetry.AddCache((int)ClientMsgId.CS_GAMEMSGID_ONTICK_BATTLE_ENTITY_REQ, onTickBattleEntityReq);
NetMsgGateway.Instance?.SendMsgReqCoreGame(ClientMsgId.CS_GAMEMSGID_ONTICK_BATTLE_ENTITY_REQ,
onTickBattleEntityReq);
}
}
}