Ejemplo n.º 1
0
 public void Add(Bullet bullet)
 {
     LiveBullets.Add(new LiveBullet
     {
         Bullet   = bullet,
         Position = GetNewLiveBulletPosition(bullet)
     });
 }
Ejemplo n.º 2
0
 private void AnimatedControl_Draw(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args)
 {
     foreach (var item in LiveBullets.ToList())
     {
         var textFormat = new CanvasTextFormat
         {
             FontSize = item.Bullet.FontSize
         };
         args.DrawingSession.DrawText(item.Bullet.Text, item.Position, item.Bullet.Color, textFormat);
     }
 }
Ejemplo n.º 3
0
        private Vector2 GetNewLiveBulletPosition(Bullet bullet)
        {
            float x         = (float)_animatedControl.Size.Width;
            float boundaryY = (float)_animatedControl.Size.Height;
            float y         = 0;

            if (LiveBullets.Count > 0)
            {
                var last = LiveBullets.Last();
                y = last.Position.Y + last.Bullet.FontSize;
                if (y + bullet.FontSize > boundaryY)
                {
                    y = 0;
                }
            }
            return(new Vector2(x, y));
        }
Ejemplo n.º 4
0
 private void AnimatedControl_Update(ICanvasAnimatedControl sender, CanvasAnimatedUpdateEventArgs args)
 {
     if (State == BulletScreenState.Running)
     {
         foreach (var item in LiveBullets.ToList())
         {
             if (item.Bullet.MoveSpeed.HasValue)
             {
                 item.Position = new Vector2(item.Position.X - item.Bullet.MoveSpeed.Value, item.Position.Y);
             }
             else
             {
                 item.Position = new Vector2(item.Position.X - MoveSpeed, item.Position.Y);
             }
             if (item.Position.X + item.Bullet.Width < 0)
             {
                 LiveBullets.Remove(item);
             }
         }
     }
 }
Ejemplo n.º 5
0
 public void Clear()
 {
     LiveBullets.Clear();
 }