예제 #1
0
        /// <summary>
        /// Create the main menu.
        /// </summary>
        /// <param name="game">The game instance.</param>
        public MainMenu(GammaDraconis game)
            : base(game)
        {
            skybox = new Skybox();
            screenScene.track(skybox, GO_TYPE.SKYBOX);
            Skybox.lights[0] = new Light(new Vector3(-0.05f,  0.1f, -1f), new Vector3(0.9f, 0.7f, 0.7f), new Vector3(1f,1f,1f));
            Skybox.lights[1] = new Light(new Vector3(0.95f, -0.9f, 1f), new Vector3(0.4f, 0.4f, 0.4f), new Vector3(0.5f, 0.5f, 0.5f));

            racer = (((new Random()).Next(1, 3) == 1) ? Proto.getRacer("Thor") : Proto.getRacer("Raptor"));
            racer.position = new Coords(startLocation.X, startLocation.Y, startLocation.Z, 0.2f, 1.5f, 1.0f);
            racer.models[0].scale *= 1;
            racer.size *= 1;
            screenScene.track(racer, GO_TYPE.RACER);

            GameObject planet = new GameObject();
            planet.position = new Coords(500f, -300f, -1250f);
            planet.models.Add(new FBXModel("Resources/Models/Planet", "", 1f));
            screenScene.track(planet, GO_TYPE.SCENERY);

            Sprite NameText = new Sprite(game);
            NameText.textureName = "Resources/Textures/Logo";
            NameText.RelativeRotation = 0.2f;
            NameText.RelativePosition = new Vector2(300.0f, 20.0f);
            screenInterface.AddComponent(NameText);
        }
예제 #2
0
 /// <summary>
 /// Clone a checkpoint object.
 /// </summary>
 /// <param name="gameObject">The object to clone.</param>
 /// <returns>The cloned object.</returns>
 public static Checkpoint cloneObject(GameObject gameObject)
 {
     Checkpoint checkpoint = new Checkpoint();
     checkpoint.position = gameObject.position;
     checkpoint.models = gameObject.models;
     checkpoint.size = gameObject.size;
     return checkpoint;
 }
예제 #3
0
        /// <summary>
        /// Create Racer object from ship definition.
        /// </summary>
        /// <param name="ship">The target ship</param>
        /// <returns>New Racer object</returns>
        public static Racer cloneShip(GameObject ship)
        {
            Racer go = new Racer();

            go.mass = ship.mass;
            go.size = ship.size;

            if (ship.explosion != null)
            {
                go.explosion = ship.explosion.clone();
            }

            go.rateL = ship.rateL;
            go.rateR = ship.rateR;
            go.dragL = ship.dragL;
            go.dragR = ship.dragR;

            foreach (FBXModel model in ship.models)
            {
                go.models.Add(model.clone());
            }

            if (ship.shieldModel != null)
            {
                go.shieldModel = ship.shieldModel.clone();
            }

            foreach(MountPoint mount in ship.mounts)
            {
                go.mounts.Add(mount.clone());
            }

            foreach (Turret turret in ship.turrets)
            {
                go.turrets.Add(turret.clone());
            }

            go.relativeLookAt = new Vector3(ship.relativeLookAt.X, ship.relativeLookAt.Y, ship.relativeLookAt.Z);
            go.relativeLookFrom = new Vector3(ship.relativeLookFrom.X, ship.relativeLookFrom.Y, ship.relativeLookFrom.Z);
            go.relationalScale = ship.relationalScale;

            go.thrusterSFX = ship.thrusterSFX;
            go.engine_startSFX = ship.engine_startSFX;
            go.onDeathSound = ship.onDeathSound;

            return go;
        }
예제 #4
0
        /// <summary>
        /// Construct a player at the specified PlayerIndex.
        /// </summary>
        /// <param name="index">The player's PlayerIndex.</param>
        public Player(PlayerIndex index)
            : base()
        {
            this.index = index;

            input = GammaDraconis.GetInstance().InputManager.GetPlayerInput(index);
            camera = new Coords();
            viewport = (Renderer.Viewports)index;
            Player.players[(int)index] = this;

            arrow = Proto.getThing("CheckpointArrow", new Coords());
            
            playerHUD = (Interface)GammaDraconis.GetInstance().GameLua.DoString("playerHudIndex = " + ((int)index + 1) + "\nreturn dofile( 'Interfaces/PlayerHUD/PlayerHUD.lua' )")[0];

            dust = new List<GameObject>();

            explosion = new Explosion();
            explosion.size = 2f;
            explosion.particles = 50;
        }
