Skip to content

Commit

Permalink
single player stop not working yet
Browse files Browse the repository at this point in the history
  • Loading branch information
YoupKuiper committed Apr 19, 2018
1 parent 7b51329 commit c651bc7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 22 deletions.
48 changes: 31 additions & 17 deletions Assets/Prefabs/UI/CommandController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Button>().enabled = false;
command.GetComponent<CanvasGroup>().blocksRaycasts = false;
}
Expand Down
14 changes: 10 additions & 4 deletions Assets/Scenes/Development/Demo1.unity
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,10 @@ Prefab:
- target: {fileID: 114819057405445294, guid: f94ab01e1ad9ef24a93b8fc874535d14,
type: 2}
propertyPath: IsMultiPlayer
value: 1
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedComponents:
- {fileID: 114373949805610370, guid: f94ab01e1ad9ef24a93b8fc874535d14, type: 2}
m_ParentPrefab: {fileID: 100100000, guid: f94ab01e1ad9ef24a93b8fc874535d14, type: 2}
m_IsPrefabParent: 0
--- !u!1001 &1204711632
Expand Down Expand Up @@ -280,6 +281,11 @@ Prefab:
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 20262750099508218, guid: c92c7c4bd72c89145b3ab41d6f1c5251,
type: 2}
propertyPath: m_ClearFlags
value: 2
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: c92c7c4bd72c89145b3ab41d6f1c5251, type: 2}
m_IsPrefabParent: 0
Expand Down Expand Up @@ -1046,7 +1052,7 @@ Prefab:
- target: {fileID: 224418313333932214, guid: e33ad771a40c8b447b3db3dd82fbbd28,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -306.99997
value: -199.09601
objectReference: {fileID: 0}
- target: {fileID: 224418313333932214, guid: e33ad771a40c8b447b3db3dd82fbbd28,
type: 2}
Expand Down Expand Up @@ -1076,7 +1082,7 @@ Prefab:
- target: {fileID: 224126922449022640, guid: e33ad771a40c8b447b3db3dd82fbbd28,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -557
value: -449.096
objectReference: {fileID: 0}
- target: {fileID: 224126922449022640, guid: e33ad771a40c8b447b3db3dd82fbbd28,
type: 2}
Expand Down
11 changes: 10 additions & 1 deletion Assets/Scripts/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,16 @@ public void ReadyButtonClicked()

public void StopButtonClicked()
{
OnPlayerStop?.Invoke();
if (_gameManager.IsMultiPlayer)
{
OnPlayerStop?.Invoke();
}
else
{
//Werkt nog niet naar behoren (single player stop)
StopCoroutine(coroutine);
EventManager.OnLevelReset(_gameManager.LevelData, _gameManager.Players.Select(x => x.Player).ToList());
}
}

public void UnreadyButtonClicked()
Expand Down

0 comments on commit c651bc7

Please sign in to comment.