public NextQueue(Randomizers.Randomizer randomizer, int capacity = 5, params PieceDefinition[] options) { this.capacity = capacity; this.options = options; this.generator = randomizer(options.Length).GetEnumerator(); this.queue = new Queue <PieceDefinition>(capacity); this.BackgroundColour = new Color(40, 40, 40); InitialLoad(); }
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. public override void Initialize() { base.Initialize(); SetDesignResolution(1280, 720, SceneResolutionPolicy.ShowAllPixelPerfect); ClearColor = new Color(16, 16, 16); AddRenderer(new DefaultRenderer()); AddPostProcessors(); randomizer = Randomizers.BagRandomizer; field = CreateEntity("grid").AddComponent(new Playfield(15) { OutlineColour = Color.White }); field.Transform.Position = new Vector2(Screen.Width / 2 - field.Width / 2, 620); { var outline = Color.OrangeRed; var leftEdge = field.Transform.Position.X; var localNextQueue = CreateEntity("next-queue1", new Vector2(leftEdge - (4 * Constants.pixelsPerTile + 20) - 20, 30)) .AddComponent(new NextQueue(randomizer, options: Tetrominos.tetrominos) { OutlineColour = outline }); var localHoldQueue = CreateEntity("hold-queue1", new Vector2(leftEdge - 2 * (4 * Constants.pixelsPerTile + 20) - 40, 30)) .AddComponent(new HoldQueue() { OutlineColour = outline }); controller1 = CreateEntity("group-controller1"); controller1.AddComponent(new KeyboardControls(lMov: Keys.A, rMov: Keys.D, softDrop: Keys.S, hardDrop: Keys.W, lRot: Keys.D1, rRot: Keys.D2, hold: Keys.D3, delayedAutoShift: 170, autoRepeatRate: 50)); controller1.AddComponent(new PlayerController(field) { nextQueue = localNextQueue, holdQueue = localHoldQueue, outlineTint = outline }); } { var outline = Color.Turquoise; var rightEdge = field.Transform.Position.X + field.Width; var localNextQueue = CreateEntity("next-queue2", new Vector2(rightEdge + 20, 30)) .AddComponent(new NextQueue(randomizer, options: Tetrominos.tetrominos) { OutlineColour = outline }); var localHoldQueue = CreateEntity("hold-queue2", new Vector2(localNextQueue.Width + rightEdge + 40, 30)) .AddComponent(new HoldQueue() { OutlineColour = outline }); controller2 = CreateEntity("group-controller2"); controller2.AddComponent(new KeyboardControls(lRot: Keys.NumPad1, rRot: Keys.NumPad2, hold: Keys.NumPad3, hardDrop: Keys.Up, delayedAutoShift: 170, autoRepeatRate: 50)); controller2.AddComponent(new PlayerController(field) { nextQueue = localNextQueue, holdQueue = localHoldQueue, outlineTint = outline, spawnLocation = new Point(10, 20) }); } Camera.AddComponent <MouseLocator>(); }