예제 #5
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="game">The game instance.</param>
        public ControlsMenu(GammaDraconis game)
            : base(game)
        {
            skybox = new Skybox();
            screenScene.track(skybox, GO_TYPE.SKYBOX);

            xbox360PadFront = new Sprite(game);
            xbox360PadFront.textureName = "Resources/Textures/Xbox 360 Controller Front";
            xbox360PadFront.RelativePosition = new Vector2(112.0f, 100.0f);
            screenInterface.AddComponent(xbox360PadFront);

            xbox360PadTop = new Sprite(game);
            xbox360PadTop.textureName = "Resources/Textures/Xbox 360 Controller Top";
            xbox360PadTop.RelativePosition = new Vector2(112.0f, 480.0f);
            screenInterface.AddComponent(xbox360PadTop);

            keyboardWASD = new Text(game, "W - Accelerate Forward\nS - Accelerate Backward\nA - Roll Left\nD - Roll Right\n" +
                "Arrow Keys - Steer Ship/Navigate Menus\n\nSpace - Fire Beam Weapons\nEnter - Fire Mine Weapons\nQ - Reset Ship\n\n" +
                "P - Pause\nEnter - Start Game\nEsc - Back/Quit Game");
            keyboardWASD.RelativePosition = new Vector2(1024 / 2, 768 / 2);
            keyboardWASD.center = true;
            keyboardWASD.color = Color.White;
            keyboardWASD.SpriteFontName = "Resources/Fonts/Menu";
            screenInterface.AddComponent(keyboardWASD);

            keyboardNumPad = new Text(game, "0 - Accelerate Forward\n5 - Accelerate Backward\n7 - Roll Left\n9 - Roll Right\n" +
                "Arrow Keys - Steer Ship/Navigate Menus\n\n1 - Fire Beam Weapons\n3 - Fire Mine Weapons\n. - Reset Ship\n\n" +
                "P - Pause\nEnter - Start Game\nEsc - Back/Quit Game");
            keyboardNumPad.RelativePosition = new Vector2(1024 / 2, 768 / 2);
            keyboardNumPad.center = true;
            keyboardNumPad.color = Color.White;
            keyboardNumPad.SpriteFontName = "Resources/Fonts/Menu";
            screenInterface.AddComponent(keyboardNumPad);

            pageSelector = new Selector(game, "Xbox 360 Controller", "Keyboard - WASD", "Keyboard - NumPad");
            pageSelector.RelativePosition = new Vector2(1024 / 2, 40.0f);
            pageSelector.center = true;
            pageSelector.color = Color.White;
            pageSelector.SpriteFontName = "Resources/Fonts/Menu";
            screenInterface.AddComponent(pageSelector);
        }
예제 #6
0
        /// <summary>
        /// Constructor for the screen.
        /// </summary>
        /// <param name="game">The instance of the game.</param>
        public LevelOverScreen(GammaDraconis game)
            : base(game, GammaDraconis.GameStates.MainMenu)
        {
            resultText = new Text(gammaDraconis);
            resultText.color = Color.White;
            resultText.text = "";
            resultText.SpriteFontName = "Resources/Fonts/Menu";
            resultText.RelativePosition = new Vector2(1024 / 2, 768 / 2);
            resultText.center = true;
            screenInterface.AddComponent(resultText);

            titleText = new Text(gammaDraconis, "Race Results");
            titleText.color = Color.White;
            titleText.SpriteFontName = "Resources/Fonts/Title";
            titleText.center = true;
            titleText.RelativePosition = new Vector2(1024 / 2, 50);
            titleText.RelativeScale = new Vector2(0.9f, 0.9f);
            screenInterface.AddComponent(titleText);

            skybox = new Skybox();
            screenScene.track(skybox, GO_TYPE.SKYBOX);
        }
