protected override void OnDetach() { EngineApp.Instance.MouseRelativeMode = false; instance = null; base.OnDetach(); }
protected override void OnAttach() { base.OnAttach(); instance = this; freeCameraPosition = Map.Instance.EditorCameraPosition; freeCameraDirection = Map.Instance.EditorCameraDirection; EngineApp.Instance.Config.RegisterClassParameters( GetType() ); if( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() ) EntitySystemWorld.Instance.Simulation = true; }
/// <summary> /// Initialization of the static class /// </summary> /// <param name="form_insert"></param> /// <param name="Brick_Width"></param> /// <param name="Brick_Height"></param> /// <param name="seed"></param> public static void Init(GameWindow form_insert, int Brick_Width, int Brick_Height, Menu m, int seed = -1) { StateSaver.Reset(); StateSaver.SetGameState(StateSaver.GameStates.BricksAlive); form = form_insert; menu = m; if (ReplaySaver.IsReplay) { seed = ReplaySaver.seed; } //If there is a given seed, use that one (debug reasons) if (seed == -1) random = new Random(); else random = new Random(seed); Console.WriteLine("Seed " + seed); ReplaySaver.seed = seed; //boundingbox gameField = new RectangleF( GameSettings.GamefieldOffsetWidth, GameSettings.GamefieldOffsetHeight, GameSettings.BrickOffsetWidth * 2 + Brick_Width * (GameSettings.BrickSpacingWidth + GameSettings.BrickSizeWidth), GameSettings.BrickOffsetHeight + 100 + Brick_Height * (GameSettings.BrickSpacingHeight + GameSettings.BrickSizeHeight)); //Fill bricks Debug.Print("" + seed); bricks = new Brick[Brick_Width, Brick_Height]; FillBricks(); numberOfBricks = Brick_Width * Brick_Height; //reset score etc. score = 0; numberOfLives = maxNumberOfLives; player = new Player(new Point((int)gameField.Left, (int)gameField.Bottom - 40)); }
public CustomDrawableLabel(GameWindow window) : base(window) { TextColor = Color.Black; }
public ProgressBar(GameWindow window, int minValue, int maxValue, Func <int> currentValueGetter) : base(window) { MinimalValue = minValue; MaximumValue = maxValue; ValueGetter = currentValueGetter; }
/// <summary> /// Create a new game form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Play_button_Click(object sender, EventArgs e) { int width = 0, height = 0, seed = 0; bool fault = false; //Parse width try { width_label.ForeColor = Color.Black; width = int.Parse(width_box.Text); } catch { width_label.ForeColor = Color.Red; fault = true; } //Parse height try { height_label.ForeColor = Color.Black; height = int.Parse(height_box.Text); } catch { height_label.ForeColor = Color.Red; fault = true; } //Parse seed try { seed_label.ForeColor = Color.Black; if (String.IsNullOrEmpty(seed_box.Text)) seed = (new Random()).Next(); else seed = int.Parse(seed_box.Text); } catch { seed_label.ForeColor = Color.Red; fault = true; } //If nothing went wrong, start the game if (!fault) { this.SendToBack(); if (!this.replayloaded) { ReplaySaver.Reset(); } else this.replayloaded = false; (gamewindow = new GameWindow(width,height,seed,this)).ShowDialog(); } }