getWidth() public method

public getWidth ( ) : int
return int
示例#1
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);
        }
示例#2
0
        /**
         * Initialises AStar to search for paths in a level.
         * This method must be called whenever levelInfo changes
         * to keep AStar up to date with the latest level.
         *
         * @param level The level information to search.
         */
        public void initialise(LevelInfo level)
        {
            this.level = level;
            width = level.getWidth() / SCALE;
            height = level.getHeight() / SCALE;
            scaledHeightMap = new float[width, height];
            traversable = new bool[width, height];

            for (int x = 0; x < width; x++)
                for (int y = 0; y < height; y++)
                {
                    scaledHeightMap[x, y] = level.getHeight(x * SCALE, y * SCALE);

                    //if a water texture then a node is not traversable
                    traversable[x, y] = level.getTextureValue(x * SCALE, y * SCALE).X > 0 ? false : true;
                }

            //set the border of the map to be non-traversable
            for (int x = 0; x < width; x++)
            {
                traversable[x, 0] = false;
                traversable[x, height - 1] = false;
            }

            for (int y = 0; y < height; y++)
            {
                traversable[0, y] = false;
                traversable[width - 1, y] = false;
            }

            /*
            StringBuilder sb = new StringBuilder();
            for (int x = 0; x < width; x++)
            {
                sb.Append("\n");
                for (int y = 0; y < height; y++)
                    sb.Append(level.getHeight(x, y) + " ");
            }
            Console.WriteLine(sb);
             */
        }
示例#3
0
 private bool notEdgePoint(Vector3 p, LevelInfo levelInfo)
 {
     return (p.X > 0 && p.X < levelInfo.getWidth()-1 && p.Y > 0 && p.Y < levelInfo.getHeight()-1);
 }