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 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 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); }
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 static List<ResourceAmount> createList(JSONTable template) { List<ResourceAmount> costs = new List<ResourceAmount>(); if (template != null) { foreach (string key in template.Keys) { costs.Add(new ResourceAmount(ResourceType.get(key), template.getInt(key))); } } return costs; }
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 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 ChemicalOutbox(CityLevel cityLevel, JSONTable template) : base(cityLevel, TextureCache.outbox, template.getVector2("pos"), TextureCache.outbox.Size()) { this.signature = new ChemicalSignature(template.getArray("chemical")); this.price = template.getInt("price"); Init(); }
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 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"); }
public CrystalOutbox(CityLevel cityLevel, JSONTable template) : base(cityLevel, TextureCache.depot, template.getVector2("pos"), TextureCache.depot.Size()) { this.signature = new ChemicalSignature(template.getArray("chemical")); this.numCrystals = template.getInt("crystals", 1); Init(); }