AddObject() 공개 메소드

public AddObject ( object obj ) : void
obj object
리턴 void
예제 #1
0
        protected override void ProcessAction_Injured(GameStruct.Action act)
        {
            BaseObject attack_obj = act.GetObject(0) as BaseObject;

            NetMsg.MsgAttackInfo info = act.GetObject(2) as NetMsg.MsgAttackInfo;
            if (attack_obj == null)
            {
                return;
            }
            uint injured = (uint)act.GetObject(1);  //受伤害的值

            mTarget = attack_obj;

            this.GetAi().Injured(attack_obj);

            //死亡-- 锁定后不允许死亡
            if (IsDie() && !this.IsLock() && info.tag == 2 /*单体攻击*/)
            {
                GameStruct.Action action;
                //死亡
                action = new GameStruct.Action(GameStruct.Action.DIE, null);
                action.AddObject(attack_obj);
                action.AddObject(injured);
                this.PushAction(action);
            }
            //魔法攻击要延迟一秒下发死亡消息

            if (info.tag == 21 && IsDie() && !this.IsLock())
            {
                mnDieMagicTick = System.Environment.TickCount;
                mDieMagicInfo  = act;
            }
        }
예제 #2
0
        public override void Injured(BaseObject obj, uint value, NetMsg.MsgAttackInfo info)
        {
            if (value > attr.life)
            {
                attr.life = 0;
            }
            else
            {
                attr.life -= (int)value;
            }
            GameStruct.Action action;


            action = new GameStruct.Action(GameStruct.Action.INJURED, null);
            action.AddObject(obj);
            action.AddObject(value);
            action.AddObject(info);
            this.PushAction(action);
        }
예제 #3
0
        public override bool Run()
        {
            if (this.GetAi() == null)
            {
                return(true);
            }
            base.Run();
            //单体魔法攻击延迟死亡
            if (mDieMagicInfo != null &&
                System.Environment.TickCount - mnDieMagicTick >= 500)
            {
                GameStruct.Action action = new GameStruct.Action(GameStruct.Action.DIE, null);
                action.AddObject(mDieMagicInfo.GetObject(0));
                action.AddObject(mDieMagicInfo.GetObject(1));

                this.PushAction(action);
                mDieMagicInfo = null;
                return(true);
            }
            else if (mDieMagicInfo != null)
            {
                return(true);
            }
            this.GetAi().Run();


            if (this.IsLock())
            {
                if (!this.CheckLockTime())
                {
                    this.UnLock(false);
                    if (IsDie())
                    {
                        GameStruct.Action action;
                        //死亡
                        action = new GameStruct.Action(GameStruct.Action.DIE, null);
                        action.AddObject(mTarget);
                        action.AddObject((uint)mTarget.GetMinAck()); //取最小攻击为经验值
                        this.PushAction(action);
                        LastDieTime = System.Environment.TickCount;
                    }
                }
            }

            //死亡后三秒后发送清除怪物消息
            if (IsDie() && !this.IsLock())
            {
                if (!IsClear() && System.Environment.TickCount - LastDieTime > 3000)
                {
                    this.ClearThis();
                }
            }

            ////复活
            //if (IsClear() && IsDie() && mRebirthTime > 0)
            //{
            //    if (System.Environment.TickCount - LastDieTime > mRebirthTime)
            //    {
            //        Alive(false);
            //    }
            //}
            if (IsClear() && IsDie() && mAliveTime.ToNextTime())
            {
                Alive(false);
            }
            return(true);
        }
예제 #4
0
        public override bool Run()
        {
            //意外断开处理
            if (GetGameSession() == null)
            {
                //广播出去,清除该玩家
                if (GetVisibleList().Count > 0)
                {
                    NetMsg.MsgClearObjectInfo clear = new NetMsg.MsgClearObjectInfo();
                    clear.id = this.GetTypeId();
                    GetGameMap().BroadcastBuffer(this, clear.GetBuffer());
                }

                return false;
            }
            base.Run();
            //连招解锁
            if (this.IsLock())
            {
                if (!this.CheckLockTime())
                {
                    this.UnLock();
                }
            }
            this.GetTimerSystem().Run();
            //战斗系统
            this.GetFightSystem().Run();
            this.GetPKSystem().Run();
            //角色死亡变为鬼魂状态,
            if (this.IsDie() && m_bGhost && mnGhostTick != -1)
            {
                if (System.Environment.TickCount - mnGhostTick >= 3000)
                {
                    this.ChangeAttribute(UserAttribute.STATUS, 6);
                    this.ChangeAttribute(UserAttribute.LOOKFACE, GetLookFace(), true);

                    mnGhostTick = -1;

                }
            }

            //死亡--因为会被连击锁定-- 所以放到run方法
            if (IsDie() && !this.IsLock() && mTarget != null && m_bGhost == false)
            {
                GameStruct.Action action;
                //死亡
                action = new GameStruct.Action(GameStruct.Action.DIE, null);
                action.AddObject(mTarget);

                this.PushAction(action);
            }

            //定时保存玩家数据
            if (mSaveTime.ToNextTime())
            {
                UserEngine.Instance().AddSaveRole(this);
            }

            //传送状态
            if (mbTransmit && mTransmitTimeOut.ToNextTime())
            {
                //幻兽出征
                this.GetEudemonSystem().Eudemon_BattleAll();
                //发送天气信息
                this.GetGameMap().SendWeatherInfo(this);
                this.SetTransmitIng(false);
            }
            return true;
        }
