Пример #1
0
        public MonsterObject(uint _id,int nAi_Id,short x,short y,bool isCreateTypeId = true)
        {
            mTarget = null;
            id = _id;
            type = OBJECTTYPE.MONSTER;
            attr = new GameStruct.MonterAttribute();
            mRebirthTime = 1000; //默认复活时间
            if (isCreateTypeId)
            {
                typeid = IDManager.CreateTypeId(type);
            }
            mInitPoint = new GameStruct.Point();
            mInitPoint.x = x;
            mInitPoint.y = y;
            m_Ai = CreateAi(nAi_Id);

            mnDieMagicTick = System.Environment.TickCount;
            mDieMagicInfo = null;
            attr.life = attr.life_max = 0;
            mAliveTime = new GameBase.Core.TimeOut();
            mAliveTime.SetInterval(mRebirthTime);

            this.SetPoint(x, y);
               // ai = new AI.BaseAI(this);
            Alive();
        }
Пример #2
0
        public MonsterObject(uint _id, int nAi_Id, short x, short y, bool isCreateTypeId = true)
        {
            mTarget      = null;
            id           = _id;
            type         = OBJECTTYPE.MONSTER;
            attr         = new GameStruct.MonterAttribute();
            mRebirthTime = 1000; //默认复活时间
            if (isCreateTypeId)
            {
                typeid = IDManager.CreateTypeId(type);
            }
            mInitPoint   = new GameStruct.Point();
            mInitPoint.x = x;
            mInitPoint.y = y;
            m_Ai         = CreateAi(nAi_Id);

            mnDieMagicTick = System.Environment.TickCount;
            mDieMagicInfo  = null;
            attr.life      = attr.life_max = 0;
            mAliveTime     = new GameBase.Core.TimeOut();
            mAliveTime.SetInterval(mRebirthTime);

            this.SetPoint(x, y);
            // ai = new AI.BaseAI(this);
            Alive();
        }
Пример #3
0
        private int walkTime; //下次走路时间戳

        #endregion Fields

        #region Constructors

        public BaseObject()
        {
            // mVisibleList = new Dictionary<uint, BaseObject>();
            mVisibleList = new Dictionary<uint, RefreshObject>();

            mActionList = new List<GameStruct.Action>();
            mPoint = new GameStruct.Point();
            type = OBJECTTYPE.NORMAL;
            gameid = IDManager.CreateId();
            session = null;
        }
Пример #4
0
        public BaseObject()
        {
            // mVisibleList = new Dictionary<uint, BaseObject>();
            mVisibleList = new Dictionary <uint, RefreshObject>();

            mActionList = new List <GameStruct.Action>();
            mPoint      = new GameStruct.Point();
            type        = OBJECTTYPE.NORMAL;
            gameid      = IDManager.CreateId();
            session     = null;
        }
Пример #5
0
        //主动攻击
        protected virtual void ActiveAttackPlay()
        {
            if (mAiInfo.nType != Define.MONSTER_TYPE_ACTIVE)
            {
                return;                                             //不是主动怪物-
            }
            //寻找目标需要时间--
            if (System.Environment.TickCount - mnActiveAttackTick < Define.MONSTER_ACTIVEATTACK_TIME * 1000)
            {
                return;
            }
            mnActiveAttackTick = System.Environment.TickCount;
            GameStruct.Point point    = null;
            GameStruct.Point newPoint = null;
            BaseObject       newObj   = null;

            if (TargetObj == null &&
                System.Environment.TickCount - mnLastMoveTick > mAiInfo.nMove_Speed &&
                SelObj.GetVisibleList().Count > 0
                )
            {
                foreach (RefreshObject refobj in SelObj.GetVisibleList().Values)
                {
                    if (refobj.obj.type != OBJECTTYPE.PLAYER && //只攻击角色与幻兽与暗黑龙骑的守护骑士
                        refobj.obj.type != OBJECTTYPE.EUDEMON &&
                        refobj.obj.type != OBJECTTYPE.GUARDKNIGHT &&
                        refobj.obj.type != OBJECTTYPE.MONSTER &&
                        refobj.obj.type != OBJECTTYPE.CALLOBJECT)
                    {
                        continue;
                    }
                    //如果是暗杀邪龙. 不攻击主人

                    if (!SelObj.CanPK(refobj.obj))
                    {
                        continue;
                    }
                    point   = new GameStruct.Point();
                    point.x = (short)Math.Abs(refobj.obj.GetCurrentX() - SelObj.GetCurrentX());
                    point.y = (short)Math.Abs(refobj.obj.GetCurrentY() - SelObj.GetCurrentY());
                    if (newPoint == null)
                    {
                        newPoint = point;
                        newObj   = refobj.obj;
                    }
                    if (point.x < newPoint.x &&
                        point.y < newPoint.y)
                    {
                        newPoint = point;
                        newObj   = refobj.obj;
                    }
                }
                if (newObj != null)
                {
                    //设置为攻击状态
                    TargetObj      = newObj;
                    nState         = BaseAI.ATTACK;
                    mnLastMoveTick = System.Environment.TickCount;
                }
            }
        }
