/// <summary> /// 响应aoi消失的消息 /// </summary> /// <param name="pack"></param> public void HandleUnitDisapper(S2CNwarDisappear pack) { #if TEST_WILD_PROTOCOL if (IsPlayer(pack.uuid)) { GameDebug.Log(">>>MSG_NWAR_DISAPPEAR player id = " + pack.uuid); } else if (IsSummon(pack.uuid)) { GameDebug.Log(">>>MSG_NWAR_DISAPPEAR summon id = " + pack.uuid); } else { GameDebug.Log(">>>MSG_NWAR_DISAPPEAR monster id = " + pack.uuid); } #endif var uuid = pack.uuid; // 不需要处理本地玩家的disappear if (uuid == Game.Instance.LocalPlayerID.obj_idx) { return; } // 如果是玩家或者人形怪 if (ActorHelper.IsPlayer(uuid) || ActorHelper.IsShemale(uuid)) { var player_info = GetWildPlayerInfo(uuid, false); if (player_info != null) { player_info.HandleDisappear(); AddPlayerToDisappear(player_info); } } // 如果是召唤怪 else if (ActorHelper.IsSummon(uuid)) { var monster_info = GetWildMonsterInfo(uuid, false); if (monster_info != null) { monster_info.HandleDisappear(); AddMonsterToDisappear(monster_info); } } // 如果是普通怪物 else { var monster_info = GetWildMonsterInfo(uuid, false); if (monster_info != null) { monster_info.HandleDisappear(); AddMonsterToDisappear(monster_info); } } }
public void UpdateUnitCache(bool doAll, UnitCacheDataFilter filter) { const int MAX_PROCESS_UNIT_PER_FRAME = 3; for (int i = 0; mUnitCacheData.Count != 0; ++i) { if (!doAll) { if (i >= MAX_PROCESS_UNIT_PER_FRAME) { break; } } UnitCacheInfo info = PopUnitCacheData(); if (info == null) { continue; } if (info.UnitType != EUnitType.UNITTYPE_PLAYER && info.UnitType != EUnitType.UNITTYPE_NPC && info.UnitType != EUnitType.UNITTYPE_MONSTER && info.UnitType != EUnitType.UNITTYPE_PET) { continue; } if (filter != null && !filter(info)) { continue; } Actor actor = null; if (info.CacheType == UnitCacheInfo.EType.ET_Create) { float rawY = info.PosBorn.y; info.PosBorn = PhysicsHelp.GetPosition(info.PosBorn.x, info.PosBorn.z); if (info.UnitType == EUnitType.UNITTYPE_PLAYER) { if (info.UnitID.Equals(mGame.LocalPlayerID))// 创建本地玩家 { actor = mGame.GetLocalPlayer(); if (actor == null) { var vocation = (Actor.EVocationType)ActorHelper.TypeIdToRoleId(info.AOIPlayer.type_idx); info.AOIPlayer.model_id_list = ReplaceModelList(info.AOIPlayer.model_id_list, vocation, false); actor = ActorManager.Instance.CreateActor <LocalPlayer>(info, info.Rotation, null); ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_LOCALPLAYER_CREATE, new CEventBaseArgs(actor)); } } else// 创建其他玩家 { if (ActorManager.Instance.ActorSet.ContainsKey(info.UnitID)) { GameDebug.Log(string.Format("Player(ID: {0}) has been created.", info.UnitID.obj_idx)); continue; } actor = ActorManager.Instance.CreateActor <RemotePlayer>(info, info.Rotation, null); // FIXME 创建本地玩家的时候也会发送该消息 ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_REMOTEPLAYER_CREATE, new CEventBaseArgs(actor)); } } else if (info.UnitType == EUnitType.UNITTYPE_NPC) { actor = ActorManager.Instance.CreateActor <NpcPlayer>(info, info.ClientNpc.Rotation, null); } else if (info.UnitType == EUnitType.UNITTYPE_MONSTER) { if (ActorManager.Instance.ActorSet.ContainsKey(info.UnitID)) { GameDebug.LogError(string.Format("Monster(ID: {0}) has been created.", info.UnitID.obj_idx)); continue; } Monster.CreateParam createParam = new Monster.CreateParam(); createParam.is_pet = false; if (ActorHelper.IsSummon(info.UnitID.obj_idx)) { createParam.summon = true; createParam.summonType = Monster.MonsterType.SummonRemoteMonster; if (info.ParentActor != null) { createParam.master = info.ParentActor.UID; // 判断是不是本地召唤怪 if (createParam.master.Equals(Game.Instance.LocalPlayerID) == true) { createParam.summonType = Monster.MonsterType.SummonLocalMonster; } } } var obj = ActorManager.Instance.CreateActor <Monster>(info, info.Rotation, createParam); } else if (info.UnitType == EUnitType.UNITTYPE_PET) { if (ActorManager.Instance.ActorSet.ContainsKey(info.UnitID)) { GameDebug.LogError(string.Format("Pet(ID: {0}) has been created.", info.UnitID.obj_idx)); continue; } Monster.CreateParam createParam = new Monster.CreateParam(); createParam.is_pet = true; createParam.summon = false; if (info.ParentActor != null) { createParam.master = info.ParentActor.UID; } if (info.AOIPet.is_local) { ActorManager.Instance.CreateActor <LocalPet>(info, info.Rotation, createParam); } else { ActorManager.Instance.CreateActor <RemotePet>(info, info.Rotation, createParam); } } } else if (info.CacheType == UnitCacheInfo.EType.ET_Destroy) { ActorManager.Instance.DestroyActor(info.UnitID, 0); } else { GameDebug.LogError("Error Cache data!"); } } }
/// <summary> /// 响应aoi出现的消息 /// </summary> /// <param name="pack"></param> public void HandleUnitAppear(S2CNwarAppear pack) { var uuid = pack.move.id; // 如果是玩家或者人形怪 if (ActorHelper.IsPlayer(uuid) || ActorHelper.IsShemale(uuid)) { #if TEST_WILD_PROTOCOL GameDebug.Log(">>>MSG_NWAR_APPEAR player id = " + pack.moves.id); #endif // 不需要处理本地玩家的appear if (uuid == Game.GetInstance().LocalPlayerID.obj_idx) { return; } // 超出极限了,直接抛弃 if (IsPlayerReachLimit()) { return; } var info = GetWildPlayerInfo(pack.move.id, true); if (info != null) { info.HandleAppear(pack.move, pack.version, pack.buffs, (uint)pack.appear_bit); } } // 如果是召唤怪物 else if (ActorHelper.IsSummon(uuid)) { #if TEST_WILD_PROTOCOL GameDebug.Log(">>>MSG_NWAR_APPEAR summon id = " + pack.moves.id); #endif // 不需要处理本地玩家的召唤怪 if (ActorHelper.IsMySummon(uuid)) { return; } var monster_info = GetWildMonsterInfo(pack.move.id, true); if (monster_info != null) { monster_info.HandleAppear(pack.move, pack.buffs); } } // 如果是普通怪物 else { #if TEST_WILD_PROTOCOL GameDebug.Log(">>>MSG_NWAR_APPEAR monster id = " + pack.moves.id); #endif var monster_info = GetWildMonsterInfo(pack.move.id, true); if (monster_info != null) { monster_info.HandleAppear(pack.move, pack.buffs); } } var monBrief = pack.mon_brief; if (monBrief != null) { GetWildMonsterInfo(monBrief.uuid, true).HandleBriefInfo(monBrief); } }