예제 #5
0
        public bool Move(NetMsg.MsgMoveInfo move)
        {
            byte dir = (byte)((int)move.dir % 8);
            this.SetDir(dir);
            short nNewX = this.GetCurrentX();
            short nNewY = this.GetCurrentY();
               //作弊判断,与宿主距离不得超过格子范围 否则传送回身边
            if (Math.Abs(play.GetCurrentX() - this.GetCurrentX()) > GameBase.Config.Define.MAX_EUDEMON_PLAY_DISTANCE ||
                Math.Abs(play.GetCurrentY() - this.GetCurrentY()) > GameBase.Config.Define.MAX_EUDEMON_PLAY_DISTANCE)
            {
                nNewX = (short)(play.GetCurrentX());
                nNewY = (short)(play.GetCurrentY());
                this.SetPoint(nNewX, nNewY);
                this.SendEudemonInfo();
                return false;
            }

            nNewX += DIR._DELTA_X[dir];
            nNewY += DIR._DELTA_Y[dir];
            if (!mGameMap.CanMove(nNewX, nNewY))
            {
               // Log.Instance().WriteLog("非法封包..禁止走路!!x:" + nNewX.ToString() + "y:" + nNewY.ToString());
                return false;
            }
            //// 跑步模式的阻挡判断
            bool IsRun = false;
            if (move.ucMode >= DIR.MOVEMODE_RUN_DIR0 && move.ucMode <= DIR.MOVEMODE_RUN_DIR7 )
            {
                nNewX += DIR._DELTA_X[move.ucMode - DIR.MOVEMODE_RUN_DIR0];
                nNewY += DIR._DELTA_Y[move.ucMode - DIR.MOVEMODE_RUN_DIR0];
                IsRun = true;
                //if (!mGameMap.CanMove(nNewX, nNewY))
                //{
                //    return false;
                //}
            }
            GameStruct.Action action = new GameStruct.Action(GameStruct.Action.MOVE);
            if (IsRun) action.AddObject(move.ucMode);
            this.SetPoint(nNewX, nNewY);
            PushAction(action);
            return true;
        }
