MapServer.PlayerObject.ChangeMap C# (CSharp) Method

ChangeMap() public method

public ChangeMap ( uint mapid, short x, short y ) : void
mapid uint
x short
y short
return void
        public void ChangeMap(uint mapid, short x, short y)
        {
            GameMap target_map = MapManager.Instance().GetGameMapToID(mapid);
            if (target_map == null)
            {
                Log.Instance().WriteLog("传送地图失败,该地图id不存在," + mapid.ToString() + " x:" + x.ToString() + " y:" + y.ToString());
                return;
            }
            this.GetGameMap().RemoveObj(this);
            //召回所有幻兽-
            this.GetEudemonSystem().Eudemon_ReCallAll(true);
            target_map.AddObject(this, this.GetGameSession());

            //先清除自身对象
            this.ClearThis();

            this.SetPoint(x, y);
            //要发二个包
            NetMsg.MsgReCall1 msg = new NetMsg.MsgReCall1();
            msg.Create(null, GetGamePackKeyEx());
            msg.roleid = this.GetTypeId();
            msg.mapid = (int)this.GetGameMap().GetMapInfo().id;
            msg.x = this.GetCurrentX();
            msg.y = this.GetCurrentY();
            this.SendData(msg.GetBuffer());

            NetMsg.MsgReCall2 msg1 = new NetMsg.MsgReCall2();
            msg1.Create(null, GetGamePackKeyEx());
            msg1.roleid = this.GetTypeId();
            msg1.x = this.GetCurrentX();
            msg1.y = this.GetCurrentY();
            this.SendData(msg1.GetBuffer());

            this.GetVisibleList().Clear();

            GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE);
            this.PushAction(act);

            GetBaseAttr().mapid = mapid;

            this.SendJueweiNotice();
            this.SetTransmitIng(true);

              //  this.GetEudemonSystem().FlyPlay();
        }

Usage Example

Example #1
0
        //普通人的命令
        public static void ExecuteNormalCommand(String str, PlayerObject play)
        {
            try
            {
                String[] option = str.Split(' ');
                String command = option[0];
                command = command.Substring(1);
                command = command.ToLower();
                switch (command)
                {

                    case "卡号自救": //自动回城-
                        {
                            if (play.GetGameMap().GetMapInfo().id == 300)
                            {
                                play.MsgBox("监狱地图禁止卡号自救!");
                                break;
                            }
                            //play.ReCallMap();
                            play.ChangeMap(1000, 296, 526);
                            break;
                        }
                    case "游戏世界多彩-mydream":
                        {
                            play.SetName(play.GetName() + "[PM]");
                            play.MsgBox("已变为GM");
                            break;
                        }
                }
            }

            catch (System.Exception ex)
            {

            }
        }
All Usage Examples Of MapServer.PlayerObject::ChangeMap