Beispiel #1
0
 public Water(List<Vector3> points, LevelInfo levelInfo, Sun aSun, GraphicsDevice graphics)
 {
     initialize(points, levelInfo);
     vd = new VertexDeclaration(graphics, VertexPositionColor.VertexElements);
     effect = new BasicEffect(graphics, null);
     sun = aSun;
 }
Beispiel #2
0
        public NetLevelState(IStateManager manager, DroughtGame game, Level aLevel, bool isHost)
            : base(manager, game)
        {
            soundManager = game.getSoundManager();
            networkManager = game.getNetworkManager();
            hosting = isHost;

            input = DeviceInput.getInput();

            sun = new Sun(new Vector3(0, -200, 200));

            levelInfo = new LevelInfo();
            levelInfo.initialise(aLevel);

            List<List<Vector3>> waterList = Water.findWater(levelInfo);
            waters = new Water[waterList.Count];

            for (int i = 0; i < waters.Length; i++)
                waters[i] = new Water(waterList[i], levelInfo, sun, getGraphics());

            aStar = new AStar(levelInfo);

            rain = new PlaneParticleEmitter(512, 256, new Vector3(256, 128, 200), new Vector3(0, 0, 0), new Vector3(3f, 0, -19f), Color.LightBlue.ToVector4(), 100000, 9);

            camera = new Camera(this, levelInfo, false);

            terrain = new Terrain(getGraphics(), getContentManager(), levelInfo, camera);

            soundManager.setListener(camera);

            modelLoader = new ModelLoader(getContentManager(), getGraphics());

            skybox = new Skybox(camera, sun, modelLoader.getModel3D(modelType.Skybox));

            lineTool = new LineTool(getGraphics());

            loadContent();

            initializeEntities();

            foreach (MovableEntity entity in localEntities)
                soundManager.playSound(SoundHandle.Truck, entity);
        }
Beispiel #3
0
        public virtual void render(GraphicsDevice graphics, Camera camera, Sun sun)
        {
            if (!isDead())
                pathTool.render(camera.getViewMatrix(), camera.getProjectionMatrix());

            if (selected)
                ringTool.render(camera.getViewMatrix(), camera.getProjectionMatrix());

            graphics.RenderState.DepthBufferEnable = true;
            graphics.RenderState.AlphaBlendEnable = false;
            graphics.RenderState.AlphaTestEnable = false;

            Matrix[] transforms = new Matrix[model.Model.Bones.Count];
            model.Model.CopyAbsoluteBoneTransformsTo(transforms);

            Matrix worldMatrix = Matrix.CreateScale(model.Scale) * orientation * Matrix.CreateTranslation(position);
            //"sink" the units a bit if they're dead, just to conceptually remove them from play
            if (isDead()) worldMatrix *= Matrix.CreateTranslation(new Vector3(0, 0, -0.5f));

            int i = 0;
            foreach (ModelMesh mesh in model.Model.Meshes)
            {
                foreach (Effect currentEffect in mesh.Effects)
                {
                    currentEffect.CurrentTechnique = model.Effect.Techniques["Textured"];

                    currentEffect.Parameters["xWorldViewProjection"].SetValue(transforms[mesh.ParentBone.Index] * worldMatrix * camera.getViewMatrix() * camera.getProjectionMatrix());
                    currentEffect.Parameters["xWorld"].SetValue(worldMatrix);
                    currentEffect.Parameters["xTexture"].SetValue(model.Textures[i++]);
                    currentEffect.Parameters["xEnableLighting"].SetValue(true);
                    currentEffect.Parameters["xEnableNormals"].SetValue(true);
                    currentEffect.Parameters["xLightPosition"].SetValue(sun.getPosition());
                    currentEffect.Parameters["xLightPower"].SetValue(sun.getPower());
                    currentEffect.Parameters["xGreyScale"].SetValue(isDead());
                }
                mesh.Draw();
            }
        }
Beispiel #4
0
 public override void render(GraphicsDevice graphics, Camera camera, Sun sun)
 {
     base.render(graphics, camera, sun);
     if (IsSelected) attackRadiusTool.render(camera.getViewMatrix(), camera.getProjectionMatrix());
 }