예제 #7
0
        /// <summary>
        /// Create this menu.
        /// </summary>
        /// <param name="game">The game instance.</param>
        public VideoSettingsMenu(GammaDraconis game)
            : base(game)
        {
            skybox = new Skybox();
            screenScene.track(skybox, GO_TYPE.SKYBOX);

            racer = Proto.getRacer("Raptor");
            racer.position = new Coords(startLocation.X, startLocation.Y, startLocation.Z, 0.2f, 1.5f, 1.0f);
            racer.models[0].scale *= 1;
            racer.size *= 1;
            screenScene.track(racer, GO_TYPE.RACER);

            GameObject planet = new GameObject();
            planet.position = new Coords(500f, -300f, -1250f);
            planet.models.Add(new FBXModel("Resources/Models/Planet", "", 1f));
            screenScene.track(planet, GO_TYPE.SCENERY);

            Sprite NameText = new Sprite(game);
            NameText.textureName = "Resources/Textures/Logo";
            NameText.RelativeRotation = 0.2f;
            NameText.RelativePosition = new Vector2(300.0f, 20.0f);
            screenInterface.AddComponent(NameText);
        }
예제 #8
0
        /// <summary>
        /// Render an object based on an FBX file within a given camera matrix.
        /// </summary>
        /// <param name="gameObject">The GameObject the model belongs to.</param>
        /// <param name="fbxmodel">The FBX model to draw.</param>
        /// <param name="cameraMatrix">The camera matrix.</param>
        /// <param name="objectMatrix">The object matrix.</param>
        /// <param name="player">What player's view is being rendered.</param>
        private void renderFBXModel(GameObject gameObject, FBXModel fbxmodel, Matrix cameraMatrix, Matrix objectMatrix, Player player)
        {
            Matrix modelMatrix;
            if (fbxmodel == null || !fbxmodel.visible)
            {
                return;
            }
            // TODO: We need to get an appropriate colored fog if we really want to not fog the skybox
            bool enableFog = false; // || !(gameObject is Skybox);
            if (gameObject is Checkpoint)
            {
                int currentLocation = Engine.GetInstance().race.status(player, true).checkpoint;
                int checkpointPosition = ((Checkpoint)gameObject).racePosition;
                if (checkpointPosition > currentLocation)
                {
                    // TODO: change differentiation from visible/invisible to differences in how the checkpoints are rendered (color? brightness?)
                    fbxmodel.visible = true;
                }
                else
                {
                    fbxmodel.visible = false;
                }
            }
            modelMatrix = Matrix.CreateScale(fbxmodel.scale) * objectMatrix * fbxmodel.offset.matrix();
            Model model = fbxmodel.model;

            // Copy any parent transforms.
            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            // Draw the model. A model can have multiple meshes, so loop.
            foreach (ModelMesh mesh in model.Meshes)
            {
                bool meshbloom = false;
                foreach (BasicEffect mesheffect in mesh.Effects)
                {
                    if (mesheffect.EmissiveColor != Vector3.Zero)
                    {
                        meshbloom = true;
                    }
                }

                // This is where the mesh orientation is set, as well as our camera and projection.
                foreach (BasicEffect mesheffect in mesh.Effects)
                {
                    mesheffect.PreferPerPixelLighting = Properties.Settings.Default.PerPixelLighting;
                    mesheffect.FogEnabled = enableFog;
                    mesheffect.FogStart = viewingDistance / 2;
                    mesheffect.FogEnd = viewingDistance * 1.25f;
                    mesheffect.FogColor = new Vector3(0, 0, 0);

                    mesheffect.World = transforms[mesh.ParentBone.Index] * modelMatrix;
                    //effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
                    mesheffect.View = cameraMatrix;
                    mesheffect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(viewingAngle),
                        GammaDraconis.GetInstance().GraphicsDevice.Viewport.AspectRatio, 10f, viewingDistance);

                    if (renderBloom)
                    {
                        if (meshbloom)
                        {
                            applyLights(mesheffect, fbxmodel.lighted);
                        }
                        else
                        {
                            mesheffect.LightingEnabled = true;
                            mesheffect.DirectionalLight0.Enabled = false;
                            mesheffect.DirectionalLight1.Enabled = false;
                            mesheffect.DirectionalLight2.Enabled = false;
                            mesheffect.AmbientLightColor = Vector3.Zero;
                        }
                    }
                    else
                    {
                        applyLights(mesheffect, fbxmodel.lighted);
                    }
                }

                mesh.Draw();

            }
        }
