Scriptum/Assets/Scripts/SceneManager/OnMapAppearanceMethod.cs
2023-01-02 00:22:39 +01:00

125 lines
3.2 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Tell what is the beginning state of loaded scene
[Serializable]
public enum OnMapAppearanceMethodEnum
{
NewGame = 0,
LoadGame = 1,
Gateway = 2
//maybe respawn too
}
[Serializable]
public enum GameStatus
{
NewGame = 0,
Continue = 1
}
[Serializable]
public class OnMapAppearanceMethod : MonoBehaviour
{
[SerializeField]
public static OnMapAppearanceMethodEnum Gateway { get; set; } // Map status
[SerializeField]
public static GameStatus GameStatus { get; set; }
// every script which makes player appear somewhere should change this variable ! ! !
void Awake()
{
if(GameStatus == null)
GameStatus = GameStatus.NewGame;
if(Gateway == null)
Gateway = OnMapAppearanceMethodEnum.NewGame;
}
/// <summary>
/// Set game global state as new game
///
/// Marked after pressing "New Game" on Main Menu
/// </summary>
public static void SetNewGameStatus()
{
GameStatus = GameStatus.NewGame;
Gateway = OnMapAppearanceMethodEnum.NewGame;
}
/// <summary>
/// Function to check if its new game
/// </summary>
/// <returns></returns>
public static bool IsNewGame()
{
return GameStatus == GameStatus.NewGame;
}
/// <summary>
/// Function to set game's global state as continued
///
/// Markes after pressing "Continue" in Main Menu
///
/// In this state we want to use previously saved game data
/// </summary>
public static void SetContinueStatus()
{
GameStatus = GameStatus.Continue;
}
/// <summary>
/// Function to check if its continued game
///
/// In this state we want to use previously saved game data
/// </summary>
/// <returns></returns>
public static bool IsContinue()
{
return GameStatus == GameStatus.Continue;
}
/// <summary>
/// Function to set state as after telkeporting (from another map)
///
/// In this case we want to remember that player went through the teleporter previously ! !
/// </summary>
public static void SetTeleportedStatus()
{
Gateway = OnMapAppearanceMethodEnum.Gateway;
}
/// <summary>
/// Function to check if its continued game but in special game
///
/// In this case we want to make sure ourselves that player previously went through the teleporter ! !
/// </summary>
public static bool IsAfterGateway()
{
return Gateway == OnMapAppearanceMethodEnum.Gateway;
}
/// <summary>
/// Function to check that player just have been started new game
/// </summary>
/// <returns></returns>
public static bool IsNewGameJustLaunched()
{
return IsNewGame() && Gateway == OnMapAppearanceMethodEnum.NewGame;
}
/// <summary>
/// Function to check that player just started game
/// </summary>
/// <returns></returns>
public static bool IsJustLaunched()
{
return (IsNewGame() || IsContinue()) && Gateway == OnMapAppearanceMethodEnum.LoadGame;
}
}