protected override void LoadContent() { spriteBatch = new SpriteBatch(GameScreenManager.GraphicsDevice); // F*****g around backgrounds = new SpriteBatch(GraphicsDevice); background = Content.Load <Texture2D>("DOGGIE"); offset = Content.Load <Effect>("offset"); // *** Lab 8 Item *********************** GameScreenManager.Setup(false, 1080, 720); //*************************************** particleManager = new ParticleManager(GraphicsDevice, 100); particleEffect = Content.Load <Effect>("ParticleShader"); PlayerBehav.bulletMesh = Content.Load <Model>("Sphere"); AsteroidObject.AstroidModel = Content.Load <Model>("Sphere"); AsteroidObject.tex = Content.Load <Texture2D>("lunaTexture"); StandardLightingMaterial.effect = Content.Load <Effect>("StandardShading"); particleTex = Content.Load <Texture2D>("fire"); font = Content.Load <SpriteFont>("font"); Player = GameObject3d.Initialize(); Player.transform.LocalScale *= 0.01f; Player.transform.Rotate(Vector3.Left, -(float)Math.PI / 2); PlayerBehav.bulletMesh = Content.Load <Model>("Sphere"); Player.addBehavior(new PlayerBehav()); Rigidbody r = new Rigidbody(); Player.addBehavior(r); SphereCollider s = new SphereCollider(); Player.addBehavior(s); Player.mesh = Content.Load <Model>("PlayerModel"); // Sound shit gunSound = Content.Load <SoundEffect>("Gun"); soundInstance = gunSound.CreateInstance(); AudioListener listener = new AudioListener(); listener.Position = camera.Transform.Position; listener.Forward = camera.Transform.Forward; AudioEmitter emitter = new AudioEmitter(); emitter.Position = Vector3.Zero; soundInstance.Apply3D(listener, emitter); foreach (GameObject3d gameObject in GameObject3d.activeGameObjects) { gameObject.Start(); } GameObject.gameStarted = true; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { StandardLightingMaterial.effect = Content.Load <Effect>("Standard"); text = new SpriteBatch(GraphicsDevice); // *** ScreenManager *********************** ScreenManager.Setup(false, 1080, 720); camera.Transform.LocalPosition = Vector3.Up * 20; camera.Transform.Rotate(camera.Transform.Left, (float)Math.PI / 2); camera.FieldOfView = 2.6f; mapCam.orthographic = true; mapCam.Transform.LocalPosition = Vector3.Up * 100; mapCam.Transform.Rotate(mapCam.Transform.Left, (float)Math.PI / 2); mapCam.Size = Vector2.One * 100; mapCam.Position = new Vector2(0.9f, 0.01f); //*************************************** // F*****g around backgrounds = new SpriteBatch(GraphicsDevice); background = Content.Load <Texture2D>("DOGGIE"); offset = Content.Load <Effect>("offset"); Enemy.enemyModel = Content.Load <Model>("sphere"); terrain = new TerrainRenderer( Content.Load <Texture2D>("HeightMap"), Vector2.One * 100, Vector2.One * 200); terrain.NormalMap = Content.Load <Texture2D>("NormalMap"); terrainObject = GameObject3d.Initialize(); terrain.ourObject = terrainObject; terrainObject.material = terrain; terrainObject.transform.LocalScale *= new Vector3(1, 5, 1); font = Content.Load <SpriteFont>("font"); TerrainRenderer.effect = Content.Load <Effect>("TerrainShader"); Enemy.terrain = terrain; // Create Player playerObject = GameObject3d.Initialize(); playerObject.addBehavior(new PlayerBehav(terrain)); playerObject.mesh = Content.Load <Model>("sphere"); Enemy.createEnemy(playerObject); Enemy.createEnemy(playerObject); Enemy.createEnemy(playerObject); foreach (GameObject3d gameObject in GameObject3d.activeGameObjects) { gameObject.Start(); } GameObject.gameStarted = true; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { ScreenManager.Setup(false, 1080, 720); // Create a new SpriteBatch, which can be used to draw textures. backgrounds = new SpriteBatch(GraphicsDevice); text = new SpriteBatch(GraphicsDevice); // Load Font font = Content.Load <SpriteFont>("font"); // Load shaders SpeedAndCollideEffect.effect = Content.Load <Effect>("SpeedEffectShader"); SpeedAndCollideEffect.disperseSample = Content.Load <Texture2D>("noiseTexture"); offset = Content.Load <Effect>("offset"); background = Content.Load <Texture2D>("DOGGIE"); // Load the models sphere = Content.Load <Model>("Sphere"); foreach (ModelMesh mesh in sphere.Meshes) { foreach (BasicEffect e in mesh.Effects) { e.EnableDefaultLighting(); } } // Misc Setup camera.Transform.LocalPosition = new Vector3(0, 0, 20); random = new Random(); BoxCollider boxCollider; boxCollider = new BoxCollider(); boxCollider.Size = 10; GameObject3d b = GameObject3d.Initialize(); b.drawable = false; b.addBehavior(boxCollider); for (int i = 0; i < 2; i++) { makeThatSphere(); } //init foreach (GameObject3d gameObject in GameObject3d.activeGameObjects) { gameObject.Start(); } GameObject.gameStarted = true; }
private void makeThatSphere() { Transform transform = new Transform(); transform.LocalPosition += new Vector3((float)random.NextDouble() * 5, (float)random.NextDouble() * 5, (float)random.NextDouble() * 5); //avoid overlapping each sphere Rigidbody rigidbody = new Rigidbody(); rigidbody.Mass = 1; Vector3 direction = new Vector3( (float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble()); direction.Normalize(); rigidbody.Velocity = direction * ((float)random.NextDouble() * 5 + 5); rigidbody.Mass = 1f + (float)random.NextDouble(); SphereCollider sphereCollider = new SphereCollider(); sphereCollider.Radius = 1 * transform.LocalScale.Y; SpeedColorEffectController effectControl = new SpeedColorEffectController(); GameObject3d g = GameObject3d.Initialize(); g.transform = transform; g.mesh = sphere; g.material = new SpeedAndCollideEffect(); g.addBehavior(rigidbody); g.addBehavior(sphereCollider); g.addBehavior(effectControl); if (GameObject.gameStarted) { g.Start(); } }
// Static method for creating new enemies public static GameObject3d createEnemy(GameObject3d player) { GameObject3d g = GameObject3d.Initialize(); Enemy e = new Enemy(player); g.addBehavior(e); g.mesh = enemyModel; g.material = new StandardLightingMaterial(); (g.material as StandardLightingMaterial).diffuseColor = Vector3.Up; //SETUPSEARCH int size = 100; e.search = new AStarSearch(size, size); // size of grid // use heightmap foreach (AStarNode node in e.search.Nodes) { node.Passable = (terrain.GetAltitude(node.Position) < 0.5); } //****** GameObject3d child = GameObject3d.Initialize(); child.transform.LocalPosition = g.transform.LocalPosition; child.transform.LocalPosition += Vector3.Forward; child.transform.LocalScale *= 0.5f; child.transform.Parent = g.transform; e.heldObject = child; child.mesh = enemyModel; StandardLightingMaterial s = new StandardLightingMaterial(); s.ambientColor = Vector3.Down; child.material = s; g.transform.LocalScale = Vector3.One * 2; e.reposition(); return(g); }