private int GetBulletDisplayPart(Bullet bullet) { return Math.Max(0, GetBulletActualWidth(bullet) - GetBulletHidePart(bullet)); }
private int GetBulletActualWidth(Bullet bullet) { return bullet.GetSize(Font).Width + MarginCol; }
private int GetBulletHidePart(Bullet bullet) { return Math.Max(0, GetBulletWidth(bullet) - Width); }
private int GetBulletWidth(Bullet bullet) { return bullet.X + GetBulletActualWidth(bullet); }
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)); }
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); }
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); }
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; } }