Advertisement
dronkowitz

GameInstance.cs

Mar 1st, 2021 (edited)
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.68 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public static class GameInstance
  7. {
  8.     public static int currentRings = 0;
  9.     public static int goalring = 0;
  10.     public static SaveData currentSave;
  11.     public static int character = 0;
  12.     public static float timeSeconds = 0;
  13.     public static int scoreCount;
  14.     public static int currentTeam;
  15.     public static int livesCount;
  16.     public static bool[] emerald;
  17.     public static bool greenEmerald, blueEmerald, yellowEmerald, whiteEmerald, lightBlueEmerald, purpleEmerald, redEmerald;
  18.     public static TeamComposition TeamComp;
  19.     public static int speedScore, flyScore, powerScore, bonusScore;
  20.     public static int speedLevelUp, flyLevelUp, powerLevelUp;
  21.     private static int saveSlot;
  22.     public static int LevelScore
  23.     {
  24.         get
  25.         {
  26.             return (speedScore + flyScore + powerScore + bonusScore);
  27.         }
  28.     }
  29.  
  30.     public static int speedCoreLevelUp { get; internal set; }
  31.     public static int flyCorelevelUp { get; internal set; }
  32.     public static int powerLevelUpCore { get; internal set; }
  33.  
  34.     public delegate void BasicDelegate();
  35.     public static BasicDelegate UpdateData;
  36.  
  37.     public static void SetTime(int levelNumber, float timeSeconds)
  38.     {
  39.         currentSave.Times[levelNumber] = timeSeconds;
  40.     }
  41.     public static void CreateSave()
  42.     {
  43.         currentSave = new SaveData
  44.         {
  45.             Score = scoreCount,
  46.             TeamUsed = currentTeam,
  47.             ChaosEmerald = emerald,
  48.             Lives = livesCount,
  49.             CurrentLevel = SceneManager.GetActiveScene().name
  50.         };
  51.  
  52.         SaveLoad.SaveGame(currentSave, saveSlot);
  53.  
  54.     }
  55.  
  56.     public static void LoadSave(int Slot)
  57.     {
  58.         if (SaveLoad.Load(Slot))
  59.         {
  60.             currentSave = SaveLoad.SavedGame;
  61.             saveSlot = Slot;
  62.         }
  63.     }
  64.  
  65.     public static void AddRings(CHARACTERTYPES type)
  66.     {
  67.         if (type == CHARACTERTYPES.Speed) speedScore += 10;
  68.         if (type == CHARACTERTYPES.Fly) flyScore += 10;
  69.         if (type == CHARACTERTYPES.Power) powerScore += 10;
  70.         currentRings += 1;
  71.         UpdateData?.Invoke();
  72.     }
  73.  
  74.     public static void AddScore(int points, CHARACTERTYPES type)
  75.     {
  76.         if (type == CHARACTERTYPES.Speed) speedScore += points;
  77.         if (type == CHARACTERTYPES.Fly) flyScore += points;
  78.         if (type == CHARACTERTYPES.Power) powerScore += points;
  79.         UpdateData?.Invoke();
  80.     }
  81.  
  82.     public static int RemoveRings()
  83.     {
  84.         int rings = currentRings;
  85.         currentRings = 0;
  86.         UpdateData?.Invoke();
  87.         return rings;
  88.     }
  89. }
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement