public void Add(ConvergeManaAmount other) { for (int Idx = 0; Idx < amounts.Length; ++Idx) { amounts[Idx] += other.amounts[Idx]; } }
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 bool CanSpend(ConvergeManaAmount cost) { if (cost == null) { return(true); } for (int Idx = 0; Idx < amounts.Length; ++Idx) { if (amounts[Idx] < cost.amounts[Idx]) { return(false); } } return(true); }
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 bool TrySpend(ConvergeManaAmount cost) { if (cost == null) { return(true); } if (!CanSpend(cost)) { return(false); } for (int Idx = 0; Idx < amounts.Length; ++Idx) { amounts[Idx] -= cost.amounts[Idx]; } return(true); }
public ConvergeCommand_ProduceMana(JSONArray template) { produced = new ConvergeManaAmount(template.getString(1)); }
public bool TryPayCost(ConvergeManaAmount cost) { return(resources.TrySpend(cost)); }
public bool CanPayCost(ConvergeManaAmount cost) { return(resources.CanSpend(cost)); }