public void InitializeCampaign() { MagicWord.RegisterMagicWordsReflectively(); CardRegistrar.InitCardsReflectively(); InitializeSelectableMissions(); InitializeRoster(); CampaignMapState.GameInitialized = true; ShowDeckScreen.Start(); // done to ensure that Instance variable gets initialized }
public void selectKit(WorldBase world) { if (!locked) { SoundManager.getSound("click").playWithVariance(0, .25f, 0, SoundType.MONSTER); foreach (Item item in kit) { world.player.inventory.add(item.clone(item.uses)); } if (starterCards[0] != null) { ((Player)(world.player)).cards[0] = CardRegistrar.getCardFromIdPlayerAndLevel(CardRegistrar.getIDFromCard(starterCards[0]), starterCards[0].level, (Player)world.player); } if (starterCards[1] != null) { ((Player)(world.player)).cards[1] = CardRegistrar.getCardFromIdPlayerAndLevel(CardRegistrar.getIDFromCard(starterCards[1]), starterCards[1].level, (Player)world.player); } animations.apply(((Player)(world.player))); world.player.tutorialStringMovement = tutorialStringMovement; world.player.tutorialStringInventory = tutorialStringInventory; world.player.tutorialStringUseItems = tutorialStringUseItems; world.player.tutorialStringPostKeybinds = tutorialStringPostKeybinds; world.player.tutorialStringCrafting = tutorialStringCrafting; world.player.tutorialStringWeapon = tutorialStringWeapon; world.player.rebindAndFinish = rebindAndFinish; if (world is TutorialWorld) { ((TutorialWorld)world).processInstructionStrings(); } } }
public virtual List <AbstractCard> UniqueCardRewardPool() { return(CardRegistrar.GetCardPool(this.GetType())); }
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); }