public Game() { inRun = false; isFixedTimeStep = true; visibleDrawable = new List <IDrawable>(); enabledUpdateable = new List <IUpdateable>(); components = new GameComponentCollection(); components.ComponentAdded += new EventHandler <GameComponentCollectionEventArgs>(GameComponentAdded); components.ComponentRemoved += new EventHandler <GameComponentCollectionEventArgs>(GameComponentRemoved); services = new GameServiceContainer(); content = new ContentManager(services); gameUpdateTime = new GameTime(TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero); inactiveSleepTime = TimeSpan.FromTicks(0); targetElapsedTime = TimeSpan.FromTicks(DefaultTargetElapsedTicks); gameHost = new SdlGameHost(this); gameHost.EnsureHost(); isActive = true; }
public MultiSelectableText(PPDDevice device, IGameHost gameHost, PPDFramework.Resource.ResourceManager resourceManager, string startText, string[] menuTexts, int fontHeight) : base(device) { this.gameHost = gameHost; this.resourceManager = resourceManager; this.fontHeight = fontHeight; this.AddChild(startTextString = new TextureString(device, startText, fontHeight, PPDColors.White)); var menus = new List <TextureString>(); foreach (var menuText in menuTexts) { var obj = new TextureString(device, menuText, fontHeight, PPDColors.White) { Alpha = 0 }; this.AddChild(obj); menus.Add(obj); } menuTextStrings = menus.ToArray(); this.AddChild(rectangle = new RectangleComponent(device, resourceManager, PPDColors.Active) { Position = new Vector2(0, -fontHeight / 2), RectangleHeight = fontHeight + fontHeight, RectangleWidth = 0, Alpha = 0.75f }); GotFocused += MultiSelectableText_GotFocused; LostFocused += MultiSelectableText_LostFocused; Inputed += MultiSelectableText_Inputed; }
public DxTextBox(PPDDevice device, IGameHost host, PPDFramework.Resource.ResourceManager resourceManager) : base(device) { this.host = host; back = new RectangleComponent(device, resourceManager, PPDColors.White); selection = new RectangleComponent(device, resourceManager, PPDColors.Active); border = new LineRectangleComponent(device, resourceManager, PPDColors.Selection); caret = new RectangleComponent(device, resourceManager, PPDColors.Black); caret.CanDraw += (o, c, d, ci) => { return(count >= 30 && Focused); }; stringObj = new TextureString(device, "", 14, PPDColors.Black); TextBoxWidth = 150; MaxTextLength = int.MaxValue; MaxWidth = int.MaxValue; DrawMode = DrawingMode.DrawAll; DrawOnlyFocus = true; GotFocused += DxTextBox_GotFocused; LostFocused += DxTextBox_LostFocused; Inputed += DxTextBox_Inputed; host.IMEStarted += host_IMEStarted; host.TextBoxEnabledChanged += host_TextBoxEnabledChanged; this.AddChild(border); this.AddChild(caret); this.AddChild(stringObj); this.AddChild(selection); this.AddChild(back); }
public void RunGame(IGameHost gameHost) { gameHost.NewGame(); while (gameHost.Winner == 0) { for (int p = 0; p < gameHost.Player.Length; p++) { var baseState = gameHost.TransformStateForPlayer(gameHost.GetCurrentState(), p); // player never gets access to original state var playerBaseState = new byte[baseState.Length]; Array.Copy(baseState, playerBaseState, baseState.Length); var newState = gameHost.Player[p].GetMove(playerBaseState, gameHost.MoveCount); if (!gameHost.ValidatePlayerMove(baseState, newState)) { throw new Exception("Player made illegal move."); } gameHost.SetCurrentState(gameHost.UntransformStateForPlayer(newState, p)); gameHost.PrintState(); Console.ReadKey(); } } }
public DungeonGame(IGameHost gameHost, IConsoleOutputService consoleOut, IUserPromptService userPrompt, ISoundPlayerService soundPlayer) : base(gameHost, consoleOut, userPrompt, soundPlayer) { }
//- Constructors public BackgroundArea(XmlNode areaXml, IGameHost host) : base(areaXml, host) { //XmlNode backgroundXml = null; //foreach (XmlNode node in areaXml.ChildNodes) //{ // if (node.Name == "background") // { // backgroundXml = node; // break; // } //} //if (backgroundXml == null) //{ // throw new ArgumentException("The xml provided for this area dosen't contain a background tag."); //} Background = FormGrid(areaXml.ChildNodes.Item(1), Convert.ToInt32(areaXml.Attributes["width"].Value), Convert.ToInt32(areaXml.Attributes["height"].Value)); DisplayGrid = new string[Convert.ToInt32(areaXml.Attributes["width"].Value), Convert.ToInt32(areaXml.Attributes["height"].Value)]; List <Tuple <int[], int[]> > updates = new List <Tuple <int[], int[]> >(); for (int i = 0; i < Convert.ToInt32(areaXml.Attributes["width"].Value); i++) { for (int j = 0; j < Convert.ToInt32(areaXml.Attributes["height"].Value); j++) { updates.Add(new Tuple <int[], int[]>(new int[] { i, j }, null)); } } UpdateDisplay(updates); }
/// <summary> /// Runs a game application and returns a Task that only completes when the token is triggered or shutdown is triggered. /// </summary> /// <param name="host">The <see cref="IGameHost"/> to run.</param> /// <param name="token">The token to trigger shutdown.</param> public static async Task RunAsync(this IGameHost host, CancellationToken token = default(CancellationToken)) { // Wait for token shutdown if it can be canceled if (token.CanBeCanceled) { await host.RunAsync(token, startupMessage : null); return; } // If token cannot be canceled, attach Ctrl+C and SIGTERM shutdown var done = new ManualResetEventSlim(false); using (var cts = new CancellationTokenSource()) { var shutdownMessage = host.Services.GetRequiredService <GameHostOptions>().SuppressStatusMessages ? string.Empty : "Application is shutting down..."; using (var lifetime = new GameHostLifetime(cts, done, shutdownMessage: shutdownMessage)) try { await host.RunAsync(cts.Token, "Application started. Press Ctrl+C to shut down."); lifetime.SetExitedGracefully(); } finally { done.Set(); } } }
public void AssociateWithHost(IGameHost gameHost) { if(_host != null) throw new InvalidOperationException("Already associated with a host."); _host = gameHost; }
public GameViewModel(Game model, IGameHost host) { this.model = model; this.host = host; Numbers = new ObservableCollection <NumberViewModel>(); foreach (Number number in model.CurrentNumbers) { Numbers.Add(new NumberViewModel(number)); } Operators = new[] { new OperatorViewModel(Operator.Add, Number.Add), new OperatorViewModel(Operator.Subtract, Number.Subtract), new OperatorViewModel(Operator.Multiply, Number.Multiply), new OperatorViewModel(Operator.Divide, Number.Divide), }; CyclicSelectionBehavior numbersSelectionBehavior = new CyclicSelectionBehavior(Numbers, 2); CyclicSelectionBehavior operatorsSelectionBehavior = new CyclicSelectionBehavior(Operators, 1); numbersSelectionBehavior.SelectionChanged += (sender, e) => RaiseSelectionChanged(); operatorsSelectionBehavior.SelectionChanged += (sender, e) => RaiseSelectionChanged(); }
public GameController(ILogger <GameController> logger, IGameBuilder builder, IGameHost gameHost, IGameSimulationService simulator) { _logger = logger; _builder = builder; _gameHost = gameHost; _simulator = simulator; }
public void AssociateWithHost(IGameHost gameHost) { if (_host != null) { throw new InvalidOperationException("Already associated with a host."); } _host = gameHost; }
public static Dictionary <string, StaticData> StaticDataStore;//TODO: add into xml and read in constructors of objects //- Constructors // use host's other events to pause/resume ect... public Engine(XmlDocument gameData, IGameHost host) { Host = host; //- Validate the XML document GameData = gameData; GameData.Schemas.Add(null, "https://raw.githubusercontent.com/QuasarX1/GridGamesEngine/master/GridEngine/GridGamesData.xsd"); //void ValidationEventHandler(object sender, ValidationEventArgs e) //{ // throw new XmlSchemaException("The format of the game data was invalid."); //} GameData.Validate(new ValidationEventHandler((object sender, ValidationEventArgs e) => throw new XmlSchemaException("The format of the game data was invalid. The schema the XML must conform to can be found at \"https://raw.githubusercontent.com/QuasarX1/GridGamesEngine/master/GridEngine/GridGamesData.xsd\""))); Name = GameData.DocumentElement.Attributes["name"].Value; //- Create areas XmlNode gameSubNode = GameData.DocumentElement.FirstChild;// selects the "areas" node Areas = new Dictionary <string, IArea>(); foreach (XmlNode node in gameSubNode) { Areas[node.Attributes["name"].Value] = (IArea)Activator.CreateInstance(Type.GetType(node.Attributes["type"].Value), node, host); } //- Add player and actions Actions = new Dictionary <Keys, Tuple <Responce, string[]> >(); ReservedKeys = new List <Keys> { Keys.Escape }; // TODO: Make pause menu Actions[Keys.Escape] = new Tuple <Responce, string[]>(new Responce((IPlayer player, string[] args) => null), new string[0]); gameSubNode = gameSubNode.NextSibling;; // selects the "player" node foreach (XmlNode playerSubNode in gameSubNode.ChildNodes) { foreach (XmlNode actionNode in playerSubNode.LastChild)// The actions node is the final child of the player { KeyAction((Keys)Enum.Parse(typeof(Keys), actionNode.Attributes["key"].Value), (Responce)Delegate.CreateDelegate(typeof(Responce), typeof(Methods).GetMethod(actionNode.Attributes["method"].Value)), actionNode.ChildNodes); } } AddPlayer(gameSubNode, Type.GetType("GridEngine.Entities." + gameSubNode.Attributes["type"].Value)); //- Add images gameSubNode = gameSubNode.NextSibling;; // selects the "images" node Images = new Dictionary <string, string>(); foreach (XmlNode imageNode in gameSubNode) { Images[imageNode.Attributes["name"].Value] = imageNode.Attributes["filename"].Value; } }
protected override void OnInitialize() { base.OnInitialize(); if (Manager.Items.ContainsKey("GameHost")) { gameHost = Manager.Items["GameHost"] as IGameHost; } }
public ReplayListComponent(PPDDevice device, IGameHost gameHost, PPDFramework.Resource.ResourceManager resourceManager, ISound sound) : base(device) { this.gameHost = gameHost; this.resourceManager = resourceManager; this.sound = sound; PictureObject back; waitSprite = new SpriteObject(device) { Hidden = true }; this.AddChild(waitSprite); waitSprite.AddChild(new TextureString(device, Utility.Language["LoadingReplays"], 20, true, PPDColors.White) { Position = new Vector2(400, 220) }); waitSprite.AddChild(new RectangleComponent(device, resourceManager, PPDColors.Black) { RectangleHeight = 450, RectangleWidth = 800, Alpha = 0.65f }); rectangle = new LineRectangleComponent(device, resourceManager, PPDColors.Selection) { Hidden = true, RectangleWidth = 700, RectangleHeight = ItemHeight }; this.AddChild(rectangle); mainSprite = new SpriteObject(device) { Position = new Vector2(50, SpriteY), Clip = new ClipInfo(gameHost) { PositionX = 40, PositionY = ClipY, Width = 750, Height = ClipHeight } }; this.AddChild(mainSprite); this.AddChild(back = new PictureObject(device, resourceManager, Utility.Path.Combine("dialog_back.png"))); this.AddChild(new RectangleComponent(device, resourceManager, PPDColors.Black) { RectangleHeight = 450, RectangleWidth = 800, Alpha = 0.80f }); back.AddChild(new TextureString(device, Utility.Language["ReplayList"], 30, PPDColors.White) { Position = new Vector2(35, 30) }); Inputed += ReplayListComponent_Inputed; GotFocused += ReplayListComponent_GotFocused; }
/// <summary> /// For use with IGameHostBuilder. /// </summary> /// <param name="builder"></param> /// <param name="featureCollection"></param> public TestServer(IGameHostBuilder builder, IFeatureCollection featureCollection) : this(featureCollection) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } var host = builder.UseServer(this).Build(); host.StartAsync().GetAwaiter().GetResult(); _hostInstance = host; }
public Game(IGameHost gameHost, IConsoleOutputService consoleOut, IUserPromptService userPrompt, ISoundPlayerService soundPlayer) { this.gameHost = gameHost; this.consoleOut = consoleOut; this.userPrompt = userPrompt; this.soundPlayer = soundPlayer; this.mapName = null; this.Reset(); }
//- Constructors public Save(XmlNode saveData, IGameHost host) { Name = saveData.Attributes["name"].Value; ModifiedAreas = new Dictionary <string, IArea>(); foreach (XmlNode area in saveData.ChildNodes[0].ChildNodes) { ModifiedAreas[area.Attributes["name"].Value] = (IArea)Activator.CreateInstance(Type.GetType(area.Attributes["type"].Value), area, host); } ModifiedPlayer = new PlayerEntity(saveData.ChildNodes[1], new Dictionary <Keys, Tuple <Responce, string[]> >()); StartLocation = new Tuple <string, string>(saveData.ChildNodes[2].Attributes["area"].Value, saveData.ChildNodes[2].Attributes["entry_point"].Value); }
public GameSimulationModel Simulate(IGameHost host, Game game) { var report = new GameSimulationModel { Ships = game.PlayerA.Ships.Select(x => new GameSimulationShip() { Length = x.Length, }).ToList(), BoardA = new List <List <GameGridCellModel> >(game.Size), BoardB = new List <List <GameGridCellModel> >(game.Size), }; for (int x = 0; x < game.Size; x++) { report.BoardA.Add(new List <GameGridCellModel>(game.Size)); report.BoardB.Add(new List <GameGridCellModel>(game.Size)); for (int y = 0; y < game.Size; y++) { report.BoardA[x].Add(new() { IsOccupied = game.PlayerA[x, y].IsOccupied, State = game.PlayerA[x, y].State }); report.BoardB[x].Add(new() { IsOccupied = game.PlayerB[x, y].IsOccupied, State = game.PlayerB[x, y].State }); } } host.Host(game); host.Simulate(); report.PlayerMoves = host.PlayerMoves.Select(x => new GameSimulationPlayerMove() { X = x.X, Y = x.Y, Messgae = x.Message, Source = x.Source, }).ToList(); report.GameResult = host.GameResult; return(report); }
/// <summary> /// Returns a Task that completes when shutdown is triggered via the given token, Ctrl+C or SIGTERM. /// </summary> /// <param name="host">The running <see cref="IGameHost"/>.</param> /// <param name="token">The token to trigger shutdown.</param> public static async Task WaitForShutdownAsync(this IGameHost host, CancellationToken token = default(CancellationToken)) { var done = new ManualResetEventSlim(false); using (var cts = CancellationTokenSource.CreateLinkedTokenSource(token)) using (var lifetime = new GameHostLifetime(cts, done, shutdownMessage: string.Empty)) try { await host.WaitForTokenShutdownAsync(cts.Token); lifetime.SetExitedGracefully(); } finally { done.Set(); } }
private static void MonitorStateServer(DataReceivedModel data) { var state = data.ServerStates?.FirstOrDefault(o => o.ParameterName.Equals("ServerOFF")); if (state != null) { //_server.DataReceived -= _server_DataReceived; Console.WriteLine($"Сервер {_connectparam.FamilyGame} остановлен."); _connectparam = null; _server = null; _isWriteCommand = true; WriteCommand(); } state = data.ServerStates?.FirstOrDefault(o => o.ParameterName.Equals("Console")); if (state != null && state.ParameterValue == "Ready") { _isConsoleOpen = true; } state = data.ServerStates?.FirstOrDefault(o => o.ParameterName.Equals("Status")); if (state != null && state.ParameterValue == "Ready") { //CloseConsole(); _isConsoleOpen = false; foreach (var el in data.ServerStates) { Console.WriteLine($"{el.ParameterName} : {el.ParameterValue}"); } Console.Write("|"); foreach (var head in data.TableInfo.Headers) { Console.Write($"{head}\t|"); } Console.Write('\n'); if (data.TableInfo.Values.Any()) { Console.Write("|"); } foreach (var value in data.TableInfo.Values) { Console.Write($"{value}\t|"); } Console.Write('\n'); WriteCommand(); } }
public RoomListComponent(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager, ISound sound, IGameHost gameHost) : base(device) { this.resourceManager = resourceManager; this.sound = sound; this.gameHost = gameHost; this.AddChild(back = new PictureObject(device, resourceManager, Utility.Path.Combine("dialog_back.png"))); back.AddChild(loading = new EffectObject(device, resourceManager, Utility.Path.Combine("loading_icon.etd")) { Position = new Vector2(700, 60) }); back.AddChild(scrollBar = new RectangleComponent(device, resourceManager, PPDColors.White) { Position = new Vector2(756, 80), RectangleHeight = 330, RectangleWidth = 5 }); back.AddChild(selectRectangle = new LineRectangleComponent(device, resourceManager, PPDColors.Selection) { RectangleWidth = 714, RectangleHeight = 28 }); back.AddChild(new TextureString(device, Utility.Language["RoomList"], 30, PPDColors.White) { Position = new Vector2(35, 30) }); back.AddChild(listSprite = new SpriteObject(device) { Position = new SharpDX.Vector2(38, 77) }); loading.PlayType = Effect2D.EffectManager.PlayType.Loop; loading.Play(); loading.Scale = new Vector2(0.125f); loading.Hidden = true; getRoomListExecutor = new GetRoomListExecutor(); getRoomListExecutor.Finished += getRoomListExecutor_Finished; timerID = gameHost.AddTimerCallBack(timerCallBack, 15000, false, true); Inputed += RoomListComponent_Inputed; LostFocused += RoomListComponent_LostFocused; }
static async Task RunAsync(this IGameHost host, CancellationToken token, string startupMessage) { try { await host.StartAsync(token); var hostingEnvironment = host.Services.GetService <IHostEnvironment>(); var options = host.Services.GetRequiredService <GameHostOptions>(); if (!options.SuppressStatusMessages) { Console.WriteLine($"Hosting environment: {hostingEnvironment.EnvironmentName}"); Console.WriteLine($"Content root path: {hostingEnvironment.ContentRootPath}"); var serverAddresses = host.ServerFeatures?.Get <IServerAddressesFeature>()?.Addresses; if (serverAddresses != null) { foreach (var address in serverAddresses) { Console.WriteLine($"Now listening on: {address}"); } } if (!string.IsNullOrEmpty(startupMessage)) { Console.WriteLine(startupMessage); } } await host.WaitForTokenShutdownAsync(token); } finally { #if !NET2 if (host is IAsyncDisposable asyncDisposable) { await asyncDisposable.DisposeAsync().ConfigureAwait(false); } else #endif host.Dispose(); } }
private static void RunServer() { Console.Write(" 1 - Ark \t 2 - Arma3\n 3 - CS\t 4 - CSGO\n 5 - CSS\t 6 - Dod\n 7 - Gmod\t 8 - L4D\n 9 - L4D2\t 10 - Minecraft\n" + " 11 - TF2\t 12 - Bmdm\n 13 - Cscz\t 14 - Cure\n 15 - Insurgency\t 16 - JustCause2\n 17 - Rust\t 18 - Dods\n" + " 19 - Dst\t 20 - DoubleAction\n 21 - FistfulofFrags\t 22 - Hurtworld\n 23 - KillingFloor\t 24 - NS2\n" + " 25 - Nmrih\t 26 - Opfor\n 27 - Pvkii\t 28 - Quake Live\n Выберите игру: "); var key = Console.ReadLine(); _connectparam = GetLinuxConnect(key); if (_connectparam == null) { return; } _server = GameServerFactory.Instance.Get(_connectparam); var res = _server.Connect(); _gameparam = new CreateParam { Slots = 2, GamePort = 27020, GameServerId = _connectparam.GameServerId, GamePassword = "", }; res = _server.Create(_gameparam); if (!res.Succes) { Console.WriteLine($"{res.ErrorMessage}"); } var param = GetChangeStatusParam(); param.TypeStatus = GameHostTypeStatus.Enable; res = _server.ChangeStatus(param); if (!res.Succes) { Console.WriteLine($"{res.ErrorMessage}"); } //_server.DataReceived += _server_DataReceived; //var res = _server.On(_gameparam); //if (res.ServerStates == null) return; //foreach (var param in res.ServerStates) // Console.WriteLine($"{param.ParameterName}: {param.ParameterValue}"); }
/// <summary> /// Prepares the game to be hosted by the given IGameHost. This should not be called manually unless you are /// creating your own IGameHost; it is automatically called when running a game with a ManaWindow. /// </summary> public void OnBeforeRun(IGameHost host) { if (Disposed) { throw new InvalidOperationException("Cannot call OnBeforeRun on a disposed Game."); } if (host == null) { throw new ArgumentNullException(nameof(host)); } RenderContext = host.RenderContext ?? throw new ArgumentException("host's RenderContext may not be null", nameof(host)); AssetManager = new AssetManager(this, RenderContext); Initialize(); RenderContext.ViewportRectangle = new Rectangle(0, 0, host.Width, host.Height); }
public LeftMenu(PPDDevice device, IGameHost gameHost, PPDFramework.Resource.ResourceManager resourceManager, DxTextBox textBox, SelectSongManager ssm, ISound sound) : base(device) { this.gameHost = gameHost; this.resourceManager = resourceManager; this.sound = sound; this.textBox = textBox; this.ssm = ssm; scoreUpdateCountBack = new PictureObject(device, resourceManager, Utility.Path.Combine("update_count_back.png")) { Position = new Vector2(20, 90), Hidden = true, Alpha = 0.75f }; scoreUpdateCountBack.AddChild(scoreUpdateCount = new NumberPictureObject(device, resourceManager, Utility.Path.Combine("result", "scoresmall.png")) { Position = new Vector2(17, 5), Alignment = PPDFramework.Alignment.Center, MaxDigit = -1, Scale = new Vector2(0.75f) }); modUpdateCountBack = new PictureObject(device, resourceManager, Utility.Path.Combine("update_count_back.png")) { Position = new Vector2(20, 330), Hidden = true, Alpha = 0.75f }; modUpdateCountBack.AddChild(modUpdateCount = new NumberPictureObject(device, resourceManager, Utility.Path.Combine("result", "scoresmall.png")) { Position = new Vector2(17, 5), Alignment = PPDFramework.Alignment.Center, MaxDigit = -1, Scale = new Vector2(0.75f) }); WebSongInformationManager.Instance.Updated += Instance_Updated; WebSongInformationManager.Instance.Update(true); this.Inputed += LeftMenu_Inputed; this.GotFocused += LeftMenu_GotFocused; }
internal bool Connect(IGameHost gameHost, out IRemoteGameUI ui) { try { factory = new DuplexChannelFactory <IRemoteGameUI>(new InstanceContext(gameHost), GetBinding(), new EndpointAddress(string.Format("net.tcp://{1}:{0}/simulator", SettingsViewModel.Model.HttpPort, SettingsViewModel.Model.RemotePCName))); factory.Open(); ui = factory.CreateChannel(); ui.UpdateSettings(SettingsViewModel.SIUISettings.Model); // Проверим соединение заодно ((IChannel)ui).Closed += GameEngine_Closed; ((IChannel)ui).Faulted += GameEngine_Closed; return(true); } catch (Exception exc) { ui = null; ShowError(exc.Message); return(false); } }
static async Task WaitForTokenShutdownAsync(this IGameHost host, CancellationToken token) { var applicationLifetime = host.Services.GetService <IHostApplicationLifetime>(); token.Register(state => { ((IHostApplicationLifetime)state).StopApplication(); }, applicationLifetime); var waitForStop = new TaskCompletionSource <object>(TaskCreationOptions.RunContinuationsAsynchronously); applicationLifetime.ApplicationStopping.Register(obj => { var tcs = (TaskCompletionSource <object>)obj; tcs.TrySetResult(null); }, waitForStop); await waitForStop.Task; // GameHost will use its default ShutdownTimeout if none is specified. await host.StopAsync(); }
public ChatComponent(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager, IGameHost gameHost) : base(device) { this.resourceManager = resourceManager; this.gameHost = gameHost; SpriteObject scrollSprite; this.AddChild((messageSprite = new SpriteObject(device) { Clip = new ClipInfo(gameHost) { PositionX = 450, PositionY = 0, Width = 340, Height = 374 } })); this.AddChild(scrollSprite = new SpriteObject(device) { Position = new Vector2(352, 5) }); scrollSprite.AddChild((scrollBar = new PictureObject(device, resourceManager, Utility.Path.Combine("chat_scrollbar.png")))); this.AddChild((back = new PictureObject(device, resourceManager, Utility.Path.Combine("chat_back.png")))); }
/// <summary> /// 对游戏进行初始化 /// </summary> /// <param name="host">游戏宿主</param> /// <param name="initializer">初始化游戏的用户宿主</param> public async Task Initialize(IGameHost host, IPlayerHost initializer) { lock ( SyncRoot ) { if (GameState != GameState.NotInitialized) { return; } GameState = GameState.Initializing; } try { GameHost = host; await InitializeCore(initializer); GameState = GameState.Initialized; } catch { GameState = GameState.End; throw; } }
public ModSettingPanel(PPDDevice device, IGameHost gameHost, PPDFramework.Resource.ResourceManager resourceManager, ISound sound, ModInfo modInfo) : base(device) { this.gameHost = gameHost; this.sound = sound; this.resourceManager = resourceManager; this.modInfo = modInfo; back = new PictureObject(device, resourceManager, Utility.Path.Combine("dialog_back.png")); black = new RectangleComponent(device, resourceManager, PPDColors.Black) { RectangleHeight = 450, RectangleWidth = 800, Alpha = 0.65f }; back.AddChild(new TextureString(device, String.Format("{0}-{1}", Utility.Language["ModSetting"], modInfo.FileName), 30, PPDColors.White) { Position = new Vector2(35, 30) }); StackObject stackObject; back.AddChild(stackObject = new StackObject(device, new StackObject(device, new SpaceObject(device, 0, 2), new PictureObject(device, resourceManager, Utility.Path.Combine("circle.png"))) { IsHorizontal = false }, new TextureString(device, String.Format(":{0}", Utility.Language["ChangeSetting"]), 18, PPDColors.White)) { IsHorizontal = true }); stackObject.Update(); stackObject.Position = new Vector2(760 - stackObject.Width, 50); settingSprite = new SpriteObject(device) { Position = new Vector2(50, SpriteY) }; settingSprite.AddChild(settingListSprite = new SpriteObject(device) { Clip = new ClipInfo(gameHost) { PositionX = 40, PositionY = ClipY, Width = 750, Height = ClipHeight } }); float height = 0; foreach (ModSetting modSetting in modInfo.Settings) { var component = new ModSettingComponent(device, resourceManager, modSetting, modSetting.GetStringValue(modInfo.ModSettingManager[modSetting.Key])) { Position = new Vector2(0, height) }; component.Update(); settingListSprite.AddChild(component); height += component.Height + 10; } CurrentComponent.IsSelected = true; settingSprite.AddChild(rectangle = new LineRectangleComponent(device, resourceManager, PPDColors.Selection) { RectangleWidth = 700, RectangleHeight = 100 }); this.AddChild(settingSprite); this.AddChild(back); this.AddChild(black); UpdateBorderPosition(true); Inputed += ModSettingPanel_Inputed; }
public Game() { inRun = false; isFixedTimeStep = true; visibleDrawable = new List<IDrawable>(); enabledUpdateable = new List<IUpdateable>(); components = new GameComponentCollection(); components.ComponentAdded += new EventHandler<GameComponentCollectionEventArgs>(GameComponentAdded); components.ComponentRemoved += new EventHandler<GameComponentCollectionEventArgs>(GameComponentRemoved); services = new GameServiceContainer(); content = new ContentManager(services); gameUpdateTime = new GameTime(TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero); inactiveSleepTime = TimeSpan.FromTicks(0); targetElapsedTime = TimeSpan.FromTicks(DefaultTargetElapsedTicks); gameHost = new SdlGameHost(this); gameHost.EnsureHost(); isActive = true; }
/// <summary> /// Runs a game application and block the calling thread until host shutdown. /// </summary> /// <param name="host">The <see cref="IGameHost"/> to run.</param> public static void Run(this IGameHost host) => host.RunAsync().GetAwaiter().GetResult();
/// <summary> /// Block the calling thread until shutdown is triggered via Ctrl+C or SIGTERM. /// </summary> /// <param name="host">The running <see cref="IGameHost"/>.</param> public static void WaitForShutdown(this IGameHost host) => host.WaitForShutdownAsync().GetAwaiter().GetResult();