public override void Init() { #region Setup Display #region Canvas playCanvas = new Canvas(); playCanvas.Width = Constants.ScreenWidth; playCanvas.Height = Constants.ScreenHeight; playCanvas.VerticalAlignment = System.Windows.VerticalAlignment.Top; playCanvas.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; playCanvas.MouseLeftButtonDown += MouseDownClick; width = Constants.ScreenWidth - 50; height = Constants.ScreenHeight; #endregion #region Background background = new Background(Constants.GameBackgroundPath); playCanvas.Background = background.GetBrush(); #endregion #region Setup Panel gp = new GamePanel(this.game); gp.HorizontalAlignment = HorizontalAlignment.Right; gp.VerticalAlignment = VerticalAlignment.Center; gp.Margin = new Thickness(Constants.ScreenWidth - 60, 0, 20, 0); gp.shootButton.Click += Shoot; #endregion #endregion #region Setup Assets cross = new PointerCross(); cm = new CollisionManager(width, height); rn = new Randomizer(); #region amount if (Constants.ObjectSize * AmountOfShips <= (Constants.ObjectSize/2 + Constants.ObjectSize * (2 * AmountOfShips))+Constants.ObjectSize/2) { amount = AmountOfShips; } else { amount = 6; } playerAmount = amount; enemyAmount = amount; #endregion #region Setup Coordinates pCoordinates = new int[amount][]; eCoordinates = new int[amount][]; for (int i = 0; i < amount; i++) { pCoordinates[i] = new int[2]; eCoordinates[i] = new int[2]; pCoordinates[i][0] = 100; pCoordinates[i][1] = (Constants.ObjectSize/2 + Constants.ObjectSize * (2 * i)); eCoordinates[i][0] = width - 100; eCoordinates[i][1] = Constants.ObjectSize + Constants.ObjectSize*(2*i); } #endregion gameobjects = new List<GameObject>(); players = new Player[amount]; enemies = new Computer[amount]; #endregion #region Setup Ships SetupShips(); GameObject.SetGameState(this); player = true; computer = false; #endregion #region Setup Controls ai = new AI(this); game.PlayTime.Start(); #endregion }
public MenuState(Game g) :base(g) { Init(); cm = new CollisionManager(Constants.ScreenWidth, Constants.ScreenHeight); }