美文网首页
添加超杀机制(Overkill)

添加超杀机制(Overkill)

作者: 慕海生 | 来源:发表于2020-09-05 13:33 被阅读0次

1.超杀机制的识别

1.silverfish_HB.cs

getMinions()方法下:

        m.Overkill= (entitiy.GetTag(GAME_TAG.OVERKILL) == 0) ? false : true;

在if (TritonHs.DoWeHaveWeapon)下添加

                ownWeapon.Overkill = (weapon.GetTag(GAME_TAG.OVERKILL) == 1) ? true : false;

同理在if (TritonHs.DoesEnemyHasWeapon)下添加

                enemyWeapon.Overkill = (weapon.GetTag(GAME_TAG.OVERKILL) == 1) ? true : false;

2.Minion.cs

Minion类中添加Overkill属性:

        private bool _overkill = false;
        public bool Overkill { get => _overkill; set => _overkill = value; }

public Minion(Minion m)方法下:

            this.Overkill = m.Overkill;// 超杀

public void setMinionToMinion(Minion m)方法下:

            this.Overkill = m.Overkill;// 超杀

public void becomeSilence(Playfield p)方法:

            Overkill = false;

3.CardDB.cs

同Minion.cs

如果编译失败,属性初始值应写为

            private bool _overkill = false;
            /// <summary>
            /// 超杀
            /// </summary>
            public bool Overkill
            {
                get { return _overkill; }
                set { _overkill = value; }
            }

构造函数中读取carddefs的地方:

                            case 923: c.Overkill = value == 1; break;//overkill

2.虚函数的增加

SimTemplate.cs:

        /// <summary>
        /// 超杀效果(武器)
        /// </summary>
        /// <param name="p">场面</param>
        /// <param name="w">武器</param>
        public virtual void OnOverkill(Playfield p, Weapon w)
        {
            return;
        }

        /// <summary>
        /// 超杀效果(随从)
        /// </summary>
        /// <param name="p">场面</param>
        /// <param name="m">具有超杀效果的随从</param>
        public virtual void OnOverkill(Playfield p, Minion m)
        {
            return;
        }

3.超杀机制的实现

Playfiled.cs:

在minionAttacksMinion方法下:
在//defender gets dmg下添加

            bool defenderHasDivineshild = defender.divineshild;//攻击前,被攻击随从是否具有圣盾

            if (defender.isHero)//target is enemy hero
            {
                doDmgTriggers();
                return;
            }

下添加

            #region 随从或武器攻击后触发超杀效果
            if (oldHp < attackerAngr && !defenderHasDivineshild)
            {
                if (!attacker.isHero)
                {
                    attacker.handcard.card.sim_card.OnOverkill(this, attacker); 
                }
                else
                {
                    Weapon weapon = attacker.own ? this.ownWeapon : this.enemyWeapon;
                    weapon.card.sim_card.OnOverkill(this, weapon);
                }
            }
            #endregion

解释一下定义defenderHasDivineshild的原因:超杀在攻击伤害结算之后进行结算,此时原有圣盾效果已经失效,所以必须在攻击前定义

转载来源https://www.cnblogs.com/dch0319/p/13544577.html
仅供个人研究学习之用

相关文章

网友评论

      本文标题:添加超杀机制(Overkill)

      本文链接:https://www.haomeiwen.com/subject/sgtfektx.html