/// <summary> /// 响应角色死亡的消息 /// </summary> /// <param name="pack"></param> public void HandleUnitDead(S2CNwarUnitDead pack) { var uuid = pack.id; if (ActorHelper.IsPlayer(uuid)) { // 玩家死亡暂时不用做任何处理 } else { var monster = GetWildMonsterInfo(uuid, false); if (monster != null) { if (pack.killer_id == xc.Game.Instance.LocalPlayerID.obj_idx) { ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_MONSTER_DEAD, new CEventBaseArgs(uuid)); } monster.HandleDead(); mAppearWildMonstersInfo.Remove(uuid); mDisappearWildMonstersInfo.Remove(uuid); } } }
void HandleKillActor(S2CNwarUnitDead kDeathMsg) { if (!mIsRecvMsg) { return; } bool has_trigger = false; SkillAttackInstance inst = EffectManager.GetInstance().GetAttackInstance(kDeathMsg.em_id); if (inst != null) { // 需要从伤害信息中获取攻击者(此处要求服务端的伤害消息一定在死亡消息之前发送) Actor src = ActorManager.Instance.GetActor(inst.SrcActorID); if (src != null && src.Trans != null && mOwner.Trans != null) { has_trigger = true; Vector3 vec = mOwner.Trans.position - src.Trans.position; vec.y = 0; vec.Normalize(); // 设置击飞方向信息 SkillAttackInstance.DeathAppendInfo info = new SkillAttackInstance.DeathAppendInfo(); info.Id = kDeathMsg.id; info.FlyDir = vec; inst.AddDeathInfo(info); } } if (has_trigger == false) { mOwner.ActorMachine.DeathFlyInfo = new ActorMachine.DeathInfo(); mOwner.Kill(); } }