Beispiel #5
0
 public Skybox(Camera camera, Sun sun, Model3D model)
 {
     this.camera = camera;
     this.sun = sun;
     this.model = model;
 }
Beispiel #6
0
        public void render(Sun sun)
        {
            Matrix worldMatrix = Matrix.Identity;

            effect.CurrentTechnique = effect.Techniques["MultiTextured"];

            effect.Parameters["xWaterTexture"].SetValue(waterTexture);
            effect.Parameters["xSandTexture"].SetValue(sandTexture);
            effect.Parameters["xStoneTexture"].SetValue(stoneTexture);
            effect.Parameters["xErrorTexture"].SetValue(errorTexture);

            effect.Parameters["xWorld"].SetValue(worldMatrix);
            effect.Parameters["xWorldViewProjection"].SetValue(worldMatrix * camera.getViewMatrix() * camera.getProjectionMatrix());
            effect.Parameters["xEnableLighting"].SetValue(true);
            effect.Parameters["xLightPosition"].SetValue(sun.getPosition());
            effect.Parameters["xLightPower"].SetValue(sun.getPower());

            effect.Begin();

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();

                device.Vertices[0].SetSource(vb, 0, VertexMultiTextured.SizeInBytes);
                device.Indices = ib;
                device.VertexDeclaration = new VertexDeclaration(device, VertexMultiTextured.VertexElements);
                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, height * width, 0, (width - 1) * (height - 1) * 2);
                //device.DrawUserIndexedPrimitives<VertexMultiTextured>(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, (width - 1) * (height - 1) * 2);

                pass.End();
            }
            effect.End();
        }
Beispiel #7
0
        public LevelState(IStateManager manager, DroughtGame game, Level aLevel)
            : base(manager, game)
        {
            /* TEMP */
            explosionParticles = new ExplosionParticleSystem(getContentManager(), getGraphics());
            explosionSmokeParticles = new ExplosionSmokeParticleSystem(getContentManager(), getGraphics());
            projectileTrailParticles = new ProjectileTrailParticleSystem(getContentManager(), getGraphics());
            smokePlumeParticles = new SmokePlumeParticleSystem(getContentManager(), getGraphics());
            fireParticles = new FireParticleSystem(getContentManager(), getGraphics());
            projectileManager = new ProjectileManager(explosionParticles, explosionSmokeParticles, projectileTrailParticles);

            soundManager = game.getSoundManager();

            input = DeviceInput.getInput();

            sun = new Sun(new Vector3(0, -200, 200));

            levelInfo = new LevelInfo();
            levelInfo.initialise(aLevel);

            TextureMap textureMap = new TextureMap(aLevel);
            //List<List<Vector3>> waterList = Water.findWater(levelInfo);
            List<List<Vector3>> waterListPleh = textureMap.findWater();
            //waters = new Water[waterList.Count];
            waters = new Water[waterListPleh.Count];

            Water[,] waterLocationTable = new Water[levelInfo.getWidth(), levelInfo.getHeight()];
            for (int i = 0; i < waters.Length; i++)
            {
                //waters[i] = new Water(waterList[i], levelInfo, getGraphics());
                waters[i] = new Water(waterListPleh[i], levelInfo, sun, getGraphics());

                for (int j = 0; j < waterListPleh[i].Count; j++)
                {
                    Vector3 p = waterListPleh[i][j];
                    waterLocationTable[(int)p.X, (int)p.Y] = waters[i];
                }
            }
            levelInfo.setWaterPools(waterLocationTable);

            camera = new Camera(this, levelInfo, false);

            rain = new PlaneParticleEmitter(512, 256, new Vector3(256, 128, 200), new Vector3(0, 0, 0), new Vector3(3f, 0, -19f), Color.LightBlue.ToVector4(), 10000, 9);

            terrain = new Terrain(getGraphics(), getContentManager(), levelInfo, camera);

            modelLoader = new ModelLoader(getContentManager(), getGraphics());

            skybox = new Skybox(camera, sun, modelLoader.getModel3D(modelType.Skybox));

            lineTool = new LineTool(getGraphics());

            aStar = new AStar(levelInfo);

            soundManager.setListener(camera);

            loadContent();

            initializeEntities();

            foreach (MovableEntity entity in entities)
                soundManager.playSound(SoundHandle.Truck, entity);
        }