public void CommandsTest() { CommandList cl = new CommandList(); cl.Push(new Command("North")); cl.Push(new Command("West")); cl.Push(new Command("South")); cl.Pop(); cl.Push(new Command("West")); Assert.Equal("WestWestNorth", cl.Execute()); }
void Update() { if (Input.GetKeyDown(KeyCode.W)) { _CommandList.Execute(new MoveCommand(this, Vector3.up)); } if (Input.GetKeyDown(KeyCode.A)) { _CommandList.Execute(new MoveCommand(this, Vector3.left)); } if (Input.GetKeyDown(KeyCode.S)) { _CommandList.Execute(new MoveCommand(this, Vector3.down)); } if (Input.GetKeyDown(KeyCode.D)) { _CommandList.Execute(new MoveCommand(this, Vector3.right)); } if (Input.GetKeyDown(KeyCode.Keypad0)) { _CommandList.Execute(new ColorCommand(this, Color.white)); } if (Input.GetKeyDown(KeyCode.Keypad1)) { _CommandList.Execute(new ColorCommand(this, Color.green)); } if (Input.GetKeyDown(KeyCode.Keypad2)) { _CommandList.Execute(new ColorCommand(this, Color.red)); } if (Input.GetKeyDown(KeyCode.Keypad3)) { _CommandList.Execute(new ColorCommand(this, Color.blue)); } if (Input.GetKey(KeyCode.KeypadMinus)) { _CommandList.Undo(); } if (Input.GetKey(KeyCode.KeypadPlus)) { _CommandList.Redo(); } }