public bool AddNewUser(User newUser) { foreach (User us in m_RoomUsers) { if (us != null && us.Guid == newUser.Guid) { //当前玩家已在游戏房间内 if (us.GetKey() == newUser.GetKey()) { LogSys.Log(LOG_TYPE.DEBUG, "Add user success: User already in the room! RoomId:{0}, Guid:{1}, OldUser[{2}]({3}) NewUser[{4}]({5}) ", m_RoomId, us.Guid, us.LocalID, us.GetKey(), newUser.LocalID, newUser.GetKey()); LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for new {1} {2}, [Room.AddNewUser]", newUser.LocalID, newUser.Guid, newUser.GetKey()); m_UserPool.FreeUser(newUser.LocalID); return(true); } else if (us.UserControlState != (int)UserControlState.User) { LogSys.Log(LOG_TYPE.DEBUG, "Add user success: User already in the room! RoomId:{0}, Guid:{1}, OldUser[{2}]({3}) NewUser[{4}]({5}) ", m_RoomId, us.Guid, us.LocalID, us.GetKey(), newUser.LocalID, newUser.GetKey()); LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for old {1} {2}, [Room.AddNewUser]", us.LocalID, us.Guid, us.GetKey()); RemoveUser(us); break; } else { LogSys.Log(LOG_TYPE.DEBUG, "Add user false: User already in the room and online! RoomId:{0}, Guid:{1}, OldUser[{2}]({3}) NewUser[{4}]({5}) ", m_RoomId, us.Guid, us.LocalID, us.GetKey(), newUser.LocalID, newUser.GetKey()); LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for new {1} {2}, [Room.AddNewUser]", newUser.LocalID, newUser.Guid, newUser.GetKey()); m_UserPool.FreeUser(newUser.LocalID); return(false); } } } newUser.EnterRoomTime = TimeUtility.GetLocalMilliseconds(); newUser.OwnRoomUserManager = this; newUser.RegisterObservers(m_RoomObservers); newUser.CharacterCreateTime = TimeUtility.GetLocalMilliseconds(); newUser.TimeCounter = 0; if ((int)UserControlState.Ai == newUser.UserControlState) { newUser.IsEntered = true; } if (null != m_ActiveScene && m_ActiveScene.SceneState == SceneState.Running) { Scene scene = m_ActiveScene; scene.EnterScene(newUser); } foreach (User otheruser in m_RoomUsers) { if (otheruser != null) { otheruser.AddSameRoomUser(newUser); newUser.AddSameRoomUser(otheruser); } } m_RoomUsers.Add(newUser); LogSys.Log(LOG_TYPE.DEBUG, "Add user success ! RoomId:{0} , UserGuid:{1}({2})", m_RoomId, newUser.Guid, newUser.GetKey()); return(true); }
//-------------------------------------------------------------------------------- /// <summary>他のシーンへ移行する。あらかじめAddScene()で登録していないと失敗する</summary> //-------------------------------------------------------------------------------- protected void ChangeScene(Scene scene) { if (m_list_Scene.Contains(scene) == false) { DebugLog("無効なシーンへチェンジしようとしました。\n"); return; } // 現在のシーンが null なら ExitScene()は実行しない if (m_scene_current != null) { m_scene_current.ExitScene( ); } // シーン変更 m_scene_current = scene; // シーン開始処理 m_scene_current.EnterScene( ); }