Пример #1
0
        private static GlobalRegister SetupGameRegister()
        {
            var gamecontext = new GlobalRegister();


            return(gamecontext);
        }
Пример #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHttpClientFactory clientFactory)
        {
            AppInfoHelper.EnvironmentName      = env.EnvironmentName;
            HttpClientHelper.HttpClientFactory = clientFactory;

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles();
            app.UseRouting();

            app.UseOssCore(new CoreContextOption()
            {
                JSRequestHeaderName = "x-core-app"
            });

            if (!env.IsDevelopment())
            {
                app.UseOssCoreException();
            }

            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });

            GlobalRegister.RegisterConfig();
        }
        public CreateGameService(GlobalRegister gamecontext)
        {
            _gr = gamecontext;
            NetworkComms.AppendGlobalIncomingPacketHandler <MapRequests>(RequestNames.GetMapInfos, (header, connection, incomingObject) =>
            {
                ProcessMapRequests(connection, incomingObject);
            });

            NetworkComms.AppendGlobalIncomingPacketHandler <GameSettings>(RequestNames.StartGame, (
                                                                              (header, connection, incomingObject) =>
            {
                var user = _gr.User.GetUserByConnection(connection);
                CreateGameWithSettings(user, incomingObject);
            }));

            NetworkComms.AppendGlobalIncomingPacketHandler <JoinGame>(RequestNames.JoinGame, (header, connection, incomingObject) =>
            {
                var user = _gr.User.GetUserByConnection(connection);
                JoinOpenGame(user, incomingObject);
            });

            NetworkComms.AppendGlobalIncomingPacketHandler <GameNotifications>(RequestNames.GameNotification, (header, connection, incomingObject) =>
            {
                var user = _gr.User.GetUserByConnection(connection);
                ProcessGameNotifications(incomingObject, connection);
            });
            NetworkComms.AppendGlobalIncomingPacketHandler <GameCommands>(RequestNames.GameCommand,
                                                                          (header, connection, incomingObject) =>
            {
                var user                = _gr.User.GetUserByConnection(connection);
                var session             = _gr.GameSessions.GetSessionByUserId(user);
                incomingObject.SenderId = user.Id;
                session.Commands.Push(incomingObject);
            });
        }
Пример #4
0
        static BaseTests()
        {
            SetConfig();

            GlobalRegister.RegisterConfig();

            InitialTestContext();
        }
 protected GameBot(GlobalRegister gr, GameSession session, GameUser botPlayer, int teamId)
 {
     _gr      = gr;
     _session = session;
     _botUser = botPlayer;
     _teamId  = teamId;
     RegisterBot();
 }
Пример #6
0
        public LoginService(GlobalRegister gr)
        {
            _userHandler = gr.User;
            _gr          = gr;

            NetworkComms.AppendGlobalIncomingPacketHandler <Login>("login", (header, connection, incomingObject) =>
            {
                Process(connection, incomingObject);
            });
        }
        public RaceTestBot(GlobalRegister gr, GameSession session, GameUser botPlayer, int teamId, int raceId) : base(gr, session, botPlayer, teamId)
        {
            _maxPerUniqTower = 200;
            _raceId          = raceId;
            foreach (var mapTile in session.MapData.Data.Where(a => a.BuildableByTeamId == _teamId).OrderBy(d => d.X)
                     .ThenByDescending(d => d.Y).ToList())
            {
                _myMap.Push(mapTile);
            }

            _gr.TowerRaces[_raceId].Towers.Split(',').ToList().ForEach(a =>
            {
                _myTower.Add(_gr.Towers.Single(x => x.TowerId == int.Parse(a)));
                _towersBuild.Add(int.Parse(a), 0);
            });
        }
Пример #8
0
        public void Setup()
        {
            TStuffLog.LogActions.Add((message, serializedObject, level, member, filepat, line) =>
            {
                if (TStuffLog.LogLevel > level)
                {
                    return;
                }

                output.WriteLine("[{5},{0}/{1}:{2}, Level:{3}] Message: {4}", filepat.Split('\\').Last(), member, line, level.ToString(), message, DateTime.Now.ToString("T"));
            });

            _context = new GlobalRegister();
            _context.User.AddSystemUser(GConfig.D.MainBotName + " 0", 0);
            _context.User.AddSystemUser(GConfig.D.MainBotName + " 1", 1);
            _context.User.AddSystemUser(GConfig.D.MainBotName + " 2", 2);
            _context.User.AddSystemUser(GConfig.D.MainBotName + " 3", 3);
            _context.User.AddSystemUser(GConfig.D.MainBotName + " 4", 4);
        }
