Ejemplo n.º 1
0
 //, float timeMult)
 public PlatformSprite(Texture2D texture, PlatformData data)
     : base(texture, data.StartPos)
 {
     this.data = data;
     this.timeMult = 30;// timeMult;
     myScale = 0.5f;
     myColor.A = baseOpacity;
 }
Ejemplo n.º 2
0
        private void DrawPlatform(Graphics g, PlatformData platform)
        {
            Vector2 pos = platform.GetPosition(Degree);
            Point canvasPos = MapPointOnCanvas(pos);

            Pen pen = editorState.SelectedPlatforms.Contains(platform) ? Pens.DarkRed : Pens.Black;
            if (editorState.SelectedPlatform == platform) pen = Pens.Red;

            Pen circlePen = new Pen(pen.Color, 4);

            if (!platform.Invisible)
            {
                foreach (XNAPoint point in platform.Segments)
                {
                    DrawSegment(canvasPos, g, point);
                }
            }
            else
            {
                Color c = pen.Color;
                c = Color.FromArgb(100, c.R, c.G, c.B);
                pen = new Pen(c);
                circlePen = new Pen(c);
            }

            DrawPath(g, platform, pen);

            DrawSegue(g, platform.StartSegue, pen);

            List<PlatformSegue> segs = new List<PlatformSegue>(platform.segues);
            segs.Insert(0, platform.StartSegue);
            foreach (PlatformSegue segue in segs)
            {
                DrawSegue(g, segue, pen);
            }

            g.DrawEllipse(circlePen, new Rectangle(canvasPos.X - 25, canvasPos.Y - 25, 50, 50));
        }
Ejemplo n.º 3
0
 public MapData()
 {
     startPlatform = new PlatformData(Vector2.Zero);
     Platforms.Add(startPlatform);
     startPlatform.SafePlatform = true;
 }
Ejemplo n.º 4
0
 public void Reset()
 {
     SelectedPlatform = null;
     SelectedPlatforms.Clear();
     SelectedSegue = null;
     SelectedSegues.Clear();
     MapOffset = new Point();
     Degree = 0;
 }
Ejemplo n.º 5
0
        private void updatePlatformOffset(PlatformData platform, int degree, Vector2 pos)
        {
            //look for the closest position in the platform's path
            //to where the mouse is, then offset it so it's there now
            float desiredDegree = 0;
            float minDis = float.MaxValue;
            for (float deg = 0; deg < 360; deg += 0.1f)
            {
                float dis = (platform.GetPosition(deg) - pos).Length();
                if (dis < minDis)
                {
                    minDis = dis;
                    desiredDegree = deg;
                }
            }

            platform.DegreeOffset += desiredDegree - degree;
            platform.DegreeOffset = (platform.DegreeOffset + 360) % 360;
        }
Ejemplo n.º 6
0
 public void MouseUp(MouseEventArgs e)
 {
     //just clear dragging variables
     draggingMap = false;
     draggingPlatform = null;
     draggingSegue = null;
 }
Ejemplo n.º 7
0
        //Ugly method that handles all mouse down events. Needs to be cleaned
        public void MouseDown(MouseEventArgs e)
        {
            Vector2 pos = editorState.MousePosOnMap(e.Location);
            MapData map = editorState.Map;
            shiftDrag = false;

            if (CurrentActionType == Actions.Move)
            {
                startMapDrag(e);
            }
            else if (CurrentActionType == Actions.Platform)
            {
                draggingPlatform = new PlatformData(pos, Degree);
                draggingItemOffset = new Vector2();
                map.Platforms.Add(draggingPlatform);
            }
            else if (CurrentActionType == Actions.Select)
            {

                if (Control.ModifierKeys != Keys.Control)
                {
                    //set selections to null
                    SelectedPlatform = null;
                    SelectedSegue = null;
                    SelectedPlatforms.Clear();
                    SelectedSegues.Clear();
                }
                draggingPlatform = null;
                draggingSegue = null;

                if (SelectedPlatform == null)
                {
                    foreach (PlatformData platform in map.Platforms)
                    {
                        //check the start "segue" which is really just
                        //the start position of the platform
                        //but you can move that, so it's selectable
                        if (segueContains(platform.StartSegue, pos))
                        {
                            SelectedSegue = platform.StartSegue;
                            draggingSegue = SelectedSegue;
                            break;
                        }
                        //and check all the rest
                        foreach (PlatformSegue segue in platform.segues)
                        {
                            if (segueContains(segue, pos))
                            {
                                SelectedSegue = segue;
                                draggingSegue = SelectedSegue;
                                break;
                            }
                        }
                    }
                }

                //drag the selected segue
                if (draggingSegue != null)
                {
                    draggingItemOffset = SelectedSegue.Destination - pos;
                }
                if (SelectedSegue != null && !SelectedSegues.Contains(SelectedSegue))
                {
                    SelectedSegues.Add(SelectedSegue);
                }

                if (SelectedSegue == null)
                {
                    //look for a platform first
                    foreach (PlatformData platform in map.Platforms)
                    {
                        if (platform.contains(pos, Degree))
                        {
                            SelectedPlatform = platform;
                            draggingPlatform = platform;
                        }
                    }
                    if (SelectedPlatform != null)
                    {
                        SelectedPlatforms.Add(SelectedPlatform);
                        shiftDrag = Control.ModifierKeys == Keys.Shift;
                    }
                }

                //drag the selected platform
                draggingPlatform = SelectedPlatform;
                if (draggingPlatform != null)
                {
                    draggingItemOffset = SelectedPlatform.GetPosition(Degree) - pos;
                }

                //if we're not selecting anything, just drag the map
                if (SelectedPlatform == null && SelectedSegue == null)
                {
                    startMapDrag(e);
                }

                if (SelectedPlatform != null && e.Clicks == 2)
                {
                    draggingPlatform = null;
                    platformDialog.EditorState = editorState;
                    platformDialog.ShowDialog();
                }
            }
            else if (CurrentActionType == Actions.Segue)
            {
                //add a new segue and start dragging it
                if (SelectedPlatform == null) return;
                PlatformSegue segue = null;

                if (CurrentSegueType == Segues.Linear)
                {
                    segue = new PlatformSegueLinear(pos);
                }
                else if (CurrentSegueType == Segues.Curved)
                {
                    segue = new PlatformSegueCurved(pos);
                }

                if (segue == null) return;

                SelectedPlatform.segues.Add(segue);
                draggingSegue = segue;
                draggingItemOffset = new Vector2();
            }
        }