예제 #1
0
        public void RegisterActors()
        {
            #region 3D Stuff

            Camera camera = new Camera("mainMenuCamera", new Vector3(0, 50, 600), Vector3.Zero);
            camera.LoadContent();
            CameraManager.Instance.CurrentCamera = "mainMenuCamera";

            SkySphere sky = new SkySphere("SkySphereMainMenuView", "space", 10000f);
            sky.Position = Vector3.Zero;
            sky.LoadContent();
            SceneGraphManager.RootNode.Children.Add(sky);

            Planet planet = new Planet("GamePlanetEarth",700f);
            planet.Position = new Vector3(-1200, 0, -600);
            planet.LoadContent();
            SceneGraphManager.RootNode.Children.Add(planet);

               /* Box box = new Box("box", 1f);
            box.Position = new Vector3(0, 0, 0);
            //box.Offset = new Vector3(0, 0, 0);
            box.LoadContent();

            Sphere sphere = new Sphere("sphereBox", 2f);
            sphere.Offset = new Vector3(0, 0, 0);
            sphere.LoadContent();
            box.Children.Add(sphere);*/

            //SceneGraphManager.RootNode.Children.Add(box);

            #endregion

            #region UI Stuff
            TextElement headline = new TextElement("TextElementHeadline", new Vector2(400, 100), Color.Yellow, "Space Commander", ResourceManager.Instance.GetResource<SpriteFont>("Arial"));
            headline.Scale = 1f;
            UIManager.Instance.AddActor(headline);

            Button startNewGameButton = new Button("ButtonStartNewGame", new Vector2(400, 150), ResourceManager.Instance.GetResource<Texture2D>("startnewgame_button"), 312, 83);
            startNewGameButton.LoadContent();
            UIManager.Instance.AddActor(startNewGameButton);
            #endregion
        }
예제 #2
0
        private void CreateSkySphereMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (Level != null)
            {
                CreateSkySphereWindow createSkySphereWindow = new CreateSkySphereWindow();
                createSkySphereWindow.Owner = this;

                if (createSkySphereWindow.ShowDialog().Value)
                {
                    SkySphere sphere = new SkySphere(createSkySphereWindow.ID, createSkySphereWindow.Texture, 1f);
                    sphere.Position = createSkySphereWindow.Position;
                    sphere.Scale = createSkySphereWindow.Scale;
                    sphere.LoadContent();
                    sceneGraph.RootNode.Children.Add(sphere);
                    LoadWorldView();
                }
            }
            else
            {
                MessageBox.Show("Please create or load a level first before you add any actor");
            }
        }
