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;
///
/// Called at the beginning of a new Round
///
protected abstract void OnRoundStart(PlayerData[] allPlayers);
///
/// Called for each player after they finished one move. Even if they didn't move!
///
/// Character which moved
/// Client which controls character
/// Block which the character finished on
protected abstract void OnPlayerFinishedMove(Character character, ClientData client, Block currentBlock);
///
/// Called once after every player has finished one move
///
/// List of all player Info
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();
}
}