Пример #1
0
        private static void HandleRunLevelChanged(object sender, RunLevelChangedEventArgs args)
        {
            switch (args.NewLevel)
            {
            case ServerRunLevel.PreGame:
                var timing = IoCManager.Resolve <IGameTiming>();

                IoCManager.Resolve <IPlayerManager>().FallbackSpawnPoint = new LocalCoordinates(0, 0, GridId.DefaultGrid, new MapId(2));

                var mapLoader = IoCManager.Resolve <IMapLoader>();
                var mapMan    = IoCManager.Resolve <IMapManager>();

                var startTime = timing.RealTime;
                {
                    var newMap = mapMan.CreateMap(new MapId(2));

                    mapLoader.LoadBlueprint(newMap, new GridId(4), "Maps/Demo/DemoGrid.yaml");

                    var grid = newMap.GetGrid(new GridId(4));
                    SpawnHelpers.SpawnLightTurret(grid, new Vector2(-15, 15));
                }
                var timeSpan = timing.RealTime - startTime;
                Logger.Info($"Loaded map in {timeSpan.TotalMilliseconds:N2}ms.");

                IoCManager.Resolve <IChatManager>().DispatchMessage(ChatChannel.Server, "Gamemode: Round loaded!");
                break;

            case ServerRunLevel.Game:
                IoCManager.Resolve <IPlayerManager>().SendJoinGameToAll();
                IoCManager.Resolve <IChatManager>().DispatchMessage(ChatChannel.Server, "Gamemode: Round started!");
                break;

            case ServerRunLevel.PostGame:
                IoCManager.Resolve <IChatManager>().DispatchMessage(ChatChannel.Server, "Gamemode: Round over!");
                break;
            }
        }