private void TickPreloading() { long curTime = TimeUtility.GetLocalMilliseconds(); if (m_LastPreloadingTickTime + c_PreloadingTickInterval < curTime) { m_LastPreloadingTickTime = curTime; bool haveUser = false; bool canStart = true; foreach (User us in m_RoomInfo.RoomUsers) { if (us.IsEntered) { haveUser = true; } } if (!haveUser) { canStart = false; } if (canStart) { LoadObjects(); RoomUserManager roomUserMgr = GetRoomUserManager(); if (null != roomUserMgr) { foreach (User us in m_RoomInfo.RoomUsers) { EnterScene(us); } } //先让各客户端创建自己与场景相关信息 foreach (User us in m_RoomInfo.RoomUsers) { if (us.IsEntered) { //发玩家阵营给玩家 Msg_RC_CampChanged msg = new Msg_RC_CampChanged(); msg.obj_id = 0; msg.camp_id = us.LobbyUserData.Camp; us.SendMessage(RoomMessageDefine.Msg_RC_CampChanged, msg); //将场景里的对象发给玩家 SyncSceneObjectsToUser(us); } } //给观察者发初始玩家与场景对象信息 foreach (Observer observer in m_RoomInfo.RoomObservers) { if (null != observer && !observer.IsIdle && observer.IsEntered) { SyncForNewObserver(observer); } } m_SceneState = SceneState.Running; } } }
public static Msg_RC_CampChanged BuildCampChangedMessage(EntityInfo obj) { Msg_RC_CampChanged msg = new Msg_RC_CampChanged(); msg.obj_id = obj.GetId(); msg.camp_id = obj.GetCampId(); return(msg); }
internal static Msg_RC_CampChanged BuildCampChangedMessage(CharacterInfo obj) { Msg_RC_CampChanged msg = new Msg_RC_CampChanged(); msg.obj_id = obj.GetId(); msg.camp_id = obj.GetCampId(); return(msg); }
internal static void Execute(object msg, NetConnection conn, NetworkSystem networkSystem) { Msg_RC_CampChanged _msg = msg as Msg_RC_CampChanged; if (null == _msg) { return; } }
public void SyncForNewUser(User user) { if (null != user) { EntityInfo userInfo = user.Info; RoomUserManager roomUserMgr = GetRoomUserManager(); if (null != userInfo && null != roomUserMgr && null != roomUserMgr.ActiveScene) { //发阵营给自己 Msg_RC_CampChanged msg = new Msg_RC_CampChanged(); msg.obj_id = 0; msg.camp_id = user.LobbyUserData.Camp; user.SendMessage(RoomMessageDefine.Msg_RC_CampChanged, msg); //同步场景数据给自己 SyncSceneObjectsToUser(user); SyncUserObjectToOtherUsers(user); } } }
internal static void Execute(object msg, NetConnection conn) { Msg_RC_CampChanged _msg = msg as Msg_RC_CampChanged; if (null == _msg) { return; } if (_msg.obj_id <= 0) { PluginFramework.Instance.CampId = _msg.camp_id; } else { EntityInfo obj = PluginFramework.Instance.GetEntityById(_msg.obj_id); if (null != obj) { obj.SetCampId(_msg.camp_id); Utility.EventSystem.Publish("ui_actor_color", "ui", _msg.obj_id, CharacterRelation.RELATION_FRIEND == EntityInfo.GetRelation(PluginFramework.Instance.CampId, _msg.camp_id)); } } }