Esempio n. 1
0
        //百分比交换
        void PercentExchange(List <AttrbuteConfig> used, NPCData self, NPCData tar, float Min, WarSrcAnimParam SrcParam, WarTarAnimParam TarParam)
        {
            int cnt = used.Count;

            if (cnt <= 0)
            {
                return;
            }

            for (int i = 0; i < cnt; ++i)
            {
                AttrbuteConfig att = used[i];

                NPCRuntimeData selfRt = self.rtData;
                NPCRuntimeData tarRt  = tar.rtData;

                NPCConfigData selfCfg = self.configData;
                NPCConfigData tarCfg  = tar.configData;

                float selfCfgVal = selfCfg.getValue <float>(att.note);
                float tarCfgVal  = tarCfg.getValue <float>(att.note);

                float selfRtVal = selfRt.getFloatValue(att.note);
                float tarRtVal  = tarRt.getFloatValue(att.note);
                //自己的值
                float self_att1_per = selfRtVal / selfCfgVal;
                //敌人的值
                float tar_att1_per = tarRtVal / tarCfgVal;
                //敌人值的下限
                float tar_att1_per_min = Min;


                float tarVal = 0f;
                //如果传递过去的百分比大于下限,则将自己的值和敌人直接替换
                if (self_att1_per > tar_att1_per_min)
                {
                    tarVal = tarCfgVal * self_att1_per;
                }
                else
                {
                    tarVal = tarCfgVal * tar_att1_per_min;
                }

                if (att.type == "float")
                {
                    tarRt.setValue(att.note, tarVal);
                }
                else
                {
                    tarRt.setValue(att.note, (int)tarVal);
                }

                float selfVal = selfCfgVal * tar_att1_per;
                if (att.type == "float")
                {
                    selfRt.setValue(att.note, selfVal);
                }
                else
                {
                    selfRt.setValue(att.note, (int)selfVal);
                }

                ///
                /// 血量的信息需要特别的传递给UI
                ///
                if (att.note == "curHp")
                {
                    SrcParam.described.srcEnd = new EndResult()
                    {
                        param1 = (int)(selfVal - selfRtVal),
                        param2 = TarParam.described.target,
                    };

                    TarParam.described.targetEnd = new EndResult()
                    {
                        param1 = (int)(tarVal - tarRtVal),
                        param2 = TarParam.described.target,
                    };
                }
            }
        }
Esempio n. 2
0
        //固定比例交换
        void FixtureExchange(List <AttrbuteConfig> used, NPCRuntimeData selfRt, NPCRuntimeData tarRt, int Min, WarSrcAnimParam SrcParam, WarTarAnimParam TarParam)
        {
            int cnt = used.Count;

            if (cnt <= 0)
            {
                return;
            }

            for (int i = 0; i < cnt; ++i)
            {
                AttrbuteConfig att = used[i];
                //自己的值
                float self_att1_val = selfRt.getFloatValue(att.note);
                //敌人的值
                float tar_att1_val = tarRt.getFloatValue(att.note);
                //敌人值的下限
                float tar_att1_val_min = (float)Min;

                float final_tar_val = 0F;

                //如果传递过去的值大于下限,则将自己的值和敌人直接替换
                if (self_att1_val > tar_att1_val_min)
                {
                    final_tar_val = self_att1_val;
                }
                else
                {
                    //如果传递过去的值小于下限,则将敌人的值给自己,敌人的为最低下限
                    final_tar_val = tar_att1_val_min;
                }

                //敌人
                if (att.type == "float")
                {
                    tarRt.setValue(att.note, (FloatFog)final_tar_val);
                }
                else
                {
                    tarRt.setValue(att.note, (Int32Fog)final_tar_val);
                }

                //自己
                if (att.type == "float")
                {
                    selfRt.setValue(att.note, (FloatFog)tar_att1_val);
                }
                else
                {
                    selfRt.setValue(att.note, (Int32Fog)tar_att1_val);
                }

                ///
                /// 血量的信息需要特别的传递给UI
                ///
                if (att.note == "curHp")
                {
                    SrcParam.described.srcEnd = new EndResult()
                    {
                        param1 = (int)(tar_att1_val - self_att1_val),
                        param2 = TarParam.described.target,
                    };

                    TarParam.described.targetEnd = new EndResult()
                    {
                        param1 = (int)(final_tar_val - tar_att1_val),
                        param2 = TarParam.described.target,
                    };
                }
            }
        }