private void SendSynchFeed() { for (int idx = 0, l = instructionsFeed.Count; idx < l; idx++) { if (instructionsFeed[idx].LeftOrOn(idx)) { instructionsFeed[idx] = ShiftCommand.MoveLeftFrom(instructionsFeed[idx].command, idx); } } OnSyncCommands?.Invoke(instructionsFeed, heldCard); }
private void UIRobotCommand_OnReleaseRobotCommand(ShiftCommand command, ShiftCommand insertBefore) { if (!robotAlive || reachedGoal) { return; } if (!heldCard.SameAs(command)) { Debug.LogWarning(string.Format("Trying to insert card {0} that doesn't match what is held {1}.", command, heldCard)); return; } bool inserted = false; ShiftCommand insertion = ShiftCommand.NothingHeld; int position = 0; for (int i = 0, l = instructionsFeed.Count; i < l; i++) { if (inserted) { instructionsFeed[i] = ShiftCommand.JumpRight(instructionsFeed[i]); } else { if (instructionsFeed[i].SameAs(insertBefore)) { insertion = ShiftCommand.Insert(instructionsFeed[i], command.command); inserted = true; position = i; } } } if (inserted) { instructionsFeed.Insert(position, insertion); } else { instructionsFeed.Add(ShiftCommand.MoveLeftFrom(command.command, instructionsFeed.Count)); } heldCard = ShiftCommand.NothingHeld; OnSyncCommands?.Invoke(instructionsFeed, heldCard); }
private void DrawOne() { // Get new draw deck if needed if (drawDeck.Count == 0) { FlipTrash(); } // Get the card RobotCommand cmd = RobotCommand.NONE; if (drawDeck.Count > 0) { cmd = drawDeck[0]; drawDeck.RemoveAt(0); } // Insert card instructionsFeed.Add(ShiftCommand.MoveLeftFrom(cmd, instructionsFeed.Count)); // Inform subscribers SendSynchFeed(); }