예제 #1
0
        void Update()
        {
            if (Raylib.IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
            {
                var mousePos    = Raylib.GetMousePosition();
                int mouseXIndex = (int)((mousePos.X - board.pos.X) / board.tileSize);
                int mouseYIndex = (int)((mousePos.Y - board.pos.Y) / board.tileSize);

                var selected = board.GetSelected();
                if (selected != null && selected.IsValidMove(mouseYIndex, mouseXIndex))
                {
                    selected.MoveTo(mouseYIndex, mouseXIndex);
                }
                else
                {
                    board.SelectTile(mouseYIndex, mouseXIndex);
                }
            }
        }