Пример #1
0
        public void Awake()
        {
            parent             = GetParent <BenchmarkClientComponent>();
            timerComponent     = Game.Scene.GetComponent <TimerComponent>();
            session            = parent.session;
            benchmarkComponent = Game.Scene.GetComponent <BenchmarkComponent>();
            mapUnitBotModule   = parent.GetComponent <MapUnitBotModule>();

            state = State.CreateOrEnterRoom;

            //_nowSpeed = random.Next(5, 30);
            _nowSpeed = 1;

            //while (!IsDisposed)
            //{
            //    await timerComponent.WaitForSecondAsync(5);
            //    Console.WriteLine($"Name:{parent.userName}, State:{state}");
            //}
        }
Пример #2
0
        public async void Awake()
        {
            parent           = GetParent <BenchmarkClientComponent>();
            timerComponent   = Game.Scene.GetComponent <TimerComponent>();
            session          = parent.session;
            mapUnitBotModule = parent.GetComponent <MapUnitBotModule>();

            L2C_RoamingGetList l2C_RoamingGetList = await RoamingUtility.GetMapList(session);

            if (l2C_RoamingGetList.Error != ErrorCode.ERR_Success)
            {
                Console.WriteLine($"To get roaming road list Failed");
                return;
            }
            var              info             = l2C_RoamingGetList.Infos.FirstOrDefault(e => e.RoadSettingId == parent.roadSettingId);
            long             roomId           = info != null ? info.RoomId : 0L;
            L2C_RoamingEnter l2C_RoamingEnter = await RoamingUtility.EnterRoamingRoom(session, roomId);

            if (l2C_RoamingEnter.Error != ErrorCode.ERR_Success)
            {
                Console.WriteLine($"To enter roaming room[{roomId}] Failed. Error:{l2C_RoamingEnter.Error}");
                return;
            }

            //記錄自身MapUnitId
            mapUnitId = l2C_RoamingEnter.SelfInfo.MapUnitId;

            //記錄自身MapUnitInfo
            mapUnitBotModule.mapUnitInfos.TryAdd(mapUnitId, new MapUnitBotModule.MapUnitData
            {
                mapUnitInfo       = l2C_RoamingEnter.SelfInfo,
                m2C_MapUnitUpdate = null,
            });

            _nowSpeed = random.Next(5, 30);

            mapUnitBotModule.EnableGame(true);
        }