Exemplo n.º 1
0
        public void RemoveOffscreenObjects()
        {
            bool firstOne = true;
            LevelEntryCollection removes    = new LevelEntryCollection();
            RectangleF           insideRect = RectangleF.FromLTRB(-Level.DrawAdjustX, -Level.DrawAdjustY, 800 - Level.DrawAdjustX, 600 - Level.DrawAdjustY);

            foreach (LevelEntry o in mLevel.Entries)
            {
                PointF pegPnt = new PointF(o.X, o.Y);

                if (!insideRect.Contains(pegPnt))
                {
                    if (firstOne)
                    {
                        CreateUndoPoint();
                        firstOne = false;
                    }

                    removes.Add((LevelEntry)o);
                }
            }

            foreach (LevelEntry le in removes)
            {
                le.OnDelete();
                mLevel.Entries.Remove(le);
            }

            UpdateRedraw();

            CheckSelectionChanged();
        }
Exemplo n.º 2
0
		public LevelEntryCollection GetSelectedObjects()
		{
			LevelEntryCollection objects = new LevelEntryCollection();
			foreach (LevelEntry le in mSelectedEntries) {
				objects.Add(le);
			}

			return objects;
		}
Exemplo n.º 3
0
        public LevelEntryCollection GetSelectedObjects()
        {
            LevelEntryCollection objects = new LevelEntryCollection();

            foreach (LevelEntry le in mSelectedEntries)
            {
                objects.Add(le);
            }

            return(objects);
        }
Exemplo n.º 4
0
		public LevelEntryCollection GetSelectedObjectsInZOrder()
		{
			LevelEntryCollection objects = new LevelEntryCollection();
			foreach (LevelEntry le in Level.Entries) {
				if (!mSelectedEntries.Contains(le))
					continue;

				objects.Add(le);
			}

			return objects;
		}
Exemplo n.º 5
0
        public LevelEntryCollection GetSelectedObjectsInZOrder()
        {
            LevelEntryCollection objects = new LevelEntryCollection();

            foreach (LevelEntry le in Level.Entries)
            {
                if (!mSelectedEntries.Contains(le))
                {
                    continue;
                }

                objects.Add(le);
            }

            return(objects);
        }
Exemplo n.º 6
0
		public void CreateUndoPoint()
		{
			LevelEntryCollection copies = new LevelEntryCollection();
			foreach (LevelEntry le in mLevel.Entries) {
				copies.Add((LevelEntry)le.Clone());
			}

			//if (mHistory.Count >= 100) {
			//    Queue<LevelEntry[]> tmpQueue = new Queue<LevelEntry[]>();
			//    while (mHistory.Count > 0) {
			//        tmpQueue.Enqueue(mHistory.Pop());
			//    }

			//    for (int i = 0; i < 99; i++) {
			//        mHistory.Push(tmpQueue.Dequeue());
			//    }
			//}

			mHistory.Push(copies.ToArray());
		}
Exemplo n.º 7
0
        public void CreateUndoPoint()
        {
            LevelEntryCollection copies = new LevelEntryCollection();

            foreach (LevelEntry le in mLevel.Entries)
            {
                copies.Add((LevelEntry)le.Clone());
            }

            //if (mHistory.Count >= 100) {
            //    Queue<LevelEntry[]> tmpQueue = new Queue<LevelEntry[]>();
            //    while (mHistory.Count > 0) {
            //        tmpQueue.Enqueue(mHistory.Pop());
            //    }

            //    for (int i = 0; i < 99; i++) {
            //        mHistory.Push(tmpQueue.Dequeue());
            //    }
            //}

            mHistory.Push(copies.ToArray());
        }
Exemplo n.º 8
0
        private void duplicateAndPhaseRibbonButton_Click(object sender, EventArgs e)
        {
            if (!IsEditorAvailable())
            {
                return;
            }

            //Check if there is only one peg selected
            LevelEntryCollection objs = LevelEditor.GetSelectedObjects();

            if (objs.Count != 1)
            {
                MessageBox.Show("You must have only one movement peg selected.");
                return;
            }

            //Check if its a moving peg
            LevelEntry movementPeg = objs[0];

            if (movementPeg == null)
            {
                MessageBox.Show("You must have only one movement peg selected.");
                return;
            }

            //Check if the peg has moving details
            Movement movement = movementPeg.MovementInfo;

            if (movement == null)
            {
                MessageBox.Show("The peg must have movement properties.");
                return;
            }

            //Find out how many pegs to duplicate
            string ans = InputForm.Show("How many pegs would you like in this movement cycle, including the selected one?", "Duplicate and Phase", "8");
            int    num_pegs;

            if (!Int32.TryParse(ans, out num_pegs) || num_pegs < 0 || num_pegs > 100)
            {
                MessageBox.Show("Invalid number of pegs.");
                return;
            }

            LevelEntryCollection entries = new LevelEntryCollection();

            entries.Add((LevelEntry)objs[0]);

            //Duplicate the peg
            for (int i = 0; i < num_pegs - 1; i++)
            {
                LevelEntry entry = (LevelEntry)objs[0].Clone();
                LevelEditor.Level.Entries.Add(entry);
                entries.Add(entry);
            }

            LevelEditor.ClearSelection();
            LevelEditor.SelectedEntries = entries;

            spreadPhaseRibbonButton_Click(sender, e);

            LevelEditor.UpdateRedraw();
            UpdatePropertyGrid();
        }
