Scriptum/Assets/Scripts/SceneManager/OnMapAppearanceMethod.cs

125 lines
3.2 KiB
C#
Raw Permalink Normal View History

2023-01-02 00:05:47 +01:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2022-12-06 01:20:01 +01:00
// Tell what is the beginning state of loaded scene
2023-01-02 00:05:47 +01:00
[Serializable]
public enum OnMapAppearanceMethodEnum
{
NewGame = 0,
LoadGame = 1,
Gateway = 2
//maybe respawn too
}
2023-01-02 00:05:47 +01:00
[Serializable]
2022-12-06 01:20:01 +01:00
public enum GameStatus
{
NewGame = 0,
Continue = 1
}
2023-01-02 00:05:47 +01:00
[Serializable]
public class OnMapAppearanceMethod : MonoBehaviour
{
2023-01-02 00:05:47 +01:00
[SerializeField]
2022-12-06 01:20:01 +01:00
public static OnMapAppearanceMethodEnum Gateway { get; set; } // Map status
2023-01-02 00:05:47 +01:00
[SerializeField]
2022-12-06 01:20:01 +01:00
public static GameStatus GameStatus { get; set; }
// every script which makes player appear somewhere should change this variable ! ! !
void Awake()
{
2022-12-06 01:20:01 +01:00
if(GameStatus == null)
GameStatus = GameStatus.NewGame;
if(Gateway == null)
Gateway = OnMapAppearanceMethodEnum.NewGame;
}
2022-12-06 01:20:01 +01:00
/// <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;
}
}