Exemple #1
0
 public PowerUpStatus(PowerUp powerUp, ImageModel image)
 {
     this.PowerUp = powerUp;
     this.Image = image;
 }
Exemple #2
0
 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);
 }
Exemple #6
0
        /// <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;
        }
Exemple #7
0
        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;
        }
Exemple #8
0
 public void SetFps(ImageModel model, int fps)
 {
     model.FPS = fps;
 }
Exemple #9
0
 /// <summary>
 /// Set current frame at given image model
 /// </summary>
 /// <param name="model"></param>
 public void SetFrame(ImageModel model, int frame)
 {
     model.CurrentFrame = frame;
 }
Exemple #10
0
 /// <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);
 }
Exemple #11
0
 public void RemovePosition(ImageModel pos)
 {
     if (pos != null)
         imageQueue.Enqueue(Tuple.Create(false, pos));
 }
Exemple #12
0
 /// <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);
 }
Exemple #13
0
        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;
        }
Exemple #14
0
 /// <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);
 }
Exemple #15
0
        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;
        }
Exemple #16
0
        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;
        }