Exemple #1
0
        public void OnCastSpell()
        {
            if (IsMoving)
            {
                return;
            }

            if (null == mAttackTarget || !mAttackTarget.CanBeAttacked())
            {
                ChangeState(ePlayerState.Idle);
                return;
            }
            //if (Spell(mCurrentSpellID, mAttackTarget) == eSkillResult.OK)
            eSkillResult ret = eSkillResult.OK;

            if (CastSpell(mCurrentSpellID, mAttackTarget.Id, ref ret))
            {
                mCurrSpellNode++;
                ChangeState(ePlayerState.WaitCoolDown);
            }
            else
            {
                ChangeState(ePlayerState.Idle);
            }
        }
Exemple #2
0
        /// <summary>
        /// 得到仇恨列表里仇恨值最大的可攻击对象
        /// </summary>
        public ulong GetFirstEnmityCanHit()
        {
            RoleActor target = GetTarget(mMaxEnmityObjID);

            if (null != target && target.CanBeAttacked())
            {
                return(mMaxEnmityObjID);
            }

            int tmp = 0;

            target = null;
            for (var i = 0; i < mEnmityList.Count(); i++)
            {
                EnmityInfo ite = mEnmityList[i];
                if (ite.mEnmityValue > tmp)
                {
                    RoleActor r = GetTarget(ite.playerID);
                    if (null != r && r.CanBeAttacked())
                    {
                        target = r;
                    }
                }
            }
            if (null == target)
            {
                return(0);
            }

            return(target.Id);
        }
Exemple #3
0
        public override void OnCastSpell()
        {
            if (!mIsCanAttack)
            {
                return;
            }
            if (IsMoving)
            {
                return;
            }

            RoleActor target = GetTarget(mAttackTarget);

            if (null == target || !target.CanBeAttacked())
            {
                ChangeState(eNPCState.Idle);
                return;
            }
            //if (Spell(mCurrentSpellID, target) == eSkillResult.OK)
            eSkillResult ret = eSkillResult.OK;

            if (CastSpell(mCurrentSpellID, mAttackTarget, ref ret))
            {
                mCurrSpellNode++;
                ChangeState(eNPCState.WaitCoolDown);
            }
        }
Exemple #4
0
        //监测阵营关系导致的是否可以攻击
        public virtual bool CanAttack(RoleActor target)
        {
            if (!CanAttack())
            {
                return(false);
            }

            if (HostMap.CanAttack(this, target) == eMapAttackRule.AtkNO)
            {
                return(false);
            }

            return(target.CanBeAttacked());
        }
Exemple #5
0
        public virtual void OnWaitCoolDown()
        {
            if (mSpellType == (ushort)eSkillTargetType.Enemy)
            {
                RoleActor target = GetTarget(mAttackTarget);
                if (null == target || !target.CanBeAttacked())
                {
                    if (!SelectTarget())
                    {
                        mAttackTarget = 0;
                        ReturnSpawnPoint();
                        return;
                    }
                    target = GetTarget(mAttackTarget);
                }

                //够攻击距离
                if (CanCastSpell())
                {
                    if (mNowTime > mSpellCD)
                    {
                        ChangeState(eNPCState.CastSpell);
                    }
                }
                else if (!FollowTarget(target))
                {
                    ReturnSpawnPoint();
                }
            }
            else
            {
                if (mNowTime > mSpellCD)
                {
                    ChangeState(eNPCState.CastSpell);
                }
            }
        }