/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (WarGame game = new WarGame()) { game.Run(); } }
/// <summary> /// Constructor of the selection rectangle /// </summary> /// <param name="game">Game in which the selection rectangle is set</param> public SelectionRectangle(WarGame game, MainScene _scene) : base(game) { scene = _scene; Hide(); DrawOrder = (int)WarGame.DrawingOrder.GameObject; }
/// <summary> /// Constructor of base rectangle /// </summary> /// <param name="_owner">Game object which owns the base rectangle</param> /// <param name="_game">Game which the base rectangle is set in</param> public BaseRectangle(GameObject _owner, WarGame _game, MainScene _scene) : base(_game) { owner = _owner; scene = _scene; DrawOrder = (int)WarGame.DrawingOrder.GameObject; Hide(); }
/// <summary> /// Constructor of the bounding box /// </summary> /// <param name="_owner">Game object which owns the bounding box</param> /// <param name="_game">Game which the bounding box i set in</param> public Bbox(GameObject _owner, WarGame _game, MainScene _scene) : base(_game) { scene = _scene; owner = _owner; baseBox = (BoundingBox)_owner.GameObjectModel.Tag; Visible = false; DrawOrder = (int)WarGame.DrawingOrder.GameObject; }
/// <summary> /// Constructor of the Menu item. /// </summary> /// <param name="game">War game in which the item is used</param> /// <param name="_scene">Menu in which the item is used</param> /// <param name="_position">Position of the item</param> /// <param name="_label">Label of the item</param> /// <param name="_action">Action attached to this item</param> public MenuItem(WarGame game, MenuScene _scene, Vector2 _position, string _label, ItemActions _action) : base(game) { scene = _scene; Position = _position; label = _label; action = _action; DrawOrder = (int)WarGame.DrawingOrder.Sprite; }
/// <summary> /// Constructor of the health points bar /// </summary> /// <param name="_owner">Owner of the health points bar</param> /// <param name="_game">Game which the health points bar is set in</param> public HealthPointsBar(GameObject _owner, WarGame _game, MainScene _scene) : base(_game) { owner = _owner; scene = _scene; Hide(); DrawOrder = (int)WarGame.DrawingOrder.Sprite; }
public ResolutionMenu(WarGame game) : base(game) { backgroundImage = game.menuBackgroundTexture; int x_position; string label; int y_position = 0; MenuItem item; MenuItem.ItemActions action; foreach (DisplayMode d in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) availableResoultions.Add(new Vector2(d.Width, d.Height)); List<Vector2> highestResolutions = new List<Vector2>(); do { Vector2 maxValue = new Vector2(float.MinValue, float.MinValue); foreach (Vector2 v in availableResoultions) { if (v.X + v.Y > maxValue.X + maxValue.Y) maxValue = v; } availableResoultions.Remove(maxValue); if (!highestResolutions.Contains(maxValue)) highestResolutions.Add(maxValue); } while (highestResolutions.Count < numberOfResolutions); availableResoultions = highestResolutions; foreach (Vector2 v in availableResoultions) { label = v.X.ToString() + " X " + v.Y.ToString(); x_position = x_position = game.Window.ClientBounds.Width / 2 - (int)game.menuFont.MeasureString(label).X / 2; y_position += 50; action = MenuItem.ItemActions.SetResolution; item = new MenuItem(game, this, new Vector2(x_position, y_position), label, action); SceneComponents.Add(item); } activeItemNumber = 0; (SceneComponents[activeItemNumber] as MenuItem).Activate(); game.Components.Add(this); game.SetResolution((int)availableResoultions[activeItemNumber].X, (int)availableResoultions[activeItemNumber].Y); Hide(); }
/// <summary> /// Constructor of alien craft /// </summary> /// <param name="game">Game in which the alien craft is set</param> public AlienCraft(WarGame game, MainScene _scene, Vector3 _position) : base(game, _scene, _position) { gameObjectModel = game.alienCraftModel; scale = new Vector3(0.5f, 0.5f, 0.5f); maxSpeed = 0.05f; maxForce = 10 * maxSpeed; mass = 20.0f; currentSB = SBNames.WanderReadyToAttack; currentWorld = Matrix.CreateScale(scale) * Matrix.CreateWorld(Position, lastNonZeroVelocity, Vector3.Up); boundingBox = new Bbox(this, game, scene); scene.SceneComponents.Add(boundingBox); boundingBox.RecalculateBoundingBox(); }
/// <summary> /// Constructor of the ground element /// </summary> /// <param name="game">Game in which the ground element is set</param> /// <param name="_position">Position of the ground element</param> public GroundElement(WarGame game, Vector3 _position, MainScene _scene) : base(game, _scene, _position) { gameObjectModel = game.groundElementModel; scale = new Vector3(widthOfGroundElement, 0.1f, heightOfGroundElement); maxSpeed = 0f; maxForce = 10 * maxSpeed; mass = 200.0f; currentSB = SBNames.None; isModelTextured = true; modelTexture = game.moonTexture; scene = _scene; boundingBox = new Bbox(this, game, scene); scene.SceneComponents.Add(boundingBox); }
/// <summary> /// Constructor of the fighter /// </summary> /// <param name="game">Game in which the fighter is set</param> /// <param name="_position">Initial position of the fighter</param> public Fighter(WarGame game, Vector3 _position, MainScene _scene) : base(game, _scene, _position) { gameObjectModel = game.spaceShipModel; scale = new Vector3(0.5f, 0.5f, 0.5f); maxSpeed = 0.5f; maxForce = 10 * maxSpeed; mass = 20.0f; currentSB = SBNames.None; currentWorld = Matrix.CreateScale(scale) * Matrix.CreateWorld(Position, lastNonZeroVelocity, Vector3.Up); boundingBox = new Bbox(this, game, scene); scene.SceneComponents.Add(boundingBox); boundingBox.RecalculateBoundingBox(); // show the bounding box if the game is in debug mode if (scene.IsInDebugMode) DebugModeToggle(); }
/// <summary> /// Constructor of the building /// </summary> /// <param name="game">Game where the building is set</param> /// <param name="_position">Position of the building</param> public Building(WarGame game, Vector3 _position, MainScene _scene) : base(game, _scene, _position) { gameObjectModel = game.castleModel; scale = new Vector3(0.001f, 0.001f, 0.001f); maxSpeed = 0f; maxForce = 0f; mass = 1000f; currentSB = SBNames.None; currentWorld = Matrix.CreateScale(scale) * Matrix.CreateWorld(Position, lastNonZeroVelocity, Vector3.Up); HealthPoints = 0.05f; bar.Show(); boundingBox = new Bbox(this, game, scene); scene.SceneComponents.Add(boundingBox); boundingBox.RecalculateBoundingBox(); // show the bounding box if the game is in debug mode if (scene.IsInDebugMode) DebugModeToggle(); }
/// <summary> /// Constructor of the main Menu. /// </summary> /// <param name="game">Game where the main Menu is used</param> public MainMenu(WarGame game) : base(game) { backgroundImage = game.menuBackgroundTexture; int x_position; string label; int y_position; MenuItem item; MenuItem.ItemActions action; label = "New Game"; x_position = game.Window.ClientBounds.Width / 2 - (int)game.menuFont.MeasureString(label).X / 2; y_position = 50; action = MenuItem.ItemActions.NewGame; item = new MenuItem(game, this, new Vector2(x_position, y_position), label, action); item.Activate(); activeItemNumber = 0; SceneComponents.Add(item); label = "Settings"; x_position = game.Window.ClientBounds.Width / 2 - (int)game.menuFont.MeasureString(label).X / 2; y_position = 100; action = MenuItem.ItemActions.GoToResolutionMenu; item = new MenuItem(game, this, new Vector2(x_position, y_position), label, action); SceneComponents.Add(item); label = "Exit"; x_position = game.Window.ClientBounds.Width / 2 - (int)game.menuFont.MeasureString(label).X / 2; y_position = 150; action = MenuItem.ItemActions.Exit; item = new MenuItem(game, this, new Vector2(x_position, y_position), label, action); SceneComponents.Add(item); game.Components.Add(this); resMenu = new ResolutionMenu(game); resMenu.baseScene = this; }
/// <summary> /// Contructor for the input controller /// </summary> /// <param name="game">Game in which the controller is used</param> public InputController(WarGame game) : base(game) { // TODO: Construct any child components here }
public MainScene(WarGame game) : base(game) { // creating post render target with 24-bit depth PresentationParameters pp = game.Graphics.GraphicsDevice.PresentationParameters; postTarget = new RenderTarget2D(game.Graphics.GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, false, game.Graphics.GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24); // creating objects used by environment shader alienBaseEnvironmentRenTarget = new RenderTargetCube(game.Graphics.GraphicsDevice, 256, false, game.Graphics.GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24); alienBaseEnvironmentTextureCube = new TextureCube(game.Graphics.GraphicsDevice, 256, false, game.Graphics.GraphicsDevice.DisplayMode.Format); // creating selection rectangle and adding it to the Scene SelectionRectangle = new SelectionRectangle(game, this); SceneComponents.Add(SelectionRectangle); // the game is initially not in the debug mode IsInDebugMode = false; // adding ground element to the Scene groundElement = new GroundElement(game, new Vector3(0, groundYAxisPosition, 0), this); SceneComponents.Add(groundElement); sceneObjects.Add(groundElement); // setting the position of the alien base alienBasePosition = new Vector3(170, groundYAxisPosition, 170); //adding alien's base to the Scene AlienBase = new AlienBuilding(game, alienBasePosition, this); SceneComponents.Add(AlienBase); sceneObjects.Add(AlienBase); // adding alien crafts to the Scene for (int i = 0; i < numberOfAliens; i++) { AlienCraft a; // placing new craft in the first random and free place do { Vector3 randomPosition = new Vector3(AlienBase.Position.X + (float)WarGame.RandomGenerator.NextDouble() * 50.0f - 25.0f, GroundYAxisPosition + 1.0f, AlienBase.Position.Z + (float)WarGame.RandomGenerator.NextDouble() * 50.0f - 25.0f); a = new AlienCraft(game, this, randomPosition); } while (a.CheckForCollisions() != null); SceneComponents.Add(a); sceneObjects.Add(a); alienCrafts.Add(a); } // adding skybox to the Scene SceneComponents.Add(new Skybox(game)); }
/// <summary> /// Constructor of the Scene /// </summary> /// <param name="game">Game in which the Scene is used</param> public Scene(WarGame game) : base(game) { SceneComponents = new List<GameComponent>(); Show(); }
/// <summary> /// Constructor of the skybox /// </summary> /// <param name="game"></param> public Skybox(WarGame game) : base(game) { skybox = game.skyboxModel; DrawOrder = (int)WarGame.DrawingOrder.GameObject; }
/// <summary> /// Constructor of the game object /// </summary> /// <param name="game">World in which the game object is set</param> public GameObject(WarGame game, MainScene _scene, Vector3 _position) : base(game) { Position = _position; scene = _scene; HealthPoints = 1.0f; Velocity = Vector3.Zero; Target = Vector3.Zero; lastNonZeroVelocity = Vector3.Right; WanderChange = 0.1f; // creating and activating health points bar bar = new HealthPointsBar(this, game, scene); scene.SceneComponents.Add(bar); // creating and activating base rectangle baseRectangle = new BaseRectangle(this, game, scene); scene.SceneComponents.Add(baseRectangle); DrawOrder = (int)WarGame.DrawingOrder.GameObject; }
public MenuScene(WarGame game) : base(game) { }