예제 #3
0
        public void RegisterActors()
        {
            #region 3D Stuff

            SceneGraphManager.CullingActive = false;

            float testTimeOffset = 6000;

            //ship-position path
            Path path = new Path("targetPath",ID);
            path.LoadContent();
            path.AddPoint(new Vector3(0, -100, 0), 0);
            path.AddPoint(new Vector3(0, -300, -8000), testTimeOffset+2000);
            path.AddPoint(new Vector3(500, -100, -16000), 2*testTimeOffset+4000);
            path.AddPoint(new Vector3(000, 500, -24000), 3*testTimeOffset+6000);
            path.AddPoint(new Vector3(0, 0, -30000), 4*testTimeOffset+8000);

            //camera-position path
            Path path2 = new Path("positionPath", ID,Color.Green);
            path2.LoadContent();
            path2.AddPoint(new Vector3(0, 200, 500), 0);
            path2.AddPoint(new Vector3(0, 300, -8000), testTimeOffset+2400);
            path2.AddPoint(new Vector3(500, 100, -16000), 2*testTimeOffset+4400);
            path2.AddPoint(new Vector3(000, 500, -24000), 3*testTimeOffset+6400);
            path2.AddPoint(new Vector3(0, 0, -29000), 4*testTimeOffset+8000);

            path.SetTangents();
            path2.SetTangents();

            SceneGraphManager.RootNode.Children.Add(path);
            SceneGraphManager.RootNode.Children.Add(path2);

            //create a ship
            Ship ship = new Ship("SpaceShip", ID,path);
            ship.LoadContent();
            ship.Updateable = true;

            Planet p = new Planet("testplanet", 1000);
            p.Position = new Vector3(-1000,-1000,-10000);
            p.Visible = true;
            p.LoadContent();

            SceneGraphManager.RootNode.Children.Add(p);

            Laser laser = new Laser("testlaser","laser", 5);
            laser.Visible = false;
            laser.LoadContent();
            SceneGraphManager.RootNode.Children.Add(laser);

            SceneGraphManager.RootNode.Children.Add(ship);

            //cameras
            ChaseCamera chaseCamera = new ChaseCamera("chaseCamera", new Vector3(0, 50, 700), ship);
            chaseCamera.LoadContent();

            FPSCamera fpsCamera = new FPSCamera("fpsCamera", Vector3.Zero, Vector3.UnitZ,500);
            fpsCamera.LoadContent();

            PathCamera pathCamera = new PathCamera("pathCamera",path,path2);
            pathCamera.LoadContent();

            CameraManager.Instance.CurrentCamera = "pathCamera";

            //create a skySphere
            SkySphere skySphere = new SkySphere("skySphere", "level1_skymap", 30000f);
            skySphere.Position = Vector3.Zero;
            skySphere.Visible = true;
            skySphere.LoadContent();

            SceneGraphManager.RootNode.Children.Add(skySphere);

            //100 asteroids with random position, scale and rotation
            Random random = new Random();

            /*
            for (int i = 0; i < 100; i++)
            {
                EffectProperty effectProp = new EffectProperty("TextureMappingEffect");
                effectProp.Effect = ResourceManager.Instance.GetResource<Effect>("TextureMappingEffect");

                MeshObject asteroid01 = new MeshObject("asteroid" + i, "asteroid", 1f);
                //asteroid01.Properties.Add(ActorPropertyType.EFFECT, effectProp);

                CollideableProperty collidable = new CollideableProperty();
                asteroid01.Properties.Add(ActorPropertyType.COLLIDEABLE, collidable);

                asteroid01.Scale = new Vector3(random.Next(15, 100), random.Next(15, 100), random.Next(15, 100));
                asteroid01.Rotation = Quaternion.CreateFromYawPitchRoll(random.Next(20,100),random.Next(20,100),random.Next(20,100));
                asteroid01.Position = new Vector3(random.Next(-1000, 1000), random.Next(-500, 500), random.Next(-100, 0) - i * 300);
                asteroid01.LoadContent();
                asteroid01.SetModelEffect(ResourceManager.Instance.GetResource<Effect>("PPModel"),true);

                SceneGraphManager.RootNode.Children.Add(asteroid01);
            }
             * */

            MeshObject obj = new MeshObject("tea", "teapot", 1.0f);
            obj.LoadContent();
            obj.Position = new Vector3(0,-100,0);
            obj.SetModelEffect(ResourceManager.Instance.GetResource<Effect>("PPModel"), true);
            SceneGraphManager.RootNode.Children.Add(obj);

            #endregion

            #region UI Stuff
            TextElement headline = new TextElement("TextElementHeadline2", new Vector2(500, 20), Color.Yellow, "GamePlayView", ResourceManager.Instance.GetResource<SpriteFont>("Arial"));
            headline.Scale = 1f;
            headline.Visible = false;
            UIManager.Instance.AddActor(headline);

            TextElement TextPositionShip = new TextElement("TextPositionShip", new Vector2(500, 40), Color.Yellow, "GamePlayView", ResourceManager.Instance.GetResource<SpriteFont>("Arial"));
            TextPositionShip.Scale = 1f;
            TextPositionShip.Visible = true;
            UIManager.Instance.AddActor(TextPositionShip);

            //create crossfade
            CrossHair crosshair_near = new CrossHair("crosshair_near", "SpaceShip", "crosshair_near", 1500);
            crosshair_near.LoadContent();
            UIManager.Instance.AddActor(crosshair_near);
            #endregion
        }