Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
 /// <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();
 }
Ejemplo n.º 3
0
 /// <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;
 }
Ejemplo n.º 4
0
        /// <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;
        }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
0
        /// <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();
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructor of the bullet
 /// </summary>
 /// <param name="_owner">Fighter which shoots the bullet</param>
 /// <param name="_game">Game in which the bullet exists</param>
 public Bullet(Fighter _owner, Game _game, MainScene _scene)
     : base(_game)
 {
     scene = _scene;
     owner = _owner;
     position = _owner.Position;
     headVector = Vector3.Normalize(_owner.TargetToAttack.Position - position);
     velocity = headVector * owner.MaxSpeed * 2;
     secondPoint = position + headVector * length;
     color = new Color(new Vector3((float)WarGame.RandomGenerator.NextDouble(),
                                   (float)WarGame.RandomGenerator.NextDouble(),
                                   (float)WarGame.RandomGenerator.NextDouble()));
     DrawOrder = (int)WarGame.DrawingOrder.GameObject;
     scene.SceneComponents.Add(this);
     lifeTime = new TimeSpan();
 }
Ejemplo n.º 8
0
        /// <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();
        }
Ejemplo n.º 9
0
        /// <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();
        }
Ejemplo n.º 10
0
        public void NewGame()
        {
            // if there is an old camera controller than destroy it
            if (Camera != null)
            {
                Components.Remove(Camera);
                Camera.Dispose();
            }

            // creating new camera controller and adding it to the game
            Camera = new CameraController(this);
            Components.Add(Camera);

            // if there is an old main Scene destroy it
            if (Scene != null)
            {
                Components.Remove(Scene);
                Scene.Dispose();
            }

            // creating new main Scene and adding it to the game
            Scene = new MainScene(this);
            Components.Add(Scene);

            // setting the base scenes for the Menu and main Scene
            Menu.baseScene = Scene;
            Scene.baseScene = Menu;

            // displaying the main Scene and hiding the Menu
            Scene.Show();
            CurrentScene = Scene;
            Menu.Hide();

            // playing the main music theme
            if (Sound.ThemeSoundInstance.State == SoundState.Paused)
                Sound.ThemeSoundInstance.Stop();
            Sound.ThemeSoundInstance.Play();

            // setting initial rendering technique
            currentTechnique = 0;
            PostEffect.CurrentTechnique = PostEffect.Techniques[currentTechnique];
        }
Ejemplo n.º 11
0
        /// <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;
        }