internal void Draw(Camera camera) { var zoomMatrix = IgnoresZoom ? Matrix.Identity : Matrix.CreateScale((float)(camera.ZoomFactor), (float)(camera.ZoomFactor), 1f); var worldMatrix = Matrix.CreateTranslation((float)(-camera.Position.X * RelativeTransition.X), (float)(-camera.Position.Y * RelativeTransition.Y), 0) * zoomMatrix; switch (DrawOrder) { case DrawOrder.Irrelevant: DrawEfficientlyInNoParticularOrder(ref worldMatrix); break; case DrawOrder.FirstToLast: DrawInOrderFromFirstToLast(ref worldMatrix); break; default: break; } //#if !DISABLE_EFFECTS Effects.ForEach(e => e.Draw(worldMatrix)); //#endif if (Grid != null) { DrawGrid(ref worldMatrix); } }
internal void Draw(Camera camera) { var zoomMatrix = IgnoresZoom ? Matrix.Identity : Matrix.CreateScale((float)(camera.ZoomFactor), (float)(camera.ZoomFactor), 1f); var worldMatrix = Matrix.CreateTranslation((float)(-camera.Position.X * RelativeTransition.X), (float)(-camera.Position.Y * RelativeTransition.Y), 0) * zoomMatrix; SortObjects(); switch (DrawOrder) { case DrawOrder.Irrelevant: DrawEfficientlyInNoParticularOrder(ref worldMatrix); break; case DrawOrder.FirstToLast: DrawInOrderFromFirstToLast(ref worldMatrix); // TODO: Halutaanko tätä vaihtoehtoa enää säilyttää, jos piirtojärjestykseen halutaan vaikuttaa, olisi layerit oikea vaihtoehto. break; default: break; } Effects.ForEach(e => e.Draw(worldMatrix)); if (Grid != null) { DrawGrid(ref worldMatrix); } }
/// <summary> /// Alustaa lapsioliot /// </summary> protected virtual void InitChildren() { if (_childObjects != null) { return; } _childObjects = new SynchronousList <GameObject>(); _childObjects.ItemAdded += this.OnChildAdded; _childObjects.ItemRemoved += this.OnChildRemoved; _childObjects.Changed += this.NotifyParentAboutChangedSizingAttributes; this.AddedToGame += () => _childObjects.ForEach(c => Game.OnAddObject(c)); this.Removed += () => _childObjects.ForEach(c => Game.OnRemoveObject(c)); // Objects list needs updating IsUpdated = true; }
/// <summary> /// Poistaa kaikki värähtelyt kappaleelta. /// </summary> /// <param name="returnToOriginalPosition">Palautetaanko kappale takaisin sen alkuperäiseen sijaintiin.</param> /// <param name="stopGradually">Suoritetaanko oskillaatio ensin loppuun, jonka jälkeen vasta pysähdytään alkuperäiseen sijaintiin.</param> public void ClearOscillations(bool returnToOriginalPosition = false, bool stopGradually = false) { if (oscillators != null && oscillators.Count >= 1) { oscillators.ForEach(o => o.Stop(returnToOriginalPosition, stopGradually)); } if (!stopGradually) { oscillators = null; } }
public void UpdateTouches() { lock (TouchLock) { if (!RawTouchesUpdated) { return; } foreach (var rawTouch in RawTouches) { Touch prevTouch = touches.Find(s => s.Id == rawTouch.Id); Touch thisTouch = prevTouch != null ? prevTouch : new Touch(rawTouch); if (!rawTouch.Up) { newTouches.Add(thisTouch); } DownListeners.ForEach(dl => dl.CheckAndInvoke(thisTouch)); if (prevTouch == null) { // New touch PressListeners.ForEach(dl => dl.CheckAndInvoke(thisTouch)); } else if (!rawTouch.Up) { // Existing touch touches.Remove(thisTouch); thisTouch.Update(rawTouch); } } for (int i = 0; i < touches.Count; i++) { // Released touch ReleaseListeners.ForEach(dl => dl.CheckAndInvoke(touches[i])); } DownListeners.UpdateChanges(); PressListeners.UpdateChanges(); ReleaseListeners.UpdateChanges(); touches.Clear(); var empty = touches; touches = newTouches; newTouches = empty; RawTouches.Clear(); RawTouchesUpdated = false; } }
public void UpdateTouches() { var xnaTouches = XnaTouchPanel.GetState(); for (int i = 0; i < xnaTouches.Count; i++) { Touch prevTouch = touches.Find(s => s.Id == xnaTouches[i].Id); Touch thisTouch = prevTouch != null ? prevTouch : new Touch(screen, xnaTouches[i]); newTouches.Add(thisTouch); DownListeners.ForEach(dl => dl.CheckAndInvoke(thisTouch)); if (prevTouch == null) { // New touch PressListeners.ForEach(dl => dl.CheckAndInvoke(thisTouch)); } else { // Existing touch touches.Remove(thisTouch); thisTouch.Update(xnaTouches[i]); } } for (int i = 0; i < touches.Count; i++) { // Released touch ReleaseListeners.ForEach(dl => dl.CheckAndInvoke(touches[i])); } DownListeners.UpdateChanges(); PressListeners.UpdateChanges(); ReleaseListeners.UpdateChanges(); touches.Clear(); var empty = touches; touches = newTouches; newTouches = empty; }
/// <summary> /// Poistaa kaikki ajastimet. /// </summary> internal static void ClearAll() { timers.ForEach(t => { t.Enabled = false; }); timers.Clear(); }
private void RemoveControls() { // SynchronousList removes every destroyed object automatically _controls.ForEach(c => c.Destroy()); }