Beispiel #1
0
        private BattleInitClass()
        {
            var asm = Assembly.GetExecutingAssembly();

            foreach (var b in asm.GetTypes())
            {
                if (b.IsSubclassOf(typeof(SkillLogic)))
                {
                    //自动填充SkillLogics
                    SkillLogic ins = asm.CreateInstance(b.FullName) as SkillLogic;
                    BattleModule.SkillLogics.Add(b.Name, ins);
                }
                else if (b.IsSubclassOf(typeof(SkillLogicState)))
                {
                    //自动填充SkillLogicStates
                    SkillLogicState ins = asm.CreateInstance(b.FullName) as SkillLogicState;
                    BattleModule.SkillLogicStates.Add(b.Name, ins);
                }
                else if (b.IsSubclassOf(typeof(TargetSelect)))
                {
                    //自动填充TargetSelect
                    TargetSelect ins = asm.CreateInstance(b.FullName) as TargetSelect;
                    BattleModule.TargetSelects.Add(b.Name, ins);
                }
                else if (b.IsSubclassOf(typeof(TargetType)))
                {
                    //自动填充TargetType
                    TargetType ins = asm.CreateInstance(b.FullName) as TargetType;
                    BattleModule.TargetTypes.Add(b.Name, ins);
                }
                else if (b.IsSubclassOf(typeof(BuffLogicState)))
                {
                    //自动填充BuffLogicStates
                    BuffLogicState ins = asm.CreateInstance(b.FullName) as BuffLogicState;
                    BattleModule.BuffLogicStates.Add(b.Name, ins);
                }
                else if (b.IsSubclassOf(typeof(BuffLogic)))
                {
                    //自动填充BuffLogicStates
                    BuffLogic ins = asm.CreateInstance(b.FullName) as BuffLogic;
                    BattleModule.BuffLogics.Add(b.Name, ins);
                }
                else if (b.IsSubclassOf(typeof(BuffSuperpositionLogic)))
                {
                    //自动填充BuffSuperpositionLogics
                    BuffSuperpositionLogic ins = asm.CreateInstance(b.FullName) as BuffSuperpositionLogic;
                    BattleModule.BuffSuperpositionLogics.Add(b.Name, ins);
                }
                else if (b.IsSubclassOf(typeof(SkillBulletMovingLogic)))
                {
                    //自动填充SkillBulletMovingLogic
                    SkillBulletMovingLogic ins = asm.CreateInstance(b.FullName) as SkillBulletMovingLogic;
                    BattleModule.SkillBulletMovingLogics.Add(b.Name, ins);
                }
                else if (b.IsSubclassOf(typeof(SkillBulletCollisionLogic)))
                {
                    //自动填充SkillBulletCollisionLogic
                    SkillBulletCollisionLogic ins = asm.CreateInstance(b.FullName) as SkillBulletCollisionLogic;
                    BattleModule.SkillBulletCollisionLogics.Add(b.Name, ins);
                }
            }
        }
Beispiel #2
0
        public static bool AddBuff(SkillObj tarObj, SkillObj srcObj, int newBuffId, BattleReason reason)
        {
            if (tarObj == null)
            {
                return(false);
            }
            var buffConfig = tarObj.GetBuffConfig(newBuffId);

            if (buffConfig == null)
            {
                return(false);
            }

            var buffSuperpositionLogicId = tarObj.GetBuffSuperpositionLogicId(buffConfig);

            if (!BuffSuperpositionLogics.ContainsKey(buffSuperpositionLogicId))
            {
                return(false);
            }
            BuffSuperpositionLogic buffSuperpositionLogic = BuffSuperpositionLogics[buffSuperpositionLogicId];

            var          buffRet = buffSuperpositionLogic.OnBuffSuperposition(tarObj, srcObj, reason, buffConfig);
            BuffInfo_New buff    = buffRet.buff;

            if (buffRet.bType == BuffSuperpositionType.Refresh)
            {
                var buffLogicId = tarObj.GetBuffLogicId(buffConfig);
                if (!BuffLogics.ContainsKey(buffLogicId))
                {
                    return(false);
                }
                BuffLogic buffLogic = BuffLogics[buffLogicId];
                buffLogic.InitBuffInfo(tarObj, srcObj, reason, buff, buffConfig, false);
            }
            else if (buffRet.bType == BuffSuperpositionType.Add)
            {
                var buffLogicId = tarObj.GetBuffLogicId(buffConfig);
                if (!BuffLogics.ContainsKey(buffLogicId))
                {
                    return(false);
                }
                BuffLogic buffLogic = BuffLogics[buffLogicId];
                buffLogic.InitBuffInfo(tarObj, srcObj, reason, buff, buffConfig);

                //先从src方进行修正
                if (srcObj != null)
                {
                    var srcSkillList = srcObj.GetSkillList();
                    var srcBuffList  = srcObj.GetBuffList();
                    if (srcSkillList != null)
                    {
                        foreach (var skillInfo in srcSkillList)
                        {
                            int             skillId     = srcObj.GetSkillID(skillInfo);
                            SkillConfig_New skillConfig = srcObj.GetSkillConfig(skillId);
                            var             logic       = GetSkillLogic(skillInfo, srcObj);
                            logic.OnSendBuff(tarObj, srcObj, buff, skillInfo, skillConfig);
                        }
                    }
                    if (srcBuffList != null)
                    {
                        foreach (var buffInfo in srcBuffList)
                        {
                            int            buffId        = srcObj.GetBuffID(buffInfo);
                            BuffConfig_New srcBuffConfig = srcObj.GetBuffConfig(buffId);
                            var            logic         = GetBuffLogic(buffInfo, srcObj);
                            logic.OnSendBuff(tarObj, srcObj, buff, buffInfo, srcBuffConfig);
                        }
                    }
                }
                {
                    var tarSkillList = tarObj.GetSkillList();
                    var tarBuffList  = tarObj.GetBuffList();
                    if (tarSkillList != null)
                    {
                        foreach (var skillInfo in tarSkillList)
                        {
                            int             skillId     = tarObj.GetSkillID(skillInfo);
                            SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId);
                            var             logic       = GetSkillLogic(skillInfo, tarObj);
                            logic.OnAttachBuff(tarObj, srcObj, buff, skillInfo, skillConfig);
                        }
                    }
                    if (tarBuffList != null)
                    {
                        foreach (var buffInfo in tarBuffList)
                        {
                            int            buffId        = tarObj.GetBuffID(buffInfo);
                            BuffConfig_New tarBuffConfig = tarObj.GetBuffConfig(buffId);
                            var            logic         = GetBuffLogic(buffInfo, tarObj);
                            logic.OnAttachBuff(tarObj, srcObj, buff, buffInfo, tarBuffConfig);
                        }
                    }
                }
                buffLogic.OnAttach(tarObj, srcObj, buff, buffConfig);
                tarObj.AddTempBuffList(buff);
            }
            tarObj.NotifyBuffInfo(buff, BattleInfoNotifyType.All_Buff, BattleNotifyTime.TickEnd);
            return(true);
        }