public static void SaveLootDrop(string root, LootDrop lD)
 {
     File.WriteAllText(root + "chance", "" + lD.chance);
     File.WriteAllText(root + "rangel", "" + lD.range[0]);
     File.WriteAllText(root + "rangeh", "" + lD.range[1]);
     File.WriteAllText(root + "drop", "" + lD.drop);
 }
Beispiel #2
0
        public static Entity GetEntity(string filePath)
        {
            if (!Directory.Exists(filePath))
            {
                return(null);
            }

            uint   id = UInt32.Parse(File.ReadAllText(filePath + @"\id"));
            uint   h  = UInt32.Parse(File.ReadAllText(filePath + @"\health"));
            string n  = File.ReadAllText(filePath + @"\name");

            LootDrop[] ds = null;
            if (Directory.Exists(filePath + @"\lootDrops"))
            {
                string[] dirs = Directory.GetDirectories(filePath + @"\lootDrops");
                ds = new LootDrop[dirs.Length];
                for (int i = 0; i < dirs.Length; i++)
                {
                    ds[i] = LootDrop.GetLootDrop(dirs[i] + @"\" + i);
                }
            }

            float x  = float.Parse(File.ReadAllText(filePath + @"\X"));
            float y  = float.Parse(File.ReadAllText(filePath + @"\Y"));
            int   cX = Int32.Parse(File.ReadAllText(filePath + @"\chunkX"));
            int   cY = Int32.Parse(File.ReadAllText(filePath + @"\chunkY"));
            int   l  = Int32.Parse(File.ReadAllText(filePath + @"\layer"));

            Entity e = Entity.GetEntity(id);

            e.health = h;
            e.name   = n;
            e.drops  = ds;
            e.X      = x;
            e.Y      = y;
            e.chunkX = cX;
            e.chunkY = cY;
            e.layer  = l;

            e.GetExtra(filePath);

            return(e);
        }
Beispiel #3
0
        public virtual void Save(string root)
        {
            File.WriteAllText(root + "id", "" + id);
            File.WriteAllText(root + "health", "" + health);
            File.WriteAllText(root + "name", "" + name);
            File.WriteAllText(root + "X", "" + X);
            File.WriteAllText(root + "Y", "" + Y);
            File.WriteAllText(root + "chunkX", "" + chunkX);
            File.WriteAllText(root + "chunkY", "" + chunkY);
            File.WriteAllText(root + "layer", "" + layer);

            Game.DebugBreakPoint();

            Directory.CreateDirectory(root + @"lootDrops");
            for (int i = 0; i < drops.Length; i++)
            {
                Directory.CreateDirectory(root + @"lootDrops\" + i);
                LootDrop.SaveLootDrop(root + @"lootDrops\" + i + @"\", drops[i]);
            }
        }