MapServer.PlayerObject.ScroolRandom C# (CSharp) Method

ScroolRandom() public method

public ScroolRandom ( short _x, short _y ) : void
_x short
_y short
return void
        public void ScroolRandom(short _x = 0, short _y = 0)
        {
            int index = 0;
            short x = _x;
            short y = _y;
            if (x == 0 && y == 0)
            {
                while (true)
                {
                    x = (short)IRandom.Random(1, (int)this.GetGameMap().mnWidth);
                    y = (short)IRandom.Random(1, (int)this.GetGameMap().mnHeight);
                    if (this.GetGameMap().CanMove(x, y)) break;
                    if (index > 100) return;
                    index++;
                }

            }
            //先清除自身对象
            this.ClearThis();
            this.SetPoint(x, y);

            NetMsg.MsgScroolRandom msg = new NetMsg.MsgScroolRandom();
            msg.Create(null, GetGamePackKeyEx());
            msg.time = System.Environment.TickCount;
            msg.x = msg._x = this.GetCurrentX();
            msg.y = msg._y = this.GetCurrentY();
            msg.roleid = this.GetTypeId();
            this.SendData(msg.GetBuffer());

            this.GetVisibleList().Clear();

            GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE);
            this.PushAction(act);
            //幻兽也要跟随
            this.GetEudemonSystem().FlyPlay();
        }

Usage Example

Example #1
0
 private bool Action_Map_Random(ActionInfo info, PlayerObject play)
 {
     play.ScroolRandom();//随机传送
     return true;
 }
All Usage Examples Of MapServer.PlayerObject::ScroolRandom