Esempio n. 1
0
        public void FlyMap(uint mapid, short x, short y, byte dir)
        {
            GameMap map = MapManager.Instance().GetGameMapToID(mapid);
            if (map == null)
            {
                Log.Instance().WriteLog("未找到游戏地图id:" + mapid.ToString());
                return;
            }
            if (GetGameMap() != null)
            {
                GetGameMap().RemoveObj(this);
            }
            this.mGameMap = map;
            this.GetBaseAttr().mapid = mapid;
            this.SetPoint(x, y);
            this.SetDir(dir);
            map.AddObject(this, this.GetGameSession());
            //重新刷新可视列表

            GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE);
            this.PushAction(act);
            //发给玩家
            NetMsg.MsgMapInfo mapinfo = new NetMsg.MsgMapInfo();
            mapinfo.Create(null, GetGamePackKeyEx());
            mapinfo.Init(mapid, x, y, NetMsg.MsgMapInfo.ENTERMAP);
            this.SendData(mapinfo.GetBuffer());
            //发送天气信息
            this.GetGameMap().SendWeatherInfo(this);
        }
Esempio n. 2
0
        //private void AutoAttack()
        //{
        //    return;
        //    //if (GetTargetObj() == null) return;
        //    //if (GetTargetObj().IsDie())
        //    //{
        //    //    SetTargetObj(null);
        //    //    return;
        //    //}
        //    //if (System.Environment.TickCount - lastattacktime > attack_speed)
        //    //{
        //    //    uint injured = 10;
        //    //    //targetObject.Injured(this, injured,2);
        //    //    lastattacktime = System.Environment.TickCount;
        //    //}
        //}
        //进入游戏 参数1: 是否是创建角色第一次进入游戏
        public void EnterGame(GameBase.Network.GameSession _session, bool isFirst = false)
        {
            if (_session != null)
            {
                this.SetGameSession(_session);
            }
            if (this.GetGameSession() == null)
            {
                Log.Instance().WriteLog("玩家进入游戏EnterGame,会话对象为空!!");
                return;
            }
            this.CalcAttribute();//计算属性-
            this.GetGameSession().gameid = this.GetGameID();
            //加入到全局用户列表
            UserEngine.Instance().AddPlayerObject(this);
            PlayerObject pay = this;
            //公告信息
            NetMsg.MsgNotice msgNotice = new NetMsg.MsgNotice();
            msgNotice.Create(null, GetGamePackKeyEx());
            ////玩家个人信息

            // byte[] selfdata = {  238, 3, 64, 66, 15, 0, 17, 152, 2, 0, 101, 0, 0, 0, 125, 61, 2, 0, 0, 0, 0, 0, 133, 133, 207, 231, 1, 0, 0, 0, 14, 166, 0, 0, 0, 0, 0, 0, 231, 29, 0, 0, 180, 1, 0, 0, 31, 0, 100, 0, 74, 2, 0, 0, 0, 0, 46, 25, 46, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 20, 0, 1, 1, 5, 0, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 21, 10, 0, 0, 84, 154, 126, 156, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, 25, 0, 0, 0, 0, 0, 0, 54, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 4, 0, 0, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 97, 118, 49, 51, 49, 52, 2, 206, 222, 0, 0, 0 };
            // this.GetGamePackKeyEx().EncodePacket(ref selfdata, selfdata.Length);
            // this.SendData(selfdata);
            //
            NetMsg.MsgSelfRoleInfo rolemsg = new NetMsg.MsgSelfRoleInfo();
            //rolemsg.Create(selfdata, this.GetGamePackKeyEx());
            rolemsg.Create(null, this.GetGamePackKeyEx());
            rolemsg.roleid = this.GetTypeId();
            rolemsg.lookface = this.GetBaseAttr().lookface;

            rolemsg.profession = this.GetBaseAttr().profession;
            rolemsg.name = this.GetName();
            //一登录进满血
            this.GetBaseAttr().life = this.GetBaseAttr().life_max;
            rolemsg.life = (ushort)this.GetBaseAttr().life;
            rolemsg.maxlife = (ushort)this.GetBaseAttr().life_max;
            rolemsg.manna = (ushort)this.GetBaseAttr().mana_max;
            rolemsg.maxpetcall = this.GetBaseAttr().maxeudemon;
            //一登录进满蓝

            rolemsg.level = this.GetBaseAttr().level;
            rolemsg.gold = (uint)this.GetBaseAttr().gold;
            rolemsg.godlevel = this.GetBaseAttr().godlevel;
            rolemsg.gamegold = (uint)this.GetBaseAttr().gamegold;
               // rolemsg.maxpetcall = (ushort)GameBase.Config.Define.MAX_CALL_EUDEMON;//最大召唤宠物数量
            rolemsg.hair = (uint)this.GetBaseAttr().hair;
            //第一次进入游戏
            if (isFirst)
            {
                this.SendData(msgNotice.GetStartGameBuff());
                //个人信息
                //偷懒,一参加角色神等级20级 2016.1.21 封包协议号没分析全的结果
                //2016.2.1 神力等级归0
                rolemsg.godlevel = 0;
                session.SendData(rolemsg.GetBuffer());

                SendRoleOtherSystemInfo();
                ScripteManager.Instance().ExecuteAction(GameBase.Config.Define.FIRSTSCRIPTID, this);

                return;
            }

            GameMap map = MapManager.Instance().GetGameMapToID(this.GetBaseAttr().mapid);
            if (map == null)
            {
                Log.Instance().WriteLog("非法玩家,非法坐标.." + this.GetName() + " 地图id:" + this.GetBaseAttr().mapid.ToString()
                    +"已修正到回卡诺萨城");
                //重新回到卡诺萨城
                this.GetBaseAttr().mapid = 1000;
                this.SetPoint(145, 413);
                map = MapManager.Instance().GetGameMapToID(this.GetBaseAttr().mapid);
               // return;
            }

            MapManager.Instance().GetGameMapToID(this.GetBaseAttr().mapid).AddObject(this, GetGameSession());
            //发送爵位公告
            this.SendJueweiNotice();
            ////加入到正式列表
            //公告信息
            session.SendData(msgNotice.GetStartGameBuff());
            // session.GetGamePackKeyEx().EncodePacket(ref data, data.Length);
            session.SendData(rolemsg.GetBuffer());
            //session.SendData(data);
            SendRoleOtherSystemInfo();

            //测试增加装备 测试装备
            //NetMsg.MsgItemInfo item = new NetMsg.MsgItemInfo();
            //item.Create(null, session.GetGamePackKeyEx());
            //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_ARMOR;
            //item.id = 112434;
            //item.item_id = 135114;
            //item.amount = item.amount_limit = 1;
            //session.SendData(item.GetBuffer());
            //测试武器
            //item = new NetMsg.MsgItemInfo();
            //item.Create(null, session.GetGamePackKeyEx());
            //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_WEAPONR;
            //item.id = 112435;
            //item.item_id = 440244;
            //item.amount = item.amount_limit = 1;
            //session.SendData(item.GetBuffer());

            //item = new NetMsg.MsgItemInfo();
            //item.Create(null, session.GetGamePackKeyEx());
            //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_BACKPACK;
            //item.id = 112436;
            //item.item_id = 440244;
            //item.amount = item.amount_limit = 1;
            //session.SendData(item.GetBuffer());

            //NetMsg.MsgUpdateSP sp = new NetMsg.MsgUpdateSP();
            //sp.Create(null, session.GetGamePackKeyEx());
            //sp.role_id = this.GetTypeId();
            //sp.value = 37;
            //sp.sp = 100;
            //session.SendData(sp.GetBuffer());

            //sp = new NetMsg.MsgUpdateSP();
            //sp.Create(null, session.GetGamePackKeyEx());
            //sp.role_id = this.GetTypeId();
            //session.SendData(sp.GetBuffer());

            //进入地图
            NetMsg.MsgMapInfo mapinfo = new NetMsg.MsgMapInfo();
            mapinfo.Create(null, session.GetGamePackKeyEx());
            mapinfo.Init(this.GetBaseAttr().mapid, this.GetCurrentX(), this.GetCurrentY(), NetMsg.MsgMapInfo.ENTERMAP);
            session.SendData(mapinfo.GetBuffer());

            //初始化一些信息
            this.ChangeAttribute(UserAttribute.LOOKFACE, GetLookFace());
            //刷新可视列表;
            GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE);
            this.PushAction(act);

            ScriptTimerManager.Instance().PlayerEnterGame(this.GetBaseAttr().player_id);
            //发送天气信息
            this.GetGameMap().SendWeatherInfo(this);

            //
             //   this.MsgBox("QQ群号:306929937");
        }