예제 #6
0
        //public override void RefreshVisibleObject() //刷新可视对象
        //{
        //    base.RefreshVisibleObject();
        //    mRefreshList.Clear();
        //    foreach (BaseObject o in mGameMap.mDicObject.Values)
        //    {
        //        if (o.GetGameID() == this.GetGameID()) continue;
        //        //玩家和玩家的视野范围扩大-
        //       // int dis = o.type == OBJECTTYPE.PLAYER ? Define.MAX_PLAY_VISIBLE_DISTANCE : Define.MAX_VISIBLE_DISTANCE;
        //        int dis = Define.MAX_VISIBLE_DISTANCE;
        //        //如果是怪物和npc 掉落物品对象就不发消息了-- 已经在视野范围了嘛
        //        if ((o.type == OBJECTTYPE.NPC || o.type == OBJECTTYPE.MONSTER ||
        //            o.type == OBJECTTYPE.EUDEMON  || o.type == OBJECTTYPE.DROPITEM ||
        //            o.type == OBJECTTYPE.PLAYER || o.type == OBJECTTYPE.ROBOT)  &&
        //            this.mVisibleList.ContainsKey(o.GetGameID()))
        //        {
        //            if (!GetPoint().CheckVisualDistance(o.GetCurrentX(), o.GetCurrentY(), dis)
        //                 && this.mVisibleList.ContainsKey(o.GetGameID()))
        //            {
        //                this.mVisibleList.Remove(o.GetGameID());
        //                if (this.mPlayObject.ContainsKey(o.GetGameID()))
        //                {
        //                    this.mPlayObject.Remove(o.GetGameID());
        //                }
        //            }
        //            continue;
        //        }
        //        if (GetPoint().CheckVisualDistance(o.GetCurrentX(), o.GetCurrentY(), dis))
        //        {
        //            this.mVisibleList[o.GetGameID()] = o;
        //             if (o.type == OBJECTTYPE.MONSTER)
        //             {
        //                    MonsterObject mobj = o as MonsterObject;
        //                    if (mobj.IsDie()) continue;
        //             }
        //             if (o.type == OBJECTTYPE.NPC ||
        //                 o.type == OBJECTTYPE.MONSTER ||
        //                 o.type == OBJECTTYPE.PLAYER ||
        //                 o.type == OBJECTTYPE.DROPITEM ||
        //                 o.type == OBJECTTYPE.EUDEMON ||
        //                 o.type == OBJECTTYPE.ROBOT)
        //            {
        //                mRefreshList[o.GetGameID()] = o;
        //            }
        //        }
        //        else
        //        {
        //            if (!GetPoint().CheckVisualDistance(o.GetCurrentX(), o.GetCurrentY(), dis)
        //                && this.mVisibleList.ContainsKey(o.GetGameID()))
        //            {
        //                this.mVisibleList.Remove(o.GetGameID());
        //                if ((o.type == OBJECTTYPE.PLAYER || o.type == OBJECTTYPE.EUDEMON ||
        //                    o.type == OBJECTTYPE.ROBOT) &&
        //                    mPlayObject.ContainsKey(o.GetGameID()))
        //                {
        //                    mPlayObject.Remove(o.GetGameID());
        //                    //清除目标对象
        //                    NetMsg.MsgClearObjectInfo clearobj = new NetMsg.MsgClearObjectInfo();
        //                    clearobj.Create(null, this.GetGamePackKeyEx());
        //                    clearobj.id = o.GetTypeId();
        //                    this.SendData(clearobj.GetBuffer());
        //                    if (o.type == OBJECTTYPE.PLAYER)
        //                    {
        //                        clearobj = new NetMsg.MsgClearObjectInfo();
        //                        clearobj.Create(null, o.GetGamePackKeyEx());
        //                        clearobj.id = this.GetTypeId();
        //                        o.SendData(clearobj.GetBuffer());
        //                        (o as PlayerObject).GetPlayObjectList().Remove(this.GetGameID());
        //                    }
        //                    if (o.type == OBJECTTYPE.EUDEMON)
        //                    {
        //                        (o as EudemonObject).GetPlayObjectList().Remove(this.GetGameID());
        //                    }
        //                }
        //            }
        //        }
        //    }
        //}
        public bool Move(NetMsg.MsgMoveInfo move)
        {
            if (!this.GetMagicSystem().CheckMoveSpeed())
            {
                this.ScroolRandom(this.GetCurrentX(), this.GetCurrentY());

                return false;
            }
            // testeudemon();
            byte dir = (byte)((int)move.dir % 8);
            this.SetDir(dir);

            short nNewX = GetCurrentX();
            short nNewY = GetCurrentY();
            nNewX += DIR._DELTA_X[dir];
            nNewY += DIR._DELTA_Y[dir];
            if (!mGameMap.CanMove(nNewX, nNewY))
            {
                nNewX = this.GetCurrentX();
                nNewY = this.GetCurrentY();
                if (!mGameMap.CanMove(nNewX, nNewY))
                {
                    nNewX = (short)mGameMap.GetMapInfo().recallx;
                    nNewY = (short)mGameMap.GetMapInfo().recally;
                }
                //暂时使用随机卷的方式重置玩家坐标
                this.ScroolRandom(nNewX, nNewY);
               // Log.Instance().WriteLog("非法封包..禁止走路!!x:" + nNewX.ToString() + "y:" + nNewY.ToString());
                return false;
            }
            // 跑步模式的阻挡判断
            bool IsRun = false;
            if (move.ucMode >= DIR.MOVEMODE_RUN_DIR0 && move.ucMode <= DIR.MOVEMODE_RUN_DIR7 && GetBaseAttr().sp > 0 /*没有体力不让跑*/)
            {

                nNewX += DIR._DELTA_X[move.ucMode - DIR.MOVEMODE_RUN_DIR0];
                nNewY += DIR._DELTA_Y[move.ucMode - DIR.MOVEMODE_RUN_DIR0];
                IsRun = true;
                if (!mGameMap.CanMove(nNewX, nNewY))
                {
                    nNewX = this.GetCurrentX();
                    nNewY = this.GetCurrentY();
                    if (!mGameMap.CanMove(nNewX, nNewY))
                    {
                        nNewX = (short)mGameMap.GetMapInfo().recallx;
                        nNewY = (short)mGameMap.GetMapInfo().recally;
                    }
                    //暂时使用随机卷的方式重置玩家坐标
                    this.ScroolRandom(nNewX, nNewY);
                    //Log.Instance().WriteLog("非法封包..禁止走路!!x:" + nNewX.ToString() + "y:" + nNewY.ToString());
                    //Log.Instance().WriteLog("这个家伙肯定用了外挂,不如我们把他封号吧,角色名称:" + this.GetName() +
                    //    "如果下次他还开外挂,就把他硬盘里的种子全删掉...");
                    return false;
                }
            }
            //传送点判断
            uint mapid = 0; short x = 0; short y = 0;
            if (ConfigManager.Instance().CheckMapGate(this.GetGameMap().GetMapInfo().id, nNewX, nNewY, ref mapid, ref x, ref y))
            {
                this.ChangeMap(mapid, x, y);
                return false;
            }
            if (GetBaseAttr().sp <= 0) move.ucMode = 0;
            SetPoint(nNewX, nNewY);

            GameStruct.Action action = new GameStruct.Action(GameStruct.Action.MOVE);
            if (IsRun) action.AddObject(move.ucMode);

            //解除锁定目标
            this.GetFightSystem().SetAutoAttackTarget(null);
            PushAction(action);
            return true;
        }
