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.
 
 
 
 
 
 

81 lines
2.5 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Networking.Server;
public abstract class GameMode : ScriptableObject
{
[SerializeField]
[Tooltip("Scene to load which contains Gamemode UI")]
private string GameModeScene;
public Action RoundStartEvent;
public Action AllPlayersMovedEvent;
public Action RoundEndEvent;
public Action OnGameOverEvent;
protected abstract void OnGameStart(PlayerData[] allPlayers);
/// <summary>
/// Called at the beginning of a new Round
/// </summary>
protected abstract void OnRoundStart(PlayerData[] allPlayers);
/// <summary>
/// Called for each player after they finished one move. Even if they didn't move!
/// </summary>
/// <param name="character">Character which moved</param>
/// <param name="client">Client which controls character</param>
/// <param name="currentBlock">Block which the character finished on</param>
protected abstract void OnPlayerFinishedMove(Character character, ClientData client, Block currentBlock);
/// <summary>
/// Called once after every player has finished one move
/// </summary>
/// <param name="allCharacters">List of all player Info</param>
protected abstract void OnAllPlayersFinishedMove(PlayerData[] allPlayers);
public abstract bool isGameOver(PlayerData[] allPlayers);
protected abstract void OnRoundEnd(PlayerData[] allPlayers);
protected abstract void OnGameOver(PlayerData[] allPlayers);
public void GameStart(PlayerData[] allPlayers)
{
if (!String.IsNullOrEmpty(GameModeScene))
UnityEngine.SceneManagement.SceneManager.LoadScene(GameModeScene,UnityEngine.SceneManagement.LoadSceneMode.Additive);
OnGameStart(allPlayers);
}
public void RoundStart(PlayerData[] allPlayers)
{
OnRoundStart(allPlayers);
RoundStartEvent?.Invoke();
}
public void FinishedMove(PlayerData[] allPlayers)
{
foreach (PlayerData player in allPlayers)
OnPlayerFinishedMove(player.character, player.client, player.character.CurrentBlock);
OnAllPlayersFinishedMove(allPlayers);
AllPlayersMovedEvent?.Invoke();
}
public void RoundEnd(PlayerData[] allPlayers)
{
OnRoundEnd(allPlayers);
RoundEndEvent?.Invoke();
}
public void GameOver(PlayerData[] allPlayers)
{
OnGameOver(allPlayers);
OnGameOverEvent?.Invoke();
}
}