コード例 #1
0
 private static void ExecuteCommands()
 {
     if (commandBuffer.Count > 0)
     {
         IObjectPlaceCommand command = commandBuffer.Dequeue();
         command.Execute();
         commandHistory.Add(command);
         counter++;
     }
     else
     {
         if (Input.GetKeyDown(KeyCode.Z))
         {
             if (counter > 0)
             {
                 counter--;
                 commandHistory[counter].Undo();
             }
         }
         else if (Input.GetKeyDown(KeyCode.R))
         {
             if (counter < commandHistory.Count)
             {
                 commandHistory[counter].Execute();
                 counter++;
             }
         }
     }
 }
コード例 #2
0
 public static void AddCommand(IObjectPlaceCommand command)
 {
     while (commandHistory.Count > counter)
     {
         commandHistory.RemoveAt(counter);
     }
     commandBuffer.Enqueue(command);
 }