public PowerUpStatus(PowerUp powerUp, ImageModel image) { this.PowerUp = powerUp; this.Image = image; }
private void BgImageAnimationDone(ImageController target, ImageModel imagePosition) { if (imagePosition.CurrentPos.Y <= -10) target.IsVisible = false; }
private void OnAnimationDone(ImageController img, ImageModel pos) { switch (State) { case PopupState.Colapsed: break; case PopupState.GamePause: ShowGamePauseMenu(); break; case PopupState.Removed: break; case PopupState.Options: ShowOptionsMenu(); break; case PopupState.Help: ShowHelpMenu(); break; default: break; } }
private void countDownNext(ImageModel imgModel) { if (imgModel.CurrentFrame == 3) { imgModel.AnimationOn = false; RemoveController(countDown); } else { if (imgModel.CurrentFrame == 2) { imgModel.EndScale = 1.1f; } imgModel.CurrentFrame++; } }
private void OnHitAnimationDone(ImageController target, ImageModel imagePosition) { target.RemovePosition(imagePosition); }
/// <summary> /// Remove all other image models and create new model with position /// </summary> public ImageModel SetPosition(Vector2 pos) { this.imageModels = new List<ImageModel>(); this.imageView.imageModels = imageModels; var model = new ImageModel(pos) { CurrentScale = ScaleDefault, Origin = OriginDefault }; this.imageModels.Add(model); return model; }
private bool updateAnimation(GameTime gameTime, ImageModel model) { model.timeUsed += gameTime.ElapsedGameTime.Milliseconds; float percent = model.timeUsed / model.timeTotal; if (percent >= 1) { if (model.Callback != null) { model.Callback.Invoke(model); } if (model.loop) { if(model.animatePos) model.CurrentPos = model.StartPos; if(model.animateScale) model.CurrentScale = model.StartScale; if (model.animateFrame) model.CurrentFrame = model.StartFrame; model.timeUsed = 0; } else { model.CurrentPos = model.EndPos; model.CurrentScale = model.EndScale; model.CurrentFrame = model.EndFrame; model.AnimationOn = false; return true; } } else { if (model.animateFrame) { DebugWrite("Frame",model.StartFrame + (int)Math.Round((model.EndFrame - model.StartFrame) * percent)); model.CurrentFrame = model.StartFrame + (int)Math.Round((model.EndFrame - model.StartFrame) * percent); } if (model.animateScale) model.CurrentScale = model.StartScale + (model.EndScale + -model.StartScale) * percent; if (model.animatePos) model.CurrentPos = model.StartPos + (model.EndPos - model.StartPos) * percent; } return false; }
public void SetFps(ImageModel model, int fps) { model.FPS = fps; }
/// <summary> /// Set current frame at given image model /// </summary> /// <param name="model"></param> public void SetFrame(ImageModel model, int frame) { model.CurrentFrame = frame; }
/// <summary> /// Annimates the given model to the given scale /// </summary> public void AnimateScale(ImageModel model, float toScale, float timeInMs, bool loop = false) { Animate(model, model.CurrentPos, timeInMs, loop, toScale); }
public void RemovePosition(ImageModel pos) { if (pos != null) imageQueue.Enqueue(Tuple.Create(false, pos)); }
/// <summary> /// Annimates the given model to the given position(x,y) /// </summary> public void AnimatePos(ImageModel model, float toX, float toY, float timeInMs, bool loop = false) { this.Animate(model, new Vector2(toX,toY), timeInMs, loop, model.CurrentScale); }
public void AnimateFrame(ImageModel model, int startFrame, int endFrame, int fps, bool loop = true) { model.StartFrame = startFrame; model.CurrentFrame = startFrame; model.EndFrame = endFrame; model.timeTotal = ((endFrame - startFrame) / fps) * 1000; model.loop = loop; model.animateFrame = true; }
/// <summary> /// Animates texture at positionIndex /// </summary> /// <param name="xTo">new X position</param> /// <param name="yTo">new Y position</param> /// <param name="timeInMs">Time to use to animate</param> public void Animate(ImageModel model, float toX, float toY, float timeInMs, bool loop = false, float toScale = 1f) { Animate(model, new Vector2(toX, toY), timeInMs, loop, toScale); }
public void Animate(ImageModel model, Vector2 toPos, float timeInMs, bool loop, float toScale = 1f) { model.StartPos = new Vector2(model.CurrentPos.X, model.CurrentPos.Y); model.EndPos = toPos; model.StartScale = model.CurrentScale; model.EndScale = toScale; model.loop = loop; model.timeTotal = timeInMs; model.timeUsed = 0; //Check what kind of animation that is started model.animatePos = model.EndPos.X != model.StartPos.X || model.EndPos.Y != model.StartPos.Y; model.animateScale = model.EndScale != model.StartScale; }
public ImageModel AddPosition(Vector2 pos, int posId = -1) { ImageModel i = null; //Sjekker om pos id eksisterer fra før if (posId != -1) { var c = imageModels.Where(a => a.Id == posId); i = c.Count() != 0 ? c.First() : null; if (i != null) i.CurrentPos = pos; } if (i == null) { i = new ImageModel(pos, ScaleDefault) { Id = posId , Origin = OriginDefault}; imageQueue.Enqueue(Tuple.Create(true, i)); } return i; }