Beispiel #1
0
        public Effect Trigger(CardEffectType trigger)
        {
            var text = string.Format("{0}:", trigger.ToString().Replace('_', ' '));

            Tokens.Add(new EffectToken(EffectTokenType.Trigger, string.Empty, text, text, string.Empty));
            return(this);
        }
Beispiel #2
0
        bool removeWhenExitArea         = true;          //离场是否移除

        public CardEffect(CardBase effectCard, CardBase effectedCard, CardEffectType cardEffectType, int value)
        {
            this.effectCard     = effectCard;
            this.effectedCard   = effectedCard;
            this.cardEffectType = cardEffectType;
            this.value          = value;
        }
    private void applyEffectToPlayer(ref PlayerGunState state, CardEffectType type, int val, bool positive)
    {
        switch (type)
        {
        case CardEffectType.Aim:
            state.Aim += val * (positive ? 1.0f : -1.0f);
            state.Aim  = Mathf.Clamp(state.Aim, -10.0f, 10.0f);
            break;

        case CardEffectType.Guidance:
            state.Guidance += val * (positive ? 1.0f : -1.0f);
            state.Guidance  = Mathf.Clamp(state.Guidance, -10.0f, 10.0f);
            break;

        case CardEffectType.Multi:
            state.Multi += val * (positive ? 1 : -1);
            state.Multi  = Mathf.Clamp(state.Multi, 1, 100);
            break;

        case CardEffectType.Rate:
            state.Rate += val * (positive ? 1.0f : -1.0f);
            state.Rate  = Mathf.Clamp(state.Rate, -10.0f, 10.0f);
            break;

        case CardEffectType.Size:
            state.Size += val * (positive ? 1.0f : -1.0f);
            state.Size  = Mathf.Clamp(state.Size, -10.0f, 10.0f);
            break;
        }
    }
Beispiel #4
0
        public string GetDescription(CardEffectType cardEffectType)
        {
            string description = "";

            if (healthChange != 0)
            {
                description  = cardEffectType == CardEffectType.ON_DESTROY ? "On destroy: " : "On end turn: ";
                description += (healthChange > 0 ? "Repair " : "Deals ") + Mathf.Abs(healthChange) + " damage to ";

                if (cardEffectTarget == CardEffectTarget.TANK_PART)
                {
                    description += tankPart;
                }
                else if (cardEffectTarget == CardEffectTarget.RANDOM_TANK_PART)
                {
                    description += " random section";
                }
                else if (cardEffectTarget == CardEffectTarget.PLAYER_TANK)
                {
                    description += " tank";
                }
            }

            return(description);
        }
Beispiel #5
0
        /// <summary>
        /// 添加卡牌效果
        /// </summary>
        public CardEffect AddCardEffect(CardBase cardBase, CardEffectType cardEffectType, int value)
        {
            CardEffect cardEffect = new CardEffect(cardBase, this, cardEffectType, value);

            cardEffectedMap.Add(cardEffect);
            RecalculationCardByCardEffect();
            return(cardEffect);
        }
Beispiel #6
0
        public Spell(int id)
        {
            ID = id;
            XMLFile file = new XMLFile("Data/Spell.xml");

            foreach (XMLSection spell in file.GetSections()[0].GetSections("spell"))
            {
                if (Convert.ToInt32(spell.GetAttribute("id")) == id)
                {
                    Name          = spell.Get("name", "Unknown");
                    Description   = spell.Get("description", "Description not found.");
                    voluntary     = spell.Get("voluntary", true);
                    Level         = spell.Get("level", 0);
                    spelltype     = spell.GetEnum("type", CardEffectType.INSTANT);
                    spelltrigger  = spell.GetEnum("trigger", CardEffectTrigger.IMMEDIATE);
                    triggeramount = spell.Get("triggeramount", 0);

                    effects = new List <CardEffect>();
                    foreach (XMLSection e in spell.GetSections("effect"))
                    {
                        CardEffect effect = new CardEffect();

                        effect.Range            = e.GetEnum("range", CardEffectTargetRange.ANY);
                        effect.Action           = e.GetEnum <CardEffectAction>("action");
                        effect.TargetAssignment = e.GetEnum("assignment", CardEffectTargetAssignment.NONE);
                        if (effect.TargetAssignment == CardEffectTargetAssignment.PREVIOUS && effects.Count > 0)
                        {
                            effect.TargetType = effects.Last().TargetType;
                        }
                        else
                        {
                            effect.TargetType = e.GetEnum <CardEffectTargetType>("target");
                        }
                        effect.EffectStat = e.GetEnum("stat", CardEffectStat.NULL);
                        effect.Amount     = e.Get("amount", 0);

                        effect.Requirements = new List <CardEffectTargetRequirement>();
                        foreach (XMLSection r in e.GetSections("requirement"))
                        {
                            CardEffectTargetRequirement requirement = new CardEffectTargetRequirement();
                            requirement.Stat    = r.GetEnum <CardEffectStat>("stat");
                            requirement.Maximum = r.Get("maximum", 9999);
                            requirement.Minimum = r.Get("minimum", 0);
                            effect.Requirements.Add(requirement);
                        }

                        effects.Add(effect);
                    }

                    break;
                }
            }
        }
Beispiel #7
0
 public void InitCardInfo(CardModel cardModel, int arrayIndex, Func <Land, int> CardFunc)
 {
     this.cardId     = cardModel.cardID;
     BG.sprite       = Resources.Load <Sprite>(cardModel.spritePath);
     goldCost.text   = cardModel.costGold.ToString();
     cardName.text   = cardModel.cardName;
     isSelfCard      = cardModel.isSelfCard == 1;
     this.arrayIndex = arrayIndex;
     triggerTime     = (BattleCardTriggerTime)Enum.Parse(typeof(BattleCardTriggerTime), cardModel.cardTriggerTime);
     this.CardFunc   = CardFunc;
     cardEffectType  = (CardEffectType)Enum.Parse(typeof(CardEffectType), cardModel.cardEffectType);
 }
Beispiel #8
0
        private Color ColorFromEffectType(CardEffectType effectType)
        {
            if (effectType == CardEffectType.ATTACK)
            {
                return(ecsManager.GetAnimationSystem <HighlightDisplaySystem>().orangeColor);
            }
            else if (effectType == CardEffectType.MOVE)
            {
                return(ecsManager.GetAnimationSystem <HighlightDisplaySystem>().darkGreenColor);
            }

            return(Color.grey);
        }
Beispiel #9
0
 public CardModel(CardPrototype prototype)
 {
     this.prototype = prototype;
     id             = prototype.id;
     name           = prototype.name;
     description    = prototype.description.Replace("\\n", "\n"); // Allow newlines
     animation      = prototype.animation;
     rarity         = prototype.rarity;
     cost           = prototype.cost;
     effect         = prototype.effect;
     statGainType   = prototype.statGainType;
     statGainAmount = prototype.statGainAmount;
     numCardsToDraw = prototype.numCardsToDraw;
 }
Beispiel #10
0
 public static Effect New(CardEffectType effectType, LayoutType layoutType)
 {
     return(new Effect(effectType, layoutType));
 }
Beispiel #11
0
 public Effect(CardEffectType effectType, LayoutType layoutType)
 {
     this.EffectType = effectType;
     this.LayoutType = layoutType;
     this.Tokens     = new List <EffectToken>();
 }