コード例 #1
0
ファイル: Tile.cs プロジェクト: Osuology/code-diagram-test
 public void LoadTexture(ContentHouse ch)
 {
     switch (ID)
     {
     default:
         texture.Load(ch.Get("tile_" + ID));
         break;
     }
 }
コード例 #2
0
        public void Load(string prefix, ContentHouse ch)
        {
            DirectoryInfo taskDirectory = new DirectoryInfo("Tilemaps/");

            FileInfo[] taskFiles = taskDirectory.GetFiles(prefix + "*.txt");
            foreach (var file in taskFiles)
            {
                var x        = 0;
                var y        = 0;
                var position = file.Name.Substring(prefix.Length + 1);
                position = position.Replace(".txt", "");
                position = position.Replace("_", "");
                if (position[0] == '-')
                {
                    x = Int32.Parse(position.Substring(0, 2));
                    if (position[2] == '-')
                    {
                        y = Int32.Parse(position.Substring(2, 2));
                    }
                    else
                    {
                        y = Int32.Parse(position.Substring(2, 1));
                    }
                }
                else
                {
                    x = Int32.Parse(position.Substring(0, 1));

                    if (position[1] == '-')
                    {
                        y = Int32.Parse(position.Substring(1, 2));
                    }
                    else
                    {
                        y = Int32.Parse(position.Substring(1, 1));
                    }
                }
                Tilemap tilemap = new Tilemap(x, y);
                tilemap.Load(ch, file.DirectoryName + "/" + file.Name);
                tilemaps.Add(tilemap);
            }
        }
コード例 #3
0
        public void Load(ContentHouse ch, string path)
        {
            List <List <Tile> > tileS;

            using (StreamReader sr = File.OpenText(path))
            {
                JsonSerializer serializer = new JsonSerializer();
                tileS = (List <List <Tile> >)serializer.Deserialize(sr, typeof(List <List <Tile> >));
            }

            layers = new List <List <Tile> >();
            for (int i = 0; i < tileS.Count; i++)
            {
                layers.Add(new List <Tile>());
                for (int h = 0; h < tileS[i].Count; h++)
                {
                    Tile tile = tileS[i][h];
                    layers[i].Add(new Tile((int)(position.X + tile.position.X), (int)(position.Y + tile.position.Y), tile.ID));
                    layers[i][h].LoadTexture(ch);
                }
            }
        }
コード例 #4
0
 public virtual void Unload()
 {
     ch = null;
 }
コード例 #5
0
 //Constructor
 public Scene()
 {
     ch = new ContentHouse();
 }