You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.0 KiB

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Networking.Server;
  6. public abstract class GameMode : ScriptableObject
  7. {
  8. public Action RoundStartEvent;
  9. public Action AllPlayersMovedEvent;
  10. public Action RoundEndEvent;
  11. public Action OnGameOverEvent;
  12. /// <summary>
  13. /// Called at the beginning of a new Round
  14. /// </summary>
  15. protected abstract void OnRoundStart(PlayerData[] allPlayers);
  16. /// <summary>
  17. /// Called for each player after they finished one move. Even if they didn't move!
  18. /// </summary>
  19. /// <param name="character">Character which moved</param>
  20. /// <param name="client">Client which controls character</param>
  21. /// <param name="currentBlock">Block which the character finished on</param>
  22. protected abstract void OnPlayerFinishedMove(Character character, ClientData client, Block currentBlock);
  23. /// <summary>
  24. /// Called once after every player has finished one move
  25. /// </summary>
  26. /// <param name="allCharacters">List of all player Info</param>
  27. protected abstract void OnAllPlayersFinishedMove(PlayerData[] allPlayers);
  28. public abstract bool isGameOver(PlayerData[] allPlayers);
  29. public abstract void OnRoundEnd(PlayerData[] allPlayers);
  30. public abstract void OnGameOver(PlayerData[] allPlayers);
  31. public void RoundStart(PlayerData[] allPlayers)
  32. {
  33. OnRoundStart(allPlayers);
  34. RoundStartEvent.Invoke();
  35. }
  36. public void FinishedMove(PlayerData[] allPlayers)
  37. {
  38. foreach (PlayerData player in allPlayers)
  39. OnPlayerFinishedMove(player.character, player.client, player.character.CurrentBlock);
  40. OnAllPlayersFinishedMove(allPlayers);
  41. AllPlayersMovedEvent.Invoke();
  42. }
  43. public void RoundEnd(PlayerData[] allPlayers)
  44. {
  45. OnRoundEnd(allPlayers);
  46. RoundEndEvent.Invoke();
  47. }
  48. public void GameOver(PlayerData[] allPlayers)
  49. {
  50. OnGameOver(allPlayers);
  51. OnGameOverEvent.Invoke();
  52. }
  53. }