public void UpdateObjectState(DynamicObject obj) { var result = obj.Momentum + _GravityVector * GameCore.Delta; var projection = _GravityVector.X.IsAlmostNull() ? _GravityVector.X : _GravityVector.Y; if (Math.Abs(projection) <= SpeedLimit) obj.Momentum = result; }
public void UpdateObjectState(DynamicObject obj) { var coeff = (1 - _FrictionCoefficient*GameCore.Delta); if((_Direction & FrictionDirection.Horizontal) != 0) obj.Momentum.X *= coeff; if ((_Direction & FrictionDirection.Vertical) != 0) obj.Momentum.Y *= coeff; }
public void UpdateObjectState(DynamicObject obj) { _TimeToLive -= GameCore.Delta; if (_TimeToLive < 0) { obj.Remove(); GameCore.RegisterDeferredAction(() => obj.Behaviours.Remove<TimebombBehaviour>()); } }
public void UpdateObjectState(DynamicObject obj) { _ElapsedTime += GameCore.Delta; if (_ElapsedTime >= _FlipTime) { obj.TransparencyShift = (_FlipsLeft & 1) == 0 ? -1/_FlipTime : 1/_FlipTime; _ElapsedTime = 0; if(_FlipsLeft > 0) _FlipsLeft--; } if (_FlipsLeft == 0) GameCore.RegisterDeferredAction(() => obj.Behaviours.Remove<BlinkingBehaviour>()); }
public void UpdateObjectState(DynamicObject obj) { if (!_IsActivated) { obj.Position = _Points[0]; _IsActivated = true; _Segment = new BezierSegment(_Points[0], _Points[1], _Points[2]); } if (IsFinished || (PauseBinding != null && PauseBinding()) || GameCore.Delta.IsAlmostNull()) return; // calculate the desired momentum var speed = obj.Speed; var oldPoint = _Segment.CurrentPoint; _Segment.Step(speed*GameCore.Delta); var newPoint = _Segment.CurrentPoint; var vector = newPoint - oldPoint; if (vector.Length() > 0) { vector.Normalize(); obj.Momentum = vector*speed; } else { obj.Momentum = Vector2.Zero; } // advance to the next segment if needed if (_Segment.IsFinished) { if (_CurrentPoint + 4 > _Points.Count) { IsFinished = true; GameCore.RegisterDeferredAction(() => { obj.Momentum = Vector2.Zero; obj.Behaviours.Remove<BezierMovementBehaviour>(); } ); return; } _CurrentPoint += 2; _Segment = new BezierSegment(_Points[_CurrentPoint], _Points[_CurrentPoint + 1], _Points[_CurrentPoint+2]); } }
public void UpdateObjectState(DynamicObject obj) { var iObj = obj as InteractableObject; if (iObj == null) return; var box = obj.GetBoundingBox(_Absolute); if (obj.Momentum.X < 0 && box.Left <= _Rect.Left) obj.Momentum.X = Math.Abs(obj.Momentum.X); else if (obj.Momentum.X > 0 && box.Right >= _Rect.Right) obj.Momentum.X = -Math.Abs(obj.Momentum.X); else if (obj.Momentum.Y < 0 && box.Top <= _Rect.Top) obj.Momentum.Y = Math.Abs(obj.Momentum.Y); else if (obj.Momentum.Y > 0 && box.Bottom >= _Rect.Bottom) obj.Momentum.Y = -Math.Abs(obj.Momentum.Y); }
public void UpdateObjectState(DynamicObject obj) { if (_OriginalPosition == null) _OriginalPosition = obj.Position; _ElapsedTime += GameCore.Delta; var time = 1/JitterRate; if (_ElapsedTime > time) { _ElapsedTime -= time; obj.Position = new Vector2( _OriginalPosition.Value.X + Globals.RandomInt(-JitterAmount, JitterAmount), _OriginalPosition.Value.Y + Globals.RandomInt(-JitterAmount, JitterAmount) ); } }
public void UpdateObjectState(DynamicObject obj) { if (!_ElapsedTime.HasValue) return; if (!_Applied) { if (_Effect == FadeEffect.Fade || _Effect == FadeEffect.ZoomAndFade || _Effect == FadeEffect.InverseZoomAndFade) obj.AnimateProperty(AnimatableProperty.Transparency, 0, _Time, _Mode); if (_Effect == FadeEffect.Zoom || _Effect == FadeEffect.ZoomAndFade || _Effect == FadeEffect.InverseZoomAndFade) obj.AnimateProperty(AnimatableProperty.Scale, _Effect == FadeEffect.Zoom ? 0 : 2, _Time, _Mode); _Applied = true; } _ElapsedTime += GameCore.Delta; }
public void UpdateObjectState(DynamicObject obj) { if (!_InitialScale.HasValue) { _InitialScale = obj.Scale; _InitialTransparency = obj.Transparency; } if (_Effect == FadeEffect.Fade || _Effect == FadeEffect.ZoomAndFade || _Effect == FadeEffect.InverseZoomAndFade) { obj.Transparency = 0; obj.AnimateProperty(AnimatableProperty.Transparency, _InitialTransparency.Value, _Time, _Mode); } if (_Effect == FadeEffect.Zoom || _Effect == FadeEffect.ZoomAndFade || _Effect == FadeEffect.InverseZoomAndFade) { obj.Scale = _Effect == FadeEffect.InverseZoomAndFade ? 2 : 0; obj.AnimateProperty(AnimatableProperty.Scale, _InitialScale.Value, _Time, _Mode); } GameCore.RegisterDeferredAction(() => obj.Behaviours.Remove<FadeInBehaviour>()); }
public void ActivateFadeOut(DynamicObject obj) { _ElapsedTime = 0; }
public void ActivateFadeOut(DynamicObject obj) { _Handler(obj); }
public void UpdateObjectState(DynamicObject obj) { }
/// <summary> /// Set the particle's default properties. /// </summary> /// <param name="obj">Particle to tweak.</param> protected virtual void tweakParticle(DynamicObject obj) { obj.Position = ParticleOrigin.GetValue(); obj.Momentum = Globals.CreateVector(ParticlePropulsion.GetValue(), ParticleAngle.GetValue()); obj.Behaviours.Add(new TimebombBehaviour(TimeToLive.GetValue())); // speed optimization: disable touch support for particles var itb = obj as InteractableObject; if (itb != null) itb.IsTouchable = false; }