Beispiel #1
0
        public static RoomManager GetInstance(LRCreateNewRoom roomData)
        {
            RoomManager rm   = new RoomManager();
            var         room = rm.CreateRoom(roomData);

            s_RoomManagers.Add(room.Id, rm);
            return(rm);
        }
Beispiel #2
0
 private Room CreateRoom(LRCreateNewRoom roomData)
 {
     lock (s_CreateRoomLock)
     {
         m_Room    = new Room();
         m_Room.Id = s_CurrentRoomId;
         CacheSet.RoomCache.TryAdd(s_CurrentRoomId.ToString(), m_Room);
         s_CurrentRoomId++;
     }
     InitRoom(roomData);
     m_RoomUpdater = new RoomUpdater(m_Room);
     s_RoomUpdaters.Add(m_Room.Id, m_RoomUpdater);
     m_RoomUpdater.Start();
     return(m_Room);
 }
 protected override bool Check()
 {
     m_RequestPacket = ProtoBufUtils.Deserialize <LRCreateNewRoom>(Convert.FromBase64String(paramGetter.RequestPackage.Params["Data"]));
     return(true);
 }
Beispiel #4
0
        private void InitRoom(LRCreateNewRoom roomData)
        {
            m_Room.State      = RoomState.WaitingConnect;
            m_Room.EndReason  = InstanceSuccessReason.Unknown;
            m_Room.CreateTime = DateTime.UtcNow.Ticks;
            m_Room.Token      = roomData.Token;
            var allInstance = CacheSet.SinglePvpInstanceTable.GetAllData();

            m_Room.InstanceId = new Random().Next(1, allInstance.Count);
            DTSinglePvpInstance instanceData = CacheSet.SinglePvpInstanceTable.GetData(m_Room.InstanceId);

            m_Room.RemainingTime = instanceData.TimerDuration + 5;
            int curEntityId = 1;
            int playerIndex = 0;

            foreach (var playerData in roomData.RoomPlayerInfo)
            {
                RoomPlayer player = new RoomPlayer()
                {
                    PlayerId       = playerData.PlayerInfo.Id,
                    Name           = playerData.PlayerInfo.Name,
                    Level          = playerData.PlayerInfo.Level,
                    VipLevel       = playerData.PlayerInfo.VipLevel,
                    PortraitType   = playerData.PlayerInfo.PortraitType,
                    State          = RoomPlayerState.WaitingConnect,
                    PositionX      = playerIndex < roomData.RoomPlayerInfo.Count / 2 ? instanceData.SpawnPointX : instanceData.SpawnPointX2,
                    PositionY      = playerIndex < roomData.RoomPlayerInfo.Count / 2 ? instanceData.SpawnPointY : instanceData.SpawnPointY2,
                    Rotation       = playerIndex < roomData.RoomPlayerInfo.Count / 2 ? instanceData.SpawnAngle : instanceData.SpawnAngle2,
                    InBattleEntity = curEntityId,
                    Camp           = playerIndex < roomData.RoomPlayerInfo.Count / 2 ? (int)CampType.Player : (int)CampType.Player2,
                    ServerId       = playerData.LobbyServerId,
                };
                foreach (var heroData in playerData.RoomHeroInfo)
                {
                    RoomHero hero = new RoomHero()
                    {
                        EntityId           = curEntityId++,
                        HeroType           = heroData.LobbyHeroInfo.Type,
                        HeroLv             = heroData.LobbyHeroInfo.Level,
                        HeroStarLevel      = heroData.LobbyHeroInfo.StarLevel,
                        ElevationLevel     = heroData.LobbyHeroInfo.ElevationLevel,
                        ConsciousnessLevel = heroData.LobbyHeroInfo.ConsciousnessLevel,
                    };
                    hero.Skills.AddRange(heroData.LobbyHeroInfo.SkillLevels);
                    foreach (var gear in heroData.LobbyHeroInfo.GearInfo)
                    {
                        GearData heroGear = new GearData()
                        {
                            Id              = gear.Id,
                            Type            = gear.Type,
                            Level           = gear.Level,
                            StrengthenLevel = gear.StrengthenLevel
                        };
                        hero.Gears.Add(heroGear);
                    }
                    foreach (var soul in heroData.LobbyHeroInfo.SoulInfo)
                    {
                        hero.Souls.Add(new SoulData()
                        {
                            Id     = soul.Id,
                            TypeId = soul.Type,
                        });
                    }
                    hero.HP                  = hero.MaxHP;
                    hero.SteadyBarValue      = hero.SteadyBarValue;
                    hero.HasSteadyBar        = true;
                    hero.LastBreakSteadyTime = DateTime.UtcNow.Ticks;
                    player.Heros.Add(hero);
                }
                m_Room.Players.Add(player.PlayerId, player);
                playerIndex++;
            }
        }