Beispiel #1
0
 public AssetsHelper(ICultureHelper _cultureHelper)
 {
     cultureHelper = _cultureHelper;
     Styles = new ItemRegistrar(cultureHelper);
     Styles.Format = ItemRegistrarFromatters.StyleFormat;
     Scripts = new ItemRegistrar(cultureHelper);
     Scripts.Format = ItemRegistrarFromatters.ScriptFormat;
 }
Beispiel #2
0
 public Script()
 {
     Styles = new ItemRegistrar(ItemRegistrarFormatters.StyleFormat);
     JavaScripts = new ItemRegistrar(ItemRegistrarFormatters.ScriptFormat);
 }
Beispiel #3
0
 public AssetsHelper()
 {
     Styles = new ItemRegistrar(ItemRegistrarFromatters.StyleFormat);
     Scripts = new ItemRegistrar(ItemRegistrarFromatters.ScriptFormat);
 }
Beispiel #4
0
 public AssetsHelper()
 {
     Styles  = new ItemRegistrar(ItemRegistrarFormatters.StyleFormat);
     Scripts = new ItemRegistrar(ItemRegistrarFormatters.ScriptFormat);
 }
        public static void save(String path, WorldBase world)
        {
            Logger.log("Saving game at " + path);
            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }



                using (System.IO.StreamWriter file = new System.IO.StreamWriter(path + "save.txt"))
                {
                    Entity playerBase = world.player;
                    Console.WriteLine("1: " + playerBase);
                    if (playerBase is TransformedPlayer)
                    {
                        Console.WriteLine("Transformed");
                        while (!(playerBase is Player))
                        {
                            Console.WriteLine("up: " + playerBase);
                            playerBase = ((TransformedPlayer)playerBase).transformedFrom;
                        }
                    }
                    Player player = (Player)playerBase;

                    file.WriteLine(UniverseProperties.seed);
                    file.WriteLine(world.difficulty);
                    file.WriteLine(player.animationPackage.id);
                    file.WriteLine(player.location.X);
                    file.WriteLine(player.location.Y);
                    file.WriteLine(player.health);
                    file.WriteLine(player.hunger);
                    file.WriteLine(player.warmth);
                    Inventory.PlayerInventory inventory = player.inventory;
                    foreach (Item item in inventory.items)
                    {
                        file.WriteLine("Inventory:" + ItemRegistrar.getIDFromItem(item) + "," + item.getRemainingUses());
                    }

                    for (int i = 0; i < player.cards.Length; i++)
                    {
                        if (player.cards[i] != null)
                        {
                            file.WriteLine("Card:" + CardRegistrar.getIDFromCard(player.cards[i]) + "," + player.cards[i].level);
                        }
                    }
                    file.WriteLine("Keyed Items:");
                    for (int i = 0; i < player.keyedItems.Length; i++)
                    {
                        if (player.keyedItems[i] != null)
                        {
                            file.WriteLine(ItemRegistrar.getIDFromItem(player.keyedItems[i]));
                        }
                        else
                        {
                            file.WriteLine(-1);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Logger.log(exception.ToString());
            }
        }
        public static void load(String path)
        {
            Logger.log("Loading game at " + path);
            bool      foundWorld = false;
            WorldBase world      = null;

            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                else if (File.Exists(path + "save.txt"))
                {
                    foundWorld = true;
                    using (System.IO.StreamReader file = new System.IO.StreamReader(path + "save.txt"))
                    {
                        World.universeProperties = new UniverseProperties(file.ReadLine());
                        int difficulty = int.Parse(file.ReadLine());

                        world = Game1.instance.getWorldBasedOnDifficulty(difficulty);
                        Player player = ((Player)world.player);
                        PlayerAnimationPackage animationPackage = PlayerAnimationPackage.animationPackageKey[int.Parse(file.ReadLine())];
                        animationPackage.apply(player);
                        Inventory.PlayerInventory inventory = player.inventory;
                        float playerX = float.Parse(file.ReadLine());
                        float playerY = float.Parse(file.ReadLine());
                        player.location = new Vector2(playerX, playerY);
                        player.health   = float.Parse(file.ReadLine());
                        player.hunger   = float.Parse(file.ReadLine());
                        player.warmth   = float.Parse(file.ReadLine());

                        int    currentCard = 0;
                        string line        = file.ReadLine();
                        while (!line.StartsWith("Keyed Items:"))
                        {
                            if (line.StartsWith("Inventory:"))
                            {
                                line = line.Replace("Inventory:", "");
                                string[] entry = line.Split(',');
                                int      id    = int.Parse(entry[0]);
                                int      count = int.Parse(entry[1]);
                                inventory.add(ItemRegistrar.getItemFromIdAndCount(id, count));
                            }
                            else if (line.StartsWith("Card:"))
                            {
                                line = line.Replace("Card:", "");
                                string[] entry = line.Split(',');
                                int      id    = int.Parse(entry[0]);
                                float    level = float.Parse(entry[1]);
                                player.cards[currentCard] = CardRegistrar.getCardFromIdPlayerAndLevel(id, level, player);
                                currentCard++;
                            }
                            line = file.ReadLine();
                        }
                        for (int i = 0; i < player.keyedItems.Length; i++)
                        {
                            int itemData = int.Parse(file.ReadLine());
                            if (itemData != -1)
                            {
                                player.keyedItems[i] = ItemRegistrar.getItemFromIdAndCount(itemData, 1);
                            }
                        }
                    }
                    File.Delete(path + "save.txt");
                }
            }
            catch (Exception e)
            {
                Logger.log(e.ToString());
            }


            if (!foundWorld)
            {
                world = Game1.instance.getWorldBasedOnDifficulty(0);
                Game1.instance.queuedSplashScreens.Add(new PlayerSelectScreen(MetaData.unlocks.ToArray(), world));
            }
            Card.setUpCards();


            Game1.instance.switchWorlds(world);
        }
 public CssJsViewAppnder()
 {
     Styles = new ItemRegistrar(ItemRegistrarFromatters.StyleFormat);
     Scripts = new ItemRegistrar(ItemRegistrarFromatters.ScriptFormat);
 }