コード例 #1
0
 public void Add(ConvergeManaAmount other)
 {
     for (int Idx = 0; Idx < amounts.Length; ++Idx)
     {
         amounts[Idx] += other.amounts[Idx];
     }
 }
コード例 #2
0
        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"));
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
                }
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public ConvergeCommand_ProduceMana(JSONArray template)
 {
     produced = new ConvergeManaAmount(template.getString(1));
 }
コード例 #7
0
 public bool TryPayCost(ConvergeManaAmount cost)
 {
     return(resources.TrySpend(cost));
 }
コード例 #8
0
 public bool CanPayCost(ConvergeManaAmount cost)
 {
     return(resources.CanSpend(cost));
 }