Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
    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);
    }