Exemplo n.º 9
0
		private void duplicateAndPhaseRibbonButton_Click(object sender, EventArgs e)
		{
			if (!IsEditorAvailable())
				return;

			//Check if there is only one peg selected
			LevelEntryCollection objs = LevelEditor.GetSelectedObjects();
			if (objs.Count != 1) {
				MessageBox.Show("You must have only one movement peg selected.");
				return;
			}

			//Check if its a moving peg
			LevelEntry movementPeg = objs[0];
			if (movementPeg == null) {
				MessageBox.Show("You must have only one movement peg selected.");
				return;
			}

			//Check if the peg has moving details
			Movement movement = movementPeg.MovementInfo;
			if (movement == null) {
				MessageBox.Show("The peg must have movement properties.");
				return;
			}

			//Find out how many pegs to duplicate
			string ans = InputForm.Show("How many pegs would you like in this movement cycle, including the selected one?", "Duplicate and Phase", "8");
			int num_pegs;
			if (!Int32.TryParse(ans, out num_pegs) || num_pegs < 0 || num_pegs > 100) {
				MessageBox.Show("Invalid number of pegs.");
				return;
			}

			LevelEntryCollection entries = new LevelEntryCollection();
			entries.Add((LevelEntry)objs[0]);

			//Duplicate the peg
			for (int i = 0; i < num_pegs - 1; i++) {
				LevelEntry entry = (LevelEntry)objs[0].Clone();
				LevelEditor.Level.Entries.Add(entry);
				entries.Add(entry);
			}

			LevelEditor.ClearSelection();
			LevelEditor.SelectedEntries = entries;

			spreadPhaseRibbonButton_Click(sender, e);

			LevelEditor.UpdateRedraw();
			UpdatePropertyGrid();
		}
Exemplo n.º 10
0
		public LevelEntry[] GetPegsIn(RectangleF rect)
		{
			LevelEntryCollection entries = new LevelEntryCollection();
			foreach (LevelEntry le in mEntries) {
				if (le.HasPegInfo) {
					RectangleF pBounds = new RectangleF(le.X - 10, le.Y - 10, 20, 20);
					if (pBounds.IntersectsWith(rect)) {
						entries.Add(le);
					}
				} else if (le is Brick) {
					Brick b = (Brick)le;
					RectangleF bBounds = new RectangleF(b.X - (b.Width / 2), b.Y - (b.Width / 2), b.Width, b.Width);
					if (bBounds.IntersectsWith(rect)) {
						entries.Add(b);
					}
				}
			}

			return entries.ToArray();
		}
Exemplo n.º 11
0
		public LevelEntry[] GetObjectsIn(RectangleF rect)
		{
			LevelEntryCollection entries = new LevelEntryCollection();
			foreach (LevelEntry le in mEntries) {
				RectangleF pBounds = le.Bounds;
				if (pBounds.IntersectsWith(rect)) {
					entries.Add(le);
				}
			}

			return entries.ToArray();
		}
Exemplo n.º 12
0
		public void RemoveOffscreenObjects()
		{
			bool firstOne = true;
			LevelEntryCollection removes = new LevelEntryCollection();
			RectangleF insideRect = RectangleF.FromLTRB(-Level.DrawAdjustX, -Level.DrawAdjustY, 800 - Level.DrawAdjustX, 600 - Level.DrawAdjustY);
			foreach (LevelEntry o in mLevel.Entries) {
				PointF pegPnt = new PointF(o.X, o.Y);

				if (!insideRect.Contains(pegPnt)) {
					if (firstOne) {
						CreateUndoPoint();
						firstOne = false;
					}

					removes.Add((LevelEntry)o);
				}
			}

			foreach (LevelEntry le in removes) {
				le.OnDelete();
				mLevel.Entries.Remove(le);
			}

			UpdateRedraw();

			CheckSelectionChanged();

		}
Exemplo n.º 13
0
        public void AddToSelection(LevelEntry entry)
        {
            mSelectedEntries.Add(entry);

            CheckSelectionChanged();
        }