Пример #9
0
        private static void SetupGlobalNetworkHandler(GlobalRegister gamecontext)
        {
            #region Global Handler

            NetworkComms.AppendGlobalConnectionEstablishHandler(connection => { TStuffLog.Debug("Icomming connection"); });
            NetworkComms.AppendGlobalConnectionCloseHandler(connection =>
            {
                gamecontext.GameSessions.LeaveGame(connection);
                gamecontext.User.RemoveUser(connection);
            });

            NetworkComms.AppendGlobalIncomingPacketHandler <EchoObject>("echo", (header, connection, incomingObject) =>
            {
                TStuffLog.Debug("Echo Object");
                TStuffLog.Debug($"Object info {incomingObject.Id} - {incomingObject.Message}");
                connection.SendObject("echo", incomingObject);
            });

            #endregion
        }
Пример #10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            AppInfoHelper.EnvironmentName = env.EnvironmentName;

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles();
            app.UseRouting();

            if (!env.IsDevelopment())
            {
                app.UseExceptionMiddleware();
            }

            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });

            GlobalRegister.RegisterConfig();
        }
Пример #11
0
        static void Main()
        {
            Process instance = RunningInstance();

            if (instance == null)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                frmFlash frm = new frmFlash();
#if SINGLECOMPUTER
#else
                //if (Configer.IsCheckUser)
                //    using (FrmLogin frmLogin = new FrmLogin())
                //    {
                //        if (frmLogin.ShowDialog() == DialogResult.Cancel)
                //            return;
                //    }
#endif
                frm.Show();
                using (CheckEnvironmentIsOK checker = new CheckEnvironmentIsOK(frm as IStartProgress))
                {
                    if (!checker.Check())
                    {
                        frm.Close();
                        return;
                    }
                }
                frm.PrintStartInfo("正在加载模块......");
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                frmMainForm mainFrm = new frmMainForm(frm as IStartProgress);
                GlobalRegister.RegisteAll();
                Application.Run(mainFrm);
            }
            else
            {
                MessageBox.Show(null, "系统已经在运行!", "系统提示");
                HandleRunningInstance(instance);
            }
        }
Пример #12
0
        public GameLoop(GlobalRegister gr, GameSession session)
        {
            TStuffLog.Info("Start Gameloop");
            _gr      = gr;
            _session = session;
            InitializeGameLoopData();



            _startTime = new TimeSpan(DateTime.UtcNow.Ticks).TotalMilliseconds;
            _lastTime  = _startTime;
            _gameTimer = new Timer(state =>
            {
                var delta = new TimeSpan(DateTime.UtcNow.Ticks).TotalMilliseconds - _lastTime;
                var total = new TimeSpan(DateTime.UtcNow.Ticks).TotalMilliseconds - _startTime;
                MaintainGameSession(delta);
                ProcessGame(delta, total);
                _lastTime = new TimeSpan(DateTime.UtcNow.Ticks).TotalMilliseconds;
            }, null, 0, GConfig.D.LogicUpdateEachMillisecond);
            _startSendTime   = new TimeSpan(DateTime.UtcNow.Ticks).TotalMilliseconds;
            _lastSendTime    = _startTime;
            _sendUpdateTimer = new Timer(state =>
            {
                var delta = new TimeSpan(DateTime.UtcNow.Ticks).TotalMilliseconds - _lastSendTime;
                var total = new TimeSpan(DateTime.UtcNow.Ticks).TotalMilliseconds - _startSendTime;
                try
                {
                    SendDataState(delta);
                }
                catch (Exception ex)
                {
                    TStuffLog.Error(ex.ToString());
                }
                _lastSendTime = new TimeSpan(DateTime.UtcNow.Ticks).TotalMilliseconds;
            }, null, 0, GConfig.D.SendLoopMilliseconds);
        }
        public async Task <JsonResult> OnPostSelectCity([FromBody] GlobalRegister Region)
        {
            ListCountry country = await _globalService.ConsultaCitiesTF(new ParamCountry { Id = Int32.Parse(Request.Cookies["Country"]), Region = Region.State });

            return(new JsonResult(country.Regions[0].Cities));
        }
 public GameLogicService(GlobalRegister gamecontext)
 {
     _gr = gamecontext;
 }
Пример #15
0
 public DemoBotImpl(GlobalRegister gr, GameSession session, GameUser user, int teamId) : base(gr, session, user, teamId)
 {
 }
Пример #16
0
 static BaseTests()
 {
     SetConfig();
     GlobalRegister.RegisterConfig();
 }