diff --git a/Assets/ParrelSync/Examples/CustomArgumentExample.cs b/Assets/ParrelSync/Examples/CustomArgumentExample.cs
index 3d9b1a6c5..147674897 100644
--- a/Assets/ParrelSync/Examples/CustomArgumentExample.cs
+++ b/Assets/ParrelSync/Examples/CustomArgumentExample.cs
@@ -1,19 +1,14 @@
// This should be editor only
+
#if UNITY_EDITOR
-using System.Collections;
-using System.Collections.Generic;
using UnityEngine;
-namespace ParrelSync.Example
-{
- public class CustomArgumentExample : MonoBehaviour
- {
+namespace ParrelSync.Example {
+ public class CustomArgumentExample : MonoBehaviour {
// Start is called before the first frame update
- void Start()
- {
+ private void Start() {
// Is this editor instance running a clone project?
- if (ClonesManager.IsClone())
- {
+ if (ClonesManager.IsClone()) {
Debug.Log("This is a clone project.");
//Argument can be set from the clones manager window.
@@ -21,8 +16,7 @@ namespace ParrelSync.Example
Debug.Log("The custom argument of this clone project is: " + customArgument);
// Do what ever you need with the argument string.
}
- else
- {
+ else {
Debug.Log("This is the original project.");
}
}
diff --git a/Assets/ParrelSync/ParrelSync/Editor/AssetModBlock/EditorQuit.cs b/Assets/ParrelSync/ParrelSync/Editor/AssetModBlock/EditorQuit.cs
index dc181d19b..5bc480aed 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/AssetModBlock/EditorQuit.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/AssetModBlock/EditorQuit.cs
@@ -1,22 +1,20 @@
using UnityEditor;
-namespace ParrelSync
-{
+
+namespace ParrelSync {
[InitializeOnLoad]
- public class EditorQuit
- {
+ public class EditorQuit {
+ static EditorQuit() {
+ IsQuiting = false;
+ EditorApplication.quitting += Quit;
+ }
+
///
- /// Is editor being closed
+ /// Is editor being closed
///
- static public bool IsQuiting { get; private set; }
- static void Quit()
- {
- IsQuiting = true;
- }
+ public static bool IsQuiting { get; private set; }
- static EditorQuit()
- {
- IsQuiting = false;
- EditorApplication.quitting += Quit;
+ private static void Quit() {
+ IsQuiting = true;
}
}
}
\ No newline at end of file
diff --git a/Assets/ParrelSync/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs b/Assets/ParrelSync/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs
index 6587482ad..1afa63f1c 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/AssetModBlock/ParrelSyncAssetModificationProcessor.cs
@@ -1,18 +1,14 @@
using UnityEditor;
using UnityEngine;
-namespace ParrelSync
-{
+
+namespace ParrelSync {
///
- /// For preventing assets being modified from the clone instance.
+ /// For preventing assets being modified from the clone instance.
///
- public class ParrelSyncAssetModificationProcessor : UnityEditor.AssetModificationProcessor
- {
- public static string[] OnWillSaveAssets(string[] paths)
- {
- if (ClonesManager.IsClone() && Preferences.AssetModPref.Value)
- {
- if (paths != null && paths.Length > 0 && !EditorQuit.IsQuiting)
- {
+ public class ParrelSyncAssetModificationProcessor : AssetModificationProcessor {
+ public static string[] OnWillSaveAssets(string[] paths) {
+ if (ClonesManager.IsClone() && Preferences.AssetModPref.Value) {
+ if (paths != null && paths.Length > 0 && !EditorQuit.IsQuiting) {
EditorUtility.DisplayDialog(
ClonesManager.ProjectName + ": Asset modifications saving detected and blocked",
"Asset modifications saving are blocked in the clone instance. \n\n" +
@@ -21,13 +17,12 @@ namespace ParrelSync
"Please use the original editor window if you want to make changes to the project files.",
"ok"
);
- foreach (var path in paths)
- {
- Debug.Log("Attempting to save " + path + " are blocked.");
- }
+ foreach (string path in paths) Debug.Log("Attempting to save " + path + " are blocked.");
}
- return new string[0] { };
+
+ return new string[0]{ };
}
+
return paths;
}
}
diff --git a/Assets/ParrelSync/ParrelSync/Editor/ClonesManager.cs b/Assets/ParrelSync/ParrelSync/Editor/ClonesManager.cs
index 9fd125ac8..d5d2256f0 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/ClonesManager.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/ClonesManager.cs
@@ -1,138 +1,131 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Diagnostics;
-using UnityEngine;
-using UnityEditor;
-using System.Linq;
using System.IO;
+using System.Linq;
+using System.Text;
+using UnityEditor;
+using UnityEngine;
using Debug = UnityEngine.Debug;
-namespace ParrelSync
-{
+namespace ParrelSync {
///
- /// Contains all required methods for creating a linked clone of the Unity project.
+ /// Contains all required methods for creating a linked clone of the Unity project.
///
- public class ClonesManager
- {
+ public class ClonesManager {
///
- /// Name used for an identifying file created in the clone project directory.
+ /// Name used for an identifying file created in the clone project directory.
///
///
- /// (!) Do not change this after the clone was created, because then connection will be lost.
+ /// (!) Do not change this after the clone was created, because then connection will be lost.
///
public const string CloneFileName = ".clone";
///
- /// Suffix added to the end of the project clone name when it is created.
+ /// Suffix added to the end of the project clone name when it is created.
///
///
- /// (!) Do not change this after the clone was created, because then connection will be lost.
+ /// (!) Do not change this after the clone was created, because then connection will be lost.
///
public const string CloneNameSuffix = "_clone";
public const string ProjectName = "ParrelSync";
///
- /// The maximum number of clones
+ /// The maximum number of clones
///
public const int MaxCloneProjectCount = 10;
///
- /// Name of the file for storing clone's argument.
+ /// Name of the file for storing clone's argument.
///
public const string ArgumentFileName = ".parrelsyncarg";
///
- /// Default argument of the new clone
+ /// Default argument of the new clone
///
public const string DefaultArgument = "client";
#region Managing clones
///
- /// Creates clone from the project currently open in Unity Editor.
+ /// Creates clone from the project currently open in Unity Editor.
///
///
- public static Project CreateCloneFromCurrent()
- {
- if (IsClone())
- {
+ public static Project CreateCloneFromCurrent() {
+ if (IsClone()) {
Debug.LogError("This project is already a clone. Cannot clone it.");
return null;
}
- string currentProjectPath = ClonesManager.GetCurrentProjectPath();
- return ClonesManager.CreateCloneFromPath(currentProjectPath);
+ string currentProjectPath = GetCurrentProjectPath();
+ return CreateCloneFromPath(currentProjectPath);
}
///
- /// Creates clone of the project located at the given path.
+ /// Creates clone of the project located at the given path.
///
///
///
- public static Project CreateCloneFromPath(string sourceProjectPath)
- {
- Project sourceProject = new Project(sourceProjectPath);
+ public static Project CreateCloneFromPath(string sourceProjectPath) {
+ Project sourceProject = new(sourceProjectPath);
string cloneProjectPath = null;
//Find available clone suffix id
- for (int i = 0; i < MaxCloneProjectCount; i++)
- {
- string originalProjectPath = ClonesManager.GetCurrentProject().projectPath;
- string possibleCloneProjectPath = originalProjectPath + ClonesManager.CloneNameSuffix + "_" + i;
+ for (int i = 0; i < MaxCloneProjectCount; i++) {
+ string originalProjectPath = GetCurrentProject().projectPath;
+ string possibleCloneProjectPath = originalProjectPath + CloneNameSuffix + "_" + i;
- if (!Directory.Exists(possibleCloneProjectPath))
- {
+ if (!Directory.Exists(possibleCloneProjectPath)) {
cloneProjectPath = possibleCloneProjectPath;
break;
}
}
- if (string.IsNullOrEmpty(cloneProjectPath))
- {
+ if (string.IsNullOrEmpty(cloneProjectPath)) {
Debug.LogError("The number of cloned projects has reach its limit. Limit: " + MaxCloneProjectCount);
return null;
}
- Project cloneProject = new Project(cloneProjectPath);
+ Project cloneProject = new(cloneProjectPath);
Debug.Log("Start cloning project, original project: " + sourceProject + ", clone project: " + cloneProject);
- ClonesManager.CreateProjectFolder(cloneProject);
+ CreateProjectFolder(cloneProject);
//Copy Folders
Debug.Log("Library copy: " + cloneProject.libraryPath);
- ClonesManager.CopyDirectoryWithProgressBar(sourceProject.libraryPath, cloneProject.libraryPath,
+ CopyDirectoryWithProgressBar(sourceProject.libraryPath, cloneProject.libraryPath,
"Cloning Project Library '" + sourceProject.name + "'. ");
Debug.Log("Packages copy: " + cloneProject.libraryPath);
- ClonesManager.CopyDirectoryWithProgressBar(sourceProject.packagesPath, cloneProject.packagesPath,
- "Cloning Project Packages '" + sourceProject.name + "'. ");
+ CopyDirectoryWithProgressBar(sourceProject.packagesPath, cloneProject.packagesPath,
+ "Cloning Project Packages '" + sourceProject.name + "'. ");
//Link Folders
- ClonesManager.LinkFolders(sourceProject.assetPath, cloneProject.assetPath);
- ClonesManager.LinkFolders(sourceProject.projectSettingsPath, cloneProject.projectSettingsPath);
- ClonesManager.LinkFolders(sourceProject.autoBuildPath, cloneProject.autoBuildPath);
- ClonesManager.LinkFolders(sourceProject.localPackages, cloneProject.localPackages);
+ LinkFolders(sourceProject.assetPath, cloneProject.assetPath);
+ LinkFolders(sourceProject.projectSettingsPath, cloneProject.projectSettingsPath);
+ LinkFolders(sourceProject.autoBuildPath, cloneProject.autoBuildPath);
+ LinkFolders(sourceProject.localPackages, cloneProject.localPackages);
- ClonesManager.RegisterClone(cloneProject);
+ RegisterClone(cloneProject);
return cloneProject;
}
///
- /// Registers a clone by placing an identifying ".clone" file in its root directory.
+ /// Registers a clone by placing an identifying ".clone" file in its root directory.
///
///
- private static void RegisterClone(Project cloneProject)
- {
+ private static void RegisterClone(Project cloneProject) {
/// Add clone identifier file.
- string identifierFile = Path.Combine(cloneProject.projectPath, ClonesManager.CloneFileName);
+ string identifierFile = Path.Combine(cloneProject.projectPath, CloneFileName);
File.Create(identifierFile).Dispose();
//Add argument file with default argument
- string argumentFilePath = Path.Combine(cloneProject.projectPath, ClonesManager.ArgumentFileName);
- File.WriteAllText(argumentFilePath, DefaultArgument, System.Text.Encoding.UTF8);
+ string argumentFilePath = Path.Combine(cloneProject.projectPath, ArgumentFileName);
+ File.WriteAllText(argumentFilePath, DefaultArgument, Encoding.UTF8);
/// Add collabignore.txt to stop the clone from messing with Unity Collaborate if it's enabled. Just in case.
string collabignoreFile = Path.Combine(cloneProject.projectPath, "collabignore.txt");
@@ -140,19 +133,16 @@ namespace ParrelSync
}
///
- /// Opens a project located at the given path (if one exists).
+ /// Opens a project located at the given path (if one exists).
///
///
- public static void OpenProject(string projectPath)
- {
- if (!Directory.Exists(projectPath))
- {
+ public static void OpenProject(string projectPath) {
+ if (!Directory.Exists(projectPath)) {
Debug.LogError("Cannot open the project - provided folder (" + projectPath + ") does not exist.");
return;
}
- if (projectPath == ClonesManager.GetCurrentProjectPath())
- {
+ if (projectPath == GetCurrentProjectPath()) {
Debug.LogError("Cannot open the project - it is already open.");
return;
}
@@ -164,13 +154,11 @@ namespace ParrelSync
string fileName = GetApplicationPath();
string args = "-projectPath \"" + projectPath + "\"";
Debug.Log("Opening project \"" + fileName + " " + args + "\"");
- ClonesManager.StartHiddenConsoleProcess(fileName, args);
+ StartHiddenConsoleProcess(fileName, args);
}
- private static string GetApplicationPath()
- {
- switch (Application.platform)
- {
+ private static string GetApplicationPath() {
+ switch (Application.platform) {
case RuntimePlatform.WindowsEditor:
return EditorApplication.applicationPath;
case RuntimePlatform.OSXEditor:
@@ -178,87 +166,82 @@ namespace ParrelSync
case RuntimePlatform.LinuxEditor:
return EditorApplication.applicationPath;
default:
- throw new System.NotImplementedException("Platform has not supported yet ;(");
+ throw new NotImplementedException("Platform has not supported yet ;(");
}
}
///
- /// Is this project being opened by an Unity editor?
+ /// Is this project being opened by an Unity editor?
///
///
///
- public static bool IsCloneProjectRunning(string projectPath)
- {
-
+ public static bool IsCloneProjectRunning(string projectPath) {
//Determine whether it is opened in another instance by checking the UnityLockFile
- string UnityLockFilePath = new string[] { projectPath, "Temp", "UnityLockfile" }
+ string UnityLockFilePath = new[]{ projectPath, "Temp", "UnityLockfile" }
.Aggregate(Path.Combine);
- switch (Application.platform)
- {
- case (RuntimePlatform.WindowsEditor):
+ switch (Application.platform) {
+ case RuntimePlatform.WindowsEditor:
//Windows editor will lock "UnityLockfile" file when project is being opened.
//Sometime, for instance: windows editor crash, the "UnityLockfile" will not be deleted even the project
//isn't being opened, so a check to the "UnityLockfile" lock status may be necessary.
if (Preferences.AlsoCheckUnityLockFileStaPref.Value)
return File.Exists(UnityLockFilePath) && FileUtilities.IsFileLocked(UnityLockFilePath);
- else
- return File.Exists(UnityLockFilePath);
- case (RuntimePlatform.OSXEditor):
+ return File.Exists(UnityLockFilePath);
+ case RuntimePlatform.OSXEditor:
//Mac editor won't lock "UnityLockfile" file when project is being opened
return File.Exists(UnityLockFilePath);
- case (RuntimePlatform.LinuxEditor):
+ case RuntimePlatform.LinuxEditor:
return File.Exists(UnityLockFilePath);
default:
- throw new System.NotImplementedException("IsCloneProjectRunning: Unsupport Platfrom: " + Application.platform);
+ throw new NotImplementedException("IsCloneProjectRunning: Unsupport Platfrom: " +
+ Application.platform);
}
}
///
- /// Deletes the clone of the currently open project, if such exists.
+ /// Deletes the clone of the currently open project, if such exists.
///
- public static void DeleteClone(string cloneProjectPath)
- {
+ public static void DeleteClone(string cloneProjectPath) {
/// Clone won't be able to delete itself.
- if (ClonesManager.IsClone()) return;
+ if (IsClone()) return;
///Extra precautions.
if (cloneProjectPath == string.Empty) return;
- if (cloneProjectPath == ClonesManager.GetOriginalProjectPath()) return;
+ if (cloneProjectPath == GetOriginalProjectPath()) return;
//Check what OS is
string identifierFile;
string args;
- switch (Application.platform)
- {
- case (RuntimePlatform.WindowsEditor):
+ switch (Application.platform) {
+ case RuntimePlatform.WindowsEditor:
Debug.Log("Attempting to delete folder \"" + cloneProjectPath + "\"");
//The argument file will be deleted first at the beginning of the project deletion process
//to prevent any further reading and writing to it(There's a File.Exist() check at the (file)editor windows.)
//If there's any file in the directory being write/read during the deletion process, the directory can't be fully removed.
- identifierFile = Path.Combine(cloneProjectPath, ClonesManager.ArgumentFileName);
+ identifierFile = Path.Combine(cloneProjectPath, ArgumentFileName);
File.Delete(identifierFile);
args = "/c " + @"rmdir /s/q " + string.Format("\"{0}\"", cloneProjectPath);
StartHiddenConsoleProcess("cmd.exe", args);
break;
- case (RuntimePlatform.OSXEditor):
+ case RuntimePlatform.OSXEditor:
Debug.Log("Attempting to delete folder \"" + cloneProjectPath + "\"");
//The argument file will be deleted first at the beginning of the project deletion process
//to prevent any further reading and writing to it(There's a File.Exist() check at the (file)editor windows.)
//If there's any file in the directory being write/read during the deletion process, the directory can't be fully removed.
- identifierFile = Path.Combine(cloneProjectPath, ClonesManager.ArgumentFileName);
+ identifierFile = Path.Combine(cloneProjectPath, ArgumentFileName);
File.Delete(identifierFile);
FileUtil.DeleteFileOrDirectory(cloneProjectPath);
break;
- case (RuntimePlatform.LinuxEditor):
+ case RuntimePlatform.LinuxEditor:
Debug.Log("Attempting to delete folder \"" + cloneProjectPath + "\"");
- identifierFile = Path.Combine(cloneProjectPath, ClonesManager.ArgumentFileName);
+ identifierFile = Path.Combine(cloneProjectPath, ArgumentFileName);
File.Delete(identifierFile);
FileUtil.DeleteFileOrDirectory(cloneProjectPath);
@@ -275,32 +258,30 @@ namespace ParrelSync
#region Creating project folders
///
- /// Creates an empty folder using data in the given Project object
+ /// Creates an empty folder using data in the given Project object
///
///
- public static void CreateProjectFolder(Project project)
- {
+ public static void CreateProjectFolder(Project project) {
string path = project.projectPath;
Debug.Log("Creating new empty folder at: " + path);
Directory.CreateDirectory(path);
}
///
- /// Copies the full contents of the unity library. We want to do this to avoid the lengthy re-serialization of the whole project when it opens up the clone.
+ /// Copies the full contents of the unity library. We want to do this to avoid the lengthy re-serialization of the
+ /// whole project when it opens up the clone.
///
///
///
- [System.Obsolete]
- public static void CopyLibraryFolder(Project sourceProject, Project destinationProject)
- {
- if (Directory.Exists(destinationProject.libraryPath))
- {
+ [Obsolete]
+ public static void CopyLibraryFolder(Project sourceProject, Project destinationProject) {
+ if (Directory.Exists(destinationProject.libraryPath)) {
Debug.LogWarning("Library copy: destination path already exists! ");
return;
}
Debug.Log("Library copy: " + destinationProject.libraryPath);
- ClonesManager.CopyDirectoryWithProgressBar(sourceProject.libraryPath, destinationProject.libraryPath,
+ CopyDirectoryWithProgressBar(sourceProject.libraryPath, destinationProject.libraryPath,
"Cloning project '" + sourceProject.name + "'. ");
}
@@ -309,47 +290,44 @@ namespace ParrelSync
#region Creating symlinks
///
- /// Creates a symlink between destinationPath and sourcePath (Mac version).
+ /// Creates a symlink between destinationPath and sourcePath (Mac version).
///
///
///
- private static void CreateLinkMac(string sourcePath, string destinationPath)
- {
+ private static void CreateLinkMac(string sourcePath, string destinationPath) {
sourcePath = sourcePath.Replace(" ", "\\ ");
destinationPath = destinationPath.Replace(" ", "\\ ");
- var command = string.Format("ln -s {0} {1}", sourcePath, destinationPath);
+ string command = string.Format("ln -s {0} {1}", sourcePath, destinationPath);
Debug.Log("Mac hard link " + command);
- ClonesManager.ExecuteBashCommand(command);
+ ExecuteBashCommand(command);
}
///
- /// Creates a symlink between destinationPath and sourcePath (Linux version).
+ /// Creates a symlink between destinationPath and sourcePath (Linux version).
///
///
///
- private static void CreateLinkLinux(string sourcePath, string destinationPath)
- {
+ private static void CreateLinkLinux(string sourcePath, string destinationPath) {
sourcePath = sourcePath.Replace(" ", "\\ ");
destinationPath = destinationPath.Replace(" ", "\\ ");
- var command = string.Format("ln -s {0} {1}", sourcePath, destinationPath);
+ string command = string.Format("ln -s {0} {1}", sourcePath, destinationPath);
Debug.Log("Linux Symlink " + command);
- ClonesManager.ExecuteBashCommand(command);
+ ExecuteBashCommand(command);
}
///
- /// Creates a symlink between destinationPath and sourcePath (Windows version).
+ /// Creates a symlink between destinationPath and sourcePath (Windows version).
///
///
///
- private static void CreateLinkWin(string sourcePath, string destinationPath)
- {
+ private static void CreateLinkWin(string sourcePath, string destinationPath) {
string cmd = "/C mklink /J " + string.Format("\"{0}\" \"{1}\"", destinationPath, sourcePath);
Debug.Log("Windows junction: " + cmd);
- ClonesManager.StartHiddenConsoleProcess("cmd.exe", cmd);
+ StartHiddenConsoleProcess("cmd.exe", cmd);
}
//TODO(?) avoid terminal calls and use proper api stuff. See below for windows!
@@ -361,52 +339,44 @@ namespace ParrelSync
// out int pBytesReturned, System.IntPtr lpOverlapped);
///
- /// Create a link / junction from the original project to it's clone.
+ /// Create a link / junction from the original project to it's clone.
///
///
///
- public static void LinkFolders(string sourcePath, string destinationPath)
- {
- if ((Directory.Exists(destinationPath) == false) && (Directory.Exists(sourcePath) == true))
- {
- switch (Application.platform)
- {
- case (RuntimePlatform.WindowsEditor):
+ public static void LinkFolders(string sourcePath, string destinationPath) {
+ if (Directory.Exists(destinationPath) == false && Directory.Exists(sourcePath))
+ switch (Application.platform) {
+ case RuntimePlatform.WindowsEditor:
CreateLinkWin(sourcePath, destinationPath);
break;
- case (RuntimePlatform.OSXEditor):
+ case RuntimePlatform.OSXEditor:
CreateLinkMac(sourcePath, destinationPath);
break;
- case (RuntimePlatform.LinuxEditor):
+ case RuntimePlatform.LinuxEditor:
CreateLinkLinux(sourcePath, destinationPath);
break;
default:
Debug.LogWarning("Not in a known editor. Application.platform: " + Application.platform);
break;
}
- }
else
- {
Debug.LogWarning("Skipping Asset link, it already exists: " + destinationPath);
- }
}
#endregion
#region Utility methods
- private static bool? isCloneFileExistCache = null;
+ private static bool? isCloneFileExistCache;
///
- /// Returns true if the project currently open in Unity Editor is a clone.
+ /// Returns true if the project currently open in Unity Editor is a clone.
///
///
- public static bool IsClone()
- {
- if (isCloneFileExistCache == null)
- {
+ public static bool IsClone() {
+ if (isCloneFileExistCache == null) {
/// The project is a clone if its root directory contains an empty file named ".clone".
- string cloneFilePath = Path.Combine(ClonesManager.GetCurrentProjectPath(), ClonesManager.CloneFileName);
+ string cloneFilePath = Path.Combine(GetCurrentProjectPath(), CloneFileName);
isCloneFileExistCache = File.Exists(cloneFilePath);
}
@@ -414,85 +384,71 @@ namespace ParrelSync
}
///
- /// Get the path to the current unityEditor project folder's info
+ /// Get the path to the current unityEditor project folder's info
///
///
- public static string GetCurrentProjectPath()
- {
+ public static string GetCurrentProjectPath() {
return Application.dataPath.Replace("/Assets", "");
}
///
- /// Return a project object that describes all the paths we need to clone it.
+ /// Return a project object that describes all the paths we need to clone it.
///
///
- public static Project GetCurrentProject()
- {
- string pathString = ClonesManager.GetCurrentProjectPath();
+ public static Project GetCurrentProject() {
+ string pathString = GetCurrentProjectPath();
return new Project(pathString);
}
///
- /// Get the argument of this clone project.
- /// If this is the original project, will return an empty string.
+ /// Get the argument of this clone project.
+ /// If this is the original project, will return an empty string.
///
///
- public static string GetArgument()
- {
+ public static string GetArgument() {
string argument = "";
- if (IsClone())
- {
- string argumentFilePath = Path.Combine(GetCurrentProjectPath(), ClonesManager.ArgumentFileName);
- if (File.Exists(argumentFilePath))
- {
- argument = File.ReadAllText(argumentFilePath, System.Text.Encoding.UTF8);
- }
+ if (IsClone()) {
+ string argumentFilePath = Path.Combine(GetCurrentProjectPath(), ArgumentFileName);
+ if (File.Exists(argumentFilePath)) argument = File.ReadAllText(argumentFilePath, Encoding.UTF8);
}
return argument;
}
///
- /// Returns the path to the original project.
- /// If currently open project is the original, returns its own path.
- /// If the original project folder cannot be found, retuns an empty string.
+ /// Returns the path to the original project.
+ /// If currently open project is the original, returns its own path.
+ /// If the original project folder cannot be found, retuns an empty string.
///
///
- public static string GetOriginalProjectPath()
- {
- if (IsClone())
- {
+ public static string GetOriginalProjectPath() {
+ if (IsClone()) {
/// If this is a clone...
/// Original project path can be deduced by removing the suffix from the clone's path.
- string cloneProjectPath = ClonesManager.GetCurrentProject().projectPath;
+ string cloneProjectPath = GetCurrentProject().projectPath;
- int index = cloneProjectPath.LastIndexOf(ClonesManager.CloneNameSuffix);
- if (index > 0)
- {
+ int index = cloneProjectPath.LastIndexOf(CloneNameSuffix);
+ if (index > 0) {
string originalProjectPath = cloneProjectPath.Substring(0, index);
if (Directory.Exists(originalProjectPath)) return originalProjectPath;
}
return string.Empty;
}
- else
- {
- /// If this is the original, we return its own path.
- return ClonesManager.GetCurrentProjectPath();
- }
+
+ /// If this is the original, we return its own path.
+ return GetCurrentProjectPath();
}
///
- /// Returns all clone projects path.
+ /// Returns all clone projects path.
///
///
- public static List GetCloneProjectsPath()
- {
- List projectsPath = new List();
- for (int i = 0; i < MaxCloneProjectCount; i++)
- {
- string originalProjectPath = ClonesManager.GetCurrentProject().projectPath;
- string cloneProjectPath = originalProjectPath + ClonesManager.CloneNameSuffix + "_" + i;
+ public static List GetCloneProjectsPath() {
+ List projectsPath = new();
+ for (int i = 0; i < MaxCloneProjectCount; i++) {
+ string originalProjectPath = GetCurrentProject().projectPath;
+ string cloneProjectPath = originalProjectPath + CloneNameSuffix + "_" + i;
if (Directory.Exists(cloneProjectPath))
projectsPath.Add(cloneProjectPath);
@@ -502,28 +458,27 @@ namespace ParrelSync
}
///
- /// Copies directory located at sourcePath to destinationPath. Displays a progress bar.
+ /// Copies directory located at sourcePath to destinationPath. Displays a progress bar.
///
/// Directory to be copied.
/// Destination directory (created automatically if needed).
/// Optional string added to the beginning of the progress bar window header.
public static void CopyDirectoryWithProgressBar(string sourcePath, string destinationPath,
- string progressBarPrefix = "")
- {
- var source = new DirectoryInfo(sourcePath);
- var destination = new DirectoryInfo(destinationPath);
+ string progressBarPrefix = "") {
+ DirectoryInfo source = new(sourcePath);
+ DirectoryInfo destination = new(destinationPath);
long totalBytes = 0;
long copiedBytes = 0;
- ClonesManager.CopyDirectoryWithProgressBarRecursive(source, destination, ref totalBytes, ref copiedBytes,
+ CopyDirectoryWithProgressBarRecursive(source, destination, ref totalBytes, ref copiedBytes,
progressBarPrefix);
EditorUtility.ClearProgressBar();
}
///
- /// Copies directory located at sourcePath to destinationPath. Displays a progress bar.
- /// Same as the previous method, but uses recursion to copy all nested folders as well.
+ /// Copies directory located at sourcePath to destinationPath. Displays a progress bar.
+ /// Same as the previous method, but uses recursion to copy all nested folders as well.
///
/// Directory to be copied.
/// Destination directory (created automatically if needed).
@@ -531,36 +486,25 @@ namespace ParrelSync
/// To track already copied bytes. Calculated automatically, initialize at 0.
/// Optional string added to the beginning of the progress bar window header.
private static void CopyDirectoryWithProgressBarRecursive(DirectoryInfo source, DirectoryInfo destination,
- ref long totalBytes, ref long copiedBytes, string progressBarPrefix = "")
- {
+ ref long totalBytes, ref long copiedBytes, string progressBarPrefix = "") {
/// Directory cannot be copied into itself.
- if (source.FullName.ToLower() == destination.FullName.ToLower())
- {
+ if (source.FullName.ToLower() == destination.FullName.ToLower()) {
Debug.LogError("Cannot copy directory into itself.");
return;
}
/// Calculate total bytes, if required.
- if (totalBytes == 0)
- {
- totalBytes = ClonesManager.GetDirectorySize(source, true, progressBarPrefix);
- }
+ if (totalBytes == 0) totalBytes = GetDirectorySize(source, true, progressBarPrefix);
/// Create destination directory, if required.
- if (!Directory.Exists(destination.FullName))
- {
- Directory.CreateDirectory(destination.FullName);
- }
+ if (!Directory.Exists(destination.FullName)) Directory.CreateDirectory(destination.FullName);
/// Copy all files from the source.
- foreach (FileInfo file in source.GetFiles())
- {
- try
- {
+ foreach (FileInfo file in source.GetFiles()) {
+ try {
file.CopyTo(Path.Combine(destination.ToString(), file.Name), true);
}
- catch (IOException)
- {
+ catch (IOException) {
/// Some files may throw IOException if they are currently open in Unity editor.
/// Just ignore them in such case.
}
@@ -569,7 +513,7 @@ namespace ParrelSync
copiedBytes += file.Length;
/// Display the progress bar.
- float progress = (float)copiedBytes / (float)totalBytes;
+ float progress = copiedBytes / (float)totalBytes;
bool cancelCopy = EditorUtility.DisplayCancelableProgressBar(
progressBarPrefix + "Copying '" + source.FullName + "' to '" + destination.FullName + "'...",
"(" + (progress * 100f).ToString("F2") + "%) Copying file '" + file.Name + "'...",
@@ -578,66 +522,57 @@ namespace ParrelSync
}
/// Copy all nested directories from the source.
- foreach (DirectoryInfo sourceNestedDir in source.GetDirectories())
- {
+ foreach (DirectoryInfo sourceNestedDir in source.GetDirectories()) {
DirectoryInfo nextDestingationNestedDir = destination.CreateSubdirectory(sourceNestedDir.Name);
- ClonesManager.CopyDirectoryWithProgressBarRecursive(sourceNestedDir, nextDestingationNestedDir,
+ CopyDirectoryWithProgressBarRecursive(sourceNestedDir, nextDestingationNestedDir,
ref totalBytes, ref copiedBytes, progressBarPrefix);
}
}
///
- /// Calculates the size of the given directory. Displays a progress bar.
+ /// Calculates the size of the given directory. Displays a progress bar.
///
/// Directory, which size has to be calculated.
/// If true, size will include all nested directories.
/// Optional string added to the beginning of the progress bar window header.
/// Size of the directory in bytes.
private static long GetDirectorySize(DirectoryInfo directory, bool includeNested = false,
- string progressBarPrefix = "")
- {
+ string progressBarPrefix = "") {
EditorUtility.DisplayProgressBar(progressBarPrefix + "Calculating size of directories...",
"Scanning '" + directory.FullName + "'...", 0f);
/// Calculate size of all files in directory.
- long filesSize = directory.GetFiles().Sum((FileInfo file) => file.Length);
+ long filesSize = directory.GetFiles().Sum(file => file.Length);
/// Calculate size of all nested directories.
long directoriesSize = 0;
- if (includeNested)
- {
+ if (includeNested) {
IEnumerable nestedDirectories = directory.GetDirectories();
foreach (DirectoryInfo nestedDir in nestedDirectories)
- {
- directoriesSize += ClonesManager.GetDirectorySize(nestedDir, true, progressBarPrefix);
- }
+ directoriesSize += GetDirectorySize(nestedDir, true, progressBarPrefix);
}
return filesSize + directoriesSize;
}
///
- /// Starts process in the system console, taking the given fileName and args.
+ /// Starts process in the system console, taking the given fileName and args.
///
///
///
- private static void StartHiddenConsoleProcess(string fileName, string args)
- {
- System.Diagnostics.Process.Start(fileName, args);
+ private static void StartHiddenConsoleProcess(string fileName, string args) {
+ Process.Start(fileName, args);
}
///
- /// Thanks to https://github.com/karl-/unity-symlink-utility/blob/master/SymlinkUtility.cs
+ /// Thanks to https://github.com/karl-/unity-symlink-utility/blob/master/SymlinkUtility.cs
///
///
- private static void ExecuteBashCommand(string command)
- {
+ private static void ExecuteBashCommand(string command) {
command = command.Replace("\"", "\"\"");
- var proc = new Process()
- {
- StartInfo = new ProcessStartInfo
- {
+ Process proc = new(){
+ StartInfo = new ProcessStartInfo{
FileName = "/bin/bash",
Arguments = "-c \"" + command + "\"",
UseShellExecute = false,
@@ -647,22 +582,18 @@ namespace ParrelSync
}
};
- using (proc)
- {
+ using (proc) {
proc.Start();
proc.WaitForExit();
- if (!proc.StandardError.EndOfStream)
- {
- UnityEngine.Debug.LogError(proc.StandardError.ReadToEnd());
- }
+ if (!proc.StandardError.EndOfStream) Debug.LogError(proc.StandardError.ReadToEnd());
}
}
- public static void OpenProjectInFileExplorer(string path)
- {
- System.Diagnostics.Process.Start(@path);
+ public static void OpenProjectInFileExplorer(string path) {
+ Process.Start(path);
}
+
#endregion
}
-}
+}
\ No newline at end of file
diff --git a/Assets/ParrelSync/ParrelSync/Editor/ClonesManagerWindow.cs b/Assets/ParrelSync/ParrelSync/Editor/ClonesManagerWindow.cs
index ad9619e28..480c2a866 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/ClonesManagerWindow.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/ClonesManagerWindow.cs
@@ -1,106 +1,84 @@
-using UnityEngine;
-using UnityEditor;
+using System.Collections.Generic;
using System.IO;
+using System.Text;
+using UnityEditor;
+using UnityEngine;
-namespace ParrelSync
-{
+namespace ParrelSync {
///
- ///Clones manager Unity editor window
+ /// Clones manager Unity editor window
///
- public class ClonesManagerWindow : EditorWindow
- {
+ public class ClonesManagerWindow : EditorWindow {
///
- /// Returns true if project clone exists.
+ /// For storing the scroll position of clones list
///
- public bool isCloneCreated
- {
- get { return ClonesManager.GetCloneProjectsPath().Count >= 1; }
- }
-
- [MenuItem("ParrelSync/Clones Manager", priority = 0)]
- private static void InitWindow()
- {
- ClonesManagerWindow window = (ClonesManagerWindow)EditorWindow.GetWindow(typeof(ClonesManagerWindow));
- window.titleContent = new GUIContent("Clones Manager");
- window.Show();
- }
+ private Vector2 clonesScrollPos;
///
- /// For storing the scroll position of clones list
+ /// Returns true if project clone exists.
///
- Vector2 clonesScrollPos;
+ public bool isCloneCreated => ClonesManager.GetCloneProjectsPath().Count >= 1;
- private void OnGUI()
- {
+ private void OnGUI() {
/// If it is a clone project...
- if (ClonesManager.IsClone())
- {
+ if (ClonesManager.IsClone()) {
//Find out the original project name and show the help box
string originalProjectPath = ClonesManager.GetOriginalProjectPath();
if (originalProjectPath == string.Empty)
- {
/// If original project cannot be found, display warning message.
EditorGUILayout.HelpBox(
"This project is a clone, but the link to the original seems lost.\nYou have to manually open the original and create a new clone instead of this one.\n",
MessageType.Warning);
- }
else
- {
/// If original project is present, display some usage info.
EditorGUILayout.HelpBox(
- "This project is a clone of the project '" + Path.GetFileName(originalProjectPath) + "'.\nIf you want to make changes the project files or manage clones, please open the original project through Unity Hub.",
+ "This project is a clone of the project '" + Path.GetFileName(originalProjectPath) +
+ "'.\nIf you want to make changes the project files or manage clones, please open the original project through Unity Hub.",
MessageType.Info);
- }
//Clone project custom argument.
GUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Arguments", GUILayout.Width(70));
if (GUILayout.Button("?", GUILayout.Width(20)))
- {
Application.OpenURL(ExternalLinks.CustomArgumentHelpLink);
- }
GUILayout.EndHorizontal();
- string argumentFilePath = Path.Combine(ClonesManager.GetCurrentProjectPath(), ClonesManager.ArgumentFileName);
+ string argumentFilePath =
+ Path.Combine(ClonesManager.GetCurrentProjectPath(), ClonesManager.ArgumentFileName);
//Need to be careful with file reading / writing since it will effect the deletion of
// the clone project(The directory won't be fully deleted if there's still file inside being read or write).
//The argument file will be deleted first at the beginning of the project deletion process
//to prevent any further being read and write.
//Will need to take some extra cautious if want to change the design of how file editing is handled.
- if (File.Exists(argumentFilePath))
- {
- string argument = File.ReadAllText(argumentFilePath, System.Text.Encoding.UTF8);
+ if (File.Exists(argumentFilePath)) {
+ string argument = File.ReadAllText(argumentFilePath, Encoding.UTF8);
string argumentTextAreaInput = EditorGUILayout.TextArea(argument,
GUILayout.Height(50),
GUILayout.MaxWidth(300)
);
- File.WriteAllText(argumentFilePath, argumentTextAreaInput, System.Text.Encoding.UTF8);
+ File.WriteAllText(argumentFilePath, argumentTextAreaInput, Encoding.UTF8);
}
- else
- {
+ else {
EditorGUILayout.LabelField("No argument file found.");
}
}
- else// If it is an original project...
+ else // If it is an original project...
{
- if (isCloneCreated)
- {
+ if (isCloneCreated) {
GUILayout.BeginVertical("HelpBox");
GUILayout.Label("Clones of this Project");
//List all clones
clonesScrollPos =
- EditorGUILayout.BeginScrollView(clonesScrollPos);
- var cloneProjectsPath = ClonesManager.GetCloneProjectsPath();
- for (int i = 0; i < cloneProjectsPath.Count; i++)
- {
-
+ EditorGUILayout.BeginScrollView(clonesScrollPos);
+ List cloneProjectsPath = ClonesManager.GetCloneProjectsPath();
+ for (int i = 0; i < cloneProjectsPath.Count; i++) {
GUILayout.BeginVertical("GroupBox");
string cloneProjectPath = cloneProjectsPath[i];
bool isOpenInAnotherInstance = ClonesManager.IsCloneProjectRunning(cloneProjectPath);
- if (isOpenInAnotherInstance == true)
+ if (isOpenInAnotherInstance)
EditorGUILayout.LabelField("Clone " + i + " (Running)", EditorStyles.boldLabel);
else
EditorGUILayout.LabelField("Clone " + i);
@@ -109,17 +87,13 @@ namespace ParrelSync
GUILayout.BeginHorizontal();
EditorGUILayout.TextField("Clone project path", cloneProjectPath, EditorStyles.textField);
if (GUILayout.Button("View Folder", GUILayout.Width(80)))
- {
ClonesManager.OpenProjectInFileExplorer(cloneProjectPath);
- }
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Arguments", GUILayout.Width(70));
if (GUILayout.Button("?", GUILayout.Width(20)))
- {
Application.OpenURL(ExternalLinks.CustomArgumentHelpLink);
- }
GUILayout.EndHorizontal();
string argumentFilePath = Path.Combine(cloneProjectPath, ClonesManager.ArgumentFileName);
@@ -128,17 +102,15 @@ namespace ParrelSync
//The argument file will be deleted first at the beginning of the project deletion process
//to prevent any further being read and write.
//Will need to take some extra cautious if want to change the design of how file editing is handled.
- if (File.Exists(argumentFilePath))
- {
- string argument = File.ReadAllText(argumentFilePath, System.Text.Encoding.UTF8);
+ if (File.Exists(argumentFilePath)) {
+ string argument = File.ReadAllText(argumentFilePath, Encoding.UTF8);
string argumentTextAreaInput = EditorGUILayout.TextArea(argument,
GUILayout.Height(50),
GUILayout.MaxWidth(300)
);
- File.WriteAllText(argumentFilePath, argumentTextAreaInput, System.Text.Encoding.UTF8);
+ File.WriteAllText(argumentFilePath, argumentTextAreaInput, Encoding.UTF8);
}
- else
- {
+ else {
EditorGUILayout.LabelField("No argument file found.");
}
@@ -149,50 +121,44 @@ namespace ParrelSync
EditorGUI.BeginDisabledGroup(isOpenInAnotherInstance);
- if (GUILayout.Button("Open in New Editor"))
- {
- ClonesManager.OpenProject(cloneProjectPath);
- }
+ if (GUILayout.Button("Open in New Editor")) ClonesManager.OpenProject(cloneProjectPath);
GUILayout.BeginHorizontal();
- if (GUILayout.Button("Delete"))
- {
+ if (GUILayout.Button("Delete")) {
bool delete = EditorUtility.DisplayDialog(
"Delete the clone?",
- "Are you sure you want to delete the clone project '" + ClonesManager.GetCurrentProject().name + "_clone'?",
+ "Are you sure you want to delete the clone project '" +
+ ClonesManager.GetCurrentProject().name + "_clone'?",
"Delete",
"Cancel");
- if (delete)
- {
- ClonesManager.DeleteClone(cloneProjectPath);
- }
+ if (delete) ClonesManager.DeleteClone(cloneProjectPath);
}
GUILayout.EndHorizontal();
EditorGUI.EndDisabledGroup();
GUILayout.EndVertical();
-
}
+
EditorGUILayout.EndScrollView();
- if (GUILayout.Button("Add new clone"))
- {
- ClonesManager.CreateCloneFromCurrent();
- }
+ if (GUILayout.Button("Add new clone")) ClonesManager.CreateCloneFromCurrent();
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
}
- else
- {
+ else {
/// If no clone created yet, we must create it.
EditorGUILayout.HelpBox("No project clones found. Create a new one!", MessageType.Info);
- if (GUILayout.Button("Create new clone"))
- {
- ClonesManager.CreateCloneFromCurrent();
- }
+ if (GUILayout.Button("Create new clone")) ClonesManager.CreateCloneFromCurrent();
}
}
}
+
+ [MenuItem("ParrelSync/Clones Manager", priority = 0)]
+ private static void InitWindow() {
+ ClonesManagerWindow window = (ClonesManagerWindow)GetWindow(typeof(ClonesManagerWindow));
+ window.titleContent = new GUIContent("Clones Manager");
+ window.Show();
+ }
}
-}
+}
\ No newline at end of file
diff --git a/Assets/ParrelSync/ParrelSync/Editor/ExternalLinks.cs b/Assets/ParrelSync/ParrelSync/Editor/ExternalLinks.cs
index 84809bccc..07b4c3ffc 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/ExternalLinks.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/ExternalLinks.cs
@@ -1,8 +1,8 @@
-namespace ParrelSync
-{
- public class ExternalLinks
- {
- public const string RemoteVersionURL = "https://raw.githubusercontent.com/VeriorPies/ParrelSync/master/VERSION.txt";
+namespace ParrelSync {
+ public class ExternalLinks {
+ public const string RemoteVersionURL =
+ "https://raw.githubusercontent.com/VeriorPies/ParrelSync/master/VERSION.txt";
+
public const string Releases = "https://github.com/VeriorPies/ParrelSync/releases";
public const string CustomArgumentHelpLink = "https://github.com/VeriorPies/ParrelSync/wiki/Argument";
diff --git a/Assets/ParrelSync/ParrelSync/Editor/FileUtilities.cs b/Assets/ParrelSync/ParrelSync/Editor/FileUtilities.cs
index 4d0a23925..2abc78b2c 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/FileUtilities.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/FileUtilities.cs
@@ -1,22 +1,16 @@
using System.IO;
using UnityEngine;
-namespace ParrelSync
-{
- public class FileUtilities : MonoBehaviour
- {
- public static bool IsFileLocked(string path)
- {
- FileInfo file = new FileInfo(path);
- try
- {
- using (FileStream stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None))
- {
+namespace ParrelSync {
+ public class FileUtilities : MonoBehaviour {
+ public static bool IsFileLocked(string path) {
+ FileInfo file = new(path);
+ try {
+ using (FileStream stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None)) {
stream.Close();
}
}
- catch (IOException)
- {
+ catch (IOException) {
//the file is unavailable because it is:
//still being written to
//or being processed by another thread
diff --git a/Assets/ParrelSync/ParrelSync/Editor/NonCore/AskFeedbackDialog.cs b/Assets/ParrelSync/ParrelSync/Editor/NonCore/AskFeedbackDialog.cs
index 2bb988ae1..8ec6131e6 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/NonCore/AskFeedbackDialog.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/NonCore/AskFeedbackDialog.cs
@@ -1,45 +1,38 @@
-namespace ParrelSync.NonCore
-{
- using UnityEditor;
- using UnityEngine;
+using UnityEditor;
+using UnityEngine;
+namespace ParrelSync.NonCore {
///
- /// A simple script to display feedback/star dialog after certain time of project being opened/re-compiled.
- /// Will only pop-up once unless "Remind me next time" are chosen.
- /// Removing this file from project wont effect any other functions.
+ /// A simple script to display feedback/star dialog after certain time of project being opened/re-compiled.
+ /// Will only pop-up once unless "Remind me next time" are chosen.
+ /// Removing this file from project wont effect any other functions.
///
[InitializeOnLoad]
- public class AskFeedbackDialog
- {
- const string InitializeOnLoadCountKey = "ParrelSync_InitOnLoadCount", StopShowingKey = "ParrelSync_StopShowFeedBack";
- static AskFeedbackDialog()
- {
- if (EditorPrefs.HasKey(StopShowingKey)) { return; }
+ public class AskFeedbackDialog {
+ private const string InitializeOnLoadCountKey = "ParrelSync_InitOnLoadCount",
+ StopShowingKey = "ParrelSync_StopShowFeedBack";
+
+ static AskFeedbackDialog() {
+ if (EditorPrefs.HasKey(StopShowingKey)) return;
int InitializeOnLoadCount = EditorPrefs.GetInt(InitializeOnLoadCountKey, 0);
if (InitializeOnLoadCount > 20)
- {
ShowDialog();
- }
else
- {
EditorPrefs.SetInt(InitializeOnLoadCountKey, InitializeOnLoadCount + 1);
- }
}
//[MenuItem("ParrelSync/(Debug)Show AskFeedbackDialog ")]
- private static void ShowDialog()
- {
- int option = EditorUtility.DisplayDialogComplex("Do you like " + ParrelSync.ClonesManager.ProjectName + "?",
- "Do you like " + ParrelSync.ClonesManager.ProjectName + "?\n" +
- "If so, please don't hesitate to star it on GitHub and contribute to the project!",
- "Star on GitHub",
- "Close",
- "Remind me next time"
- );
+ private static void ShowDialog() {
+ int option = EditorUtility.DisplayDialogComplex("Do you like " + ClonesManager.ProjectName + "?",
+ "Do you like " + ClonesManager.ProjectName + "?\n" +
+ "If so, please don't hesitate to star it on GitHub and contribute to the project!",
+ "Star on GitHub",
+ "Close",
+ "Remind me next time"
+ );
- switch (option)
- {
+ switch (option) {
// First parameter.
case 0:
Debug.Log("AskFeedbackDialog: Star on GitHub selected");
@@ -58,9 +51,6 @@
Debug.Log("AskFeedbackDialog: Remind me next time");
EditorPrefs.SetInt(InitializeOnLoadCountKey, 0);
break;
- default:
- //Debug.Log("Close windows.");
- break;
}
}
diff --git a/Assets/ParrelSync/ParrelSync/Editor/NonCore/OtherMenuItem.cs b/Assets/ParrelSync/ParrelSync/Editor/NonCore/OtherMenuItem.cs
index 0f42af96f..aea6e3d24 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/NonCore/OtherMenuItem.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/NonCore/OtherMenuItem.cs
@@ -1,25 +1,20 @@
-namespace ParrelSync.NonCore
-{
- using UnityEditor;
- using UnityEngine;
+using UnityEditor;
+using UnityEngine;
- public class OtherMenuItem
- {
+namespace ParrelSync.NonCore {
+ public class OtherMenuItem {
[MenuItem("ParrelSync/GitHub/View this project on GitHub", priority = 10)]
- private static void OpenGitHub()
- {
+ private static void OpenGitHub() {
Application.OpenURL(ExternalLinks.GitHubHome);
}
[MenuItem("ParrelSync/GitHub/View FAQ", priority = 11)]
- private static void OpenFAQ()
- {
+ private static void OpenFAQ() {
Application.OpenURL(ExternalLinks.FAQ);
}
[MenuItem("ParrelSync/GitHub/View Issues", priority = 12)]
- private static void OpenGitHubIssues()
- {
+ private static void OpenGitHubIssues() {
Application.OpenURL(ExternalLinks.GitHubIssue);
}
}
diff --git a/Assets/ParrelSync/ParrelSync/Editor/Preferences.cs b/Assets/ParrelSync/ParrelSync/Editor/Preferences.cs
index 3ca653d09..f5f1792c3 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/Preferences.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/Preferences.cs
@@ -1,34 +1,29 @@
-using UnityEngine;
-using UnityEditor;
+using UnityEditor;
+using UnityEngine;
-namespace ParrelSync
-{
+namespace ParrelSync {
///
- /// To add value caching for functions
+ /// To add value caching for functions
///
- public class BoolPreference
- {
- public string key { get; private set; }
- public bool defaultValue { get; private set; }
- public BoolPreference(string key, bool defaultValue)
- {
+ public class BoolPreference {
+ private bool? valueCache;
+
+ public BoolPreference(string key, bool defaultValue) {
this.key = key;
this.defaultValue = defaultValue;
}
- private bool? valueCache = null;
+ public string key { get; }
+ public bool defaultValue { get; }
- public bool Value
- {
- get
- {
+ public bool Value {
+ get {
if (valueCache == null)
valueCache = EditorPrefs.GetBool(key, defaultValue);
return (bool)valueCache;
}
- set
- {
+ set {
if (valueCache == value)
return;
@@ -38,41 +33,30 @@ namespace ParrelSync
}
}
- public void ClearValue()
- {
+ public void ClearValue() {
EditorPrefs.DeleteKey(key);
valueCache = null;
}
}
- public class Preferences : EditorWindow
- {
- [MenuItem("ParrelSync/Preferences", priority = 1)]
- private static void InitWindow()
- {
- Preferences window = (Preferences)EditorWindow.GetWindow(typeof(Preferences));
- window.titleContent = new GUIContent(ClonesManager.ProjectName + " Preferences");
- window.Show();
- }
-
+ public class Preferences : EditorWindow {
///
- /// Disable asset saving in clone editors?
+ /// Disable asset saving in clone editors?
///
- public static BoolPreference AssetModPref = new BoolPreference("ParrelSync_DisableClonesAssetSaving", true);
+ public static BoolPreference AssetModPref = new("ParrelSync_DisableClonesAssetSaving", true);
///
- /// In addition of checking the existence of UnityLockFile,
- /// also check is the is the UnityLockFile being opened.
+ /// In addition of checking the existence of UnityLockFile,
+ /// also check is the is the UnityLockFile being opened.
///
- public static BoolPreference AlsoCheckUnityLockFileStaPref = new BoolPreference("ParrelSync_CheckUnityLockFileOpenStatus", true);
+ public static BoolPreference AlsoCheckUnityLockFileStaPref =
+ new("ParrelSync_CheckUnityLockFileOpenStatus", true);
- private void OnGUI()
- {
- if (ClonesManager.IsClone())
- {
+ private void OnGUI() {
+ if (ClonesManager.IsClone()) {
EditorGUILayout.HelpBox(
- "This is a clone project. Please use the original project editor to change preferences.",
- MessageType.Info);
+ "This is a clone project. Please use the original project editor to change preferences.",
+ MessageType.Info);
return;
}
@@ -88,7 +72,6 @@ namespace ParrelSync
AssetModPref.Value);
if (Application.platform == RuntimePlatform.WindowsEditor)
- {
AlsoCheckUnityLockFileStaPref.Value = EditorGUILayout.ToggleLeft(
new GUIContent(
"Also check UnityLockFile lock status while checking clone projects running status",
@@ -96,15 +79,21 @@ namespace ParrelSync
"(the Clones Manager window show the clone project is still running even it's not) if the clone editor crashed"
),
AlsoCheckUnityLockFileStaPref.Value);
- }
GUILayout.EndVertical();
- if (GUILayout.Button("Reset to default"))
- {
+ if (GUILayout.Button("Reset to default")) {
AssetModPref.ClearValue();
AlsoCheckUnityLockFileStaPref.ClearValue();
Debug.Log("Editor preferences cleared");
}
+
GUILayout.EndVertical();
}
+
+ [MenuItem("ParrelSync/Preferences", priority = 1)]
+ private static void InitWindow() {
+ Preferences window = (Preferences)GetWindow(typeof(Preferences));
+ window.titleContent = new GUIContent(ClonesManager.ProjectName + " Preferences");
+ window.Show();
+ }
}
}
\ No newline at end of file
diff --git a/Assets/ParrelSync/ParrelSync/Editor/Project.cs b/Assets/ParrelSync/ParrelSync/Editor/Project.cs
index 7e7c3874a..93fca6d12 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/Project.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/Project.cs
@@ -1,49 +1,44 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
-namespace ParrelSync
-{
- public class Project : System.ICloneable
- {
- public string name;
- public string projectPath;
- string rootPath;
+namespace ParrelSync {
+ public class Project : ICloneable {
public string assetPath;
- public string projectSettingsPath;
- public string libraryPath;
- public string packagesPath;
public string autoBuildPath;
+ public string libraryPath;
public string localPackages;
+ public string name;
+ public string packagesPath;
+ public string projectPath;
+ public string projectSettingsPath;
+ private string rootPath;
- char[] separator = new char[1] { '/' };
+ private char[] separator = new char[1]{ '/' };
///
- /// Default constructor
+ /// Default constructor
///
- public Project()
- {
-
- }
+ public Project() { }
///
- /// Initialize the project object by parsing its full path returned by Unity into a bunch of individual folder names and paths.
+ /// Initialize the project object by parsing its full path returned by Unity into a bunch of individual folder names
+ /// and paths.
///
///
- public Project(string path)
- {
+ public Project(string path) {
ParsePath(path);
}
///
- /// Create a new object with the same settings
+ /// Create a new object with the same settings
///
///
- public object Clone()
- {
- Project newProject = new Project();
+ public object Clone() {
+ Project newProject = new();
newProject.rootPath = rootPath;
newProject.projectPath = projectPath;
newProject.assetPath = assetPath;
@@ -61,22 +56,21 @@ namespace ParrelSync
///
- /// Update the project object by renaming and reparsing it. Pass in the new name of a project, and it'll update the other member variables to match.
+ /// Update the project object by renaming and reparsing it. Pass in the new name of a project, and it'll update the
+ /// other member variables to match.
///
///
- public void updateNewName(string newName)
- {
+ public void updateNewName(string newName) {
name = newName;
ParsePath(rootPath + "/" + name + "/Assets");
}
///
- /// Debug override so we can quickly print out the project info.
+ /// Debug override so we can quickly print out the project info.
///
///
- public override string ToString()
- {
+ public override string ToString() {
string printString = name + "\n" +
rootPath + "\n" +
projectPath + "\n" +
@@ -86,16 +80,15 @@ namespace ParrelSync
autoBuildPath + "\n" +
localPackages + "\n" +
libraryPath;
- return (printString);
+ return printString;
}
- private void ParsePath(string path)
- {
+ private void ParsePath(string path) {
//Unity's Application functions return the Assets path in the Editor.
projectPath = path;
//pop off the last part of the path for the project name, keep the rest for the root path
- List pathArray = projectPath.Split(separator).ToList();
+ List pathArray = projectPath.Split(separator).ToList();
name = pathArray.Last();
pathArray.RemoveAt(pathArray.Count() - 1);
diff --git a/Assets/ParrelSync/ParrelSync/Editor/UpdateChecker.cs b/Assets/ParrelSync/ParrelSync/Editor/UpdateChecker.cs
index 85dbf9649..1d9c7a068 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/UpdateChecker.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/UpdateChecker.cs
@@ -1,22 +1,20 @@
using System;
+using System.Net;
using UnityEditor;
using UnityEngine;
-namespace ParrelSync.Update
-{
+
+namespace ParrelSync.Update {
///
- /// A simple update checker
+ /// A simple update checker
///
- public class UpdateChecker
- {
+ public class UpdateChecker {
//const string LocalVersionFilePath = "Assets/ParrelSync/VERSION.txt";
public const string LocalVersion = "1.5.1";
+
[MenuItem("ParrelSync/Check for update", priority = 20)]
- static void CheckForUpdate()
- {
- using (System.Net.WebClient client = new System.Net.WebClient())
- {
- try
- {
+ private static void CheckForUpdate() {
+ using (WebClient client = new()) {
+ try {
//This won't work with UPM packages
//string localVersionText = AssetDatabase.LoadAssetAtPath(LocalVersionFilePath).text;
@@ -25,36 +23,31 @@ namespace ParrelSync.Update
string latesteVersionText = client.DownloadString(ExternalLinks.RemoteVersionURL);
Debug.Log("latest version text got: " + latesteVersionText);
- string messageBody = "Current Version: " + localVersionText +"\n"
- +"Latest Version: " + latesteVersionText + "\n";
- var latestVersion = new Version(latesteVersionText);
- var localVersion = new Version(localVersionText);
+ string messageBody = "Current Version: " + localVersionText + "\n"
+ + "Latest Version: " + latesteVersionText + "\n";
+ Version latestVersion = new Version(latesteVersionText);
+ Version localVersion = new Version(localVersionText);
- if (latestVersion > localVersion)
- {
+ if (latestVersion > localVersion) {
Debug.Log("There's a newer version");
messageBody += "There's a newer version available";
- if(EditorUtility.DisplayDialog("Check for update.", messageBody, "Get latest release", "Close"))
- {
- Application.OpenURL(ExternalLinks.Releases);
- }
+ if (EditorUtility.DisplayDialog("Check for update.", messageBody, "Get latest release",
+ "Close")) Application.OpenURL(ExternalLinks.Releases);
}
- else
- {
+ else {
Debug.Log("Current version is up-to-date.");
messageBody += "Current version is up-to-date.";
- EditorUtility.DisplayDialog("Check for update.", messageBody,"OK");
+ EditorUtility.DisplayDialog("Check for update.", messageBody, "OK");
}
-
}
- catch (Exception exp)
- {
+ catch (Exception exp) {
Debug.LogError("Error with checking update. Exception: " + exp);
- EditorUtility.DisplayDialog("Update Error","Error with checking update. \nSee console for more details.",
- "OK"
+ EditorUtility.DisplayDialog("Update Error",
+ "Error with checking update. \nSee console for more details.",
+ "OK"
);
}
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Assets/ParrelSync/ParrelSync/Editor/ValidateCopiedFoldersIntegrity.cs b/Assets/ParrelSync/ParrelSync/Editor/ValidateCopiedFoldersIntegrity.cs
index 1ee73bc7e..f5ff7b7d8 100644
--- a/Assets/ParrelSync/ParrelSync/Editor/ValidateCopiedFoldersIntegrity.cs
+++ b/Assets/ParrelSync/ParrelSync/Editor/ValidateCopiedFoldersIntegrity.cs
@@ -1,57 +1,52 @@
-namespace ParrelSync
-{
- using UnityEditor;
- using UnityEngine;
- using System;
- using System.Text;
- using System.Security.Cryptography;
- using System.IO;
- using System.Linq;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using UnityEditor;
+using UnityEngine;
+namespace ParrelSync {
[InitializeOnLoad]
- public class ValidateCopiedFoldersIntegrity
- {
- const string SessionStateKey = "ValidateCopiedFoldersIntegrity_Init";
+ public class ValidateCopiedFoldersIntegrity {
+ private const string SessionStateKey = "ValidateCopiedFoldersIntegrity_Init";
+
///
- /// Called once on editor startup.
- /// Validate copied folders integrity in clone project
+ /// Called once on editor startup.
+ /// Validate copied folders integrity in clone project
///
- static ValidateCopiedFoldersIntegrity()
- {
- if (!SessionState.GetBool(SessionStateKey, false))
- {
+ static ValidateCopiedFoldersIntegrity() {
+ if (!SessionState.GetBool(SessionStateKey, false)) {
SessionState.SetBool(SessionStateKey, true);
- if (!ClonesManager.IsClone()) { return; }
+ if (!ClonesManager.IsClone()) return;
- ValidateFolder(ClonesManager.GetCurrentProjectPath(), ClonesManager.GetOriginalProjectPath(), "Packages");
+ ValidateFolder(ClonesManager.GetCurrentProjectPath(), ClonesManager.GetOriginalProjectPath(),
+ "Packages");
}
}
- public static void ValidateFolder(string targetRoot, string originalRoot, string folderName)
- {
- var targetFolderPath = Path.Combine(targetRoot, folderName);
- var targetFolderHash = CreateMd5ForFolder(targetFolderPath);
+ public static void ValidateFolder(string targetRoot, string originalRoot, string folderName) {
+ string targetFolderPath = Path.Combine(targetRoot, folderName);
+ string targetFolderHash = CreateMd5ForFolder(targetFolderPath);
- var originalFolderPath = Path.Combine(originalRoot, folderName);
- var originalFolderHash = CreateMd5ForFolder(originalFolderPath);
+ string originalFolderPath = Path.Combine(originalRoot, folderName);
+ string originalFolderHash = CreateMd5ForFolder(originalFolderPath);
- if (targetFolderHash != originalFolderHash)
- {
+ if (targetFolderHash != originalFolderHash) {
Debug.Log("ParrelSync: Detected changes in '" + folderName + "' directory. Updating cloned project...");
FileUtil.ReplaceDirectory(originalFolderPath, targetFolderPath);
}
}
- static string CreateMd5ForFolder(string path)
- {
+ private static string CreateMd5ForFolder(string path) {
// assuming you want to include nested folders
- var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)
- .OrderBy(p => p).ToList();
+ List files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)
+ .OrderBy(p => p).ToList();
MD5 md5 = MD5.Create();
- for (int i = 0; i < files.Count; i++)
- {
+ for (int i = 0; i < files.Count; i++) {
string file = files[i];
// hash path
diff --git a/Assets/ParrelSync/ParrelSync/package.json b/Assets/ParrelSync/ParrelSync/package.json
index 29776fb78..70c17cfe8 100644
--- a/Assets/ParrelSync/ParrelSync/package.json
+++ b/Assets/ParrelSync/ParrelSync/package.json
@@ -1,10 +1,15 @@
{
- "name": "com.veriorpies.parrelsync",
- "displayName": "ParrelSync",
- "version": "1.5.1",
- "unity": "2018.4",
- "description": "ParrelSync is a Unity editor extension that allows users to test multiplayer gameplay without building the project by having another Unity editor window opened and mirror the changes from the original project.",
- "license": "MIT",
- "keywords": [ "Networking", "Utils", "Editor", "Extensions" ],
- "dependencies": {}
+ "name": "com.veriorpies.parrelsync",
+ "displayName": "ParrelSync",
+ "version": "1.5.1",
+ "unity": "2018.4",
+ "description": "ParrelSync is a Unity editor extension that allows users to test multiplayer gameplay without building the project by having another Unity editor window opened and mirror the changes from the original project.",
+ "license": "MIT",
+ "keywords": [
+ "Networking",
+ "Utils",
+ "Editor",
+ "Extensions"
+ ],
+ "dependencies": {}
}
\ No newline at end of file
diff --git a/Assets/ParrelSync/ParrelSync/projectCloner.asmdef b/Assets/ParrelSync/ParrelSync/projectCloner.asmdef
index 1e56b06f5..ece4e5974 100644
--- a/Assets/ParrelSync/ParrelSync/projectCloner.asmdef
+++ b/Assets/ParrelSync/ParrelSync/projectCloner.asmdef
@@ -1,15 +1,15 @@
{
- "name": "ParrelSync",
- "references": [],
- "includePlatforms": [
- "Editor"
- ],
- "excludePlatforms": [],
- "allowUnsafeCode": false,
- "overrideReferences": false,
- "precompiledReferences": [],
- "autoReferenced": true,
- "defineConstraints": [],
- "versionDefines": [],
- "noEngineReferences": false
+ "name": "ParrelSync",
+ "references": [],
+ "includePlatforms": [
+ "Editor"
+ ],
+ "excludePlatforms": [],
+ "allowUnsafeCode": false,
+ "overrideReferences": false,
+ "precompiledReferences": [],
+ "autoReferenced": true,
+ "defineConstraints": [],
+ "versionDefines": [],
+ "noEngineReferences": false
}
\ No newline at end of file
diff --git a/Assets/PlayerInputActions.cs b/Assets/PlayerInputActions.cs
index b35950ae3..d3abeed59 100644
--- a/Assets/PlayerInputActions.cs
+++ b/Assets/PlayerInputActions.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
-// version 1.5.0
+// version 1.5.1
// from Assets/PlayerInputActions.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
diff --git a/Assets/Prefab/Counters/CuttingCounter.prefab b/Assets/Prefab/Counters/CuttingCounter.prefab
index 0d9aadebd..45ff1edba 100644
--- a/Assets/Prefab/Counters/CuttingCounter.prefab
+++ b/Assets/Prefab/Counters/CuttingCounter.prefab
@@ -534,7 +534,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 684533fb770d426797cb0bf29a6bcdf3, type: 3}
m_Name:
m_EditorClassIdentifier:
- cuttingRecipeSOArray:
+ CuttingRecipeSOArray:
- {fileID: 11400000, guid: 7099fe20df5fcf646869c078799be4e6, type: 2}
- - {fileID: 11400000, guid: 15b9c81d8c4442547ab5bc3aa788ecc8, type: 2}
- {fileID: 11400000, guid: 1f51b2ff38b5b7b498f16d7ea781b45a, type: 2}
+ - {fileID: 11400000, guid: 15b9c81d8c4442547ab5bc3aa788ecc8, type: 2}
diff --git a/Assets/Scripts/ClientNetworkTransform.cs b/Assets/Scripts/ClientNetworkTransform.cs
index 0215f8b01..d26a3eef3 100644
--- a/Assets/Scripts/ClientNetworkTransform.cs
+++ b/Assets/Scripts/ClientNetworkTransform.cs
@@ -1,21 +1,20 @@
using Unity.Netcode.Components;
using UnityEngine;
-namespace Unity.Multiplayer.Samples.Utilities.ClientAuthority
-{
+namespace Unity.Multiplayer.Samples.Utilities.ClientAuthority {
///
- /// Used for syncing a transform with client side changes. This includes host. Pure server as owner isn't supported by this. Please use NetworkTransform
- /// for transforms that'll always be owned by the server.
+ /// Used for syncing a transform with client side changes. This includes host. Pure server as owner isn't supported by
+ /// this. Please use NetworkTransform
+ /// for transforms that'll always be owned by the server.
///
[DisallowMultipleComponent]
- public class ClientNetworkTransform : NetworkTransform
- {
+ public class ClientNetworkTransform : NetworkTransform {
///
- /// Used to determine who can write to this transform. Owner client only.
- /// This imposes state to the server. This is putting trust on your clients. Make sure no security-sensitive features use this transform.
+ /// Used to determine who can write to this transform. Owner client only.
+ /// This imposes state to the server. This is putting trust on your clients. Make sure no security-sensitive features
+ /// use this transform.
///
- protected override bool OnIsServerAuthoritative()
- {
+ protected override bool OnIsServerAuthoritative() {
return false;
}
}
diff --git a/Assets/Scripts/Counters/BaseCounter.cs b/Assets/Scripts/Counters/BaseCounter.cs
index 613e4336a..b8f6bf59f 100644
--- a/Assets/Scripts/Counters/BaseCounter.cs
+++ b/Assets/Scripts/Counters/BaseCounter.cs
@@ -3,33 +3,28 @@ using Unity.Netcode;
using UnityEngine;
public class BaseCounter : NetworkBehaviour, IKitchenObjectParent {
- public static event EventHandler OnAnyObjectPlacedHere;
- public Transform CounterTopPoint { get; set; }
- public Transform KitchenObjectHoldPoint { get; set; }
- private KitchenObject kitchenObject;
+ public KitchenObject kitchenObject;
+ private Transform CounterTopPoint { get; set; }
+
+ public Transform GetKitchenObjectFollowTransform() => CounterTopPoint;
+
+ public void Awake() {
+ CounterTopPoint = transform.Find("CounterTopPoint");
+ }
public KitchenObject KitchenObject {
get => kitchenObject;
set {
kitchenObject = value;
- if (value != null) {
- OnAnyObjectPlacedHere?.Invoke(this, EventArgs.Empty);
- }
+ if (value is not null) OnAnyObjectPlacedHere?.Invoke(this, EventArgs.Empty);
}
}
- public void Awake() {
- CounterTopPoint = transform.Find("CounterTopPoint");
- KitchenObjectHoldPoint = CounterTopPoint;
- }
+ public NetworkObject GetNetworkObject() => NetworkObject;
- public virtual void Interact(Player player) {
- Debug.LogError("Something went wrong, Interaction with BaseCounter");
- }
+ public static event EventHandler OnAnyObjectPlacedHere;
- public virtual void InteractAlternate(Player player) {
- Debug.LogError("Something went wrong, Interaction with BaseCounter");
- }
+ public virtual void Interact(Player player) => Debug.LogError("Something went wrong, Interaction with BaseCounter");
- public NetworkObject GetNetworkObject() => NetworkObject;
+ public virtual void InteractAlternate(Player player) => Debug.LogError("Something went wrong, Interaction with BaseCounter");
}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/ClearCounter.cs b/Assets/Scripts/Counters/ClearCounter.cs
index 2fd8bf239..3b3dc2786 100644
--- a/Assets/Scripts/Counters/ClearCounter.cs
+++ b/Assets/Scripts/Counters/ClearCounter.cs
@@ -1,57 +1,40 @@
using UnityEngine;
-public class ClearCounter : BaseCounter, IKitchenObjectParent
-{
- public KitchenObjectSO KitchenObjectSO { get; set; }
+public class ClearCounter : BaseCounter, IKitchenObjectParent {
+ public KitchenObjectSO KitchenObjectSO { get; set; }
- public override void Interact(Player player)
- {
- if (KitchenObject == null)
- {
- // Debug.Log("There is no KitchenObject here");
- if (player.KitchenObject != null)
- {
- //Debug.Log($"Player is putting {player.KitchenObject.KitchenObjectSO.objectName} to ClearCounter");
- player.KitchenObject.SetKitchenObjectParent(this);
- player.KitchenObject = null;
- }
- else
- {
- Debug.Log("Player not carrying anything");
- }
- }
- else
- {
- // Debug.Log("There is a KitchenObject");
- if (player.KitchenObject != null)
- {
- if (player.KitchenObject.TryGetPlate(out PlateKitchenObject plateKitchenObject))
- {
- // Debug.Log("Player is holding a plate");
- if (plateKitchenObject.TryAddIngredient(KitchenObject.KitchenObjectSO))
- {
- KitchenObject.DestroySelf();
- }
- }
- else
- {
- // Debug.Log("Player is carrying something but not a plate");
- if (KitchenObject.TryGetPlate(out plateKitchenObject))
- {
- // Debug.Log("ClearCounter is holding a plate");
- if (plateKitchenObject.TryAddIngredient(player.KitchenObject.KitchenObjectSO))
- {
- player.KitchenObject.DestroySelf();
- }
- }
- }
- }
- else
- {
- Debug.Log("Player is taking KitchenObject from ClearCounter");
- KitchenObject.SetKitchenObjectParent(player);
- KitchenObject = null;
- }
- }
- }
+ public override void Interact(Player player) {
+ if (KitchenObject == null) {
+ // Debug.Log("There is no KitchenObject here");
+ if (player.KitchenObject != null) {
+ //Debug.Log($"Player is putting {player.KitchenObject.KitchenObjectSO.objectName} to ClearCounter");
+ player.KitchenObject.SetKitchenObjectParent(this);
+ player.KitchenObject = null;
+ }
+ else {
+ Debug.Log("Player not carrying anything");
+ }
+ }
+ else {
+ // Debug.Log("There is a KitchenObject");
+ if (player.KitchenObject != null) {
+ if (player.KitchenObject.TryGetPlate(out PlateKitchenObject plateKitchenObject)) {
+ // Debug.Log("Player is holding a plate");
+ if (plateKitchenObject.TryAddIngredient(KitchenObject.KitchenObjectSO)) KitchenObject.DestroySelf();
+ }
+ else {
+ // Debug.Log("Player is carrying something but not a plate");
+ if (KitchenObject.TryGetPlate(out plateKitchenObject))
+ // Debug.Log("ClearCounter is holding a plate");
+ if (plateKitchenObject.TryAddIngredient(player.KitchenObject.KitchenObjectSO))
+ player.KitchenObject.DestroySelf();
+ }
+ }
+ else {
+ Debug.Log("Player is taking KitchenObject from ClearCounter");
+ KitchenObject.SetKitchenObjectParent(player);
+ KitchenObject = null;
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/ContainerCounter.cs b/Assets/Scripts/Counters/ContainerCounter.cs
index 9f0261611..cb80f8614 100644
--- a/Assets/Scripts/Counters/ContainerCounter.cs
+++ b/Assets/Scripts/Counters/ContainerCounter.cs
@@ -2,24 +2,24 @@ using System;
using Unity.Netcode;
using UnityEngine;
-
-public class ContainerCounter : BaseCounter
-{
+public class ContainerCounter : BaseCounter {
[SerializeField] private KitchenObjectSO kitchenObjectSO;
public event EventHandler OnPlayerGrabbedObject;
- public override void Interact(Player player)
- {
- if (kitchenObjectSO != null && player.KitchenObject == null)
- {
+ public override void Interact(Player player) {
+ if (kitchenObjectSO != null && player.KitchenObject == null) {
KitchenObject.SpawnKitchenObject(kitchenObjectSO, player);
InteractLogicServerRpc();
}
}
[ServerRpc(RequireOwnership = false)]
- private void InteractLogicServerRpc() => InteractLogicClientRpc();
+ public void InteractLogicServerRpc() {
+ InteractLogicClientRpc();
+ }
[ClientRpc]
- private void InteractLogicClientRpc() => OnPlayerGrabbedObject?.Invoke(this, EventArgs.Empty);
-}
+ public void InteractLogicClientRpc() {
+ OnPlayerGrabbedObject?.Invoke(this, EventArgs.Empty);
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/ContainerCounterVisual.cs b/Assets/Scripts/Counters/ContainerCounterVisual.cs
index b28f60f79..c92ba2d74 100644
--- a/Assets/Scripts/Counters/ContainerCounterVisual.cs
+++ b/Assets/Scripts/Counters/ContainerCounterVisual.cs
@@ -1,22 +1,20 @@
using System;
using UnityEngine;
-
-public class ContainerCounterVisual : MonoBehaviour
-{
+public class ContainerCounterVisual : MonoBehaviour {
private static readonly int openClose = Animator.StringToHash("OpenClose");
[SerializeField] private ContainerCounter containerCounter;
private Animator animator;
- private void Awake()
- {
+ private void Awake() {
animator = GetComponent();
}
- private void Start()
- {
+ private void Start() {
containerCounter.OnPlayerGrabbedObject += ContainerCounter_OnPlayerGrabbedObject;
}
- private void ContainerCounter_OnPlayerGrabbedObject(object sender, System.EventArgs e) => animator.SetTrigger(openClose);
-}
+ private void ContainerCounter_OnPlayerGrabbedObject(object sender, EventArgs e) {
+ animator.SetTrigger(openClose);
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/CuttingCounter.cs b/Assets/Scripts/Counters/CuttingCounter.cs
index d76ef2afe..913f37cb6 100644
--- a/Assets/Scripts/Counters/CuttingCounter.cs
+++ b/Assets/Scripts/Counters/CuttingCounter.cs
@@ -3,40 +3,31 @@ using System.Linq;
using Unity.Netcode;
using UnityEngine;
-public class CuttingCounter : BaseCounter, IHasProgress, IKitchenObjectParent
-{
- [SerializeField] private CuttingRecipeSO[] cuttingRecipeSOArray;
+public class CuttingCounter : BaseCounter, IHasProgress {
+ [SerializeField] private CuttingRecipeSO[] CuttingRecipeSOArray;
private int cuttingProgress;
-
public static event EventHandler OnAnyCut;
public event EventHandler OnProgressChanged;
public event EventHandler OnCut;
- public override void Interact(Player player)
- {
- if (KitchenObject == null)
- {
- if (player.KitchenObject == null) return;
+ public override void Interact(Player player) {
+ if (KitchenObject == null) {
+ if (player.KitchenObject is null) return;
+ if (!HasRecipeWithInput(player.KitchenObject.KitchenObjectSO)) return;
- if (HasRecipeWithInput(player.KitchenObject.KitchenObjectSO))
- {
- KitchenObject kitchenObject = player.KitchenObject;
- kitchenObject.SetKitchenObjectParent(this);
- player.KitchenObject = null;
- InteractLogicPlaceObjectOnCounterServerRpc();
- }
+ KitchenObject kitchenObject = player.KitchenObject;
+ kitchenObject.SetKitchenObjectParent(this);
+ player.KitchenObject = null;
+ InteractLogicPlaceObjectOnCounterServerRpc();
}
- else
- {
+ else {
if (player.KitchenObject == null) return;
- if (player.KitchenObject.TryGetPlate(out PlateKitchenObject plateKitchenObject))
- {
+ if (player.KitchenObject.TryGetPlate(out PlateKitchenObject plateKitchenObject)) {
if (plateKitchenObject.TryAddIngredient(KitchenObject.KitchenObjectSO)) KitchenObject.DestroySelf();
}
- else
- {
+ else {
KitchenObject.SetKitchenObjectParent(player);
KitchenObject = null;
}
@@ -44,70 +35,59 @@ public class CuttingCounter : BaseCounter, IHasProgress, IKitchenObjectParent
}
[ServerRpc(RequireOwnership = false)]
- private void InteractLogicPlaceObjectOnCounterServerRpc() => InteractLogicPlaceObjectOnCounterClientRpc();
+ public void InteractLogicPlaceObjectOnCounterServerRpc() => InteractLogicPlaceObjectOnCounterClientRpc();
[ClientRpc]
- private void InteractLogicPlaceObjectOnCounterClientRpc()
- {
+ public void InteractLogicPlaceObjectOnCounterClientRpc() {
cuttingProgress = 0;
- OnProgressChanged?.Invoke(this, new() { ProgressNormalized = 0f });
+ OnProgressChanged?.Invoke(this, new IHasProgress.ProgressChangedEventArgs{ ProgressNormalized = 0f });
}
- public override void InteractAlternate(Player player)
- {
+ public override void InteractAlternate(Player player) {
if (KitchenObject == null) return;
+ if (!HasRecipeWithInput(KitchenObject.KitchenObjectSO)) return;
- if (HasRecipeWithInput(KitchenObject.KitchenObjectSO))
- {
- CutObjectServerRpc();
- TestCuttingProgressDoneServerRpc();
- }
+ CutObjectServerRpc();
+ TestCuttingProgressDoneServerRpc();
}
[ServerRpc(RequireOwnership = false)]
- private void CutObjectServerRpc() => CutObjectClientRpc();
+ public void CutObjectServerRpc() => CutObjectClientRpc();
[ClientRpc]
- private void CutObjectClientRpc()
- {
+ public void CutObjectClientRpc() {
cuttingProgress++;
OnCut?.Invoke(this, EventArgs.Empty);
OnAnyCut?.Invoke(this, EventArgs.Empty);
CuttingRecipeSO cuttingRecipeSO = GetCuttingRecipeSOWithInput(KitchenObject.KitchenObjectSO);
- OnProgressChanged?.Invoke(this, new() { ProgressNormalized = (float)cuttingProgress / cuttingRecipeSO.cuttingProgressMax });
-
+ OnProgressChanged?.Invoke(this, new IHasProgress.ProgressChangedEventArgs
+ { ProgressNormalized = (float)cuttingProgress / cuttingRecipeSO.cuttingProgressMax });
}
[ServerRpc(RequireOwnership = false)]
- private void TestCuttingProgressDoneServerRpc()
- {
+ public void TestCuttingProgressDoneServerRpc() {
CuttingRecipeSO cuttingRecipeSO = GetCuttingRecipeSOWithInput(KitchenObject.KitchenObjectSO);
-
+ if (cuttingRecipeSO is null) return;
if (cuttingProgress < cuttingRecipeSO.cuttingProgressMax) return;
KitchenObjectSO outputKitchenObjectSO = GetOutputForInput(KitchenObject.KitchenObjectSO);
- if (outputKitchenObjectSO == null) return;
+ if (outputKitchenObjectSO is null) return;
KitchenObject.DestroyKitchenObject(KitchenObject);
- KitchenObject = null;
KitchenObject.SpawnKitchenObject(outputKitchenObjectSO, this);
}
- private bool HasRecipeWithInput(KitchenObjectSO inputKitchenObjectSO)
- {
- return GetCuttingRecipeSOWithInput(inputKitchenObjectSO) != null;
- }
+ private bool HasRecipeWithInput(KitchenObjectSO inputKitchenObjectSO) => GetCuttingRecipeSOWithInput(inputKitchenObjectSO) is not null;
- private KitchenObjectSO GetOutputForInput(KitchenObjectSO inputKitchenObjectSO)
- {
+ private KitchenObjectSO GetOutputForInput(KitchenObjectSO inputKitchenObjectSO) {
CuttingRecipeSO cuttingRecipeSO = GetCuttingRecipeSOWithInput(inputKitchenObjectSO);
return cuttingRecipeSO ? cuttingRecipeSO.output : null;
}
- private CuttingRecipeSO GetCuttingRecipeSOWithInput(KitchenObjectSO inputKitchenObjectSO)
- {
- return cuttingRecipeSOArray.FirstOrDefault(cuttingRecipeSO => cuttingRecipeSO.input == inputKitchenObjectSO);
- }
+ private CuttingRecipeSO GetCuttingRecipeSOWithInput(KitchenObjectSO inputKitchenObjectSO)
+ => CuttingRecipeSOArray.FirstOrDefault(cuttingRecipeSO => cuttingRecipeSO.input == inputKitchenObjectSO);
+
+ public static void ResetStaticData() => OnAnyCut = null;
}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/CuttingCounterVisual.cs b/Assets/Scripts/Counters/CuttingCounterVisual.cs
index a130b9525..8301f7fb5 100644
--- a/Assets/Scripts/Counters/CuttingCounterVisual.cs
+++ b/Assets/Scripts/Counters/CuttingCounterVisual.cs
@@ -1,24 +1,20 @@
using System;
using UnityEngine;
-public class CuttingCounterVisual : MonoBehaviour
-{
- private static readonly int cut = Animator.StringToHash("Cut");
- [SerializeField] private CuttingCounter cuttingCounter;
- private Animator animator;
+public class CuttingCounterVisual : MonoBehaviour {
+ private static readonly int cut = Animator.StringToHash("Cut");
+ [SerializeField] private CuttingCounter cuttingCounter;
+ private Animator animator;
- private void Awake()
- {
- animator = GetComponent();
- }
+ private void Awake() {
+ animator = GetComponent();
+ }
- private void Start()
- {
- cuttingCounter.OnCut += CuttingCounter_OnCut;
- }
+ private void Start() {
+ cuttingCounter.OnCut += CuttingCounter_OnCut;
+ }
- private void CuttingCounter_OnCut(object sender, System.EventArgs e)
- {
- animator.SetTrigger(cut);
- }
+ private void CuttingCounter_OnCut(object sender, EventArgs e) {
+ animator.SetTrigger(cut);
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/DeliveryCounter.cs b/Assets/Scripts/Counters/DeliveryCounter.cs
index c31f8cb1c..440c65475 100644
--- a/Assets/Scripts/Counters/DeliveryCounter.cs
+++ b/Assets/Scripts/Counters/DeliveryCounter.cs
@@ -6,11 +6,10 @@ public class DeliveryCounter : BaseCounter {
}
public override void Interact(Player player) {
- if (player.KitchenObject != null) {
+ if (player.KitchenObject != null)
if (player.KitchenObject.TryGetPlate(out PlateKitchenObject plateKitchenObject)) {
DeliveryManager.Instance.DeliverRecipe(plateKitchenObject);
KitchenObject.DestroyKitchenObject(player.KitchenObject);
}
- }
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/PlatesCounter.cs b/Assets/Scripts/Counters/PlatesCounter.cs
index 793068120..c6a59b5ea 100644
--- a/Assets/Scripts/Counters/PlatesCounter.cs
+++ b/Assets/Scripts/Counters/PlatesCounter.cs
@@ -2,44 +2,37 @@ using System;
using Unity.Netcode;
using UnityEngine;
-public class PlatesCounter : BaseCounter
-{
+public class PlatesCounter : BaseCounter {
[SerializeField] private float spawnPlateTimerMax = 10f;
[SerializeField] private int platesSpawnedAmountMax = 6;
[SerializeField] private KitchenObjectSO plateKitchenObjectSO;
private int platesSpawnedAmount;
private float spawnPlateTimer;
- private void Update()
- {
+ private void Update() {
if (!IsServer) return;
spawnPlateTimer += Time.deltaTime;
- if (spawnPlateTimer > spawnPlateTimerMax)
- {
+ if (spawnPlateTimer > spawnPlateTimerMax) {
spawnPlateTimer = 0f;
if (KitchenGameManager.Instance.IsGamePlaying() && platesSpawnedAmount < platesSpawnedAmountMax)
- {
SpawnPlateServerRpc();
- }
}
}
[ServerRpc]
- private void SpawnPlateServerRpc() => SpawnPlateClientRpc();
+ public void SpawnPlateServerRpc() => SpawnPlateClientRpc();
[ClientRpc]
- private void SpawnPlateClientRpc()
- {
+ public void SpawnPlateClientRpc() {
platesSpawnedAmount++;
- OnPlateSpawned?.Invoke(this, System.EventArgs.Empty);
+ OnPlateSpawned?.Invoke(this, EventArgs.Empty);
}
public event EventHandler OnPlateSpawned;
public event EventHandler OnPlateRemoved;
- public override void Interact(Player player)
- {
+ public override void Interact(Player player) {
if (player.KitchenObject != null) return;
if (platesSpawnedAmount == 0) return;
KitchenObject.SpawnKitchenObject(plateKitchenObjectSO, player);
@@ -48,12 +41,13 @@ public class PlatesCounter : BaseCounter
[ServerRpc(RequireOwnership = false)]
- private void InteractLogicServerRpc() => InteractLogicClientRpc();
+ public void InteractLogicServerRpc() {
+ InteractLogicClientRpc();
+ }
[ClientRpc]
- private void InteractLogicClientRpc()
- {
+ public void InteractLogicClientRpc() {
platesSpawnedAmount--;
- OnPlateRemoved?.Invoke(this, System.EventArgs.Empty);
+ OnPlateRemoved?.Invoke(this, EventArgs.Empty);
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/PlatesCounterVisual.cs b/Assets/Scripts/Counters/PlatesCounterVisual.cs
index d57583f97..897624f6d 100644
--- a/Assets/Scripts/Counters/PlatesCounterVisual.cs
+++ b/Assets/Scripts/Counters/PlatesCounterVisual.cs
@@ -2,37 +2,32 @@ using System;
using System.Collections.Generic;
using UnityEngine;
-public class PlatesCounterVisual : MonoBehaviour
-{
- [SerializeField] private PlatesCounter platesCounter;
- [SerializeField] private Transform counterTopPoint;
- [SerializeField] private Transform plateVisualPrefab;
+public class PlatesCounterVisual : MonoBehaviour {
+ [SerializeField] private PlatesCounter platesCounter;
+ [SerializeField] private Transform counterTopPoint;
+ [SerializeField] private Transform plateVisualPrefab;
- private List plateVisualGameObjectList;
+ private List plateVisualGameObjectList;
- private void Awake()
- {
- plateVisualGameObjectList = new();
- }
+ private void Awake() {
+ plateVisualGameObjectList = new List();
+ }
- private void Start()
- {
- platesCounter.OnPlateSpawned += PlatesCounter_OnPlateSpawned;
- platesCounter.OnPlateRemoved += PlatesCounter_OnPlateRemoved;
- }
+ private void Start() {
+ platesCounter.OnPlateSpawned += PlatesCounter_OnPlateSpawned;
+ platesCounter.OnPlateRemoved += PlatesCounter_OnPlateRemoved;
+ }
- private void PlatesCounter_OnPlateRemoved(object sender, System.EventArgs e)
- {
- GameObject plateGameObject = plateVisualGameObjectList[^1];
- _ = plateVisualGameObjectList.Remove(plateGameObject);
- Destroy(plateGameObject);
- }
+ private void PlatesCounter_OnPlateRemoved(object sender, EventArgs e) {
+ GameObject plateGameObject = plateVisualGameObjectList[^1];
+ _ = plateVisualGameObjectList.Remove(plateGameObject);
+ Destroy(plateGameObject);
+ }
- private void PlatesCounter_OnPlateSpawned(object sender, System.EventArgs e)
- {
- Transform plateVisualTransform = Instantiate(plateVisualPrefab, counterTopPoint);
- const float plateOffsetY = .1f;
- plateVisualTransform.localPosition = new(0, plateOffsetY * plateVisualGameObjectList.Count, 0);
- plateVisualGameObjectList.Add(plateVisualTransform.gameObject);
- }
+ private void PlatesCounter_OnPlateSpawned(object sender, EventArgs e) {
+ Transform plateVisualTransform = Instantiate(plateVisualPrefab, counterTopPoint);
+ const float plateOffsetY = .1f;
+ plateVisualTransform.localPosition = new Vector3(0, plateOffsetY * plateVisualGameObjectList.Count, 0);
+ plateVisualGameObjectList.Add(plateVisualTransform.gameObject);
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/StoveCounter.cs b/Assets/Scripts/Counters/StoveCounter.cs
index 824df43b8..523eb8e09 100644
--- a/Assets/Scripts/Counters/StoveCounter.cs
+++ b/Assets/Scripts/Counters/StoveCounter.cs
@@ -2,10 +2,8 @@ using System;
using System.Linq;
using UnityEngine;
-public class StoveCounter : BaseCounter, IHasProgress, IKitchenObjectParent
-{
- public enum State
- {
+public class StoveCounter : BaseCounter, IHasProgress, IKitchenObjectParent {
+ public enum State {
Idle,
Frying,
Fried,
@@ -21,24 +19,19 @@ public class StoveCounter : BaseCounter, IHasProgress, IKitchenObjectParent
private State state;
- private void Start()
- {
+ private void Start() {
SetStateAndFireEvent(State.Idle);
}
- private void Update()
- {
+ private void Update() {
if (KitchenObject != null)
- {
- switch (state)
- {
+ switch (state) {
case State.Idle:
break;
case State.Frying:
fryingTimer += Time.deltaTime;
FireProgressEvent(fryingTimer / fryingRecipeSO.fryingTimerMax);
- if (fryingTimer > fryingRecipeSO.fryingTimerMax)
- {
+ if (fryingTimer > fryingRecipeSO.fryingTimerMax) {
KitchenObject.DestroySelf();
KitchenObject.SpawnKitchenObject(fryingRecipeSO.output, this);
// Debug.Log("Object fried");
@@ -51,8 +44,7 @@ public class StoveCounter : BaseCounter, IHasProgress, IKitchenObjectParent
case State.Fried:
burningTimer += Time.deltaTime;
FireProgressEvent(burningTimer / burningRecipeSO.burningTimerMax);
- if (burningTimer > burningRecipeSO.burningTimerMax)
- {
+ if (burningTimer > burningRecipeSO.burningTimerMax) {
KitchenObject.DestroySelf();
KitchenObject.SpawnKitchenObject(burningRecipeSO.output, this);
// Debug.Log("Object burned");
@@ -63,37 +55,28 @@ public class StoveCounter : BaseCounter, IHasProgress, IKitchenObjectParent
break;
case State.Burned:
break;
- default:
- break;
}
- }
}
public event EventHandler OnProgressChanged;
public event EventHandler OnStateChanged;
- private void SetStateAndFireEvent(State newState)
- {
+ private void SetStateAndFireEvent(State newState) {
state = newState;
- OnStateChanged?.Invoke(this, new() { State = newState });
+ OnStateChanged?.Invoke(this, new StateChangedEventArgs{ State = newState });
}
- private void FireProgressEvent(float progress)
- {
- OnProgressChanged?.Invoke(this, new()
- {
+ private void FireProgressEvent(float progress) {
+ OnProgressChanged?.Invoke(this, new IHasProgress.ProgressChangedEventArgs{
ProgressNormalized = progress,
State = state
});
}
- public override void Interact(Player player)
- {
- if (KitchenObject == null)
- {
+ public override void Interact(Player player) {
+ if (KitchenObject == null) {
Debug.Log("There is no KitchenObject here");
- if (player.KitchenObject != null && HasRecipeWithInput(player.KitchenObject.KitchenObjectSO))
- {
+ if (player.KitchenObject != null && HasRecipeWithInput(player.KitchenObject.KitchenObjectSO)) {
Debug.Log($"Player is putting {player.KitchenObject.KitchenObjectSO.objectName} to StoveCounter");
player.KitchenObject.SetKitchenObjectParent(this);
player.KitchenObject = null;
@@ -101,38 +84,33 @@ public class StoveCounter : BaseCounter, IHasProgress, IKitchenObjectParent
SetStateAndFireEvent(State.Frying);
fryingTimer = 0f;
}
- else
- {
+ else {
Debug.Log("Player not carrying anything for the StoveCounter!");
}
}
- else
- {
+ else {
Debug.Log($"There is a {KitchenObject.KitchenObjectSO.objectName} on the StoveCounter");
- if (player.KitchenObject != null)
- {
- if (player.KitchenObject.TryGetPlate(out PlateKitchenObject plateKitchenObject))
- {
- Debug.Log($"Player is carrying a {player.KitchenObject.KitchenObjectSO.objectName}, try to put Ingredient onto it...");
- if (plateKitchenObject.TryAddIngredient(KitchenObject.KitchenObjectSO))
- {
- Debug.Log($"Player is taking {KitchenObject.KitchenObjectSO.objectName} from StoveCounter to plate");
+ if (player.KitchenObject != null) {
+ if (player.KitchenObject.TryGetPlate(out PlateKitchenObject plateKitchenObject)) {
+ Debug.Log(
+ $"Player is carrying a {player.KitchenObject.KitchenObjectSO.objectName}, try to put Ingredient onto it...");
+ if (plateKitchenObject.TryAddIngredient(KitchenObject.KitchenObjectSO)) {
+ Debug.Log(
+ $"Player is taking {KitchenObject.KitchenObjectSO.objectName} from StoveCounter to plate");
KitchenObject.DestroySelf();
SetStateAndFireEvent(State.Idle);
FireProgressEvent(0f);
}
- else
- {
- Debug.Log($"Ingredient {player.KitchenObject.KitchenObjectSO.objectName} does not fit anymore!");
+ else {
+ Debug.Log(
+ $"Ingredient {player.KitchenObject.KitchenObjectSO.objectName} does not fit anymore!");
}
}
- else
- {
+ else {
Debug.Log($"Player is already carrying a {player.KitchenObject.KitchenObjectSO.objectName}!");
}
}
- else
- {
+ else {
Debug.Log($"Player is taking {KitchenObject.KitchenObjectSO.objectName} from StoveCounter to hand");
KitchenObject.SetKitchenObjectParent(player);
KitchenObject = null;
@@ -142,48 +120,39 @@ public class StoveCounter : BaseCounter, IHasProgress, IKitchenObjectParent
}
}
- public override void InteractAlternate(Player player)
- {
+ public override void InteractAlternate(Player player) {
Debug.Log("Nothing alternate to do here!");
}
- private bool HasRecipeWithInput(KitchenObjectSO inputKitchenObjectSO)
- {
+ private bool HasRecipeWithInput(KitchenObjectSO inputKitchenObjectSO) {
return GetFryingRecipeSOWithInput(inputKitchenObjectSO);
}
- private KitchenObjectSO GetOutputForInput(KitchenObjectSO inputKitchenObjectSO)
- {
+ private KitchenObjectSO GetOutputForInput(KitchenObjectSO inputKitchenObjectSO) {
FryingRecipeSO fRSO = GetFryingRecipeSOWithInput(inputKitchenObjectSO);
return fRSO ? fRSO.output : null;
}
- private FryingRecipeSO GetFryingRecipeSOWithInput(KitchenObjectSO inputKitchenObjectSO)
- {
+ private FryingRecipeSO GetFryingRecipeSOWithInput(KitchenObjectSO inputKitchenObjectSO) {
return fryingRecipeSOArray.FirstOrDefault(fRSO => fRSO.input == inputKitchenObjectSO);
}
- private BurningRecipeSO GetBurningRecipeSOWithInput(KitchenObjectSO inputKitchenObjectSO)
- {
- BurningRecipeSO burningRecipeSO = burningRecipeSOArray.FirstOrDefault(fRSO => fRSO.input == inputKitchenObjectSO);
- if (burningRecipeSO == null)
- {
+ private BurningRecipeSO GetBurningRecipeSOWithInput(KitchenObjectSO inputKitchenObjectSO) {
+ BurningRecipeSO burningRecipeSO =
+ burningRecipeSOArray.FirstOrDefault(fRSO => fRSO.input == inputKitchenObjectSO);
+ if (burningRecipeSO == null) {
Debug.LogError($"No BurningRecipe found for {inputKitchenObjectSO.objectName}");
return null;
}
- else
- {
- return burningRecipeSO;
- }
+
+ return burningRecipeSO;
}
- public bool IsFrying()
- {
+ public bool IsFrying() {
return state == State.Frying;
}
- public bool IsFried()
- {
+ public bool IsFried() {
return state == State.Fried;
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/StoveCounterSound.cs b/Assets/Scripts/Counters/StoveCounterSound.cs
index 81b2308e2..6733fdef4 100644
--- a/Assets/Scripts/Counters/StoveCounterSound.cs
+++ b/Assets/Scripts/Counters/StoveCounterSound.cs
@@ -1,53 +1,41 @@
using UnityEngine;
-public class StoveCounterSound : MonoBehaviour
-{
- [SerializeField] private StoveCounter stoveCounter;
- private AudioSource audioSource;
- private float warningSoundTimer;
- private bool playWarningSound;
- private const float warningSoundTimerMax = .5f;
+public class StoveCounterSound : MonoBehaviour {
+ private const float warningSoundTimerMax = .5f;
+ [SerializeField] private StoveCounter stoveCounter;
+ private AudioSource audioSource;
+ private bool playWarningSound;
+ private float warningSoundTimer;
- private void Awake()
- {
- audioSource = GetComponent();
- }
+ private void Awake() {
+ audioSource = GetComponent();
+ }
- private void Start()
- {
- stoveCounter.OnStateChanged += StoveCounter_OnStateChanged;
- stoveCounter.OnProgressChanged += StoveCounter_OnProgressChanged;
- }
+ private void Start() {
+ stoveCounter.OnStateChanged += StoveCounter_OnStateChanged;
+ stoveCounter.OnProgressChanged += StoveCounter_OnProgressChanged;
+ }
- private void StoveCounter_OnStateChanged(object sender, StateChangedEventArgs e)
- {
- if (e.State is StoveCounter.State.Frying or StoveCounter.State.Fried)
- {
- audioSource.Play();
- }
- else
- {
- audioSource.Pause();
- }
- }
+ private void Update() {
+ if (playWarningSound) {
+ warningSoundTimer -= Time.deltaTime;
+ if (warningSoundTimer <= 0f) {
+ warningSoundTimer = warningSoundTimerMax;
+ SoundManager.Instance.PlayWarningSound(stoveCounter.transform.position);
+ }
+ }
+ }
- private void StoveCounter_OnProgressChanged(object sender, IHasProgress.ProgressChangedEventArgs e)
- {
- float burnShowProgressAmount = .5f;
- playWarningSound = stoveCounter.IsFried() && e.ProgressNormalized >= burnShowProgressAmount;
- }
+ private void StoveCounter_OnStateChanged(object sender, StateChangedEventArgs e) {
+ if (e.State is StoveCounter.State.Frying or StoveCounter.State.Fried)
+ audioSource.Play();
+ else
+ audioSource.Pause();
+ }
- private void Update()
- {
- if (playWarningSound)
- {
- warningSoundTimer -= Time.deltaTime;
- if (warningSoundTimer <= 0f)
- {
- warningSoundTimer = warningSoundTimerMax;
- SoundManager.Instance.PlayWarningSound(stoveCounter.transform.position);
- }
- }
- }
+ private void StoveCounter_OnProgressChanged(object sender, IHasProgress.ProgressChangedEventArgs e) {
+ float burnShowProgressAmount = .5f;
+ playWarningSound = stoveCounter.IsFried() && e.ProgressNormalized >= burnShowProgressAmount;
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/StoveCounterVisual.cs b/Assets/Scripts/Counters/StoveCounterVisual.cs
index 47ea39f6d..5f081ca9f 100644
--- a/Assets/Scripts/Counters/StoveCounterVisual.cs
+++ b/Assets/Scripts/Counters/StoveCounterVisual.cs
@@ -1,20 +1,17 @@
using UnityEngine;
-public class StoveCounterVisual : MonoBehaviour
-{
- [SerializeField] private StoveCounter stoveCounter;
- [SerializeField] private GameObject stoveOnGameObject;
- [SerializeField] private GameObject particlesGameObject;
+public class StoveCounterVisual : MonoBehaviour {
+ [SerializeField] private StoveCounter stoveCounter;
+ [SerializeField] private GameObject stoveOnGameObject;
+ [SerializeField] private GameObject particlesGameObject;
- private void Start()
- {
- stoveCounter.OnStateChanged += StoveCounter_OnStateChanged;
- }
+ private void Start() {
+ stoveCounter.OnStateChanged += StoveCounter_OnStateChanged;
+ }
- private void StoveCounter_OnStateChanged(object sender, StateChangedEventArgs e)
- {
- bool showVisual = e.State is StoveCounter.State.Frying or StoveCounter.State.Fried;
- stoveOnGameObject.SetActive(showVisual);
- particlesGameObject.SetActive(showVisual);
- }
+ private void StoveCounter_OnStateChanged(object sender, StateChangedEventArgs e) {
+ bool showVisual = e.State is StoveCounter.State.Frying or StoveCounter.State.Fried;
+ stoveOnGameObject.SetActive(showVisual);
+ particlesGameObject.SetActive(showVisual);
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/Counters/TrashCounter.cs b/Assets/Scripts/Counters/TrashCounter.cs
index ba6158214..98ea2dbef 100644
--- a/Assets/Scripts/Counters/TrashCounter.cs
+++ b/Assets/Scripts/Counters/TrashCounter.cs
@@ -17,8 +17,12 @@ public class TrashCounter : BaseCounter {
}
[ServerRpc(RequireOwnership = false)]
- private void InteractLogicServerRpc() => InteractLogicClientRpc();
+ public void InteractLogicServerRpc() {
+ InteractLogicClientRpc();
+ }
[ClientRpc]
- private void InteractLogicClientRpc() => OnAnyObjectTrashed?.Invoke(this, EventArgs.Empty);
+ public void InteractLogicClientRpc() {
+ OnAnyObjectTrashed?.Invoke(this, EventArgs.Empty);
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/DeliveryManager.cs b/Assets/Scripts/DeliveryManager.cs
index be88de40e..f03ffd46d 100644
--- a/Assets/Scripts/DeliveryManager.cs
+++ b/Assets/Scripts/DeliveryManager.cs
@@ -4,31 +4,23 @@ using Unity.Netcode;
using UnityEngine;
using Random = UnityEngine.Random;
-public class DeliveryManager : NetworkBehaviour
-{
+public class DeliveryManager : NetworkBehaviour {
+ private const float spawnRecipeTimerMax = 3f;
+ private const int waitingRecipesMax = 5;
+ [SerializeField] private RecipeListSO recipeListSO;
+
+ private float spawnRecipeTimer = 3f;
public static DeliveryManager Instance { get; private set; }
public List WaitingRecipeSOList { get; private set; }
public int SuccessfulRecipes { get; private set; }
public int Points { get; private set; }
- public event EventHandler OnRecipeSpawned;
- public event EventHandler OnRecipeCompleted;
- public event EventHandler OnRecipeSuccess;
- public event EventHandler OnRecipeFailed;
- [SerializeField] private RecipeListSO recipeListSO;
-
- private float spawnRecipeTimer = 3f;
- private const float spawnRecipeTimerMax = 3f;
- private const int waitingRecipesMax = 5;
-
- private void Awake()
- {
+ private void Awake() {
Instance = this;
- WaitingRecipeSOList = new();
+ WaitingRecipeSOList = new List();
}
- private void Update()
- {
+ private void Update() {
if (!IsServer) return;
spawnRecipeTimer -= Time.deltaTime;
@@ -37,32 +29,32 @@ public class DeliveryManager : NetworkBehaviour
spawnRecipeTimer = spawnRecipeTimerMax;
if (WaitingRecipeSOList.Count >= waitingRecipesMax) return;
- if (KitchenGameManager.Instance.IsGamePlaying())
- {
+ if (KitchenGameManager.Instance.IsGamePlaying()) {
int waitingRecipeSOIndex = Random.Range(0, recipeListSO.recipeSOList.Count);
SpawnNewWaitingRecipeClientRpc(waitingRecipeSOIndex);
}
}
+ public event EventHandler OnRecipeSpawned;
+ public event EventHandler OnRecipeCompleted;
+ public event EventHandler OnRecipeSuccess;
+ public event EventHandler OnRecipeFailed;
+
[ClientRpc]
- private void SpawnNewWaitingRecipeClientRpc(int waitingRecipeSOIndex)
- {
+ public void SpawnNewWaitingRecipeClientRpc(int waitingRecipeSOIndex) {
WaitingRecipeSOList.Add(recipeListSO.recipeSOList[waitingRecipeSOIndex]);
OnRecipeSpawned?.Invoke(this, EventArgs.Empty);
}
- public void DeliverRecipe(PlateKitchenObject plateKitchenObject)
- {
- for (int i = 0; i < WaitingRecipeSOList.Count; i++)
- {
- if (WaitingRecipeSOList[i].KitchenObjectSOList.Count != plateKitchenObject.GetKitchenObjectSOList().Count) continue;
+ public void DeliverRecipe(PlateKitchenObject plateKitchenObject) {
+ for (int i = 0; i < WaitingRecipeSOList.Count; i++) {
+ if (WaitingRecipeSOList[i].KitchenObjectSOList.Count !=
+ plateKitchenObject.GetKitchenObjectSOList().Count) continue;
bool plateContentsMatchesRecipe = true;
- foreach (KitchenObjectSO recipeKitchenObjectSO in WaitingRecipeSOList[i].KitchenObjectSOList)
- {
+ foreach (KitchenObjectSO recipeKitchenObjectSO in WaitingRecipeSOList[i].KitchenObjectSOList) {
bool ingredientFound = false;
- foreach (KitchenObjectSO plateKitchenObjectSO in plateKitchenObject.GetKitchenObjectSOList())
- {
+ foreach (KitchenObjectSO plateKitchenObjectSO in plateKitchenObject.GetKitchenObjectSOList()) {
if (plateKitchenObjectSO != recipeKitchenObjectSO) continue;
ingredientFound = true;
break;
@@ -72,8 +64,7 @@ public class DeliveryManager : NetworkBehaviour
plateContentsMatchesRecipe = false;
}
- if (!plateContentsMatchesRecipe)
- {
+ if (!plateContentsMatchesRecipe) {
DeliverIncorrectRecipeServerRpc();
continue;
}
@@ -84,26 +75,28 @@ public class DeliveryManager : NetworkBehaviour
}
[ServerRpc(RequireOwnership = false)]
- private void DeliverIncorrectRecipeServerRpc() => DeliverIncorrectRecipeClientRpc();
+ public void DeliverIncorrectRecipeServerRpc() {
+ DeliverIncorrectRecipeClientRpc();
+ }
[ClientRpc]
- private void DeliverIncorrectRecipeClientRpc()
- {
+ public void DeliverIncorrectRecipeClientRpc() {
Points -= 1;
OnRecipeFailed?.Invoke(this, EventArgs.Empty);
}
[ServerRpc(RequireOwnership = false)]
- private void DeliverCorrectRecipeServerRpc(int waitingRecipeSOListIndex) => DeliverCorrectRecipeClientRpc(waitingRecipeSOListIndex);
+ public void DeliverCorrectRecipeServerRpc(int waitingRecipeSOListIndex) {
+ DeliverCorrectRecipeClientRpc(waitingRecipeSOListIndex);
+ }
[ClientRpc]
- private void DeliverCorrectRecipeClientRpc(int waitingRecipeSOListIndex)
- {
+ public void DeliverCorrectRecipeClientRpc(int waitingRecipeSOListIndex) {
Debug.Log($"Player delievered a correct {WaitingRecipeSOList[waitingRecipeSOListIndex].RecipeName}.");
SuccessfulRecipes++;
Points += WaitingRecipeSOList[waitingRecipeSOListIndex].Points;
WaitingRecipeSOList.RemoveAt(waitingRecipeSOListIndex);
OnRecipeCompleted?.Invoke(this, EventArgs.Empty);
- OnRecipeSuccess?.Invoke(this, new RecipeEventArgs() { RecipeSO = WaitingRecipeSOList[waitingRecipeSOListIndex] });
+ OnRecipeSuccess?.Invoke(this, new RecipeEventArgs{ RecipeSO = WaitingRecipeSOList[waitingRecipeSOListIndex] });
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/EventArgs.cs b/Assets/Scripts/EventArgs.cs
index fb5b9abd1..b04325caa 100644
--- a/Assets/Scripts/EventArgs.cs
+++ b/Assets/Scripts/EventArgs.cs
@@ -1,17 +1,14 @@
using System;
using static StoveCounter;
-public class RecipeEventArgs : EventArgs
-{
- public RecipeSO RecipeSO;
+public class RecipeEventArgs : EventArgs {
+ public RecipeSO RecipeSO;
}
-public class StateChangedEventArgs : EventArgs
-{
- public State State;
+public class StateChangedEventArgs : EventArgs {
+ public State State;
}
-public class SelectedCounterChangedEventArgs : EventArgs
-{
- public BaseCounter SelectedCounter;
+public class SelectedCounterChangedEventArgs : EventArgs {
+ public BaseCounter SelectedCounter;
}
\ No newline at end of file
diff --git a/Assets/Scripts/FollowTransform.cs b/Assets/Scripts/FollowTransform.cs
index 9765e52ef..e18f18bd4 100644
--- a/Assets/Scripts/FollowTransform.cs
+++ b/Assets/Scripts/FollowTransform.cs
@@ -1,18 +1,12 @@
-using System.Collections;
-using System.Collections.Generic;
using UnityEngine;
-public class FollowTransform : MonoBehaviour
-{
- private Transform targetTransform;
+public class FollowTransform : MonoBehaviour {
+ public Transform TargetTransform { get; set; }
- public void SetTargetTransform(Transform _targetTransform) => targetTransform = _targetTransform;
+ private void LateUpdate() {
+ if (TargetTransform is null) return;
- private void LateUpdate()
- {
- if (targetTransform == null) return;
-
- transform.position = targetTransform.position;
- transform.rotation = targetTransform.rotation;
+ transform.position = TargetTransform.position;
+ transform.rotation = TargetTransform.rotation;
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/GameInput.cs b/Assets/Scripts/GameInput.cs
index 25948472a..01309a896 100644
--- a/Assets/Scripts/GameInput.cs
+++ b/Assets/Scripts/GameInput.cs
@@ -2,12 +2,8 @@ using System;
using UnityEngine;
using UnityEngine.InputSystem;
-public class GameInput : MonoBehaviour
-{
- public static GameInput Instance { get; private set; }
-
- public enum Binding
- {
+public class GameInput : MonoBehaviour {
+ public enum Binding {
MoveUp,
MoveDown,
MoveLeft,
@@ -15,19 +11,19 @@ public class GameInput : MonoBehaviour
Interact,
InteractAlternate,
Pause,
- Gamepad_Interact,
- Gamepad_InteractAlternate,
- Gamepad_Pause
+ GamepadInteract,
+ GamepadInteractAlternate,
+ GamepadPause
}
private const string PlayerPrefsBindings = "InputBindings";
private static PlayerInputActions playerInputActions;
+ public static GameInput Instance { get; private set; }
- private void Awake()
- {
+ private void Awake() {
Instance = this;
- playerInputActions = new();
+ playerInputActions = new PlayerInputActions();
if (PlayerPrefs.HasKey(PlayerPrefsBindings))
playerInputActions.LoadBindingOverridesFromJson(
PlayerPrefs.GetString(PlayerPrefsBindings)
@@ -44,25 +40,19 @@ public class GameInput : MonoBehaviour
public event EventHandler OnPauseAction;
public event EventHandler OnBindingRebind;
- private void InteractAlternate_performed(InputAction.CallbackContext obj) =>
- OnInteractAlternateAction?.Invoke(this, System.EventArgs.Empty);
+ private void InteractAlternate_performed(InputAction.CallbackContext obj) => OnInteractAlternateAction?.Invoke(this, EventArgs.Empty);
- private void InteractPerformed(InputAction.CallbackContext obj) =>
- OnInteractAction?.Invoke(this, System.EventArgs.Empty);
+ private void InteractPerformed(InputAction.CallbackContext obj) => OnInteractAction?.Invoke(this, EventArgs.Empty);
- private void Pause_performed(InputAction.CallbackContext obj) =>
- OnPauseAction?.Invoke(this, System.EventArgs.Empty);
+ private void Pause_performed(InputAction.CallbackContext obj) => OnPauseAction?.Invoke(this, EventArgs.Empty);
- public Vector2 GetMovementVectorNormalized()
- {
+ public static Vector2 GetMovementVectorNormalized() {
Vector2 inputVector = playerInputActions.Player.Move.ReadValue();
return inputVector.normalized;
}
- public string GetBindingText(Binding binding)
- {
- return binding switch
- {
+ public static string GetBindingText(Binding binding) {
+ return binding switch{
Binding.MoveUp => playerInputActions.Player.Move.bindings[1].ToDisplayString(),
Binding.MoveDown => playerInputActions.Player.Move.bindings[2].ToDisplayString(),
Binding.MoveLeft => playerInputActions.Player.Move.bindings[3].ToDisplayString(),
@@ -71,24 +61,22 @@ public class GameInput : MonoBehaviour
Binding.InteractAlternate
=> playerInputActions.Player.InteractAlternate.bindings[0].ToDisplayString(),
Binding.Pause => playerInputActions.Player.Pause.bindings[0].ToDisplayString(),
- Binding.Gamepad_Interact
+ Binding.GamepadInteract
=> playerInputActions.Player.Interact.bindings[1].ToDisplayString(),
- Binding.Gamepad_InteractAlternate
+ Binding.GamepadInteractAlternate
=> playerInputActions.Player.InteractAlternate.bindings[1].ToDisplayString(),
- Binding.Gamepad_Pause => playerInputActions.Player.Pause.bindings[1].ToDisplayString(),
- _ => throw new NotImplementedException(),
+ Binding.GamepadPause => playerInputActions.Player.Pause.bindings[1].ToDisplayString(),
+ _ => throw new NotImplementedException()
};
}
- public void RebindBinding(Binding binding, Action onActionRebound)
- {
+ public void RebindBinding(Binding binding, Action onActionRebound) {
playerInputActions.Player.Disable();
InputAction inputAction;
int bindingIndex;
- switch (binding)
- {
+ switch (binding) {
default:
case Binding.MoveUp:
inputAction = playerInputActions.Player.Move;
@@ -118,15 +106,15 @@ public class GameInput : MonoBehaviour
inputAction = playerInputActions.Player.Pause;
bindingIndex = 0;
break;
- case Binding.Gamepad_Interact:
+ case Binding.GamepadInteract:
inputAction = playerInputActions.Player.Interact;
bindingIndex = 1;
break;
- case Binding.Gamepad_InteractAlternate:
+ case Binding.GamepadInteractAlternate:
inputAction = playerInputActions.Player.InteractAlternate;
bindingIndex = 1;
break;
- case Binding.Gamepad_Pause:
+ case Binding.GamepadPause:
inputAction = playerInputActions.Player.Interact;
bindingIndex = 1;
break;
@@ -134,8 +122,7 @@ public class GameInput : MonoBehaviour
inputAction
.PerformInteractiveRebinding(bindingIndex)
- .OnComplete(callback =>
- {
+ .OnComplete(callback => {
playerInputActions.Player.Enable();
onActionRebound();
PlayerPrefs.SetString(
@@ -143,8 +130,8 @@ public class GameInput : MonoBehaviour
playerInputActions.SaveBindingOverridesAsJson()
);
PlayerPrefs.Save();
- OnBindingRebind?.Invoke(this, System.EventArgs.Empty);
+ OnBindingRebind?.Invoke(this, EventArgs.Empty);
})
.Start();
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/IHasProgress.cs b/Assets/Scripts/IHasProgress.cs
index 2ad024465..eaa7e9e5d 100644
--- a/Assets/Scripts/IHasProgress.cs
+++ b/Assets/Scripts/IHasProgress.cs
@@ -1,13 +1,11 @@
using System;
using static StoveCounter;
-public interface IHasProgress
-{
- public event EventHandler OnProgressChanged;
+public interface IHasProgress {
+ public event EventHandler OnProgressChanged;
- public class ProgressChangedEventArgs : System.EventArgs
- {
- public State State;
- public float ProgressNormalized;
- }
+ public class ProgressChangedEventArgs : EventArgs {
+ public float ProgressNormalized;
+ public State State;
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/IKitchenObjectParent.cs b/Assets/Scripts/IKitchenObjectParent.cs
index 25e6f32b7..0bdf5d06d 100644
--- a/Assets/Scripts/IKitchenObjectParent.cs
+++ b/Assets/Scripts/IKitchenObjectParent.cs
@@ -1,10 +1,10 @@
using Unity.Netcode;
using UnityEngine;
-public interface IKitchenObjectParent
-{
+public interface IKitchenObjectParent {
public KitchenObject KitchenObject { get; set; }
- public Transform KitchenObjectHoldPoint { get; set; }
+ public Transform GetKitchenObjectFollowTransform();
+
//public Transform GetKitchenObjectHoldPoint();
//public void SetKitchenObject(KitchenObject kitchenObject);
//public KitchenObject GetKitchenObject();
diff --git a/Assets/Scripts/KitchenGameManager.cs b/Assets/Scripts/KitchenGameManager.cs
index 997298be0..b65eb2cdf 100644
--- a/Assets/Scripts/KitchenGameManager.cs
+++ b/Assets/Scripts/KitchenGameManager.cs
@@ -1,99 +1,48 @@
using System;
using UnityEngine;
-public class KitchenGameManager : MonoBehaviour
-{
- public static KitchenGameManager Instance { get; private set; }
- public event EventHandler OnStateChanged;
- public event EventHandler OnGamePaused;
- public event EventHandler OnGameUnpaused;
+public class KitchenGameManager : MonoBehaviour {
[SerializeField] private const float gamePlayingTimerMax = 300f;
-
- private enum State
- {
- WaitingToStart,
- CountdownToStart,
- GamePlaying,
- GameOver
- }
+ private bool isGamePaused;
private State state;
+ public static KitchenGameManager Instance { get; private set; }
public float CountdownToStartTimer { get; private set; } = 1f;
public float GamePlayingTimer { get; private set; }
- private bool isGamePaused;
- private void Awake()
- {
+ private void Awake() {
Instance = this;
state = State.WaitingToStart;
GamePlayingTimer = gamePlayingTimerMax;
}
- private void Start()
- {
+ private void Start() {
GameInput.Instance.OnPauseAction += GameInput_OnPauseAction;
GameInput.Instance.OnInteractAction += GameInput_OnInteractAction;
//DEBUG trigger game start automatically
state = State.CountdownToStart;
- OnStateChanged?.Invoke(this, System.EventArgs.Empty);
+ OnStateChanged?.Invoke(this, EventArgs.Empty);
}
- private void GameInput_OnPauseAction(object sender, System.EventArgs e)
- {
- TogglePauseGame();
- }
-
- private void GameInput_OnInteractAction(object sender, System.EventArgs e)
- {
- if (state == State.WaitingToStart)
- {
- state = State.CountdownToStart;
- OnStateChanged?.Invoke(this, System.EventArgs.Empty);
- }
- }
-
- public void TogglePauseGame()
- {
- isGamePaused = !isGamePaused;
- if (isGamePaused)
- {
- Time.timeScale = 0f;
- OnGamePaused?.Invoke(this, System.EventArgs.Empty);
- }
- else
- {
- Time.timeScale = 1f;
- OnGameUnpaused?.Invoke(this, System.EventArgs.Empty);
- }
- }
-
- private void Update()
- {
- switch (state)
- {
+ private void Update() {
+ switch (state) {
case State.WaitingToStart:
break;
case State.CountdownToStart:
CountdownToStartTimer -= Time.deltaTime;
- if (CountdownToStartTimer > 0f)
- {
- return;
- }
+ if (CountdownToStartTimer > 0f) return;
state = State.GamePlaying;
- OnStateChanged?.Invoke(this, System.EventArgs.Empty);
+ OnStateChanged?.Invoke(this, EventArgs.Empty);
break;
case State.GamePlaying:
GamePlayingTimer -= Time.deltaTime;
- if (GamePlayingTimer > 0f)
- {
- return;
- }
+ if (GamePlayingTimer > 0f) return;
state = State.GameOver;
GamePlayingTimer = gamePlayingTimerMax;
- OnStateChanged?.Invoke(this, System.EventArgs.Empty);
+ OnStateChanged?.Invoke(this, EventArgs.Empty);
break;
case State.GameOver:
break;
@@ -102,23 +51,53 @@ public class KitchenGameManager : MonoBehaviour
// Debug.Log(state);
}
- public bool IsGamePlaying()
- {
+ public event EventHandler OnStateChanged;
+ public event EventHandler OnGamePaused;
+ public event EventHandler OnGameUnpaused;
+
+ private void GameInput_OnPauseAction(object sender, EventArgs e) {
+ TogglePauseGame();
+ }
+
+ private void GameInput_OnInteractAction(object sender, EventArgs e) {
+ if (state == State.WaitingToStart) {
+ state = State.CountdownToStart;
+ OnStateChanged?.Invoke(this, EventArgs.Empty);
+ }
+ }
+
+ public void TogglePauseGame() {
+ isGamePaused = !isGamePaused;
+ if (isGamePaused) {
+ Time.timeScale = 0f;
+ OnGamePaused?.Invoke(this, EventArgs.Empty);
+ }
+ else {
+ Time.timeScale = 1f;
+ OnGameUnpaused?.Invoke(this, EventArgs.Empty);
+ }
+ }
+
+ public bool IsGamePlaying() {
return state == State.GamePlaying;
}
- public bool IsCountToStartActive()
- {
+ public bool IsCountToStartActive() {
return state == State.CountdownToStart;
}
- public bool IsGameOver()
- {
+ public bool IsGameOver() {
return state == State.GameOver;
}
- public float GetGamePlayingTimerNormalized()
- {
- return 1 - (GamePlayingTimer / gamePlayingTimerMax);
+ public float GetGamePlayingTimerNormalized() {
+ return 1 - GamePlayingTimer / gamePlayingTimerMax;
+ }
+
+ private enum State {
+ WaitingToStart,
+ CountdownToStart,
+ GamePlaying,
+ GameOver
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/KitchenGameMultiplayer.cs b/Assets/Scripts/KitchenGameMultiplayer.cs
index 224600614..212d98580 100644
--- a/Assets/Scripts/KitchenGameMultiplayer.cs
+++ b/Assets/Scripts/KitchenGameMultiplayer.cs
@@ -1,19 +1,20 @@
using Unity.Netcode;
using UnityEngine;
-public class KitchenGameMultiplayer : NetworkBehaviour
-{
- public static KitchenGameMultiplayer Instance { get; private set; }
-
+public class KitchenGameMultiplayer : NetworkBehaviour {
[SerializeField] private KitchenObjectListSO kitchenObjectListSO;
+ public static KitchenGameMultiplayer Instance { get; private set; }
- private void Awake() => Instance = this;
+ private void Awake() {
+ Instance = this;
+ }
- public void SpawnKitchenObject(KitchenObjectSO kitchenObjectSO, IKitchenObjectParent kitchenObjectParent) => SpawnKitchenObjectServerRpc(GetKitchenObjectSOIndex(kitchenObjectSO), kitchenObjectParent.GetNetworkObject());
+ public void SpawnKitchenObject(KitchenObjectSO kitchenObjectSO, IKitchenObjectParent kitchenObjectParent) {
+ SpawnKitchenObjectServerRpc(GetKitchenObjectSOIndex(kitchenObjectSO), kitchenObjectParent.GetNetworkObject());
+ }
[ServerRpc(RequireOwnership = false)]
- private void SpawnKitchenObjectServerRpc(int kitchenObjectSOIndex, NetworkObjectReference kitchenObjectParentNetworkObjectReference)
- {
+ public void SpawnKitchenObjectServerRpc(int kitchenObjectSOIndex, NetworkObjectReference kitchenObjectParentNetworkObjectReference) {
KitchenObjectSO kitchenObjectSO = GetKitchenObjectSOFromIndex(kitchenObjectSOIndex);
Transform kitchenObjectTransform = Instantiate(kitchenObjectSO.prefab);
@@ -21,23 +22,25 @@ public class KitchenGameMultiplayer : NetworkBehaviour
kitchenObjectNetworkObject.Spawn(true);
KitchenObject kitchenObject = kitchenObjectTransform.GetComponent();
-
kitchenObjectParentNetworkObjectReference.TryGet(out NetworkObject kitchenObjectParentNetworkObject);
- IKitchenObjectParent kitchenObjectParent = kitchenObjectParentNetworkObject.GetComponent();
+ IKitchenObjectParent kitchenObjectParent = kitchenObjectParentNetworkObject.GetComponent();
kitchenObject.SetKitchenObjectParent(kitchenObjectParent);
- kitchenObjectTransform.gameObject.SetActive(true);
+ Debug.Log($"Will spawn {kitchenObjectSO.objectName} on {kitchenObjectParent}...");
}
- private int GetKitchenObjectSOIndex(KitchenObjectSO kitchenObjectSO) => kitchenObjectListSO.kitchenObjectSOList.IndexOf(kitchenObjectSO);
+ private int GetKitchenObjectSOIndex(KitchenObjectSO kitchenObjectSO) =>
+ kitchenObjectListSO.kitchenObjectSOList.IndexOf(kitchenObjectSO);
- private KitchenObjectSO GetKitchenObjectSOFromIndex(int kitchenObjectSOIndex) => kitchenObjectListSO.kitchenObjectSOList[kitchenObjectSOIndex];
+ private KitchenObjectSO GetKitchenObjectSOFromIndex(int kitchenObjectSOIndex) =>
+ kitchenObjectListSO.kitchenObjectSOList[kitchenObjectSOIndex];
- public void DestroyKitchenObject(KitchenObject kitchenObject) => DestroyKitchenObjectServerRpc(kitchenObject.NetworkObject);
+ public void DestroyKitchenObject(KitchenObject kitchenObject) {
+ DestroyKitchenObjectServerRpc(kitchenObject.NetworkObject);
+ }
[ServerRpc(RequireOwnership = false)]
- public void DestroyKitchenObjectServerRpc(NetworkObjectReference kitchenObjectNetworkObjectReference)
- {
+ public void DestroyKitchenObjectServerRpc(NetworkObjectReference kitchenObjectNetworkObjectReference) {
kitchenObjectNetworkObjectReference.TryGet(out NetworkObject kitchenObjectNetworkObject);
KitchenObject kitchenObject = kitchenObjectNetworkObject.GetComponent();
ClearKitchenObjectOnParentClientRpc(kitchenObjectNetworkObjectReference);
@@ -45,10 +48,9 @@ public class KitchenGameMultiplayer : NetworkBehaviour
}
[ClientRpc]
- private void ClearKitchenObjectOnParentClientRpc(NetworkObjectReference kitchenObjectNetworkObjectReference)
- {
+ public void ClearKitchenObjectOnParentClientRpc(NetworkObjectReference kitchenObjectNetworkObjectReference) {
kitchenObjectNetworkObjectReference.TryGet(out NetworkObject kitchenObjectNetworkObject);
KitchenObject kitchenObject = kitchenObjectNetworkObject.GetComponent();
kitchenObject.ClearKitchenObjectOnParent();
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/KitchenObject.cs b/Assets/Scripts/KitchenObject.cs
index 1ff7063cb..2e43cdcaf 100644
--- a/Assets/Scripts/KitchenObject.cs
+++ b/Assets/Scripts/KitchenObject.cs
@@ -1,72 +1,59 @@
using Unity.Netcode;
using UnityEngine;
-public class KitchenObject : NetworkBehaviour
-{
+public class KitchenObject : NetworkBehaviour {
public KitchenObjectSO KitchenObjectSO;
- private IKitchenObjectParent kitchenObjectParent;
private FollowTransform followTransform;
+ private IKitchenObjectParent kitchenObjectParent;
- protected virtual void Awake()
- {
- followTransform = GetComponent();
- }
+ protected virtual void Awake() => followTransform = GetComponent();
- public void SetKitchenObjectParent(IKitchenObjectParent kitchenObjectParent)
- {
- SetKitchenObjectParentServerRpc(kitchenObjectParent.GetNetworkObject());
- }
+ // ReSharper disable Unity.PerformanceAnalysis
+ public void SetKitchenObjectParent(IKitchenObjectParent kOP) => SetKitchenObjectParentServerRpc(kOP.GetNetworkObject());
[ServerRpc(RequireOwnership = false)]
- private void SetKitchenObjectParentServerRpc(NetworkObjectReference kitchenObjectParentNetworkObjectReference)
- {
- SetKitchenObjectParentClientRpc(kitchenObjectParentNetworkObjectReference);
- }
+ public void SetKitchenObjectParentServerRpc(NetworkObjectReference kitchenObjectParentNetworkObjectReference)
+ => SetKitchenObjectParentClientRpc(kitchenObjectParentNetworkObjectReference);
[ClientRpc]
- private void SetKitchenObjectParentClientRpc(NetworkObjectReference kitchenObjectParentNetworkObjectReference)
- {
+ public void SetKitchenObjectParentClientRpc(NetworkObjectReference kitchenObjectParentNetworkObjectReference) {
kitchenObjectParentNetworkObjectReference.TryGet(out NetworkObject kitchenObjectParentNetworkObject);
- IKitchenObjectParent _kitchenObjectParent = kitchenObjectParentNetworkObject.GetComponent();
+ IKitchenObjectParent kitchenOP = kitchenObjectParentNetworkObject.GetComponent();
- if (_kitchenObjectParent.KitchenObject != null) Debug.LogError("IKitchenObjectParent already has a KitchenObject");
- kitchenObjectParent = _kitchenObjectParent;
+ // if (kitchenObjectParent != null) kitchenObjectParent = null;
+ kitchenObjectParent = kitchenOP;
- //if (_kitchenObjectParwent.KitchenObject != null) kitchenObjectParent.KitchenObject = null;
+ if (kitchenOP.KitchenObject != null)
+ Debug.LogError($"IKitchenObjectParent {kitchenOP} already has a KitchenObject {kitchenOP.KitchenObject}");
kitchenObjectParent.KitchenObject = this;
- followTransform.SetTargetTransform(kitchenObjectParent.KitchenObjectHoldPoint);
+ followTransform.TargetTransform = kitchenObjectParent.GetKitchenObjectFollowTransform();
}
- public void DestroySelf()
- {
+ public void DestroySelf() {
Destroy(gameObject);
}
- public void ClearKitchenObjectOnParent()
- {
+ public void ClearKitchenObjectOnParent() {
kitchenObjectParent.KitchenObject = null;
-
}
- public bool TryGetPlate(out PlateKitchenObject plateKitchenObject)
- {
- if (this is PlateKitchenObject)
- {
+ public bool TryGetPlate(out PlateKitchenObject plateKitchenObject) {
+ if (this is PlateKitchenObject) {
plateKitchenObject = this as PlateKitchenObject;
return true;
}
+
plateKitchenObject = null;
return false;
}
- public static void SpawnKitchenObject(KitchenObjectSO kitchenObjectSO, IKitchenObjectParent kitchenObjectParent)
- {
+ // ReSharper disable Unity.PerformanceAnalysis
+ public static void SpawnKitchenObject(KitchenObjectSO kitchenObjectSO, IKitchenObjectParent kitchenObjectParent) {
KitchenGameMultiplayer.Instance.SpawnKitchenObject(kitchenObjectSO, kitchenObjectParent);
}
- public static void DestroyKitchenObject(KitchenObject kitchenObject)
- {
+ public static void DestroyKitchenObject(KitchenObject kitchenObject) {
KitchenGameMultiplayer.Instance.DestroyKitchenObject(kitchenObject);
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/Loader.cs b/Assets/Scripts/Loader.cs
index 636b94926..977acba0f 100644
--- a/Assets/Scripts/Loader.cs
+++ b/Assets/Scripts/Loader.cs
@@ -1,9 +1,7 @@
using UnityEngine.SceneManagement;
-public static class Loader
-{
- public enum Scene
- {
+public static class Loader {
+ public enum Scene {
MainMenuScene,
GameScene,
LoadingScene
@@ -11,14 +9,12 @@ public static class Loader
private static Scene targetScene;
- public static void Load(Scene target)
- {
+ public static void Load(Scene target) {
targetScene = target;
SceneManager.LoadScene(Scene.LoadingScene.ToString());
}
- public static void LoaderCallback()
- {
+ public static void LoaderCallback() {
SceneManager.LoadScene(targetScene.ToString());
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/LoaderCallback.cs b/Assets/Scripts/LoaderCallback.cs
index 5e0b449ee..d934c09bb 100644
--- a/Assets/Scripts/LoaderCallback.cs
+++ b/Assets/Scripts/LoaderCallback.cs
@@ -8,4 +8,4 @@ public class LoaderCallback : MonoBehaviour {
isFirstUpdate = false;
Loader.LoaderCallback();
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/LookAtCamera.cs b/Assets/Scripts/LookAtCamera.cs
index 6083b47d2..46fd3f7d4 100644
--- a/Assets/Scripts/LookAtCamera.cs
+++ b/Assets/Scripts/LookAtCamera.cs
@@ -1,30 +1,30 @@
using UnityEngine;
public class LookAtCamera : MonoBehaviour {
- [SerializeField] private Mode mode;
+ [SerializeField] private Mode mode;
- private void LateUpdate() {
- switch (mode) {
- case Mode.LookAt:
- transform.LookAt(Camera.main.transform);
- break;
- case Mode.LookAtInverted:
- Vector3 dirFromCamera = transform.position - Camera.main.transform.position;
- transform.LookAt(transform.position + dirFromCamera);
- break;
- case Mode.CameraForward:
- transform.forward = Camera.main.transform.forward;
- break;
- case Mode.CameraForwardInverted:
- transform.forward = -Camera.main.transform.forward;
- break;
- }
- }
+ private void LateUpdate() {
+ switch (mode) {
+ case Mode.LookAt:
+ transform.LookAt(Camera.main.transform);
+ break;
+ case Mode.LookAtInverted:
+ Vector3 dirFromCamera = transform.position - Camera.main.transform.position;
+ transform.LookAt(transform.position + dirFromCamera);
+ break;
+ case Mode.CameraForward:
+ transform.forward = Camera.main.transform.forward;
+ break;
+ case Mode.CameraForwardInverted:
+ transform.forward = -Camera.main.transform.forward;
+ break;
+ }
+ }
- private enum Mode {
- LookAt,
- LookAtInverted,
- CameraForward,
- CameraForwardInverted
- }
+ private enum Mode {
+ LookAt,
+ LookAtInverted,
+ CameraForward,
+ CameraForwardInverted
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/MusicManager.cs b/Assets/Scripts/MusicManager.cs
index 041fe70de..70abb9f9c 100644
--- a/Assets/Scripts/MusicManager.cs
+++ b/Assets/Scripts/MusicManager.cs
@@ -1,13 +1,12 @@
using UnityEngine;
-public class MusicManager : MonoBehaviour
-{
- public static MusicManager Instance { get; private set; }
-
+public class MusicManager : MonoBehaviour {
+ private const string PlayerPrefsMusicVolume = "MusicVolume";
+
private AudioSource audioSource;
private float volume;
- private const string PlayerPrefsMusicVolume = "MusicVolume";
-
+ public static MusicManager Instance { get; private set; }
+
private void Awake() {
Instance = this;
audioSource = GetComponent();
@@ -23,5 +22,7 @@ public class MusicManager : MonoBehaviour
PlayerPrefs.Save();
}
- public float GetVolume() => volume;
-}
+ public float GetVolume() {
+ return volume;
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/OwnerNetworkAnimator.cs b/Assets/Scripts/OwnerNetworkAnimator.cs
index 5a9933820..76230fe92 100644
--- a/Assets/Scripts/OwnerNetworkAnimator.cs
+++ b/Assets/Scripts/OwnerNetworkAnimator.cs
@@ -1,5 +1,7 @@
using Unity.Netcode.Components;
public class OwnerNetworkAnimator : NetworkAnimator {
- protected override bool OnIsServerAuthoritative() => false;
+ protected override bool OnIsServerAuthoritative() {
+ return false;
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/PlateCompleteVisual.cs b/Assets/Scripts/PlateCompleteVisual.cs
index 51164b9c9..e307b4722 100644
--- a/Assets/Scripts/PlateCompleteVisual.cs
+++ b/Assets/Scripts/PlateCompleteVisual.cs
@@ -2,38 +2,27 @@ using System;
using System.Collections.Generic;
using UnityEngine;
-public class PlateCompleteVisual : MonoBehaviour
-{
+public class PlateCompleteVisual : MonoBehaviour {
+ [SerializeField] private PlateKitchenObject plateKitchenObject;
+ [SerializeField] private List kitchenObjectSOGameObjectList;
- [Serializable]
- public struct KitchenObjectSOGameObject
- {
- public KitchenObjectSO kitchenObjectSO;
- public GameObject gameObject;
- }
+ private void Start() {
+ plateKitchenObject.OnIngredientAdded += PlateKitchenObject_OnIngredientAdded;
+ foreach (KitchenObjectSOGameObject kitchenObjectSOGameObject in kitchenObjectSOGameObjectList)
+ kitchenObjectSOGameObject.gameObject.SetActive(false);
+ }
- [SerializeField] private PlateKitchenObject plateKitchenObject;
- [SerializeField] private List kitchenObjectSOGameObjectList;
+ private void PlateKitchenObject_OnIngredientAdded(object sender, PlateKitchenObject.IngredientAddedEventArgs e) {
+ foreach (KitchenObjectSOGameObject gO in kitchenObjectSOGameObjectList)
+ // Debug.Log($"{gO.kitchenObjectSO} wird mit {e.KitchenObjectSO} verglichen... {gO.kitchenObjectSO == e.KitchenObjectSO}");
+ if (gO.kitchenObjectSO == e.KitchenObjectSO)
+ // Debug.Log($"{gO.gameObject} wird aktiviert!");
+ gO.gameObject.SetActive(true);
+ }
- private void Start()
- {
- plateKitchenObject.OnIngredientAdded += PlateKitchenObject_OnIngredientAdded;
- foreach (KitchenObjectSOGameObject kitchenObjectSOGameObject in kitchenObjectSOGameObjectList)
- {
- kitchenObjectSOGameObject.gameObject.SetActive(false);
- }
- }
-
- private void PlateKitchenObject_OnIngredientAdded(object sender, PlateKitchenObject.IngredientAddedEventArgs e)
- {
- foreach (KitchenObjectSOGameObject gO in kitchenObjectSOGameObjectList)
- {
- // Debug.Log($"{gO.kitchenObjectSO} wird mit {e.KitchenObjectSO} verglichen... {gO.kitchenObjectSO == e.KitchenObjectSO}");
- if (gO.kitchenObjectSO == e.KitchenObjectSO)
- {
- // Debug.Log($"{gO.gameObject} wird aktiviert!");
- gO.gameObject.SetActive(true);
- }
- }
- }
-}
+ [Serializable]
+ public struct KitchenObjectSOGameObject {
+ public KitchenObjectSO kitchenObjectSO;
+ public GameObject gameObject;
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/PlateKitchenObject.cs b/Assets/Scripts/PlateKitchenObject.cs
index c00eb3866..1615aeba1 100644
--- a/Assets/Scripts/PlateKitchenObject.cs
+++ b/Assets/Scripts/PlateKitchenObject.cs
@@ -2,45 +2,35 @@ using System;
using System.Collections.Generic;
using UnityEngine;
-public class PlateKitchenObject : KitchenObject
-{
-
- public event EventHandler OnIngredientAdded;
-
- public class IngredientAddedEventArgs : System.EventArgs
- {
- public KitchenObjectSO KitchenObjectSO;
- }
-
+public class PlateKitchenObject : KitchenObject {
[SerializeField] private List validKitchenObjectSOList;
private List kitchenObjectSOList;
- protected override void Awake()
- {
+ protected override void Awake() {
base.Awake();
- kitchenObjectSOList = new();
+ kitchenObjectSOList = new List();
}
- public bool TryAddIngredient(KitchenObjectSO kitchenObjectSO)
- {
+ public event EventHandler OnIngredientAdded;
+
+ public bool TryAddIngredient(KitchenObjectSO kitchenObjectSO) {
if (!validKitchenObjectSOList.Contains(kitchenObjectSO))
- {
// Debug.Log("Not a valid ingredient");
return false;
- }
if (kitchenObjectSOList.Contains(kitchenObjectSO))
- {
// Debug.Log("Ingredient is already on the plate!");
return false;
- }
kitchenObjectSOList.Add(kitchenObjectSO);
// Debug.Log("Ingredient is added to the plate.");
- OnIngredientAdded?.Invoke(this, new() { KitchenObjectSO = kitchenObjectSO });
+ OnIngredientAdded?.Invoke(this, new IngredientAddedEventArgs{ KitchenObjectSO = kitchenObjectSO });
return true;
}
- public List GetKitchenObjectSOList()
- {
+ public List GetKitchenObjectSOList() {
return kitchenObjectSOList;
}
-}
+
+ public class IngredientAddedEventArgs : EventArgs {
+ public KitchenObjectSO KitchenObjectSO;
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs
index 2db4fd9c2..2f8be803b 100644
--- a/Assets/Scripts/Player.cs
+++ b/Assets/Scripts/Player.cs
@@ -2,70 +2,65 @@ using System;
using Unity.Netcode;
using UnityEngine;
-public class Player : NetworkBehaviour, IKitchenObjectParent
-{
-
- public static event EventHandler OnAnyPlayerSpawned;
- public static event EventHandler OnAnyPickedSomething;
-
- public static void ResetStaticData()
- {
- OnAnyPlayerSpawned = null;
- OnAnyPickedSomething = null;
+public class Player : NetworkBehaviour, IKitchenObjectParent {
+ private Transform KitchenObjectHoldPoint { get; set; }
+ public static Player LocalInstance { get; private set; }
+
+ public KitchenObject KitchenObject {
+ get => kitchenObject;
+ set {
+ kitchenObject = value;
+ if (value == null) return;
+
+ OnPickedSomething?.Invoke(this, EventArgs.Empty);
+ OnAnyPickedSomething?.Invoke(this, EventArgs.Empty);
+ }
}
- public static Player LocalInstance { get; private set; }
- public Transform KitchenObjectHoldPoint { get; set; }
+ [SerializeField] private float moveSpeed = 7f;
+ [SerializeField] private float rotateSpeed = 10f;
+ [SerializeField] private float interactDistance = 2f;
+ [SerializeField] private LayerMask countersLayerMask;
private const float playerRadius = .7f;
private const float playerHeight = 2f;
-
- public event EventHandler OnPickedSomething;
-
- [SerializeField]
- private float moveSpeed = 7f;
-
- [SerializeField]
- private float rotateSpeed = 10f;
-
- [SerializeField]
- private float interactDistance = 2f;
-
- [SerializeField]
- private LayerMask countersLayerMask;
-
private Vector2 inputVector;
-
private bool isWalking;
private KitchenObject kitchenObject;
- public KitchenObject KitchenObject
- {
- get => kitchenObject;
- set
- {
- kitchenObject = value;
- if (value != null)
- {
- OnPickedSomething?.Invoke(this, EventArgs.Empty);
- OnAnyPickedSomething?.Invoke(this, EventArgs.Empty);
- }
- }
- }
-
private Vector3 lastInteractDir;
private Vector3 moveDir;
private BaseCounter selectedCounter;
- private void Start()
- {
+ private void Start() {
GameInput.Instance.OnInteractAction += GameInput_OnInteractAction;
GameInput.Instance.OnInteractAlternateAction += GameInput_OnInteractAlternateAction;
}
- public override void OnNetworkSpawn()
- {
- if (IsOwner)
- {
+ private void Update() {
+ if (!IsOwner) return;
+
+ HandleMovement();
+ HandleInteractions();
+ }
+
+ public Transform GetKitchenObjectFollowTransform() => KitchenObjectHoldPoint;
+
+
+
+ public NetworkObject GetNetworkObject() => NetworkObject;
+
+ public static event EventHandler OnAnyPlayerSpawned;
+ public static event EventHandler OnAnyPickedSomething;
+
+ public static void ResetStaticData() {
+ OnAnyPlayerSpawned = null;
+ OnAnyPickedSomething = null;
+ }
+
+ public event EventHandler OnPickedSomething;
+
+ public override void OnNetworkSpawn() {
+ if (IsOwner) {
LocalInstance = this;
KitchenObjectHoldPoint = transform.Find("KitchenObjectHoldPoint");
}
@@ -73,111 +68,85 @@ public class Player : NetworkBehaviour, IKitchenObjectParent
OnAnyPlayerSpawned?.Invoke(this, EventArgs.Empty);
}
- private void Update()
- {
- if (!IsOwner) return;
-
- HandleMovement();
- HandleInteractions();
- }
-
public event EventHandler OnSelectedCounterChanged;
- private void GameInput_OnInteractAlternateAction(object sender, System.EventArgs e)
- {
+ private void GameInput_OnInteractAlternateAction(object sender, EventArgs e) {
if (!KitchenGameManager.Instance.IsGamePlaying()) return;
selectedCounter?.InteractAlternate(this);
}
- private void GameInput_OnInteractAction(object sender, System.EventArgs e)
- {
+ private void GameInput_OnInteractAction(object sender, EventArgs e) {
if (!KitchenGameManager.Instance.IsGamePlaying()) return;
selectedCounter?.Interact(this);
}
- private void HandleInteractions()
- {
- inputVector = GameInput.Instance.GetMovementVectorNormalized();
+ private void HandleInteractions() {
+ inputVector = GameInput.GetMovementVectorNormalized();
if (moveDir != Vector3.zero) lastInteractDir = moveDir;
- if (Physics.Raycast(transform.position, lastInteractDir, out RaycastHit raycastHit, interactDistance, countersLayerMask))
- {
- if (raycastHit.transform.TryGetComponent(out BaseCounter baseCounter))
- {
- if (baseCounter != selectedCounter)
- {
- SetSelectedCounter(baseCounter);
- }
+ if (Physics.Raycast(transform.position, lastInteractDir, out RaycastHit raycastHit, interactDistance,
+ countersLayerMask)) {
+ if (raycastHit.transform.TryGetComponent(out BaseCounter baseCounter)) {
+ if (baseCounter != selectedCounter) SetSelectedCounter(baseCounter);
}
- else
- {
+ else {
SetSelectedCounter(null);
}
}
- else
- {
+ else {
SetSelectedCounter(null);
}
}
- private void SetSelectedCounter(BaseCounter _selectedCounter)
- {
+ private void SetSelectedCounter(BaseCounter _selectedCounter) {
selectedCounter = _selectedCounter;
- OnSelectedCounterChanged?.Invoke(this, new() { SelectedCounter = _selectedCounter });
+ OnSelectedCounterChanged?.Invoke(this,
+ new SelectedCounterChangedEventArgs{ SelectedCounter = _selectedCounter });
}
- public bool IsWalking()
- {
- return isWalking;
- }
+ public bool IsWalking() => isWalking;
- private void HandleMovement()
- {
- inputVector = GameInput.Instance.GetMovementVectorNormalized();
- moveDir = new(inputVector.x, 0, inputVector.y);
+ private void HandleMovement() {
+ inputVector = GameInput.GetMovementVectorNormalized();
+ moveDir = new Vector3(inputVector.x, 0, inputVector.y);
float moveDistance = moveSpeed * Time.deltaTime;
- bool canMove = !Physics.CapsuleCast(transform.position, transform.position + (Vector3.up * playerHeight), playerRadius, moveDir, moveDistance);
- if (!canMove)
- {
+ bool canMove = !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight,
+ playerRadius, moveDir, moveDistance);
+ if (!canMove) {
// Cannot move towars moveDir
//Attempt only x movement
Vector3 moveDirX = new Vector3(moveDir.x, 0, 0).normalized;
canMove =
(moveDir.x < -.5f || moveDir.x > +.5f)
- && !Physics.CapsuleCast(transform.position, transform.position + (Vector3.up * playerHeight), playerRadius, moveDir, moveDistance);
- if (canMove)
- {
+ && !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight,
+ playerRadius, moveDir, moveDistance);
+ if (canMove) {
//Can move only on the X
MovePlayer(moveDirX, moveDistance);
}
- else
- {
+ else {
//Cannot move only on the X
//Attempt only Z movement
Vector3 moveDirZ = new Vector3(0, 0, moveDir.z).normalized;
canMove =
(moveDir.z < -.5f || moveDir.z > +.5f)
- && !Physics.CapsuleCast(transform.position, transform.position + (Vector3.up * playerHeight), playerRadius, moveDir, moveDistance);
+ && !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight,
+ playerRadius, moveDir, moveDistance);
- if (canMove)
- {
+ if (canMove) {
//Can move only on the Z
MovePlayer(moveDirZ, moveDistance);
}
- else
- {
- //Cannot move in any direction
- }
+ //Cannot move in any direction
}
}
- else
- {
+ else {
MovePlayer(moveDir, moveDistance);
}
@@ -185,10 +154,5 @@ public class Player : NetworkBehaviour, IKitchenObjectParent
transform.forward = Vector3.Slerp(transform.forward, moveDir, Time.deltaTime * rotateSpeed);
}
- private void MovePlayer(Vector3 moveDirection, float moveDistance)
- {
- transform.position += moveDirection * moveDistance;
- }
-
- public NetworkObject GetNetworkObject() => NetworkObject;
+ private void MovePlayer(Vector3 moveDirection, float moveDistance) => transform.position += moveDirection * moveDistance;
}
\ No newline at end of file
diff --git a/Assets/Scripts/PlayerAnimator.cs b/Assets/Scripts/PlayerAnimator.cs
index ba3ab88b2..82cb83dd4 100644
--- a/Assets/Scripts/PlayerAnimator.cs
+++ b/Assets/Scripts/PlayerAnimator.cs
@@ -1,20 +1,17 @@
using Unity.Netcode;
using UnityEngine;
-public class PlayerAnimator : NetworkBehaviour
-{
+public class PlayerAnimator : NetworkBehaviour {
private static readonly int isWalking = Animator.StringToHash("IsWalking");
[SerializeField] private Player player;
private Animator animator;
- private void Awake()
- {
+ private void Awake() {
animator = GetComponent();
}
- private void Update()
- {
+ private void Update() {
if (!IsOwner) return;
animator.SetBool(isWalking, player.IsWalking());
}
diff --git a/Assets/Scripts/PlayerSounds.cs b/Assets/Scripts/PlayerSounds.cs
index a23be01ba..7ead6d5fc 100644
--- a/Assets/Scripts/PlayerSounds.cs
+++ b/Assets/Scripts/PlayerSounds.cs
@@ -1,12 +1,13 @@
-using System;
using UnityEngine;
public class PlayerSounds : MonoBehaviour {
- private Player player;
- private float footstepTimer;
private const float footstepTimerMax = .2f;
+ private float footstepTimer;
+ private Player player;
- private void Awake() => player = GetComponent();
+ private void Awake() {
+ player = GetComponent();
+ }
private void Update() {
footstepTimer -= Time.deltaTime;
@@ -16,4 +17,4 @@ public class PlayerSounds : MonoBehaviour {
const float volume = 1f;
SoundManager.Instance.PlayFootstepsSound(player.transform.position, volume);
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ResetStaticDataManager.cs b/Assets/Scripts/ResetStaticDataManager.cs
index 0c342b3f0..5607e7fa5 100644
--- a/Assets/Scripts/ResetStaticDataManager.cs
+++ b/Assets/Scripts/ResetStaticDataManager.cs
@@ -1,12 +1,10 @@
using UnityEngine;
-public class ResetStaticDataManager : MonoBehaviour
-{
- private void Awake()
- {
+public class ResetStaticDataManager : MonoBehaviour {
+ private void Awake() {
// CuttingCounter.ResetStaticData();
// BaseCounter.ResetStaticData();
// TrashCounter.ResetStaticData();
Player.ResetStaticData();
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ScriptableObjects/BurningRecipeSO.cs b/Assets/Scripts/ScriptableObjects/BurningRecipeSO.cs
index 2feb616b8..e045f4978 100644
--- a/Assets/Scripts/ScriptableObjects/BurningRecipeSO.cs
+++ b/Assets/Scripts/ScriptableObjects/BurningRecipeSO.cs
@@ -1,10 +1,8 @@
using UnityEngine;
-
[CreateAssetMenu]
-public class BurningRecipeSO : ScriptableObject
-{
- public KitchenObjectSO input;
- public KitchenObjectSO output;
- public float burningTimerMax;
-}
+public class BurningRecipeSO : ScriptableObject {
+ public KitchenObjectSO input;
+ public KitchenObjectSO output;
+ public float burningTimerMax;
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ScriptableObjects/CuttingRecipeSO.cs b/Assets/Scripts/ScriptableObjects/CuttingRecipeSO.cs
index b8a179874..b6ae479c7 100644
--- a/Assets/Scripts/ScriptableObjects/CuttingRecipeSO.cs
+++ b/Assets/Scripts/ScriptableObjects/CuttingRecipeSO.cs
@@ -1,10 +1,8 @@
using UnityEngine;
-
[CreateAssetMenu]
-public class CuttingRecipeSO : ScriptableObject
-{
- public KitchenObjectSO input;
- public KitchenObjectSO output;
- public int cuttingProgressMax;
-}
+public class CuttingRecipeSO : ScriptableObject {
+ public KitchenObjectSO input;
+ public KitchenObjectSO output;
+ public int cuttingProgressMax;
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ScriptableObjects/FryingRecipeSO.cs b/Assets/Scripts/ScriptableObjects/FryingRecipeSO.cs
index 0b77ae574..b3fb6afc9 100644
--- a/Assets/Scripts/ScriptableObjects/FryingRecipeSO.cs
+++ b/Assets/Scripts/ScriptableObjects/FryingRecipeSO.cs
@@ -1,10 +1,8 @@
using UnityEngine;
-
[CreateAssetMenu]
-public class FryingRecipeSO : ScriptableObject
-{
- public KitchenObjectSO input;
- public KitchenObjectSO output;
- public float fryingTimerMax;
-}
+public class FryingRecipeSO : ScriptableObject {
+ public KitchenObjectSO input;
+ public KitchenObjectSO output;
+ public float fryingTimerMax;
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ScriptableObjects/KitchenObjectListSO.cs b/Assets/Scripts/ScriptableObjects/KitchenObjectListSO.cs
index e0ab9f568..8cd40606a 100644
--- a/Assets/Scripts/ScriptableObjects/KitchenObjectListSO.cs
+++ b/Assets/Scripts/ScriptableObjects/KitchenObjectListSO.cs
@@ -4,4 +4,4 @@ using UnityEngine;
//[CreateAssetMenu()]
public class KitchenObjectListSO : ScriptableObject {
public List kitchenObjectSOList;
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ScriptableObjects/KitchenObjectSO.cs b/Assets/Scripts/ScriptableObjects/KitchenObjectSO.cs
index c3ecb0b7d..ce382dcfe 100644
--- a/Assets/Scripts/ScriptableObjects/KitchenObjectSO.cs
+++ b/Assets/Scripts/ScriptableObjects/KitchenObjectSO.cs
@@ -1,10 +1,8 @@
using UnityEngine;
-
[CreateAssetMenu]
-public class KitchenObjectSO : ScriptableObject
-{
- public Transform prefab;
- public Sprite sprite;
- public string objectName;
-}
+public class KitchenObjectSO : ScriptableObject {
+ public Transform prefab;
+ public Sprite sprite;
+ public string objectName;
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ScriptableObjects/RecipeListSO.cs b/Assets/Scripts/ScriptableObjects/RecipeListSO.cs
index 6d94469e3..ee741e610 100644
--- a/Assets/Scripts/ScriptableObjects/RecipeListSO.cs
+++ b/Assets/Scripts/ScriptableObjects/RecipeListSO.cs
@@ -3,7 +3,6 @@ using UnityEngine;
// [CreateAssetMenu]
-public class RecipeListSO : ScriptableObject
-{
- public List recipeSOList;
-}
+public class RecipeListSO : ScriptableObject {
+ public List recipeSOList;
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ScriptableObjects/RecipeSO.cs b/Assets/Scripts/ScriptableObjects/RecipeSO.cs
index 90859a101..553c0ecbe 100644
--- a/Assets/Scripts/ScriptableObjects/RecipeSO.cs
+++ b/Assets/Scripts/ScriptableObjects/RecipeSO.cs
@@ -1,11 +1,9 @@
using System.Collections.Generic;
using UnityEngine;
-
[CreateAssetMenu]
-public class RecipeSO : ScriptableObject
-{
- public List KitchenObjectSOList;
- public string RecipeName;
- public int Points;
-}
+public class RecipeSO : ScriptableObject {
+ public List KitchenObjectSOList;
+ public string RecipeName;
+ public int Points;
+}
\ No newline at end of file
diff --git a/Assets/Scripts/SelectedCounterVisual.cs b/Assets/Scripts/SelectedCounterVisual.cs
index ad7971775..e0c97f35a 100644
--- a/Assets/Scripts/SelectedCounterVisual.cs
+++ b/Assets/Scripts/SelectedCounterVisual.cs
@@ -1,57 +1,36 @@
using System;
using UnityEngine;
-public class SelectedCounterVisual : MonoBehaviour
-{
+public class SelectedCounterVisual : MonoBehaviour {
[SerializeField] private BaseCounter baseCounter;
[SerializeField] private GameObject[] visualGameObjectArray;
- private void Start()
- {
+ private void Start() {
if (Player.LocalInstance != null)
- {
Player.LocalInstance.OnSelectedCounterChanged += Player_OnSelectedCounterChanged;
- }
else
- {
Player.OnAnyPlayerSpawned += Player_OnyAnyPlayerSpawned;
- }
}
- private void Player_OnyAnyPlayerSpawned(object sender, EventArgs e)
- {
- if (Player.LocalInstance != null)
- {
+ private void Player_OnyAnyPlayerSpawned(object sender, EventArgs e) {
+ if (Player.LocalInstance != null) {
Player.LocalInstance.OnSelectedCounterChanged -= Player_OnSelectedCounterChanged;
Player.LocalInstance.OnSelectedCounterChanged += Player_OnSelectedCounterChanged;
}
}
- private void Player_OnSelectedCounterChanged(object sender, SelectedCounterChangedEventArgs e)
- {
+ private void Player_OnSelectedCounterChanged(object sender, SelectedCounterChangedEventArgs e) {
if (e.SelectedCounter == baseCounter)
- {
Show();
- }
else
- {
Hide();
- }
}
- private void Show()
- {
- foreach (GameObject visualGameObject in visualGameObjectArray)
- {
- visualGameObject.SetActive(true);
- }
+ private void Show() {
+ foreach (GameObject visualGameObject in visualGameObjectArray) visualGameObject.SetActive(true);
}
- private void Hide()
- {
- foreach (GameObject visualGameObject in visualGameObjectArray)
- {
- visualGameObject.SetActive(false);
- }
+ private void Hide() {
+ foreach (GameObject visualGameObject in visualGameObjectArray) visualGameObject.SetActive(false);
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/SoundManager.cs b/Assets/Scripts/SoundManager.cs
index f62366563..eea34962d 100644
--- a/Assets/Scripts/SoundManager.cs
+++ b/Assets/Scripts/SoundManager.cs
@@ -3,13 +3,18 @@ using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
-public class SoundManager : MonoBehaviour
-{
- public static SoundManager Instance { get; private set; }
+public class SoundManager : MonoBehaviour {
+ private const string PlayerPrefsSoundEffectsVolume = "SoundEffectsVolume";
[SerializeField] private AudioClipRefsSO audioClipRefsSO;
+ private float volume;
+ public static SoundManager Instance { get; private set; }
+
+ private void Awake() {
+ Instance = this;
+ volume = PlayerPrefs.GetFloat(PlayerPrefsSoundEffectsVolume, 1f);
+ }
- private void Start()
- {
+ private void Start() {
DeliveryManager.Instance.OnRecipeSuccess += DeliveryManager_OnRecipeSuccess;
DeliveryManager.Instance.OnRecipeFailed += DeliveryManager_OnRecipeFailed;
CuttingCounter.OnAnyCut += CuttingCounter_OnAnyCut;
@@ -18,84 +23,59 @@ public class SoundManager : MonoBehaviour
TrashCounter.OnAnyObjectTrashed += TrashCounter_OnAnyObjectTrashed;
}
- private const string PlayerPrefsSoundEffectsVolume = "SoundEffectsVolume";
- private float volume;
-
- private void Awake()
- {
- Instance = this;
- volume = PlayerPrefs.GetFloat(PlayerPrefsSoundEffectsVolume, 1f);
- }
-
- private void TrashCounter_OnAnyObjectTrashed(object sender, System.EventArgs e)
- {
+ private void TrashCounter_OnAnyObjectTrashed(object sender, EventArgs e) {
PlaySound(audioClipRefsSO.trash, (sender as TrashCounter).transform.position);
}
- private void BaseCounter_OnAnyObjectPlacedHere(object sender, System.EventArgs e)
- {
+ private void BaseCounter_OnAnyObjectPlacedHere(object sender, EventArgs e) {
PlaySound(audioClipRefsSO.objectDrop, (sender as BaseCounter).transform.position);
}
- private void Player_OnAnyPickedSomething(object sender, System.EventArgs e)
- {
+ private void Player_OnAnyPickedSomething(object sender, EventArgs e) {
PlaySound(audioClipRefsSO.objectPickup, (sender as Player).transform.position);
}
- private void CuttingCounter_OnAnyCut(object sender, System.EventArgs e)
- {
+ private void CuttingCounter_OnAnyCut(object sender, EventArgs e) {
PlaySound(audioClipRefsSO.chop, (sender as CuttingCounter).transform.position);
}
- private void DeliveryManager_OnRecipeFailed(object sender, System.EventArgs e)
- {
+ private void DeliveryManager_OnRecipeFailed(object sender, EventArgs e) {
PlaySound(audioClipRefsSO.deliveryFail, DeliveryCounter.Instance.transform.position);
}
- private void DeliveryManager_OnRecipeSuccess(object sender, System.EventArgs e)
- {
+ private void DeliveryManager_OnRecipeSuccess(object sender, EventArgs e) {
PlaySound(audioClipRefsSO.deliverySuccess, DeliveryCounter.Instance.transform.position);
}
- private void PlaySound(AudioClip audioClip, Vector3 position, float volumeMultiplier = 1f)
- {
+ private void PlaySound(AudioClip audioClip, Vector3 position, float volumeMultiplier = 1f) {
AudioSource.PlayClipAtPoint(audioClip, position, volumeMultiplier * volume);
}
- private void PlaySound(IReadOnlyList audioClipArray, Vector3 position, float volumeMultiplier = 1f)
- {
+ private void PlaySound(IReadOnlyList audioClipArray, Vector3 position, float volumeMultiplier = 1f) {
PlaySound(audioClipArray[Random.Range(0, audioClipArray.Count)], position, volumeMultiplier * volume);
}
- public void PlayFootstepsSound(Vector3 position, float volumeMultiplier)
- {
+ public void PlayFootstepsSound(Vector3 position, float volumeMultiplier) {
PlaySound(audioClipRefsSO.footstep, position, volumeMultiplier * volume);
}
- public void PlayCountdownSound()
- {
+ public void PlayCountdownSound() {
PlaySound(audioClipRefsSO.warning, Vector3.zero);
}
- public void PlayWarningSound(Vector3 position)
- {
+ public void PlayWarningSound(Vector3 position) {
PlaySound(audioClipRefsSO.warning, position);
}
- public void ChangeVolume()
- {
+ public void ChangeVolume() {
volume += .1f;
- if (volume > 1.1f)
- {
- volume = 0f;
- }
+ if (volume > 1.1f) volume = 0f;
PlayerPrefs.SetFloat(PlayerPrefsSoundEffectsVolume, volume);
PlayerPrefs.Save();
}
- public float GetVolume()
- {
+ public float GetVolume() {
return volume;
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/DeliveryManagerSingleUI.cs b/Assets/Scripts/UI/DeliveryManagerSingleUI.cs
index e49cd61f7..258b48207 100644
--- a/Assets/Scripts/UI/DeliveryManagerSingleUI.cs
+++ b/Assets/Scripts/UI/DeliveryManagerSingleUI.cs
@@ -2,35 +2,27 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
-public class DeliveryManagerSingleUI : MonoBehaviour
-{
- [SerializeField] private TextMeshProUGUI recipeNameText;
- [SerializeField] private Transform iconContainer;
- [SerializeField] private Transform iconTemplate;
+public class DeliveryManagerSingleUI : MonoBehaviour {
+ [SerializeField] private TextMeshProUGUI recipeNameText;
+ [SerializeField] private Transform iconContainer;
+ [SerializeField] private Transform iconTemplate;
- private void Awake()
- {
- iconTemplate.gameObject.SetActive(false);
- }
+ private void Awake() {
+ iconTemplate.gameObject.SetActive(false);
+ }
- public void SetRecipeSO(RecipeSO recipeSO)
- {
- recipeNameText.text = $"{recipeSO.RecipeName} ({recipeSO.Points})";
- foreach (Transform child in iconContainer)
- {
- if (child == iconTemplate)
- {
- continue;
- }
+ public void SetRecipeSO(RecipeSO recipeSO) {
+ recipeNameText.text = $"{recipeSO.RecipeName} ({recipeSO.Points})";
+ foreach (Transform child in iconContainer) {
+ if (child == iconTemplate) continue;
- Destroy(child.gameObject);
- }
+ Destroy(child.gameObject);
+ }
- foreach (KitchenObjectSO kitchenObjectSO in recipeSO.KitchenObjectSOList)
- {
- Transform iconTransform = Instantiate(iconTemplate, iconContainer);
- iconTransform.gameObject.SetActive(true);
- iconTransform.GetComponent().sprite = kitchenObjectSO.sprite;
- }
- }
+ foreach (KitchenObjectSO kitchenObjectSO in recipeSO.KitchenObjectSOList) {
+ Transform iconTransform = Instantiate(iconTemplate, iconContainer);
+ iconTransform.gameObject.SetActive(true);
+ iconTransform.GetComponent().sprite = kitchenObjectSO.sprite;
+ }
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/DeliveryManagerUI.cs b/Assets/Scripts/UI/DeliveryManagerUI.cs
index 84b43576f..67ecd3ad0 100644
--- a/Assets/Scripts/UI/DeliveryManagerUI.cs
+++ b/Assets/Scripts/UI/DeliveryManagerUI.cs
@@ -1,63 +1,50 @@
using System;
using UnityEngine;
-public class DeliveryManagerUI : MonoBehaviour
-{
- public static DeliveryManagerUI Instance { get; private set; }
- [SerializeField] private Transform container;
- [SerializeField] private Transform recipeTemplate;
-
- private void Awake()
- {
- recipeTemplate.gameObject.SetActive(false);
- Instance = this;
- }
-
- private void Start()
- {
- DeliveryManager.Instance.OnRecipeSpawned += DeliveryManager_OnRecipeSpawned;
- DeliveryManager.Instance.OnRecipeCompleted += DeliveryManager_OnRecipeCompleted;
- Show();
- UpdateVisual();
- }
-
- private void DeliveryManager_OnRecipeCompleted(object sender, System.EventArgs e)
- {
- UpdateVisual();
- }
-
- private void DeliveryManager_OnRecipeSpawned(object sender, System.EventArgs e)
- {
- UpdateVisual();
- }
-
- private void UpdateVisual()
- {
- foreach (Transform child in container)
- {
- if (child == recipeTemplate)
- {
- continue;
- }
-
- Destroy(child.gameObject);
- }
-
- foreach (RecipeSO recipeSO in DeliveryManager.Instance.WaitingRecipeSOList)
- {
- Transform recipeTransform = Instantiate(recipeTemplate, container);
- recipeTransform.gameObject.SetActive(true);
- recipeTransform.GetComponent().SetRecipeSO(recipeSO);
- }
- }
-
- public void Hide()
- {
- gameObject.SetActive(false);
- }
-
- public void Show()
- {
- gameObject.SetActive(true);
- }
+public class DeliveryManagerUI : MonoBehaviour {
+ [SerializeField] private Transform container;
+ [SerializeField] private Transform recipeTemplate;
+ public static DeliveryManagerUI Instance { get; private set; }
+
+ private void Awake() {
+ recipeTemplate.gameObject.SetActive(false);
+ Instance = this;
+ }
+
+ private void Start() {
+ DeliveryManager.Instance.OnRecipeSpawned += DeliveryManager_OnRecipeSpawned;
+ DeliveryManager.Instance.OnRecipeCompleted += DeliveryManager_OnRecipeCompleted;
+ Show();
+ UpdateVisual();
+ }
+
+ private void DeliveryManager_OnRecipeCompleted(object sender, EventArgs e) {
+ UpdateVisual();
+ }
+
+ private void DeliveryManager_OnRecipeSpawned(object sender, EventArgs e) {
+ UpdateVisual();
+ }
+
+ private void UpdateVisual() {
+ foreach (Transform child in container) {
+ if (child == recipeTemplate) continue;
+
+ Destroy(child.gameObject);
+ }
+
+ foreach (RecipeSO recipeSO in DeliveryManager.Instance.WaitingRecipeSOList) {
+ Transform recipeTransform = Instantiate(recipeTemplate, container);
+ recipeTransform.gameObject.SetActive(true);
+ recipeTransform.GetComponent().SetRecipeSO(recipeSO);
+ }
+ }
+
+ public void Hide() {
+ gameObject.SetActive(false);
+ }
+
+ public void Show() {
+ gameObject.SetActive(true);
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/DeliveryResultUI.cs b/Assets/Scripts/UI/DeliveryResultUI.cs
index c8e2734b4..5c0d96102 100644
--- a/Assets/Scripts/UI/DeliveryResultUI.cs
+++ b/Assets/Scripts/UI/DeliveryResultUI.cs
@@ -3,8 +3,7 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
-public class DeliveryResultUI : MonoBehaviour
-{
+public class DeliveryResultUI : MonoBehaviour {
private const string Popup = "Popup";
[SerializeField] private Image backgroundImage;
[SerializeField] private Image iconImage;
@@ -16,26 +15,25 @@ public class DeliveryResultUI : MonoBehaviour
private Animator animator;
- private void Awake() => animator = GetComponent();
+ private void Awake() {
+ animator = GetComponent();
+ }
- private void Start()
- {
+ private void Start() {
DeliveryManager.Instance.OnRecipeSuccess += DeliveryManager_OnRecipeSuccess;
DeliveryManager.Instance.OnRecipeFailed += DeliveryManager_OnRecipeFailed;
gameObject.SetActive(false);
}
- private void DeliveryManager_OnRecipeFailed(object sender, System.EventArgs e)
- {
+ private void DeliveryManager_OnRecipeFailed(object sender, EventArgs e) {
gameObject.SetActive(true);
animator.SetTrigger(Popup);
backgroundImage.color = failedColor;
iconImage.sprite = failedSprite;
- messageText.text = $"Delivery\nfailed!\n-1";
+ messageText.text = "Delivery\nfailed!\n-1";
}
- private void DeliveryManager_OnRecipeSuccess(object sender, RecipeEventArgs e)
- {
+ private void DeliveryManager_OnRecipeSuccess(object sender, RecipeEventArgs e) {
gameObject.SetActive(true);
animator.SetTrigger(Popup);
backgroundImage.color = successColor;
diff --git a/Assets/Scripts/UI/GameOverUI.cs b/Assets/Scripts/UI/GameOverUI.cs
index 3e4a598a5..e7ce18063 100644
--- a/Assets/Scripts/UI/GameOverUI.cs
+++ b/Assets/Scripts/UI/GameOverUI.cs
@@ -3,34 +3,28 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
-public class GameOverUI : MonoBehaviour
-{
- public static GameOverUI Instance { get; private set; }
-
+public class GameOverUI : MonoBehaviour {
[SerializeField] private TextMeshProUGUI recipeDeliveredText;
[SerializeField] private TextMeshProUGUI pointsText;
[SerializeField] private Button restartButton;
[SerializeField] private Button mainMenuButton;
+ public static GameOverUI Instance { get; private set; }
- private void Awake()
- {
+ private void Awake() {
Instance = this;
restartButton.onClick.AddListener(() => Loader.Load(Loader.Scene.GameScene));
mainMenuButton.onClick.AddListener(() => Loader.Load(Loader.Scene.MainMenuScene));
}
- private void Start()
- {
+ private void Start() {
KitchenGameManager.Instance.OnStateChanged += KitchenGameManager_OnStateChanged;
Hide();
restartButton.Select();
}
- private void KitchenGameManager_OnStateChanged(object sender, System.EventArgs e)
- {
- if (KitchenGameManager.Instance.IsGameOver())
- {
+ private void KitchenGameManager_OnStateChanged(object sender, EventArgs e) {
+ if (KitchenGameManager.Instance.IsGameOver()) {
recipeDeliveredText.text = DeliveryManager.Instance.SuccessfulRecipes.ToString();
pointsText.text = DeliveryManager.Instance.Points.ToString();
Show();
@@ -38,8 +32,7 @@ public class GameOverUI : MonoBehaviour
DeliveryManagerUI.Instance.Hide();
PointsUI.Instance.Hide();
}
- else
- {
+ else {
Hide();
GamePlayingClockUI.Instance.Show();
DeliveryManagerUI.Instance.Show();
@@ -47,7 +40,11 @@ public class GameOverUI : MonoBehaviour
}
}
- public void Hide() => gameObject.SetActive(false);
+ public void Hide() {
+ gameObject.SetActive(false);
+ }
- public void Show() => gameObject.SetActive(true);
+ public void Show() {
+ gameObject.SetActive(true);
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/GamePauseUI.cs b/Assets/Scripts/UI/GamePauseUI.cs
index c2010619b..cadcd1128 100644
--- a/Assets/Scripts/UI/GamePauseUI.cs
+++ b/Assets/Scripts/UI/GamePauseUI.cs
@@ -2,43 +2,44 @@ using System;
using UnityEngine;
using UnityEngine.UI;
-namespace UI
-{
- public class GamePauseUI : MonoBehaviour
- {
+namespace UI {
+ public class GamePauseUI : MonoBehaviour {
[SerializeField] private Button resumeButton;
+
//TODO: Restart Button
[SerializeField] private Button optionsButton;
[SerializeField] private Button mainMenuButton;
- private void Awake()
- {
+ private void Awake() {
resumeButton.onClick.AddListener(() => KitchenGameManager.Instance.TogglePauseGame());
- optionsButton.onClick.AddListener(() =>
- {
+ optionsButton.onClick.AddListener(() => {
Hide();
OptionsUI.Instance.Show(Show);
});
mainMenuButton.onClick.AddListener(() => Loader.Load(Loader.Scene.MainMenuScene));
}
- private void Start()
- {
+ private void Start() {
KitchenGameManager.Instance.OnGamePaused += KitchenGameManager_OnGamePaused;
KitchenGameManager.Instance.OnGameUnpaused += KitchenGameManager_OnGameUnpaused;
Hide();
}
- private void KitchenGameManager_OnGameUnpaused(object sender, System.EventArgs e) => Hide();
+ private void KitchenGameManager_OnGameUnpaused(object sender, EventArgs e) {
+ Hide();
+ }
- private void KitchenGameManager_OnGamePaused(object sender, System.EventArgs e) => Show();
+ private void KitchenGameManager_OnGamePaused(object sender, EventArgs e) {
+ Show();
+ }
- private void Show()
- {
+ private void Show() {
gameObject.SetActive(true);
resumeButton.Select();
}
- private void Hide() => gameObject.SetActive(false);
+ private void Hide() {
+ gameObject.SetActive(false);
+ }
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/GamePlayingClockUI.cs b/Assets/Scripts/UI/GamePlayingClockUI.cs
index 29c9e3e7e..8b01da211 100644
--- a/Assets/Scripts/UI/GamePlayingClockUI.cs
+++ b/Assets/Scripts/UI/GamePlayingClockUI.cs
@@ -2,22 +2,20 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
-public class GamePlayingClockUI : MonoBehaviour
-{
- public static GamePlayingClockUI Instance { get; private set; }
-
+public class GamePlayingClockUI : MonoBehaviour {
[SerializeField] private Image timerImage;
[SerializeField] private TextMeshProUGUI timerText;
+ public static GamePlayingClockUI Instance { get; private set; }
- private void Awake() => Instance = this;
+ private void Awake() {
+ Instance = this;
+ }
- private void Start()
- {
+ private void Start() {
Show();
}
- private void Update()
- {
+ private void Update() {
float playingTimeNormalized = KitchenGameManager.Instance.GetGamePlayingTimerNormalized();
timerImage.fillAmount = playingTimeNormalized;
timerImage.color = Color.Lerp(Color.green, Color.red, playingTimeNormalized);
@@ -25,7 +23,11 @@ public class GamePlayingClockUI : MonoBehaviour
timerText.text = timeLeft.ToString();
}
- public void Hide() => gameObject.SetActive(false);
- public void Show() => gameObject.SetActive(true);
+ public void Hide() {
+ gameObject.SetActive(false);
+ }
+ public void Show() {
+ gameObject.SetActive(true);
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/GameStartCountdownUI.cs b/Assets/Scripts/UI/GameStartCountdownUI.cs
index 1d98af9e2..ee106d2c3 100644
--- a/Assets/Scripts/UI/GameStartCountdownUI.cs
+++ b/Assets/Scripts/UI/GameStartCountdownUI.cs
@@ -2,43 +2,44 @@ using System;
using TMPro;
using UnityEngine;
-public class GameStartCountdownUI : MonoBehaviour
-{
+public class GameStartCountdownUI : MonoBehaviour {
private const string NumberPopup = "NumberPopup";
[SerializeField] private TextMeshProUGUI countdownText;
private Animator animator;
private int previousCountdownNumber;
- private void Awake() => animator = GetComponent();
+ private void Awake() {
+ animator = GetComponent();
+ }
- private void Start()
- {
+ private void Start() {
KitchenGameManager.Instance.OnStateChanged += KitchenGameManager_OnStateChanged;
Hide();
}
- private void KitchenGameManager_OnStateChanged(object sender, System.EventArgs e)
- {
- if (KitchenGameManager.Instance.IsCountToStartActive())
- Show();
- else
- Hide();
- }
-
- private void Update()
- {
+ private void Update() {
int countdownNumber = Mathf.CeilToInt(KitchenGameManager.Instance.CountdownToStartTimer);
countdownText.text = countdownNumber.ToString();
- if (previousCountdownNumber != countdownNumber)
- {
+ if (previousCountdownNumber != countdownNumber) {
previousCountdownNumber = countdownNumber;
animator.SetTrigger(NumberPopup);
SoundManager.Instance.PlayCountdownSound();
}
}
- private void Hide() => gameObject.SetActive(false);
+ private void KitchenGameManager_OnStateChanged(object sender, EventArgs e) {
+ if (KitchenGameManager.Instance.IsCountToStartActive())
+ Show();
+ else
+ Hide();
+ }
- private void Show() => gameObject.SetActive(true);
+ private void Hide() {
+ gameObject.SetActive(false);
+ }
+
+ private void Show() {
+ gameObject.SetActive(true);
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/MainMenuUI.cs b/Assets/Scripts/UI/MainMenuUI.cs
index efd2a0253..9a6cf003b 100644
--- a/Assets/Scripts/UI/MainMenuUI.cs
+++ b/Assets/Scripts/UI/MainMenuUI.cs
@@ -1,21 +1,18 @@
using UnityEngine;
using UnityEngine.UI;
-namespace UI
-{
- public class MainMenuUI : MonoBehaviour
- {
+namespace UI {
+ public class MainMenuUI : MonoBehaviour {
[SerializeField] private Button playButton;
[SerializeField] private Button quitButton;
- private void Start()
- {
- playButton.Select();
- }
- private void Awake()
- {
+ private void Awake() {
playButton.onClick.AddListener(() => Loader.Load(Loader.Scene.GameScene));
quitButton.onClick.AddListener(Application.Quit);
}
+
+ private void Start() {
+ playButton.Select();
+ }
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/OptionsUI.cs b/Assets/Scripts/UI/OptionsUI.cs
index 16dd264e5..584256ca9 100644
--- a/Assets/Scripts/UI/OptionsUI.cs
+++ b/Assets/Scripts/UI/OptionsUI.cs
@@ -3,10 +3,7 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
-public class OptionsUI : MonoBehaviour
-{
- public static OptionsUI Instance { get; private set; }
-
+public class OptionsUI : MonoBehaviour {
[SerializeField] private Button soundEffectsButton;
[SerializeField] private Button musicButton;
[SerializeField] private Button closeButton;
@@ -35,22 +32,19 @@ public class OptionsUI : MonoBehaviour
[SerializeField] private Transform pressToRebindKeyTransform;
private Action onCloseButtonAction;
+ public static OptionsUI Instance { get; private set; }
- private void Awake()
- {
+ private void Awake() {
Instance = this;
- soundEffectsButton.onClick.AddListener(() =>
- {
+ soundEffectsButton.onClick.AddListener(() => {
SoundManager.Instance.ChangeVolume();
UpdateVisual();
});
- musicButton.onClick.AddListener(() =>
- {
+ musicButton.onClick.AddListener(() => {
MusicManager.Instance.ChangeVolume();
UpdateVisual();
});
- closeButton.onClick.AddListener(() =>
- {
+ closeButton.onClick.AddListener(() => {
Hide();
onCloseButtonAction();
});
@@ -62,55 +56,61 @@ public class OptionsUI : MonoBehaviour
interactButton.onClick.AddListener(() => RebindBinding(GameInput.Binding.Interact));
interactAlternateButton.onClick.AddListener(() => RebindBinding(GameInput.Binding.InteractAlternate));
pauseButton.onClick.AddListener(() => RebindBinding(GameInput.Binding.Pause));
- gamepadInteractButton.onClick.AddListener(() => RebindBinding(GameInput.Binding.Gamepad_Interact));
- gamepadInteractAlternateButton.onClick.AddListener(() => RebindBinding(GameInput.Binding.Gamepad_InteractAlternate));
- gamepadPauseButton.onClick.AddListener(() => RebindBinding(GameInput.Binding.Gamepad_Pause));
+ gamepadInteractButton.onClick.AddListener(() => RebindBinding(GameInput.Binding.GamepadInteract));
+ gamepadInteractAlternateButton.onClick.AddListener(() =>
+ RebindBinding(GameInput.Binding.GamepadInteractAlternate));
+ gamepadPauseButton.onClick.AddListener(() => RebindBinding(GameInput.Binding.GamepadPause));
}
- private void Start()
- {
+ private void Start() {
KitchenGameManager.Instance.OnGameUnpaused += KitchenGameManager_OnGameUnpaused;
UpdateVisual();
Hide();
HidePressToRebindKey();
}
- private void KitchenGameManager_OnGameUnpaused(object sender, System.EventArgs e) => Hide();
+ private void KitchenGameManager_OnGameUnpaused(object sender, EventArgs e) {
+ Hide();
+ }
- private void UpdateVisual()
- {
+ private void UpdateVisual() {
soundEffectsText.text = $"Sound Effects: {Mathf.Round(SoundManager.Instance.GetVolume() * 10f)}";
musicText.text = $"Music: {Mathf.Round(MusicManager.Instance.GetVolume() * 10f)}";
- moveUpText.text = GameInput.Instance.GetBindingText(GameInput.Binding.MoveUp);
- moveDownText.text = GameInput.Instance.GetBindingText(GameInput.Binding.MoveDown);
- moveLeftText.text = GameInput.Instance.GetBindingText(GameInput.Binding.MoveLeft);
- moveRightText.text = GameInput.Instance.GetBindingText(GameInput.Binding.MoveRight);
- interactText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Interact);
- interactAlternateText.text = GameInput.Instance.GetBindingText(GameInput.Binding.InteractAlternate);
- pauseText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Pause);
- gamepadInteractText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Gamepad_Interact);
- gamepadInteractAlternateText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Gamepad_InteractAlternate);
- gamepadPauseText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Gamepad_Pause);
+ moveUpText.text = GameInput.GetBindingText(GameInput.Binding.MoveUp);
+ moveDownText.text = GameInput.GetBindingText(GameInput.Binding.MoveDown);
+ moveLeftText.text = GameInput.GetBindingText(GameInput.Binding.MoveLeft);
+ moveRightText.text = GameInput.GetBindingText(GameInput.Binding.MoveRight);
+ interactText.text = GameInput.GetBindingText(GameInput.Binding.Interact);
+ interactAlternateText.text = GameInput.GetBindingText(GameInput.Binding.InteractAlternate);
+ pauseText.text = GameInput.GetBindingText(GameInput.Binding.Pause);
+ gamepadInteractText.text = GameInput.GetBindingText(GameInput.Binding.GamepadInteract);
+ gamepadInteractAlternateText.text =
+ GameInput.GetBindingText(GameInput.Binding.GamepadInteractAlternate);
+ gamepadPauseText.text = GameInput.GetBindingText(GameInput.Binding.GamepadPause);
}
- public void Show(Action onCloseButton)
- {
+ public void Show(Action onCloseButton) {
onCloseButtonAction = onCloseButton;
gameObject.SetActive(true);
closeButton.Select();
}
- private void Hide() => gameObject.SetActive(false);
+ private void Hide() {
+ gameObject.SetActive(false);
+ }
+
+ private void ShowPressToRebindKey() {
+ pressToRebindKeyTransform.gameObject.SetActive(true);
+ }
- private void ShowPressToRebindKey() => pressToRebindKeyTransform.gameObject.SetActive(true);
- private void HidePressToRebindKey() => pressToRebindKeyTransform.gameObject.SetActive(false);
+ private void HidePressToRebindKey() {
+ pressToRebindKeyTransform.gameObject.SetActive(false);
+ }
- private void RebindBinding(GameInput.Binding binding)
- {
+ private void RebindBinding(GameInput.Binding binding) {
ShowPressToRebindKey();
- GameInput.Instance.RebindBinding(binding, () =>
- {
+ GameInput.Instance.RebindBinding(binding, () => {
HidePressToRebindKey();
UpdateVisual();
});
diff --git a/Assets/Scripts/UI/PlateIconSingleUI.cs b/Assets/Scripts/UI/PlateIconSingleUI.cs
index 673dcdd80..5f73dd1f5 100644
--- a/Assets/Scripts/UI/PlateIconSingleUI.cs
+++ b/Assets/Scripts/UI/PlateIconSingleUI.cs
@@ -1,12 +1,10 @@
using UnityEngine;
using UnityEngine.UI;
-public class PlateIconSingleUI : MonoBehaviour
-{
+public class PlateIconSingleUI : MonoBehaviour {
[SerializeField] private Image image;
- public void SetKitchenObjectSO(KitchenObjectSO kitchenObjectOS)
- {
+ public void SetKitchenObjectSO(KitchenObjectSO kitchenObjectOS) {
image.sprite = kitchenObjectOS.sprite;
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/PlateIconsUI.cs b/Assets/Scripts/UI/PlateIconsUI.cs
index 8d21a0fda..6d753e2ef 100644
--- a/Assets/Scripts/UI/PlateIconsUI.cs
+++ b/Assets/Scripts/UI/PlateIconsUI.cs
@@ -1,25 +1,28 @@
using UnityEngine;
-public class PlateIconsUI : MonoBehaviour
-{
+public class PlateIconsUI : MonoBehaviour {
[SerializeField] private PlateKitchenObject plateKitchenObject;
[SerializeField] private Transform iconTemplate;
- private void Awake() => iconTemplate.gameObject.SetActive(false);
+ private void Awake() {
+ iconTemplate.gameObject.SetActive(false);
+ }
- private void Start() => plateKitchenObject.OnIngredientAdded += PlateKitchenObject_OnIngredientAdded;
+ private void Start() {
+ plateKitchenObject.OnIngredientAdded += PlateKitchenObject_OnIngredientAdded;
+ }
- private void PlateKitchenObject_OnIngredientAdded(object sender, PlateKitchenObject.IngredientAddedEventArgs e) => UpdateVisual();
+ private void PlateKitchenObject_OnIngredientAdded(object sender, PlateKitchenObject.IngredientAddedEventArgs e) {
+ UpdateVisual();
+ }
- private void UpdateVisual()
- {
- foreach (Transform child in transform)
- {
+ private void UpdateVisual() {
+ foreach (Transform child in transform) {
if (child == iconTemplate) continue;
Destroy(child.gameObject);
}
- foreach (KitchenObjectSO kitchenObjectSO in plateKitchenObject.GetKitchenObjectSOList())
- {
+
+ foreach (KitchenObjectSO kitchenObjectSO in plateKitchenObject.GetKitchenObjectSOList()) {
Transform iconTransform = Instantiate(iconTemplate, transform);
iconTransform.gameObject.SetActive(true);
iconTransform.GetComponent().SetKitchenObjectSO(kitchenObjectSO);
diff --git a/Assets/Scripts/UI/PointsUI.cs b/Assets/Scripts/UI/PointsUI.cs
index 73a3392a2..615d91c09 100644
--- a/Assets/Scripts/UI/PointsUI.cs
+++ b/Assets/Scripts/UI/PointsUI.cs
@@ -1,25 +1,29 @@
using System;
using TMPro;
using UnityEngine;
-using UnityEngine.UI;
-
-public class PointsUI : MonoBehaviour
-{
- public static PointsUI Instance { get; private set; }
+public class PointsUI : MonoBehaviour {
[SerializeField] private TextMeshProUGUI pointsText;
+ public static PointsUI Instance { get; private set; }
- private void Awake() => Instance = this;
+ private void Awake() {
+ Instance = this;
+ }
- private void Start()
- {
+ private void Start() {
DeliveryManager.Instance.OnRecipeCompleted += DeliveryManager_OnRecipeCompleted;
Show();
}
- private void DeliveryManager_OnRecipeCompleted(object sender, System.EventArgs e) =>
+ private void DeliveryManager_OnRecipeCompleted(object sender, EventArgs e) {
pointsText.text = $"Points: {DeliveryManager.Instance.Points}";
+ }
+
+ public void Hide() {
+ gameObject.SetActive(false);
+ }
- public void Hide() => gameObject.SetActive(false);
- public void Show() => gameObject.SetActive(true);
-}
+ public void Show() {
+ gameObject.SetActive(true);
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/ProgressBarUI.cs b/Assets/Scripts/UI/ProgressBarUI.cs
index bd8cd8f35..c8ce81b40 100644
--- a/Assets/Scripts/UI/ProgressBarUI.cs
+++ b/Assets/Scripts/UI/ProgressBarUI.cs
@@ -2,56 +2,43 @@ using UnityEngine;
using UnityEngine.UI;
using static StoveCounter;
-namespace UI
-{
- public class ProgressBarUI : MonoBehaviour
- {
- [SerializeField] private GameObject hasProgressGameObject;
- [SerializeField] private Image barImage;
-
- private IHasProgress hasProgress;
-
- private void Start()
- {
- if (!hasProgressGameObject.TryGetComponent(out hasProgress))
- {
- Debug.LogError($"Game Object {hasProgressGameObject} does not have a component that implements IHasProgress!");
- }
- else
- {
- hasProgress.OnProgressChanged += HasProgress_OnProgressChanged;
- }
-
- barImage.fillAmount = 0f;
- Hide();
- }
-
- private void HasProgress_OnProgressChanged(object sender, IHasProgress.ProgressChangedEventArgs e)
- {
- barImage.fillAmount = e.ProgressNormalized;
-
- barImage.color = e.State == State.Fried
- ? Color.Lerp(Color.green, Color.red, t: e.ProgressNormalized)
- : Color.Lerp(Color.blue, Color.green, t: e.ProgressNormalized);
-
- if (e.ProgressNormalized is 0f or 1f)
- {
- Hide();
- }
- else
- {
- Show();
- }
- }
-
- private void Show()
- {
- gameObject.SetActive(true);
- }
-
- private void Hide()
- {
- gameObject.SetActive(false);
- }
- }
+namespace UI {
+ public class ProgressBarUI : MonoBehaviour {
+ [SerializeField] private GameObject hasProgressGameObject;
+ [SerializeField] private Image barImage;
+
+ private IHasProgress hasProgress;
+
+ private void Start() {
+ if (!hasProgressGameObject.TryGetComponent(out hasProgress))
+ Debug.LogError(
+ $"Game Object {hasProgressGameObject} does not have a component that implements IHasProgress!");
+ else
+ hasProgress.OnProgressChanged += HasProgress_OnProgressChanged;
+
+ barImage.fillAmount = 0f;
+ Hide();
+ }
+
+ private void HasProgress_OnProgressChanged(object sender, IHasProgress.ProgressChangedEventArgs e) {
+ barImage.fillAmount = e.ProgressNormalized;
+
+ barImage.color = e.State == State.Fried
+ ? Color.Lerp(Color.green, Color.red, e.ProgressNormalized)
+ : Color.Lerp(Color.blue, Color.green, e.ProgressNormalized);
+
+ if (e.ProgressNormalized is 0f or 1f)
+ Hide();
+ else
+ Show();
+ }
+
+ private void Show() {
+ gameObject.SetActive(true);
+ }
+
+ private void Hide() {
+ gameObject.SetActive(false);
+ }
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/StoveBurnFlashingBarUI.cs b/Assets/Scripts/UI/StoveBurnFlashingBarUI.cs
index 1e8a8402f..6b656c702 100644
--- a/Assets/Scripts/UI/StoveBurnFlashingBarUI.cs
+++ b/Assets/Scripts/UI/StoveBurnFlashingBarUI.cs
@@ -1,25 +1,21 @@
using UnityEngine;
-public class StoveBurnFlashingBarUI : MonoBehaviour
-{
- private const string IsFlashing = "IsFlashing";
- [SerializeField] private StoveCounter stoveCounter;
- private Animator animator;
+public class StoveBurnFlashingBarUI : MonoBehaviour {
+ private const string IsFlashing = "IsFlashing";
+ [SerializeField] private StoveCounter stoveCounter;
+ private Animator animator;
- private void Awake()
- {
- animator = GetComponent();
- }
+ private void Awake() {
+ animator = GetComponent();
+ }
- private void Start()
- {
- stoveCounter.OnProgressChanged += StoveCounter_OnProgressChanged;
- animator.SetBool(IsFlashing, false);
- }
+ private void Start() {
+ stoveCounter.OnProgressChanged += StoveCounter_OnProgressChanged;
+ animator.SetBool(IsFlashing, false);
+ }
- private void StoveCounter_OnProgressChanged(object sender, IHasProgress.ProgressChangedEventArgs e)
- {
- float burnShowProgressAmount = .5f;
- animator.SetBool(IsFlashing, stoveCounter.IsFried() && e.ProgressNormalized >= burnShowProgressAmount);
- }
+ private void StoveCounter_OnProgressChanged(object sender, IHasProgress.ProgressChangedEventArgs e) {
+ float burnShowProgressAmount = .5f;
+ animator.SetBool(IsFlashing, stoveCounter.IsFried() && e.ProgressNormalized >= burnShowProgressAmount);
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/StoveBurnWarningUI.cs b/Assets/Scripts/UI/StoveBurnWarningUI.cs
index c42db987b..086f51b3c 100644
--- a/Assets/Scripts/UI/StoveBurnWarningUI.cs
+++ b/Assets/Scripts/UI/StoveBurnWarningUI.cs
@@ -1,35 +1,26 @@
using UnityEngine;
-public class StoveBurnWarningUI : MonoBehaviour
-{
- [SerializeField] private StoveCounter stoveCounter;
+public class StoveBurnWarningUI : MonoBehaviour {
+ [SerializeField] private StoveCounter stoveCounter;
- private void Start()
- {
- stoveCounter.OnProgressChanged += StoveCounter_OnProgressChanged;
- Hide();
- }
+ private void Start() {
+ stoveCounter.OnProgressChanged += StoveCounter_OnProgressChanged;
+ Hide();
+ }
- private void StoveCounter_OnProgressChanged(object sender, IHasProgress.ProgressChangedEventArgs e)
- {
- float burnShowProgressAmount = .5f;
- if (stoveCounter.IsFried() && e.ProgressNormalized >= burnShowProgressAmount)
- {
- Show();
- }
- else
- {
- Hide();
- }
- }
+ private void StoveCounter_OnProgressChanged(object sender, IHasProgress.ProgressChangedEventArgs e) {
+ float burnShowProgressAmount = .5f;
+ if (stoveCounter.IsFried() && e.ProgressNormalized >= burnShowProgressAmount)
+ Show();
+ else
+ Hide();
+ }
- private void Show()
- {
- gameObject.SetActive(true);
- }
+ private void Show() {
+ gameObject.SetActive(true);
+ }
- private void Hide()
- {
- gameObject.SetActive(false);
- }
+ private void Hide() {
+ gameObject.SetActive(false);
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/TestingNetcodeUI.cs b/Assets/Scripts/UI/TestingNetcodeUI.cs
index 86a823eed..33bd1548a 100644
--- a/Assets/Scripts/UI/TestingNetcodeUI.cs
+++ b/Assets/Scripts/UI/TestingNetcodeUI.cs
@@ -2,29 +2,24 @@ using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;
-public class TestingNetcodeUI : MonoBehaviour
-{
+public class TestingNetcodeUI : MonoBehaviour {
[SerializeField] private Button startHostButton;
[SerializeField] private Button startClientButton;
- private void Awake()
- {
- startHostButton.onClick.AddListener(() =>
- {
+ private void Awake() {
+ startHostButton.onClick.AddListener(() => {
Debug.Log("HOST");
NetworkManager.Singleton.StartHost();
Hide();
});
- startClientButton.onClick.AddListener(() =>
- {
+ startClientButton.onClick.AddListener(() => {
Debug.Log("CLIENT");
NetworkManager.Singleton.StartClient();
Hide();
});
}
- private void Hide()
- {
+ private void Hide() {
gameObject.SetActive(false);
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/UI/TutorialUI.cs b/Assets/Scripts/UI/TutorialUI.cs
index 3356acdaf..7ef662563 100644
--- a/Assets/Scripts/UI/TutorialUI.cs
+++ b/Assets/Scripts/UI/TutorialUI.cs
@@ -1,10 +1,8 @@
using System;
using TMPro;
using UnityEngine;
-using UnityEngine.UI;
-public class TutorialUI : MonoBehaviour
-{
+public class TutorialUI : MonoBehaviour {
[SerializeField] private TextMeshProUGUI keyMoveUpText;
[SerializeField] private TextMeshProUGUI keyMoveDownText;
[SerializeField] private TextMeshProUGUI keyMoveLeftText;
@@ -16,45 +14,40 @@ public class TutorialUI : MonoBehaviour
[SerializeField] private TextMeshProUGUI keyMoveGamepadInteractAlternateText;
[SerializeField] private TextMeshProUGUI keyMoveGamepadPauseText;
- private void Start()
- {
+ private void Start() {
GameInput.Instance.OnBindingRebind += GameInput_OnBindingRebind;
KitchenGameManager.Instance.OnStateChanged += KitchenGameManager_OnStateChanged;
UpdateVisual();
Show();
}
- private void GameInput_OnBindingRebind(object sender, System.EventArgs e) => UpdateVisual();
+ private void GameInput_OnBindingRebind(object sender, EventArgs e) {
+ UpdateVisual();
+ }
- private void KitchenGameManager_OnStateChanged(object sender, System.EventArgs e)
- {
- if (KitchenGameManager.Instance.IsCountToStartActive())
- {
- Hide();
- }
+ private void KitchenGameManager_OnStateChanged(object sender, EventArgs e) {
+ if (KitchenGameManager.Instance.IsCountToStartActive()) Hide();
}
- private void UpdateVisual()
- {
- keyMoveUpText.text = GameInput.Instance.GetBindingText(GameInput.Binding.MoveUp);
- keyMoveDownText.text = GameInput.Instance.GetBindingText(GameInput.Binding.MoveDown);
- keyMoveLeftText.text = GameInput.Instance.GetBindingText(GameInput.Binding.MoveLeft);
- keyMoveRightText.text = GameInput.Instance.GetBindingText(GameInput.Binding.MoveRight);
- keyMoveInteractText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Interact);
- keyMoveInteractAlternateText.text = GameInput.Instance.GetBindingText(GameInput.Binding.InteractAlternate);
- keyMovePauseText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Pause);
- keyMoveGamepadInteractText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Gamepad_Interact);
- keyMoveGamepadInteractAlternateText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Gamepad_InteractAlternate);
- keyMoveGamepadPauseText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Gamepad_Pause);
+ private void UpdateVisual() {
+ keyMoveUpText.text = GameInput.GetBindingText(GameInput.Binding.MoveUp);
+ keyMoveDownText.text = GameInput.GetBindingText(GameInput.Binding.MoveDown);
+ keyMoveLeftText.text = GameInput.GetBindingText(GameInput.Binding.MoveLeft);
+ keyMoveRightText.text = GameInput.GetBindingText(GameInput.Binding.MoveRight);
+ keyMoveInteractText.text = GameInput.GetBindingText(GameInput.Binding.Interact);
+ keyMoveInteractAlternateText.text = GameInput.GetBindingText(GameInput.Binding.InteractAlternate);
+ keyMovePauseText.text = GameInput.GetBindingText(GameInput.Binding.Pause);
+ keyMoveGamepadInteractText.text = GameInput.GetBindingText(GameInput.Binding.GamepadInteract);
+ keyMoveGamepadInteractAlternateText.text =
+ GameInput.GetBindingText(GameInput.Binding.GamepadInteractAlternate);
+ keyMoveGamepadPauseText.text = GameInput.GetBindingText(GameInput.Binding.GamepadPause);
}
- private void Show()
- {
+ private void Show() {
gameObject.SetActive(true);
}
- private void Hide()
- {
+ private void Hide() {
gameObject.SetActive(false);
}
}
\ No newline at end of file
diff --git a/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01.cs b/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01.cs
index b48ebbdbe..8a9b57fc5 100644
--- a/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01.cs
+++ b/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01.cs
@@ -1,38 +1,28 @@
-using UnityEngine;
using System.Collections;
+using UnityEngine;
+namespace TMPro.Examples {
+ public class Benchmark01 : MonoBehaviour {
+ private const string label01 = "The <#0050FF>count is: {0}";
+ private const string label02 = "The count is: ";
-namespace TMPro.Examples
-{
-
- public class Benchmark01 : MonoBehaviour
- {
-
- public int BenchmarkType = 0;
+ public int BenchmarkType;
public TMP_FontAsset TMProFont;
public Font TextMeshFont;
- private TextMeshPro m_textMeshPro;
- private TextContainer m_textContainer;
- private TextMesh m_textMesh;
-
- private const string label01 = "The <#0050FF>count is: {0}";
- private const string label02 = "The count is: ";
-
//private string m_string;
//private int m_frame;
private Material m_material01;
private Material m_material02;
+ private TextContainer m_textContainer;
+ private TextMesh m_textMesh;
+ private TextMeshPro m_textMeshPro;
- IEnumerator Start()
- {
-
-
-
+ private IEnumerator Start() {
if (BenchmarkType == 0) // TextMesh Pro Component
{
m_textMeshPro = gameObject.AddComponent();
@@ -54,27 +44,25 @@ namespace TMPro.Examples
//m_textMeshPro.fontSharedMaterial.SetFloat("_OutlineWidth", 0.2f);
//m_textMeshPro.fontSharedMaterial.EnableKeyword("UNDERLAY_ON");
//m_textMeshPro.lineJustification = LineJustificationTypes.Center;
- m_textMeshPro.enableWordWrapping = false;
+ m_textMeshPro.enableWordWrapping = false;
//m_textMeshPro.lineLength = 60;
//m_textMeshPro.characterSpacing = 0.2f;
//m_textMeshPro.fontColor = new Color32(255, 255, 255, 255);
m_material01 = m_textMeshPro.font.material;
- m_material02 = Resources.Load("Fonts & Materials/LiberationSans SDF - Drop Shadow"); // Make sure the LiberationSans SDF exists before calling this...
-
-
+ m_material02 =
+ Resources.Load(
+ "Fonts & Materials/LiberationSans SDF - Drop Shadow"); // Make sure the LiberationSans SDF exists before calling this...
}
else if (BenchmarkType == 1) // TextMesh
{
m_textMesh = gameObject.AddComponent();
- if (TextMeshFont != null)
- {
+ if (TextMeshFont != null) {
m_textMesh.font = TextMeshFont;
m_textMesh.GetComponent().sharedMaterial = m_textMesh.font.material;
}
- else
- {
+ else {
m_textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font;
m_textMesh.GetComponent().sharedMaterial = m_textMesh.font.material;
}
@@ -86,20 +74,17 @@ namespace TMPro.Examples
}
-
- for (int i = 0; i <= 1000000; i++)
- {
- if (BenchmarkType == 0)
- {
+ for (int i = 0; i <= 1000000; i++) {
+ if (BenchmarkType == 0) {
m_textMeshPro.SetText(label01, i % 1000);
if (i % 1000 == 999)
- m_textMeshPro.fontSharedMaterial = m_textMeshPro.fontSharedMaterial == m_material01 ? m_textMeshPro.fontSharedMaterial = m_material02 : m_textMeshPro.fontSharedMaterial = m_material01;
-
-
-
+ m_textMeshPro.fontSharedMaterial = m_textMeshPro.fontSharedMaterial == m_material01
+ ? m_textMeshPro.fontSharedMaterial = m_material02
+ : m_textMeshPro.fontSharedMaterial = m_material01;
+ }
+ else if (BenchmarkType == 1) {
+ m_textMesh.text = label02 + (i % 1000);
}
- else if (BenchmarkType == 1)
- m_textMesh.text = label02 + (i % 1000).ToString();
yield return null;
}
@@ -125,4 +110,4 @@ namespace TMPro.Examples
}
*/
}
-}
+}
\ No newline at end of file
diff --git a/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01_UGUI.cs b/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01_UGUI.cs
index 38f4a275e..c01455fe0 100644
--- a/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01_UGUI.cs
+++ b/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark01_UGUI.cs
@@ -1,27 +1,18 @@
-using UnityEngine;
using System.Collections;
+using UnityEngine;
using UnityEngine.UI;
+namespace TMPro.Examples {
+ public class Benchmark01_UGUI : MonoBehaviour {
+ private const string label01 = "The <#0050FF>count is: ";
+ private const string label02 = "The count is: ";
-namespace TMPro.Examples
-{
-
- public class Benchmark01_UGUI : MonoBehaviour
- {
-
- public int BenchmarkType = 0;
+ public int BenchmarkType;
public Canvas canvas;
public TMP_FontAsset TMProFont;
public Font TextMeshFont;
- private TextMeshProUGUI m_textMeshPro;
- //private TextContainer m_textContainer;
- private Text m_textMesh;
-
- private const string label01 = "The <#0050FF>count is: ";
- private const string label02 = "The count is: ";
-
//private const string label01 = "TextMesh <#0050FF>Pro! The count is: {0}";
//private const string label02 = "Text Mesh The count is: ";
@@ -29,15 +20,16 @@ namespace TMPro.Examples
//private int m_frame;
private Material m_material01;
- private Material m_material02;
-
+ private Material m_material02;
- IEnumerator Start()
- {
+ //private TextContainer m_textContainer;
+ private Text m_textMesh;
+ private TextMeshProUGUI m_textMeshPro;
+ private IEnumerator Start() {
if (BenchmarkType == 0) // TextMesh Pro Component
{
m_textMeshPro = gameObject.AddComponent();
@@ -66,25 +58,21 @@ namespace TMPro.Examples
//m_textMeshPro.fontColor = new Color32(255, 255, 255, 255);
m_material01 = m_textMeshPro.font.material;
- m_material02 = Resources.Load("Fonts & Materials/LiberationSans SDF - BEVEL"); // Make sure the LiberationSans SDF exists before calling this...
-
-
+ m_material02 =
+ Resources.Load(
+ "Fonts & Materials/LiberationSans SDF - BEVEL"); // Make sure the LiberationSans SDF exists before calling this...
}
else if (BenchmarkType == 1) // TextMesh
{
m_textMesh = gameObject.AddComponent();
- if (TextMeshFont != null)
- {
+ if (TextMeshFont != null) {
m_textMesh.font = TextMeshFont;
//m_textMesh.renderer.sharedMaterial = m_textMesh.font.material;
}
- else
- {
- //m_textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font;
- //m_textMesh.renderer.sharedMaterial = m_textMesh.font.material;
- }
+ //m_textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font;
+ //m_textMesh.renderer.sharedMaterial = m_textMesh.font.material;
m_textMesh.fontSize = 48;
m_textMesh.alignment = TextAnchor.MiddleCenter;
@@ -92,20 +80,17 @@ namespace TMPro.Examples
}
-
- for (int i = 0; i <= 1000000; i++)
- {
- if (BenchmarkType == 0)
- {
- m_textMeshPro.text = label01 + (i % 1000);
+ for (int i = 0; i <= 1000000; i++) {
+ if (BenchmarkType == 0) {
+ m_textMeshPro.text = label01 + i % 1000;
if (i % 1000 == 999)
- m_textMeshPro.fontSharedMaterial = m_textMeshPro.fontSharedMaterial == m_material01 ? m_textMeshPro.fontSharedMaterial = m_material02 : m_textMeshPro.fontSharedMaterial = m_material01;
-
-
-
+ m_textMeshPro.fontSharedMaterial = m_textMeshPro.fontSharedMaterial == m_material01
+ ? m_textMeshPro.fontSharedMaterial = m_material02
+ : m_textMeshPro.fontSharedMaterial = m_material01;
+ }
+ else if (BenchmarkType == 1) {
+ m_textMesh.text = label02 + (i % 1000);
}
- else if (BenchmarkType == 1)
- m_textMesh.text = label02 + (i % 1000).ToString();
yield return null;
}
@@ -131,5 +116,4 @@ namespace TMPro.Examples
}
*/
}
-
-}
+}
\ No newline at end of file
diff --git a/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark02.cs b/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark02.cs
index 29d75b672..f05ff9aa4 100644
--- a/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark02.cs
+++ b/Assets/TextMesh Pro/Examples & Extras/Scripts/Benchmark02.cs
@@ -1,31 +1,19 @@
using UnityEngine;
-using System.Collections;
-
-namespace TMPro.Examples
-{
-
- public class Benchmark02 : MonoBehaviour
- {
-
- public int SpawnType = 0;
+namespace TMPro.Examples {
+ public class Benchmark02 : MonoBehaviour {
+ public int SpawnType;
public int NumberOfNPC = 12;
public bool IsTextObjectScaleStatic;
private TextMeshProFloatingText floatingText_Script;
- void Start()
- {
-
+ private void Start() {
for (int i = 0; i < NumberOfNPC; i++)
- {
-
-
- if (SpawnType == 0)
- {
+ if (SpawnType == 0) {
// TextMesh Pro Implementation
- GameObject go = new GameObject();
+ GameObject go = new();
go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f));
TextMeshPro textMeshPro = go.AddComponent();
@@ -46,10 +34,9 @@ namespace TMPro.Examples
floatingText_Script.SpawnType = 0;
floatingText_Script.IsTextObjectScaleStatic = IsTextObjectScaleStatic;
}
- else if (SpawnType == 1)
- {
+ else if (SpawnType == 1) {
// TextMesh Implementation
- GameObject go = new GameObject();
+ GameObject go = new();
go.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f));
TextMesh textMesh = go.AddComponent();
@@ -66,10 +53,9 @@ namespace TMPro.Examples
floatingText_Script = go.AddComponent();
floatingText_Script.SpawnType = 1;
}
- else if (SpawnType == 2)
- {
+ else if (SpawnType == 2) {
// Canvas WorldSpace Camera
- GameObject go = new GameObject();
+ GameObject go = new();
Canvas canvas = go.AddComponent