Esempio n. 1
0
 private int GetBulletDisplayPart(Bullet bullet)
 {
     return Math.Max(0, GetBulletActualWidth(bullet) - GetBulletHidePart(bullet));
 }
Esempio n. 2
0
 private int GetBulletActualWidth(Bullet bullet)
 {
     return bullet.GetSize(Font).Width + MarginCol;
 }
Esempio n. 3
0
 private int GetBulletHidePart(Bullet bullet)
 {
     return Math.Max(0, GetBulletWidth(bullet) - Width);
 }
Esempio n. 4
0
 private int GetBulletWidth(Bullet bullet)
 {
     return bullet.X + GetBulletActualWidth(bullet);
 }
Esempio n. 5
0
        private void AddBullet(LinkedList<Bullet> row, Bullet bullet, int delayMS)
        {
            if (row.Count > 0)
            {
                bullet.StartX = bullet.X = Math.Max(Width, GetBulletWidth(row.Last()));
            }

            bullet.ShotTime = GetPlayTime();
            bullet.Speed = 1.0 * GetBulletWidth(bullet) / (DurationTime * millisecondsPerSeconds);

            if (delayMS > 0)
            {
                bullet.StartX = bullet.X += (int)Math.Round(bullet.Speed * delayMS);
            }

            row.AddLast(new LinkedListNode<Bullet>(bullet));
        }
Esempio n. 6
0
        private void Shot(Bullet bullet, int delayMS)
        {
            if (Rows.Count == 0)
                return;

            for (int i = 0; i < Rows.Count; ++i)
            {
                if (IsFull(i))
                    continue;

                AddBullet(Rows[i], bullet, delayMS);
                return;
            }


            var row = Rows.OrderBy(r => r.Min(b => GetBulletHidePart(b))).FirstOrDefault();
            AddBullet(row, bullet, delayMS);
        }
Esempio n. 7
0
        public void Shot(string content, Color color, int delayMS = 0)
        {
            var b = new Bullet() { Content = content, Color = color, X = Width, StartX = Width, State = BulletState.Ready };

            Shot(b, delayMS);
        }
Esempio n. 8
0
 private void UpdateBullet(Bullet bullet)
 {
     switch (bullet.State)
     {
         case BulletState.Ready:
             if (GetBulletDisplayPart(bullet) > 0)
                 bullet.State = BulletState.Flying;
             break;
         case BulletState.Flying:
             if (GetBulletWidth(bullet) <= 0)
                 bullet.State = BulletState.Dropped;
             break;
         case BulletState.Dropped:
             break;
     }
 }