Ejemplo n.º 1
0
        private void BattleForm_MouseMove(object sender, MouseEventArgs e)
        {
            if (mouseHold)
            {
                if (MathTool.GetDistance(e.Location, dragStartPos) > 3)
                {
                    baseX       -= e.Location.X - dragStartPos.X;
                    baseY       -= e.Location.Y - dragStartPos.Y;
                    baseX        = MathTool.Clamp(baseX, 0, tileManager.MapPixelWidth - doubleBuffedPanel1.Width);
                    baseY        = MathTool.Clamp(baseY, 0, tileManager.MapPixelHeight - doubleBuffedPanel1.Height);
                    dragStartPos = e.Location;
                    refreshAll.Fire();
                }
            }
            else
            {
                dragStartPos = e.Location;

                var newTarget = battleManager.GetRegionUnitId(baseX + e.Location.X, baseY + e.Location.Y);
                if (newTarget != mouseOnId)
                {
                    mouseOnId = newTarget;
                    refreshAll.Fire();
                }

                var newCellPos = new Point((dragStartPos.X + baseX) / TileManager.CellSize, (dragStartPos.Y + baseY) / TileManager.CellSize);
                if (newCellPos.X != selectCellPos.X || newCellPos.Y != selectCellPos.Y)
                {
                    selectCellPos = newCellPos;
                    refreshAll.Fire();
                }

                if (battleMenu.OnMove(e.X, e.Y))
                {
                    refreshAll.Fire();
                }
            }
        }