/// <summary> /// 合并 /// </summary> public void Combine() { if (_selectedObjs.Count > 1) { //需要排序,否则绘图的先后顺序会发生改变 int[] indexA = new int[_selectedObjs.Count]; for (int i = 0; i < indexA.Length; i++) { indexA[i] = Objs.IndexOf(_selectedObjs[i]); } Array.Sort(indexA); DrawCombine draw = new DrawCombine(_selectedObjs) { Parant = Container }; _nameManager.CreateName(draw); draw.Layer = DefaultLayer; draw.LoadInitializationEvent(); foreach (IDrawObj obj in _selectedObjs) { Objs.Remove(obj); } Objs.Insert(indexA[0], draw); _selectedObjs.Clear(); if (draw.CanSelect()) { _selectedObjs.Add(draw); } _controlPoint.ChangeSelectObj(_selectedObjs); Container.Invalidate(); } }
public void Group(object sender, EventArgs e) { if (_selectedObjs.Count > 1) { //需要排序,否则绘图的先后顺序会发生改变 int[] indexA = new int[_selectedObjs.Count]; for (int i = 0; i < indexA.Length; i++) { indexA[i] = Objs.IndexOf(_selectedObjs[i]); } Array.Sort(indexA); List <IDrawObj> groupL = indexA.Select(t => Objs[t]).ToList(); DrawGroup group = new DrawGroup(groupL); _nameManager.CreateName(group); group.Layer = DefaultLayer; group.LoadInitializationEvent(); foreach (IDrawObj obj in _selectedObjs) { Objs.Remove(obj); } Objs.Insert(indexA[0], group); _selectedObjs.Clear(); if (group.CanSelect()) { _selectedObjs.Add(group); } _controlPoint.ChangeSelectObj(_selectedObjs); Container.Invalidate(); } }
public void Last(object sender, EventArgs e) { IDrawObj obj = _selectedObjs[0]; Objs.Remove(obj); Objs.Insert(0, obj); obj.Invalidate(); }
public void Top(object sender, EventArgs e) { IDrawObj obj = _selectedObjs[0]; Objs.Remove(obj); Objs.Add(obj); obj.Invalidate(); }
public void Delete() { foreach (IDrawObj obj in _selectedObjs) { Objs.Remove(obj); obj.Invalidate(); _nameManager.RemoveName(obj); } _selectedObjs.Clear(); _controlPoint.ChangeSelectObj(null); }
public void Back(object sender, EventArgs e) { IDrawObj obj = _selectedObjs[0]; int index = Objs.IndexOf(obj); if (index > 0) { Objs.Remove(obj); Objs.Insert(index - 1, obj); obj.Invalidate(); } }
public void Front(object sender, EventArgs e) { IDrawObj obj = _selectedObjs[0]; int index = Objs.IndexOf(obj); if (index != Objs.Count - 1) { Objs.Remove(obj); Objs.Insert(index + 1, obj); obj.Invalidate(); } }
private void UpdateObjects() { foreach (IGameObj o in DeadObjs) { o.Die(this); Objs.Remove(o); } DeadObjs.Clear(); foreach (IGameObj o in NewObjs) { Objs.Add(o); } NewObjs.Clear(); }
// Crap, when must this happen? // It can happen whenever Objs is the current state... which is thoretically always. // This will nuke the particles though. // This is actually pretty close to correct. public void SetLevel(int level) { UpdateObjects(); Objs.Remove(Player); Levels[CurrentLevel].Objs = Objs; // This is PROBABLY right, but I'm not sure. CurrentLevel = level; Objs = Levels[CurrentLevel].Objs; Objs.Add(Player); NewObjs.Clear(); DeadObjs.Clear(); Particles.Clear(); NewParticles.Clear(); DeadParticles.Clear(); UpdateCollisionTree(); }
public void UnGroup(object sender, EventArgs e) { DrawGroup group = null; foreach (IDrawObj obj in _selectedObjs) { if (obj.Type != DrawType.Group) { continue; } group = (DrawGroup)obj; group.Ungroup(); int index = Objs.IndexOf(group); Objs.Remove(group); Objs.InsertRange(index, group.ObjList); } if (group != null) { //去除锁定的控件 int count = group.ObjList.Count; for (int i = count - 1; i >= 0; i--) { IDrawObj obj = group.ObjList[i]; if (!group.ObjList[i].CanSelect()) { group.ObjList.Remove(obj); } } _selectedObjs.Clear(); _selectedObjs.AddRange(group.ObjList); _controlPoint.ChangeSelectObj(_selectedObjs); Container.Invalidate(); } }
public void KillGameObj(IGameObj g) { Objs.Remove(g); DeadObjs.Add(g); }
public void RemoveGameObj(IGameObj g) { Objs.Remove(g); }
public override void Update() { // Change particle colours Color newColour; // Exhaust/explosion colour switch (GM.instance.rnd.Next(3)) { case 1: newColour = Color.Orange; break; case 2: newColour = Color.OrangeRed; break; default: newColour = Color.Red; break; } GM.instance.ParticleBases["exhaust"].Colour = newColour; // Accretion disk colour switch (GM.instance.rnd.Next(6)) { case 1: newColour = Color.BlueViolet; break; case 2: newColour = Color.Red; break; case 3: newColour = Color.Purple; break; case 4: newColour = Color.PaleVioletRed; break; case 5: newColour = Color.Blue; break; default: newColour = Color.Purple; break; } GM.instance.ParticleBases["accretion"].Colour = newColour; // Update system objects foreach (GameObject obj in Objs) { obj.Update(); } // Add queued objects to world UnqueueObjects(); // Decay everything for (int i = Decayables.Count - 1; i > -1; i--) { if (Decayables[i].TTL < 0) { var remove = Decayables[i]; if (remove.Equals(Shoot)) { Shoot = null; } Decayables.RemoveAt(i); Objs.Remove(remove as GameObject); } else { break; } } // Attract to star Star.Attract(User as IGravitable); // Check collisions if (Shoot != null) { for (int i = Orbs.Count - 1; i > -1; i--) { if ((Shoot.Pos - Orbs[i].Pos).Length() < 50) { Orbs[i].Explode(); Objs.Remove(Orbs[i] as GameObject); Orbs.RemoveAt(i); Objs.Remove(Shoot); Shoot = null; break; } } } }
private void RemoveDrawObjOper(IDrawObj obj) { //Undo.Push(CreateDrawObjOper, obj, "Remove"); Objs.Remove(obj); }