From c651bc7faa8faf8536492cb00b3e044329e3ff48 Mon Sep 17 00:00:00 2001 From: yuop Date: Thu, 19 Apr 2018 15:06:23 +0200 Subject: [PATCH] single player stop not working yet --- Assets/Prefabs/UI/CommandController.cs | 48 +++++++++++++++++--------- Assets/Scenes/Development/Demo1.unity | 14 +++++--- Assets/Scripts/Player.cs | 11 +++++- 3 files changed, 51 insertions(+), 22 deletions(-) diff --git a/Assets/Prefabs/UI/CommandController.cs b/Assets/Prefabs/UI/CommandController.cs index 7fa1dad..ac63c12 100644 --- a/Assets/Prefabs/UI/CommandController.cs +++ b/Assets/Prefabs/UI/CommandController.cs @@ -67,43 +67,57 @@ public void Initialize() public void OnMoveButtonClicked() { - _player.AddCommand(_commandLibrary.MoveCommand); - GameObject moveCommand = Instantiate(SequenceBar.MoveCommand); - AddCommandToRightSlotAndFixSettings(moveCommand); + if (SequenceBar.GetNextEmptySlotIndex() != 999) + { + _player.AddCommand(_commandLibrary.MoveCommand); + GameObject moveCommand = Instantiate(SequenceBar.MoveCommand); + AddCommandToRightSlotAndFixSettings(moveCommand); + } } public void OnTurnLeftButtonClicked() { - _player.AddCommand(_commandLibrary.TurnLeftCommand); - GameObject turnLeftCommand = Instantiate(SequenceBar.TurnLeftCommand); - AddCommandToRightSlotAndFixSettings(turnLeftCommand); + if (SequenceBar.GetNextEmptySlotIndex() != 999) + { + _player.AddCommand(_commandLibrary.TurnLeftCommand); + GameObject turnLeftCommand = Instantiate(SequenceBar.TurnLeftCommand); + AddCommandToRightSlotAndFixSettings(turnLeftCommand); + } } public void OnTurnRightButtonClicked() { - _player.AddCommand(_commandLibrary.TurnRightCommand); - GameObject turnRightCommand = Instantiate(SequenceBar.TurnRightCommand); - AddCommandToRightSlotAndFixSettings(turnRightCommand); + if (SequenceBar.GetNextEmptySlotIndex() != 999) + { + _player.AddCommand(_commandLibrary.TurnRightCommand); + GameObject turnRightCommand = Instantiate(SequenceBar.TurnRightCommand); + AddCommandToRightSlotAndFixSettings(turnRightCommand); + } } public void OnWaitButtonClicked() { - _player.AddCommand(_commandLibrary.WaitCommand); - GameObject waitCommand = Instantiate(SequenceBar.WaitCommand); - AddCommandToRightSlotAndFixSettings(waitCommand); + if (SequenceBar.GetNextEmptySlotIndex() != 999) + { + _player.AddCommand(_commandLibrary.WaitCommand); + GameObject waitCommand = Instantiate(SequenceBar.WaitCommand); + AddCommandToRightSlotAndFixSettings(waitCommand); + } } public void OnInteractButtonClicked() { - _player.AddCommand(_commandLibrary.InteractCommand); - GameObject interactCommand = Instantiate(SequenceBar.InteractCommand); - AddCommandToRightSlotAndFixSettings(interactCommand); + if (SequenceBar.GetNextEmptySlotIndex() != 999) + { + _player.AddCommand(_commandLibrary.InteractCommand); + GameObject interactCommand = Instantiate(SequenceBar.InteractCommand); + AddCommandToRightSlotAndFixSettings(interactCommand); + } } private void AddCommandToRightSlotAndFixSettings(GameObject command) { - int nextFreeSlot = SequenceBar.GetNextEmptySlotIndex(); - command.transform.SetParent(SequenceBar.CommandSlots[nextFreeSlot].transform, false); + command.transform.SetParent(SequenceBar.CommandSlots[SequenceBar.GetNextEmptySlotIndex()].transform, false); command.GetComponent