コード例 #1
0
        public static DamageController Atk(ITriggerDelegate triggerDelegate,
                                           string id
                                           , string damageId
                                           , string teamId
                                           , FrameEventInfo.ParentType parentType
                                           , PrimitiveType primitiveType
                                           , Vector3 pos
                                           , Vector3 size
                                           , Vector3 orientation
                                           , HitType hitType
                                           , Vector3 hitMoveBy

                                           , DamageDirectionType damageDirectionType
                                           , DamageEffectType damageEffectType
                                           , AtkPropertyType atkPropertyType
                                           , float atk
                                           , float poiseCut
                                           , float Mass
                                           , float criticalRate = 0
                                           , float criticalAtk  = 1)
        {
            DamageController damageController = DamageManager.Instance.CreateDamage(

                pos.RotateFrontTo(orientation)

                , triggerDelegate.transform, parentType
                , size
                , primitiveType)

                                                // 设置DamageControllerId
                                                .SetId(id)
                                                //设置damageid
                                                .SetDamageId(damageId)
                                                // 设置队伍 add by TangJian 2018/10/9 16:17
                                                .SetTeamId(teamId)

                                                // 设置拥有者 add by TangJian 2018/10/9 16:43
                                                .SetOwner(triggerDelegate.gameObject)

                                                // 设置触发器代理 add by TangJian 2018/10/9 16:55
                                                .SetTriggerDelegate(triggerDelegate)

                                                // 设置攻击类型 add by TangJian 2018/10/9 17:29
                                                .SetHitType(hitType)

                                                // 设置攻击朝向 add by TangJian 2018/10/9 17:30
                                                .SetDirection(orientation)

                                                // 设置击退距离 add by TangJian 2018/10/9 17:30
                                                .SetMoveBy(hitMoveBy.RotateFrontTo(orientation));

            damageController.setDamageDirectionType(damageDirectionType);

            // 伤害效果类型 add by TangJian 2017/08/16 15:33:01
            damageController.SetDamageEffectType(damageEffectType);

            // 攻击属性类型
            damageController.SetAtkPropertyType(atkPropertyType);

            // 削韧 add by TangJian 2018/12/12 12:32
            damageController.SetPoiseCut(poiseCut);
            //攻击质量
            damageController.SetDamageMass(Mass);

            // 暴击 add by TangJian 2019/3/25 15:20
            if (Tools.RandomWithWeight(criticalRate.Range(0, 1), 1 - criticalRate.Range(0, 1)) == 0)
            {
                damageController.SetCritical(true);
            }

            // 设置攻击力 add by TangJian 2018/12/18 20:41
            switch (atkPropertyType)
            {
            case AtkPropertyType.physicalDamage:
            {
                if (damageController.IsCritical())
                {
                    damageController.SetAtk(atk * criticalAtk);
                }
                else
                {
                    damageController.SetAtk(atk);
                }
            }
            break;

            case AtkPropertyType.magicalDamage:
            {
                damageController.SetMagical(atk);
            }
            break;

            case AtkPropertyType.mixDamage:
            {
                damageController.SetMagical(atk);
            }
            break;

            default:
            {
                damageController.SetAtk(atk);
            }
            break;
            }

            return(damageController);
        }