Пример #6
0
        //主动攻击
        protected virtual void ActiveAttackPlay()
        {
            if (mAiInfo.nType != Define.MONSTER_TYPE_ACTIVE) return;//不是主动怪物-
            //寻找目标需要时间--
            if (System.Environment.TickCount - mnActiveAttackTick < Define.MONSTER_ACTIVEATTACK_TIME * 1000)
            {
                return;
            }
            mnActiveAttackTick = System.Environment.TickCount;
            GameStruct.Point point = null;
            GameStruct.Point newPoint = null;
            BaseObject newObj = null;
            if (TargetObj == null &&
                System.Environment.TickCount - mnLastMoveTick > mAiInfo.nMove_Speed &&
                SelObj.GetVisibleList().Count > 0
                )
            {
                foreach (RefreshObject refobj in SelObj.GetVisibleList().Values)
                {
                    if(refobj.obj.type != OBJECTTYPE.PLAYER && //只攻击角色与幻兽与暗黑龙骑的守护骑士
                        refobj.obj.type != OBJECTTYPE.EUDEMON &&
                        refobj.obj.type != OBJECTTYPE.GUARDKNIGHT &&
                        refobj.obj.type != OBJECTTYPE.MONSTER &&
                        refobj.obj.type != OBJECTTYPE.CALLOBJECT)
                    {
                        continue;
                    }
                    //如果是暗杀邪龙. 不攻击主人

                    if (!SelObj.CanPK(refobj.obj))
                    {
                        continue;
                    }
                    point = new GameStruct.Point();
                    point.x = (short)Math.Abs(refobj.obj.GetCurrentX() - SelObj.GetCurrentX());
                    point.y = (short)Math.Abs(refobj.obj.GetCurrentY() - SelObj.GetCurrentY());
                    if (newPoint == null)
                    {
                        newPoint = point;
                        newObj = refobj.obj;
                    }
                    if(point.x < newPoint.x &&
                        point.y < newPoint.y)
                    {
                        newPoint = point;
                        newObj = refobj.obj;
                    }
                }
                if (newObj != null)
                {
                    //设置为攻击状态
                    TargetObj = newObj;
                    nState = BaseAI.ATTACK;
                    mnLastMoveTick = System.Environment.TickCount;
                }

            }
        }
Пример #7
0
 //获取鼠标范围点的对象
 private List<BaseObject> GetPointBombVisibleObj(NetMsg.MsgAttackInfo magicinfo)
 {
     List<BaseObject> list_obj = new List<BaseObject>();
     GameStruct.MagicTypeInfo typeinfo = ConfigManager.Instance().GetMagicTypeInfo(magicinfo.usType);
     if (typeinfo == null) return list_obj;
     int nRange = (int)typeinfo.range;
     GameStruct.Point point = new GameStruct.Point();
     point.x = (short)magicinfo.usPosX; point.y = (short)magicinfo.usPosY;
     foreach (RefreshObject refobj in play.GetVisibleList().Values)
     {
         BaseObject obj = refobj.obj;
         if (!IsAddMagicVisibleObj(obj))
         {
             continue;
         }
         if (point.CheckVisualDistance(obj.GetCurrentX(), obj.GetCurrentY(), nRange))
         {
             list_obj.Add(obj);
         }
     }
     return list_obj;
 }