예제 #9
0
 /// <summary>
 /// Add an existing item to the scene manager with a given set of options.
 /// </summary>
 /// <param name="gameObject">Item to be tracked</param>
 /// <param name="type">Item properties</param>
 public void track(GameObject gameObject, int type)
 {
     if (objects.ContainsKey(type))
     {
         if (!objects[type].Contains(gameObject))
         {
             objects[type].Add(gameObject);
         }
     }
     else
     {
         List<GameObject> temp = new List<GameObject>();
         temp.Add(gameObject);
         objects.Add(type, temp);
     }
 }
예제 #10
0
 /// <summary>
 /// Remove an existing item from the scene manager - use ignore (gameObject, type) if type is known
 /// </summary>
 /// <param name="gameObject">Item to be removed</param>
 public void ignore(GameObject gameObject)
 {
     foreach (List<GameObject> objs in objects.Values)
     {
         objs.Remove(gameObject);
     }
 }
예제 #11
0
 /// <summary>
 /// Remove an existing item from the scene manager.
 /// </summary>
 /// <param name="gameObject">Item to be removed</param>
 public void ignore(GameObject gameObject, int type)
 {
     if (objects.ContainsKey(type))
     {
         objects[type].Remove(gameObject);
     }
 }
예제 #12
0
        private void collideBullet(Bullet bullet, GameObject o2)
        {
            Vector3 originalPosition = bullet.lastPosition.pos();
            Vector3 newPosition = bullet.position.pos();
            Vector3 forwardVector = bullet.position.pos() - bullet.lastPosition.pos();
            forwardVector.Normalize();
            Ray forwardRay = new Ray(bullet.lastPosition.pos(), forwardVector);
            BoundingSphere sphere = new BoundingSphere(o2.position.pos(), o2.size);
            float? intersectDistance = sphere.Intersects(forwardRay);

            if (intersectDistance != null)
            {
                if ((float)intersectDistance < forwardVector.Length())
                {
                    gameScene.ignore(bullet, GO_TYPE.BULLET);
                    o2.takeDamage(bullet.damage);
                    bullet.OnDeath();
                }
            }
        }
예제 #13
0
        /// <summary>
        /// Clone a game object
        /// </summary>
        /// <returns>The cloned object</returns>
        public virtual GameObject clone()
        {
            GameObject go = new GameObject();

            go.mass = mass;
            go.size = size;

            if (explosion != null)
            {
                go.explosion = explosion.clone();
            }

            go.rateL = rateL;
            go.rateR = rateR;
            go.dragL = dragL;
            go.dragR = dragR;

            foreach (FBXModel model in models)
            {
                go.models.Add(model.clone());
            }

            if (shieldModel != null)
            {
                go.shieldModel = shieldModel.clone();
            }

            foreach(MountPoint mount in mounts)
            {
                go.mounts.Add(mount.clone());
            }

            foreach (Turret turret in turrets)
            {
                go.turrets.Add(turret.clone());
            }

            go.maxHealth = maxHealth;
            go.invincible = invincible;
            go.immobile = immobile;
            go.health = maxHealth;
            go.maxShield = maxShield;
            go.shield = maxShield;
            go.shieldIncreaseRate = shieldIncreaseRate;
            go.OnDeathFunction = OnDeathFunction;

            go.relativeLookAt = new Vector3(relativeLookAt.X, relativeLookAt.Y, relativeLookAt.Z);
            go.relativeLookFrom = new Vector3(relativeLookFrom.X, relativeLookFrom.Y, relativeLookFrom.Z);
            go.relationalScale = relationalScale;

            go.engine_startSFX = engine_startSFX;
            go.thrusterSFX = thrusterSFX;
            go.onDeathSound = onDeathSound;

            return go;
        }