Beispiel #1
0
        public IRoom GetRoomByRoomId(IRoomId roomId)
        {
            IRoom room;

            _roomId2Room.TryGetValue(roomId, out room);
            return(room);
        }
        public IPlayerInfo GetUserInfoFromToken(IRoomId roomId, string token, bool isCheck)
        {
            IPlayerInfo rc;

            if (_token2UserInfo.TryGetValue(token, out rc) && _tokenOnce && !isCheck)
            {
                _token2UserInfo.Remove(token);
            }


            return(rc);
        }
Beispiel #3
0
        public PlayerInfo(string token, IRoomId roomId, long playerId, string playerName, int roleModelId, long teamId,
                          int num, int level, int backId, int titleId, int badgeId, int[] avatarIds, int[] weaponAvatarIds,
                          int[] sprayLacquers, bool hasTestWeapon, int jobAttrbute, CampInfo campInfo) : this()
        {
            Token       = token;
            RoomId      = roomId;
            PlayerId    = playerId;
            PlayerName  = playerName;
            RoleModelId = roleModelId;
            TeamId      = teamId;
            Num         = num;
            Level       = level;
            BackId      = backId;
            TitleId     = titleId;
            BadgeId     = badgeId;

            if (avatarIds != null)
            {
                AvatarIds.AddRange(avatarIds);
            }


            if (weaponAvatarIds != null)
            {
                WeaponAvatarIds.AddRange(weaponAvatarIds);
            }

            if (sprayLacquers != null)
            {
                SprayLacquers.AddRange(sprayLacquers);
            }

            if (hasTestWeapon)
            {
                WeaponBags[1] = new PlayerWeaponBagData
                {
                    BagIndex   = 1,
                    weaponList = new List <PlayerWeaponData>
                    {
                        new PlayerWeaponData
                        {
                            Index             = 1,
                            WeaponTplId       = 1,
                            WeaponAvatarTplId = 1,
                        }
                    }
                };
            }

            JobAttribute = jobAttrbute;
            CampInfo     = campInfo;
        }
Beispiel #4
0
        public IPlayerInfo GetUserInfoFromToken(IRoomId roomId, string token, bool isCheck)
        {
            if (RandomToken.Equals(token))
            {
                System.Random rand = new System.Random();
                return(new PlayerInfo(token, roomId, rand.Next(0, 1000), "", 2, rand.Next(0, 1000), 0, 0, 0, 0, 0, null, null, false));
            }
            IPlayerInfo rc;

            if (_token2UserInfo.TryGetValue(token, out rc) && _tokenOnce && !isCheck)
            {
                _token2UserInfo.Remove(token);
            }

            return(rc);
        }
Beispiel #5
0
        public IPlayerInfo GetPlayerInfo(IRoomId roomId, string messageToken, bool isCheck)
        {
            var playerInfo = GetUserInfoFromToken(roomId, messageToken, isCheck);

            if (playerInfo == null)
            {
                _logger.InfoFormat("login failed, token invalid {0}", messageToken);
                return(null);
            }

            if (roomId != playerInfo.RoomId)
            {
                _logger.InfoFormat("login failed, roomId {0} invalid", playerInfo.RoomId);
                return(null);
            }
            return(playerInfo);
        }
Beispiel #6
0
        public ServerRoom(IRoomId roomId, Contexts contexts, IRoomEventDispatchter eventDispatcher,
                          ICoRoutineManager coRoutineManager, IUnityAssetManager assetManager, IPlayerTokenGenerator tokenGenerator)
        {
            //SingletonManager.Get<ServerFileSystemConfigManager>().Reload();
            _state = RoomState.Initialized;

            _tokenGenerator   = tokenGenerator;
            _coRoutineManager = coRoutineManager;

            var entityIdGenerator          = new EntityIdGenerator(EntityIdGenerator.GlobalBaseId);
            var equipmentEntityIdGenerator = new EntityIdGenerator(EntityIdGenerator.EquipmentBaseId);
            var ruleId = RuleMap.GetRuleId(SingletonManager.Get <ServerFileSystemConfigManager>().BootConfig.Rule);

            RoomId    = roomId;
            _contexts = contexts;
#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)
            _contexts.InitializeContexObservers();
#endif
            SingletonManager.Get <MyProfilerManager>().Contexts = _contexts;
            _eventDispatcher = eventDispatcher;
            _bin2DManager    = CreateBin2DManager();
            IniCurrentTimeSession();


            InitEntityFactorySession(entityIdGenerator, equipmentEntityIdGenerator);
            _assetManager = assetManager;


            InitCommonSession(entityIdGenerator,
                              equipmentEntityIdGenerator, ruleId);

            InitServerSession(_bin2DManager, ruleId);


            _contexts.vehicle.SetSimulationTime(0);
            MessageDispatcher    = CreateNetworMessageHandlers();
            _snapshotFactory     = new SnapshotFactory(_contexts.session.commonSession.GameContexts);
            _sessionStateMachine = new ServerSessionStateMachine(_contexts, this);

            _damager = new SimplePlayerDamager(this);
            VehicleDamageUtility._damager = _damager;
            _sendSnapshotManager          = new SendSnapshotManager(_contexts);

            InitialWeaponSkill();
        }
Beispiel #7
0
        public ServerRoom(RoomId id, ContextsServerWrapper contextsServerWrapper, RoomEventDispatcher dispatcher,
                          IPlayerTokenGenerator playerTokenGenerator)
        {
            state               = RoomState.Initialized;
            isDisposed          = false;
            RoomId              = id;
            ContextsWrapper     = contextsServerWrapper;
            MessageDispatcher   = CreateNetworMessageHandlers();
            tokenGenerator      = playerTokenGenerator;
            eventDispatcher     = dispatcher;
            snapshotFactory     = new SnapshotFactory(ContextsWrapper.GameContexts);
            sessionStateMachine = new ServerSessionStateMachine(ContextsWrapper.contexts, this);
            damager             = new SimplePlayerDamager(this);
            compensationManager = new CompensationManager();

            VehicleDamageUtility._damager = damager;
            sendSnapshotManager           = new SendSnapshotManager(ContextsWrapper.contexts);
        }
Beispiel #8
0
 public static IPlayerInfo CreateTestPlayer(IRoomId roomId)
 {
     return(new PlayerInfo(TestToken, roomId, PlayerId, PlayerName, RoleModelId, TeamId, 0, 0, 0, 0, 0, null, null, false));
 }