public void DeleteGameObject(GameObject obj) {

        }
        public void MoveGameObject(ref GameObject obj, MapPosition position) {

            MapPosition old = obj.Position;
            
            obj.Position = position;

            DisplayBlock(old);
            DisplayBlock(position);
            
        }
 public void AddGameObject(GameObject NewObject) {
     MapObjects.Add(NewObject);
 }
 public void RemoveGameObject(GameObject Target) {
     MapObjects.Remove(Target);
 }
        private async void TextBox_PreviewKeyDown(object sender ,KeyEventArgs e) {
            if(e.Key != Key.Enter)
                return;
                
            string[] data = Cmd.Text.Split(' ');
            if(data[0].ToLower() == "?focus") {
                try {
                    int x = int.Parse(data[1]);
                    int y = int.Parse(data[2]);
                    await MapView[x, y].Focus();
                } catch {
                    chat.Text += "\r\nSYSTEM : 指令錯誤";
                }
            } else if(data[0].ToLower() == "?move") {
                if(Player == null) return;
                try {
                    int x = int.Parse(data[1]);
                    int y = int.Parse(data[2]);
                    MapView.MoveGameObject(ref Player,new MapPosition() { X = x, Y = y });
                }catch {
                    chat.Text += "\r\nSYSTEM : 指令錯誤";
                }
            } else if(data[0].ToLower() == "?player") {
                try {
                    int x = int.Parse(data[1]);
                    int y = int.Parse(data[2]);

                    MapView.AddGameObject(Player = new GameObject("Shan", new MapPosition() { X = x, Y = y }) {
                        Image = new Uri("pack://application:,,,/Texture/Shan_R.png")
                    });

                    MapView.DisplayBlock(new MapPosition() { X = x, Y = y });


                    //this.MapView.ClearScreen();
                    //await this.MapView.DisplayScreen();
                    //await MapView[x, y].Focus();
                } catch {
                    chat.Text += "\r\nSYSTEM : 指令錯誤";
                }
            } else if(data[0].ToLower() == "?set") {
                try {
                    int x = int.Parse(data[1]);
                    int y = int.Parse(data[2]);
                    int x_ = int.Parse(data[3]);
                    int y_ = int.Parse(data[4]);

                    MapView[x_, y_] = MapView[x, y].Clone<MapBlock>();
                    this.MapView.ClearScreen();
                    await this.MapView.DisplayScreen();
                    //await MapView[x, y].Focus();
                } catch {
                    chat.Text += "\r\nSYSTEM : 指令錯誤";
                }
            } else if(data[0].ToLower() == "?clear") {
                chat.Text = "";
            } else if(data[0].ToLower() == "?redisplay") {
                MapView.ClearScreen();
                MapView.DisplayScreen();
            } else if(data[0].ToLower() == "?help") {
                chat.Text += "\r\n<<help>>\r\nfocus\r\nplayer\r\nmove\r\nset\r\nclear\r\nredisplay";
            } else { 
                chat.Text += "\r\nUser : " + Cmd.Text;
            }
            //chat.IsEnabled = false;
            chat.IsEnabled = true;

            chat.Focus();
            chat.ScrollToEnd();
            Cmd.Clear();
            Cmd.Focus();

            chat.IsEnabled = false;
        }