Beispiel #1
0
        public void Init(Unit sourceUnit, string spellId,
                         Unit targetUnit, CfgSpellData cfgSpellData, Hashtable instanceArgDict)
        {
            base.Init();
            this.sourceUnit      = sourceUnit;
            this.spellId         = spellId;
            this.targetUnit      = targetUnit;
            this.cfgSpellData    = cfgSpellData;
            this.instanceArgDict = instanceArgDict;

            this.originPosition =
                this.instanceArgDict.GetOrGetDefault2 <Vector3>("origin_position", () => this.sourceUnit.GetPosition());
            this.transmitArgDict   = this.instanceArgDict.GetOrGetDefault2("transmit_arg_dict", () => new Hashtable());
            this.attackDir         = this.transmitArgDict.Get <Vector3>(attackDir);
            this.newSpellTriggerId = this.transmitArgDict.Get <string>("new_spell_trigger_id");            // 通过哪个trigger_id启动的技能

            this.argDict                  = DoerAttrParserUtil.ConvertTableWithTypeString(this.cfgSpellData._arg_dict);
            this.isCanMoveWhileCast       = this.cfgSpellData.is_can_move_while_cast;
            this.isSpellAnimationFinished = "触发".Equals(this.cfgSpellData.cast_type);

            if (this.isCanMoveWhileCast && this.sourceUnit != null && !this.sourceUnit.IsDead())
            {
                this.sourceUnit.SetIsMoveWithMoveAnimation(false);
            }
            this.InitCounter();
        }
        public bool __IsUnitMatchCondition(Unit sourceUnit, Unit targetUnit, bool isControl,
                                           CfgSpellData cfgSpellData,
                                           Type spellClass)
        {
            if (targetUnit.IsDead())
            {
                return(false);
            }
            if (!sourceUnit.IsConfused())
            {
                if ("enemy".Equals(cfgSpellData.target_type) && targetUnit.IsInvincible())
                {
                    return(false);
                }
                if (cfgSpellData.target_type.IsNullOrWhiteSpace() && !"all".Equals(cfgSpellData.target_type))
                {
                    if (!Client.instance.combat.unitManager.CheckFaction(sourceUnit.GetFaction(), targetUnit.GetFaction(),
                                                                         cfgSpellData.target_type))
                    {
                        return(false);
                    }
                }
            }

            if (!spellClass.InvokeMethod <bool>("IsUnitMatchCondition", false, sourceUnit, cfgSpellData.id, targetUnit,
                                                cfgSpellData, isControl))
            {
                return(false);
            }
            return(true);
        }
        public List <Unit> RecommendSpellRule(Unit sourceUnit, Unit targetUnit,
                                              CfgSpellData cfgSpellData, Vector3 originPosition, List <Unit> targetUnitList = null)
        {
            //当前敌人
            //随机x个敌人
            //生命最低的x个人敌人
            //全体敌人
            //自己
            //随机x个队友
            //生命最低的x个队友
            //全体队友
            //召唤单位
            //场上所有人(不分敌友)
            if (targetUnit == null)
            {
                return(null);
            }
            if (cfgSpellData._select_unit_arg_dict.IsNullOrEmpty())
            {
                return targetUnitList ?? new List <Unit>()
                       {
                           targetUnit
                       }
            }
            ;

            var selectUnitArgDict = DoerAttrParserUtil.ConvertTableWithTypeString(cfgSpellData._select_unit_arg_dict);
            var selectUnitFaction = selectUnitArgDict.Get <string>("select_unit_faction");
            var selectUnitCount   = selectUnitArgDict.GetOrGetDefault2 <int>("select_unit_count", () => 1000);
            var scope             = SpellConst.Select_Unit_Faction_Dict[selectUnitFaction];

            var rangeInfo = new Hashtable();

            rangeInfo["mode"]   = "circle";
            rangeInfo["radius"] = cfgSpellData.range;
            var conditionDict = new Hashtable();

            conditionDict["order"]      = "distance";
            conditionDict["origin"]     = originPosition;
            conditionDict["faction"]    = sourceUnit.GetFaction();
            conditionDict["scope"]      = scope;
            conditionDict["range_info"] = rangeInfo;
            targetUnitList = targetUnitList ?? Client.instance.combat.unitManager.SelectUnit(conditionDict);

            var count         = selectUnitCount;
            var newTargetList = new List <Unit>();

            //TODO select_unit
            //TODO select_unit
            newTargetList = targetUnitList.Sub(0, Math.Min(targetUnitList.Count, count));
            return(newTargetList.Count == 0 ? new List <Unit>()
            {
                targetUnit
            } : newTargetList);
        }
Beispiel #4
0
        public bool CanBreakCurrentSpell(string newSpellId, CfgSpellData newCfgSpellData = null)
        {
            if (this.currentAttack == null)
            {
                return(true);
            }

            newCfgSpellData = newCfgSpellData ?? CfgSpell.Instance.get_by_id(newSpellId);
            if (("法术".Equals(newCfgSpellData.type) && "普攻".Equals(this.currentAttack.cfgSpellData.type)) ||          //法术可以打断普攻
                "触发".Equals(newCfgSpellData.cast_type))
            {
                return(true);
            }
            return(this.currentAttack.isPastBreakTime);
        }