Пример #8
0
        //获取扇形范围内的对象
        private List<BaseObject> GetFanVisibleObj(NetMsg.MsgAttackInfo magicinfo)
        {
            List<BaseObject> list_obj = new List<BaseObject>();
            GameStruct.MagicTypeInfo typeinfo = ConfigManager.Instance().GetMagicTypeInfo(magicinfo.usType);
            if (typeinfo == null) return list_obj;

            //play.RefreshVisibleObject();
            int nRange = (int)typeinfo.range + Define.MAX_SIZEADD;
            int	nSize		= nRange*2 + 1;
            int nWidth = (int)typeinfo.width;
            foreach (RefreshObject refobj in play.GetVisibleList().Values)
            {
                BaseObject obj = refobj.obj;
                if (!IsAddMagicVisibleObj(obj))
                {
                    continue;
                }

                GameStruct.Point pos =play.GetPoint();
                GameStruct.Point magicpos = new GameStruct.Point();
                magicpos.x = (short)magicinfo.usPosX;
                magicpos.y = (short)magicinfo.usPosY;
                //原版代码翻译过来..不好使-- 就用了蹩脚的方法2015.10.26
               // GameStruct.Point posThis = new GameStruct.Point();
                //bool bFind = true;
                //for (int i = CutTrail(pos.x - nRange, 0); i <= pos.x + nRange && i < play.GetGameMap().mnWidth; i++)
                //{
                //    for (int j = CutTrail(pos.y - nRange, 0); j <= pos.y + nRange && j < play.GetGameMap().mnHeight; j++)
                //    {
                //        posThis.x = (short)i;
                //        posThis.y = (short)j;
                //        if (play.GetPoint().CheckFanDistance(posThis, pos, nRange, nWidth, magicpos))
                //        {
                //            int idx = POS2INDEX(posThis.x - pos.x + nRange, posThis.y - pos.y + nRange, nSize, nSize);
                //            int objIdx = POS2INDEX(obj.GetCurrentX() - pos.x + nRange, obj.GetCurrentY() - pos.y + nRange, nSize, nSize);
                //            if (idx == objIdx)
                //            {
                //                list_obj.Add(obj);
                //                bFind = true;
                //                break;
                //            }
                //            //inline int POS2INDEX(int x, int y, int cx, int cy) { return (x + y*cx); }

                //        }
                //        if (bFind)
                //        {
                //            break;
                //        }

                //    }
                //}
                //bFind = false;
               // posThis.x = (short)CutTrail(pos.x - nRange, 0);
               // posThis.y = (short)CutTrail(pos.y - nRange, 0);

                //if (play.GetPoint().CheckFanDistance(posThis, pos, nRange, nWidth, magicpos))
                if(play.GetPoint().CheckFanDistance(obj.GetPoint(),magicpos,nRange))
                {
                    list_obj.Add(obj);
                }
            }

            return list_obj;
        }
Пример #9
0
        //获取扇形范围内的对象
        private List<BaseObject> GetFanVisibleObj(NetMsg.MsgAttackInfo magicinfo)
        {
            List<BaseObject> list_obj = new List<BaseObject>();
            GameStruct.MagicTypeInfo typeinfo = ConfigManager.Instance().GetMagicTypeInfo(magicinfo.usType);
            if (typeinfo == null) return list_obj;

            int nRange = (int)typeinfo.range + GameBase.Config.Define.MAX_SIZEADD;
            int nSize = nRange * 2 + 1;
            int nWidth = (int)typeinfo.width;
            foreach (RefreshObject refobj in this.GetVisibleList().Values)
            {
                BaseObject obj = refobj.obj;
                if (!play.GetFightSystem().IsAddMagicVisibleObj(obj))
                {
                    continue;
                }

                GameStruct.Point pos = this.GetPoint();
                GameStruct.Point magicpos = new GameStruct.Point();
                magicpos.x = (short)magicinfo.usPosX;
                magicpos.y = (short)magicinfo.usPosY;
                if (this.GetPoint().CheckFanDistance(obj.GetPoint(), magicpos, nRange))
                {
                    list_obj.Add(obj);
                }
            }

            return list_obj;
        }