示例#1
0
 public TargettingLine(BattleMap map)
 {
     _map        = map;
     _entitities = new List <Entity>();
 }
示例#2
0
        public static BattleMap Load(string path)
        {
            // Load Albedo data
            FileStream stream      = new FileStream(path + "albedo.png", FileMode.Open);
            var        albedo      = Texture2D.FromStream(Global.GraphicsDevice, stream);
            int        width       = albedo.Width;
            int        height      = albedo.Height;
            var        albedoArray = new Color[width * height];

            albedo.GetData <Color>(albedoArray);
            stream.Dispose();

            stream = new FileStream(path + "shadow.png", FileMode.Open);
            var shadow      = Texture2D.FromStream(Global.GraphicsDevice, stream);
            var shadowArray = new Color[width * height];

            shadow.GetData <Color>(shadowArray);
            stream.Dispose();

            stream = new FileStream(path + "materials.png", FileMode.Open);
            var materials      = Texture2D.FromStream(Global.GraphicsDevice, stream);
            var materialsArray = new Color[width * height];

            materials.GetData <Color>(materialsArray);
            stream.Dispose();

            stream = new FileStream(path + "heightmap.png", FileMode.Open);
            var heightmap      = Texture2D.FromStream(Global.GraphicsDevice, stream);
            var heightmapArray = new Color[width * height];

            heightmap.GetData <Color>(heightmapArray);
            stream.Dispose();

            BattleMap map = new BattleMap(albedo.Width, albedo.Height);

            // Write Albedo data to MapConsole ( Make Cell types )
            for (int i = 0; i < (width * height); i++)
            {
                if (materialsArray[i] == TrenchTile)
                {
                    map[i] = new WWTile(TrenchFOV, TrenchUnSeen, TrenchShadow, shadowArray[i].GetBrightness(), heightmapArray[i].GetBrightness(), ',');

                    map[i].Description = "Trench";
                }
                else if (materialsArray[i] == TrenchWallTile)
                {
                    //map[i] = MapTile.TrenchWall;
                    map[i]             = new WWTile(TrenchWallFOV, TrenchWallUnSeen, TrenchShadow, shadowArray[i].GetBrightness(), heightmapArray[i].GetBrightness(), '#');
                    map[i].Description = "Trench wall.";
                }
                else if (materialsArray[i] == Bridge)
                {
                    //map[i] = MapTile.Bridge;
                    map[i]             = new WWTile(SnowFOV, SnowUnSeen, TrenchShadow, shadowArray[i].GetBrightness(), heightmapArray[i].GetBrightness(), ',');
                    map[i].Description = "Bridge deck";
                }
                else if (materialsArray[i] == BridgeRail)
                {
                    //map[i] = MapTile.BridgeRail;
                    map[i]             = new WWTile(SnowFOV, SnowUnSeen, TrenchShadow, shadowArray[i].GetBrightness(), heightmapArray[i].GetBrightness(), '#');
                    map[i].Description = "Bridge railing";
                }
                else
                {
                    map[i]             = new WWTile(SnowFOV, SnowUnSeen, SnowShadow, shadowArray[i].GetBrightness(), heightmapArray[i].GetBrightness(), '.');
                    map[i].Description = "Snow";
                }
                //WWTile tile = new WWTile( SnowFOV, SnowUnSeen, shadowArray[i].GetBrightness(), heightmapArray[i].GetBrightness(), '.' );
                //map[i].SetFlag( TileFlags.Seen | TileFlags.Lighted );
                //map[i].Height = heightmapArray[i].GetBrightness();
                //map[i].Background = Color.Lerp( map[i].Background, map[i].ShadowColor, 1f - shadowArray[i].GetBrightness() );
                //map[i].Z = heightmapArray[i].GetBrightness();
            }
            return(map);
        }