using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Networking.Server;
|
|
|
|
public abstract class GameMode : ScriptableObject
|
|
{
|
|
public Action RoundStartEvent;
|
|
public Action AllPlayersMovedEvent;
|
|
public Action RoundEndEvent;
|
|
public Action OnGameOverEvent;
|
|
|
|
/// <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);
|
|
|
|
public abstract void OnRoundEnd(PlayerData[] allPlayers);
|
|
|
|
public abstract void OnGameOver(PlayerData[] 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();
|
|
}
|
|
}
|