public Card(JSONTable template, ContentManager content) { name = template.getString("name"); cost = ResourceAmount.createList(template.getJSON("cost", null)); effect = Effect_Base.create(template.getArray("effect", null)); if (template.hasKey("ongoing") || template.hasKey("triggers")) { ongoingType = new PermanentType(template, content); } image = content.Load<Texture2D>(template.getString("texture")); smallFrameTexture = content.Load<Texture2D>("square"); Enum.TryParse<TargetType>(template.getString("target", "none"), out targetType); frameTexture = content.Load<Texture2D>("cardframe_large"); description = DragonGfx.Tooltip.StringToLines(template.getString("description", ""), Game1.font, 100); upgradeCost = ResourceAmount.createList(template.getJSON("upgradeCost", null)); targetTest = TriggerItemTest.create(template.getArray("targetTest", null)); spellSet = template.getString("spellSet", null); foreach (JSONTable upgradeTemplate in template.getArray("upgrades", JSONArray.empty).asJSONTables()) { if(upgrades == null) upgrades = new List<Card>(); upgrades.Add(new Card(upgradeTemplate, content)); } switch (template.getString("type", null)) { case "special": frameColor = new Color(235, 200, 255); break; case "minion": frameColor = new Color(200, 255, 200); break; case "production": frameColor = new Color(255, 220, 190); break; case "modifier": frameColor = new Color(255, 190, 200); break; default: frameColor = Color.White; break; } string id = template.getString("id", null); if (id != null) { cardsById.Add(id, this); } defaultUnlocked = template.getBool("unlocked", false); unlocked = defaultUnlocked; }
public ConvergePlayer(JSONTable template, ContentManager Content) { this.home = new ConvergeZone(template.getJSON("home"), this, ConvergeZoneId.Home); this.resourceZone = new ConvergeZone(template.getJSON("resources"), this, ConvergeZoneId.Resources); this.attack = new ConvergeZone(template.getJSON("attack"), this, ConvergeZoneId.Attack); this.defense = new ConvergeZone(template.getJSON("defense"), this, ConvergeZoneId.Defense); this.hand = new ConvergeZone(template.getJSON("hand"), this, ConvergeZoneId.Hand); this.homeBase = new ConvergeObject(new ConvergeCardSpec(template.getJSON("homebase"), Content), home); this.discardPile = new ConvergeZone(template.getJSON("discardPile"), this, ConvergeZoneId.DiscardPile); this.laboratory = new ConvergeZone(template.getJSON("laboratory"), this, ConvergeZoneId.Laboratory); zones = new Dictionary <ConvergeZoneId, ConvergeZone>() { { ConvergeZoneId.Home, home }, { ConvergeZoneId.Resources, resourceZone }, { ConvergeZoneId.Attack, attack }, { ConvergeZoneId.Defense, defense }, { ConvergeZoneId.Hand, hand }, { ConvergeZoneId.DiscardPile, discardPile }, { ConvergeZoneId.Laboratory, laboratory }, }; this.life = template.getInt("startingLife"); this.faceLeft = template.getBool("faceLeft", false); }
internal static MagicCard LoadCard(string card, GraphicsDevice GraphicsDevice, JSONTable table) { if (cards.ContainsKey(card)) return cards[card]; else { JSONTable cardTable = table.getJSON(card); MagicCardType type = 0; foreach (var item in cardTable.getArray("types").toStringArray()) { type |= (MagicCardType)Enum.Parse(typeof(MagicCardType), item); } cards.Add ( card, new MagicCard ( card, GraphicsDevice, type, cardTable.getArray("subtypes").toStringArray(), new Ability[0], new Cost(new List<CostComponent>() { ManaPaymentComponent.Parse(cardTable.getString("manaCost", "0")) }), int.Parse(cardTable.getString("power", "0")), int.Parse(cardTable.getString("toughness", "0")) ) ); return cards[card]; } }
/* public WorldLevel() * { * objects.Add(new WorldObject_City(new CityLevel("TUTOPIA", new Vector2(100, 140)))); * objects.Add(new WorldObject_City(new CityLevel("SHEFFIELD", new Vector2(530, 90)))); * objects.Add(new WorldObject_City(new CityLevel("MANCHESTER", new Vector2(430, 70)))); * objects.Add(new WorldObject_City(new CityLevel("LIVERPOOL", new Vector2(300, 70)))); * objects.Add(new WorldObject_City(new CityLevel("BRISTOL", new Vector2(200, 320)))); * objects.Add(new WorldObject_City(new CityLevel("LONDON", new Vector2(700, 370)))); * objects.Add(new WorldObject_City(new CityLevel("BIRMINGHAM", new Vector2(400, 190)))); * objects.Add(new WorldObject_City(new CityLevel("READING", new Vector2(530, 370)))); * objects.Add(new WorldObject_City(new CityLevel("OXFORD", new Vector2(480, 300)))); * objects.Add(new WorldObject_City(new CityLevel("CARDIFF", new Vector2(100, 310)))); * }*/ public WorldLevel(JSONTable template) { foreach (string cityCode in template.Keys) { WorldObject_City city = new WorldObject_City(new CityLevel(template.getJSON(cityCode))); objects.Add(city); if (city.cityLevel.isTutorial) { tutorialCity = city; } } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. font = Content.Load <SpriteFont>("Arial"); JSONTable settings = new JSONTable("Settings.json"); spriteBatch = new SpriteBatch(GraphicsDevice); TextureCache.Load(Content); inventory = new Inventory(); buttonStyle = UIButton.GetDefaultStyle(Content); worldLevel = new WorldLevel(settings.getJSON("cities")); platformLevel = new PlatformLevel(); currentScreen = worldLevel.tutorialCity.cityLevel; splashes = new SplashManager(); }
public BuildingSite(CityLevel cityLevel, JSONTable template) : base(cityLevel, TextureCache.building_site, template.getVector2("pos"), TextureCache.building_site.Size()) { this.price = template.getInt("price"); this.canDrag = false; JSONArray signatureTemplate = template.getArray("chemical", null); if (signatureTemplate != null) { this.signature = new ChemicalSignature(signatureTemplate); this.spawn = new ChemicalInbox(cityLevel, signature, 0, bounds.XY); } else { this.spawn = CityObject.FromTemplate(cityLevel, template.getJSON("built")); } Init(); }
public PermanentType(JSONTable template, ContentManager content) { name = template.getString("name"); string textureName = template.getString("texture"); texture = (textureName != null) ? content.Load<Texture2D>(textureName) : null; upkeep = ResourceAmount.createList(template.getJSON("upkeep", null)); ongoing = Effect_Base.create(template.getArray("ongoing", null)); ongoing_late = Effect_Base.create(template.getArray("ongoing_late", null)); triggers = TriggeredAbility.createList(template.getArray("triggers", null)); }
public static void load(JSONTable template, ContentManager content) { levelTypes = new Dictionary<string, LevelType>(); foreach (string key in template.Keys) { levelTypes[key] = new LevelType(template.getJSON(key), content); } }
public LevelType(JSONTable template, ContentManager content) { spawnPoint = new List<Point>(); foreach(JSONArray spawnTemplate in template.getArray("spawnPoint").asJSONArrays()) { spawnPoint.Add(spawnTemplate.toPoint()); } wizardPos = template.getArray("wizardPos").toPoint(); levelSize = template.getArray("levelSize").toPoint(); startingResources = ResourceAmount.createList(template.getJSON("startingResources")); floorTexture = content.Load<Texture2D>(template.getString("floorTexture")); entranceTexture = content.Load<Texture2D>(template.getString("entranceTexture")); pathTexture = content.Load<Texture2D>(template.getString("pathTexture")); }
public CityLevel(JSONTable template) { this.name = template.getString("name"); this.pos = template.getVector2("pos"); this.price = template.getInt("price"); this.isTutorial = template.getBool("isTutorial", false); blackboard.cityLevel = this; InitUI(); isNew = true; Dictionary <string, CityObject> objectsByName = new Dictionary <string, CityObject>(); JSONTable unlockTable = template.getJSON("unlocks", null); if (unlockTable != null) { foreach (string unlockName in unlockTable.Keys) { JSONTable unlockTemplates = unlockTable.getJSON(unlockName); List <CityObject> newObjects = new List <CityObject>(); List <UIElement> newUI = new List <UIElement>(); List <Weapon> newWeapons = new List <Weapon>(); foreach (string objectName in unlockTemplates.Keys) { /*if(unlockableUI.ContainsKey(objectName)) * { * newUI.Add(unlockableUI[objectName]); * } * else*/ if (Game1.instance.inventory.unlockableWeapons.ContainsKey(objectName)) { newWeapons.Add(Game1.instance.inventory.unlockableWeapons[objectName]); } else { CityObject newObj = CityObject.FromTemplate(this, unlockTemplates.getJSON(objectName)); objectsByName[objectName] = newObj; newObjects.Add(newObj); } } if (unlockName == "start") { foreach (CityObject obj in newObjects) { objects.Add(obj); //tutorial hack if (obj is ChemicalFactory) { blackboard.selectedObject = obj; } } foreach (UIElement element in newUI) { ui.Add(element); } foreach (Weapon w in newWeapons) { Game1.instance.inventory.UnlockWeapon(w); } } else { unlockRules.Add(new UnlockRule_Output(objectsByName[unlockName], newUI, newObjects, newWeapons)); } } // postprocess to add pipes foreach (string unlockName in unlockTable.Keys) { JSONTable unlockTemplates = unlockTable.getJSON(unlockName); foreach (string objectName in unlockTemplates.Keys) { //if (unlockableUI.ContainsKey(objectName) || if (Game1.instance.inventory.unlockableWeapons.ContainsKey(objectName)) { continue; } JSONTable objectTemplate = unlockTemplates.getJSON(objectName); JSONArray pipeTargets = objectTemplate.getArray("pipes", null); if (pipeTargets != null) { foreach (string pipeTarget in pipeTargets.asStrings()) { CityObject sourceObject = objectsByName[objectName]; CityObject targetObject = objectsByName[pipeTarget]; OutputPipe pipe = sourceObject.pipes.Last(); pipe.ConnectTo(targetObject.GetNearestSocket(targetObject.bounds.XY)); pipe.movable = false; } } } } } }
public static void load(JSONTable template, ContentManager content) { types = new Dictionary<string, MinionType>(); foreach (string key in template.Keys) { types.Add(key, new MinionType(template.getJSON(key), content)); } }
public MinionType(JSONTable template, ContentManager content) : base(template, content) { upkeep = ResourceAmount.createList(template.getJSON("upkeep", null)); attackCost = ResourceAmount.createList(template.getJSON("attackCost", null)); whenDies = Effect_Base.create(template.getArray("whenDies", null)); awakenTypeName = template.getString("awakenType", null); string onFireTextureName = template.getString("onFireTexture", null); if (onFireTextureName != null) onFireTexture = content.Load<Texture2D>(onFireTextureName); stats.maxHealth = template.getInt("health", 1); stats.health = stats.maxHealth; stats.attack = template.getInt("attack", 0); stats.move = template.getInt("move", 1); stats.armor = template.getInt("armor", 0); Enum.TryParse<Range>(template.getString("range", "adjacent"), out stats.range); foreach (string abilityName in template.getArray("keywords", JSONArray.empty).asStrings()) { Keyword keyword; bool ok = Enum.TryParse<Keyword>(abilityName, out keyword); Debug.Assert(ok); stats.keywords |= keyword; } spells = template.getString("spells", null); description = template.getString("description", "Just a guy"); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here data = new JSONTable("Content/data.json"); mouseOverGlow = new RichImage(data.getJSON("mouseOverGlow"), Content); cardFrame = new RichImage(data.getJSON("cardFrame"), Content); whiteFrame = new RichImage(data.getJSON("whiteFrame"), Content); blueFrame = new RichImage(data.getJSON("blueFrame"), Content); blackFrame = new RichImage(data.getJSON("blackFrame"), Content); redFrame = new RichImage(data.getJSON("redFrame"), Content); greenFrame = new RichImage(data.getJSON("greenFrame"), Content); goldFrame = new RichImage(data.getJSON("goldFrame"), Content); font = Content.Load <SpriteFont>("Arial"); shieldbg = Content.Load <Texture2D>("shieldbg"); powerbg = Content.Load <Texture2D>("powerbg"); woundbg = Content.Load <Texture2D>("woundbg"); tappedicon = Content.Load <Texture2D>("tapped"); abilityHighlight = Content.Load <Texture2D>("abilityHighlight"); targetArrow = Content.Load <Texture2D>("targetArrow"); targetBeam = Content.Load <Texture2D>("targetBeam"); badTargetArrow = Content.Load <Texture2D>("badTargetArrow"); badTargetBeam = Content.Load <Texture2D>("badTargetBeam"); attackBeam = Content.Load <Texture2D>("attackBeam"); resourceTextures = new Texture2D[] { Content.Load <Texture2D>("total_resources"), Content.Load <Texture2D>("white_hats"), Content.Load <Texture2D>("blue_science"), Content.Load <Texture2D>("black_hats"), Content.Load <Texture2D>("red_munitions"), Content.Load <Texture2D>("green_seeds"), }; ui = new UIContainer(); self = new ConvergePlayer(data.getJSON("self"), Content); opponent = new ConvergePlayer(data.getJSON("opponent"), Content); self.opponent = opponent; opponent.opponent = self; ui.Add(new ConvergeUIObject(self.homeBase)); ui.Add(new ConvergeUIObject(opponent.homeBase)); UIButtonStyle defaultStyle = UIButton.GetDefaultStyle(Content); endTurnButton = new UIButton("End Turn", new Rectangle(600, 400, 80, 40), defaultStyle, EndTurn_action, uiActions); ui.Add(endTurnButton); UIButton newHandButton = new UIButton("Cheat:New Hand", new Rectangle(600, 300, 80, 40), defaultStyle, NewHand_action, uiActions); ui.Add(newHandButton); JSONTable allCardsTemplate = data.getJSON("cards"); foreach (string cardName in allCardsTemplate.Keys) { ConvergeCardSpec newSpec = new ConvergeCardSpec(); ConvergeCardSpec.allCards.Add(cardName, newSpec); newSpec.Init(allCardsTemplate.getJSON(cardName), Content); } foreach (string cardName in data.getArray("mydeck").asStrings()) { //ConvergeObject handCard = new ConvergeObject(ConvergeCardSpec.allCards[cardName], self.laboratory); //ui.Add(new ConvergeUIObject(handCard)); } foreach (string cardName in data.getArray("oppdeck").asStrings()) { //ConvergeObject handCard = new ConvergeObject(ConvergeCardSpec.allCards[cardName], opponent.laboratory); //ui.Add(new ConvergeUIObject(handCard)); } UpdateZoneChanges(); self.BeginGame(); opponent.BeginGame(); activePlayer = self; self.BeginMyTurn(); opponent.numLandsPlayed = 1; // can't play a land in your first response phase }