Ejemplo n.º 1
0
        public ViewportCoordinates Transform(ViewportCoordinates position)
        {
            var x = position.X * M11 + position.Y * M12 + M13;
            var y = position.X * M21 + position.Y * M22 + M23;

            return(new ViewportCoordinates((int)Math.Round(x), (int)Math.Round(y)));
        }
Ejemplo n.º 2
0
        public static ViewportCoordinates[] OffsetsFor(RenderType t)
        {
            var p = new ViewportCoordinates[6];

            p[(int)SpritePosition.Whole]   = OffsetFor(SpritePosition.Whole, t);
            p[(int)SpritePosition.Up]      = OffsetFor(SpritePosition.Up, t);
            p[(int)SpritePosition.Right]   = OffsetFor(SpritePosition.Right, t);
            p[(int)SpritePosition.Down]    = OffsetFor(SpritePosition.Down, t);
            p[(int)SpritePosition.Left]    = OffsetFor(SpritePosition.Left, t);
            p[(int)SpritePosition.CellMap] = OffsetFor(SpritePosition.CellMap, t);
            return(p);
        }
Ejemplo n.º 3
0
 public MapCoordinate ScreenPositionToMapCoordinate(ViewportCoordinates screenPosition)
 {
     return(config.Viewport.ScreenPositionToMapCoordinate(screenPosition));
 }
Ejemplo n.º 4
0
        public static void OffsetFor(this SpritePosition p, RenderType t, out ViewportCoordinates result)
        {
            if (t.IsIsometric())
            {
                switch (p)
                {
                case SpritePosition.CellMap:
                    result = new ViewportCoordinates(0, 2);
                    break;

                case SpritePosition.Whole:
                    result = new ViewportCoordinates(0, 0);
                    break;

                case SpritePosition.Up:
                    result = new ViewportCoordinates(0, -1);
                    break;

                case SpritePosition.Right:
                    result = new ViewportCoordinates(1, 0);
                    break;

                case SpritePosition.Down:
                    result = new ViewportCoordinates(0, 1);
                    break;

                case SpritePosition.Left:
                    result = new ViewportCoordinates(-1, 0);
                    break;

                default:
                    result = new ViewportCoordinates(0, 0);
                    break;
                }
            }
            else
            {
                switch (p)
                {
                case SpritePosition.CellMap:
                    result = new ViewportCoordinates(2, -2);
                    break;

                case SpritePosition.Whole:
                    result = new ViewportCoordinates(0, 0);
                    break;

                case SpritePosition.Up:
                    result = new ViewportCoordinates(-1, -1);
                    break;

                case SpritePosition.Right:
                    result = new ViewportCoordinates(1, -1);
                    break;

                case SpritePosition.Down:
                    result = new ViewportCoordinates(1, 1);
                    break;

                case SpritePosition.Left:
                    result = new ViewportCoordinates(-1, 1);
                    break;

                default:
                    result = new ViewportCoordinates(0, 0);
                    break;
                }
            }
        }