public LevelScript(JSONTable template) { spawns = new List<List<MinionType>>(); name = template.getString("name", "UNNAMED"); JSONArray spawnTemplate = template.getArray("monsters"); for (int Idx = 0; Idx < spawnTemplate.Length; ++Idx) { List<MinionType> thisTurn = new List<MinionType>(); foreach (string minion in spawnTemplate.getArray(Idx).asStrings()) { MinionType type = MinionType.get(minion); thisTurn.Add(type); } spawns.Add(thisTurn); } scenery = new List<KeyValuePair<MinionType, Point>>(); foreach (JSONArray entry in template.getArray("scenery", JSONArray.empty).asJSONArrays()) { scenery.Add(new KeyValuePair<MinionType,Point>(MinionType.get(entry.getString(0)), new Point(entry.getInt(1), entry.getInt(2)))); } ongoingEffects = new List<KeyValuePair<Card, Point>>(); foreach (JSONArray entry in template.getArray("ongoingEffects", JSONArray.empty).asJSONArrays()) { ongoingEffects.Add(new KeyValuePair<Card, Point>(Card.get(entry.getString(0)), new Point(entry.getInt(1), entry.getInt(2)))); } levelType = LevelType.get(template.getString("type")); string unlock = template.getString("unlock", null); if(unlock != null) unlocksCard = Card.get(unlock); }
public ResourceType(JSONTable template, ContentManager content) { name = template.getString("name"); string textureName = template.getString("texture"); texture = (textureName != null) ? content.Load<Texture2D>(textureName) : null; }
public Blueprint(CityLevel cityLevel, JSONTable template) : base(cityLevel, TextureCache.blueprint, template.getVector2("pos"), TextureCache.blueprint.Size()) { this.unlocks = template.getString("unlocks"); this.price = template.getInt("price", 0); this.label = template.getString("label"); this.canDrag = false; Init(); }
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 Compiler(JSONTable settings) { this.settings = settings; this.operators = new List <Operator>(); int precedence = 0; foreach (string s in settings.getArray("OPERATORS").asStrings()) { foreach (char c in s) { symbols.Add(c); } operators.Add(new Operator(s, precedence)); precedence++; } string startPatternName = settings.getString("START", null); if (startPatternName != null) { startPattern = settings.getArray(startPatternName); } else { startPattern = settings.getArray("START", null); } }
public static CityObject FromTemplate(CityLevel cityLevel, JSONTable template) { string type = template.getString("type"); switch (type) { case "inbox": return(new ChemicalInbox(cityLevel, template)); case "outbox": return(new ChemicalOutbox(cityLevel, template)); case "factory": return(new ChemicalFactory(cityLevel, template)); case "silo": return(new ChemicalSilo(cityLevel, template)); case "crystalOutbox": return(new CrystalOutbox(cityLevel, template)); case "buildingSite": return(new BuildingSite(cityLevel, template)); case "plinth": return(new WeaponPlinth(cityLevel, template)); case "blueprint": return(new Blueprint(cityLevel, template)); default: throw new ArgumentException("Unknown CityObject type \"" + type + "\""); } }
public WeaponPlinth(CityLevel cityLevel, JSONTable template) : base(cityLevel, TextureCache.plinth, template.getVector2("pos"), TextureCache.plinth.Size()) { this.weapon = Game1.instance.inventory.unlockableWeapons[template.getString("weapon")]; this.price = template.getInt("price", 0); this.canDrag = false; this.crystals = template.getInt("crystals", 0); Init(); }
public ConvergeActivatedAbilitySpec(JSONTable template, ContentManager Content) { frame = Content.Load <Texture2D>(template.getString("frame", "abilityFrame")); icon = Content.Load <Texture2D>(template.getString("icon")); text = template.getString("text", "").InsertLineBreaks(Game1.font, ConvergeUIAbility.AbilityTooltipWidth - 15); textHeight = (int)Game1.font.MeasureString(text).Y; effect = ConvergeCommand.New(template.getArray("effect"), Content); frameColor = template.getString("frameColor", "FFFFFF").toColor(); if (template.hasKey("attackEffect")) { attackEffect = ConvergeCommand.New(template.getArray("attackEffect"), Content); } if (template.hasKey("target")) { target = ConvergeSelector.New(template.getProperty("target")); } manacost = new ConvergeManaAmount(template.getString("manaCost", "")); uses = template.getInt("uses", 0); altCost = 0; foreach (string altcostString in template.getArray("altCost", JSONArray.empty).asStrings()) { altCost |= (ConvergeAltCost)Enum.Parse(typeof(ConvergeAltCost), altcostString); } JSONArray zoneTemplate = template.getArray("activeZones", null); if (zoneTemplate == null) { activeZones = ConvergeZoneId.Attack | ConvergeZoneId.Defense | ConvergeZoneId.Home; } else { activeZones = 0; foreach (string zoneName in zoneTemplate.asStrings()) { activeZones |= (ConvergeZoneId)Enum.Parse(typeof(ConvergeZoneId), zoneName); } } }
public void Init(JSONTable template, ContentManager Content) { string artName = template.getString("art"); art = Content.Load <Texture2D>(artName); name = template.getString("name", artName); // for now text = template.getString("text", "").InsertLineBreaks(Game1.font, ConvergeUIObject.CardTooltipWidth - 15); textHeight = (int)Game1.font.MeasureString(text).Y; cardType = 0; foreach (string name in template.getArray("cardType").asStrings()) { cardType |= (ConvergeCardType)Enum.Parse(typeof(ConvergeCardType), name); } power = template.getInt("power", 0); toughness = template.getInt("toughness", 0); string producesTemplate = template.getString("produces", ""); if (producesTemplate != "") { produces = new ConvergeManaAmount(template.getString("produces")); } string costTemplate = template.getString("cost", ""); if (costTemplate != "") { cost = new ConvergeManaAmount(costTemplate); } keywords = 0; foreach (string name in template.getArray("keywords", JSONArray.empty).asStrings()) { keywords |= (ConvergeKeyword)Enum.Parse(typeof(ConvergeKeyword), name); } activatedAbilities = new List <ConvergeActivatedAbilitySpec>(); foreach (JSONTable abilityTemplate in template.getArray("activated", JSONArray.empty).asJSONTables()) { activatedAbilities.Add(new ConvergeActivatedAbilitySpec(abilityTemplate, Content)); } triggeredAbilities = new List <ConvergeTriggeredAbilitySpec>(); foreach (JSONTable abilityTemplate in template.getArray("triggered", JSONArray.empty).asJSONTables()) { triggeredAbilities.Add(new ConvergeTriggeredAbilitySpec(abilityTemplate, Content)); } if (template.hasKey("effect")) { actionEffect = ConvergeCommand.New(template.getArray("effect"), Content); } if (template.hasKey("target")) { actionTarget = ConvergeSelector.New(template.getProperty("target")); } }
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 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 ConvergeTriggeredAbilitySpec(JSONTable template, ContentManager Content) { triggerType = (ConvergeTriggerType)Enum.Parse(typeof(ConvergeTriggerType), template.getString("trigger")); triggerPlayer = ConvergeSelector.New(template.getProperty("triggerPlayer", null)); triggerSubject = ConvergeSelector.New(template.getProperty("triggerSubject", null)); triggerTarget = ConvergeSelector.New(template.getProperty("triggerTarget", null)); condition = ConvergeSelector.New(template.getProperty("condition", null)); effect = ConvergeCommand.New(template.getArray("effect"), 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"); }