예제 #7
0
        public override void Injured(BaseObject obj, uint value, NetMsg.MsgAttackInfo info)
        {
            this.GetFightSystem().SetFighting();

            //幻兽优先受伤害
            if (!this.GetEudemonSystem().Eudemon_Injured(obj, value, info))
            {
                //如果没有幻兽抵挡. 玩家就受到真实伤害
                this.ChangeAttribute(GameStruct.UserAttribute.LIFE, -(int)value);
            }
            GameStruct.Action action;
            action = new GameStruct.Action(GameStruct.Action.INJURED, null);
            action.AddObject(obj);
            action.AddObject(value);
            action.AddObject(info);
            this.PushAction(action);
        }
예제 #8
0
        protected override void ProcessAction_Injured(GameStruct.Action act)
        {
            BaseObject attack_obj = act.GetObject(0) as BaseObject;
            NetMsg.MsgAttackInfo info = act.GetObject(2) as NetMsg.MsgAttackInfo;
            if (attack_obj == null) return;
            uint injured = (uint)act.GetObject(1) ; //受伤害的值
            mTarget = attack_obj;

            this.GetAi().Injured(attack_obj);

            //死亡-- 锁定后不允许死亡
            if (IsDie() && !this.IsLock() && info.tag == 2/*单体攻击*/)
            {
                GameStruct.Action action;
                //死亡
                action = new GameStruct.Action(GameStruct.Action.DIE, null);
                action.AddObject(attack_obj);
                action.AddObject(injured);
                this.PushAction(action);
            }
            //魔法攻击要延迟一秒下发死亡消息

            if (info.tag == 21 && IsDie() && !this.IsLock())
            {
                mnDieMagicTick = System.Environment.TickCount;
                mDieMagicInfo = act;
            }
        }
예제 #9
0
        public override bool Run()
        {
            if (this.GetAi() == null) return true;
            base.Run();
            //单体魔法攻击延迟死亡
            if (mDieMagicInfo != null &&
                System.Environment.TickCount - mnDieMagicTick >= 500)
            {
                GameStruct.Action action = new GameStruct.Action(GameStruct.Action.DIE, null);
                action.AddObject(mDieMagicInfo.GetObject(0));
                action.AddObject(mDieMagicInfo.GetObject(1));

                this.PushAction(action);
                mDieMagicInfo = null;
                return true;
            }
            else if (mDieMagicInfo != null)
            {
                return true;
            }
            this.GetAi().Run();

            if(this.IsLock())
            {
                if (!this.CheckLockTime())
                {
                    this.UnLock(false);
                    if (IsDie())
                    {
                        GameStruct.Action action;
                        //死亡
                        action = new GameStruct.Action(GameStruct.Action.DIE, null);
                        action.AddObject(mTarget);
                        action.AddObject((uint)mTarget.GetMinAck()); //取最小攻击为经验值
                        this.PushAction(action);
                        LastDieTime = System.Environment.TickCount;
                    }

                }
            }

            //死亡后三秒后发送清除怪物消息
            if (IsDie() && !this.IsLock())
            {
                if (!IsClear() && System.Environment.TickCount - LastDieTime > 3000 )
                {
                    this.ClearThis();
                }

            }

            ////复活
            //if (IsClear() && IsDie() && mRebirthTime > 0)
            //{
            //    if (System.Environment.TickCount - LastDieTime > mRebirthTime)
            //    {
            //        Alive(false);
            //    }
            //}
            if (IsClear() && IsDie() && mAliveTime.ToNextTime())
            {
                Alive(false);
            }
            return true;
        }
예제 #10
0
        public override void Injured(BaseObject obj, uint value,NetMsg.MsgAttackInfo info)
        {
            if (value > attr.life) attr.life = 0;
            else attr.life -= (int)value;
            GameStruct.Action action;

            action = new GameStruct.Action(GameStruct.Action.INJURED, null);
            action.AddObject(obj);
            action.AddObject(value);
            action.AddObject(info);
            this.PushAction(action);
        }