UnityGameProjectsCode / Rise2Point0Game / Managers / ObjectManager.cs
ObjectManager.cs
Raw
using UnityEngine;

public static class ObjectManager
{
    //collects all important objects for later reference
    private static GameObject[] gameObjects = new GameObject[100];

    public static void SetReferences()
    {
        gameObjects[0] = GameObject.FindGameObjectWithTag("Player");
        gameObjects[1] = GameObject.Find("Drag Line");
        gameObjects[2] = GameObject.Find("Death Wall");
        gameObjects[3] = GameObject.Find("Interaction Surface");
        gameObjects[4] = GameObject.Find("Persistent Object");
        gameObjects[5] = GameObject.Find("EventSystem");
    }

    public static GameObject GetObject(int objectIndex)
    {
        return gameObjects[objectIndex];
    }

    public static void SetInteractionSurfaceState()
    {
        //if the death, pause, unlocks panel, or main menu canvas are open, turn it off.
        if (GUIManager.GetPauseCanvasState() || GUIManager.GetDeathCanvasState() || GUIManager.GetMainMenuCanvasState() || GUIManager.GetUnlocksPanelState())
        {
            gameObjects[3].GetComponent<ApplyForceToPlayer>().ManuallyDisabledMovement = true;
            gameObjects[3].GetComponent<ApplyForceTouch>().ManuallyDisabledMovement = true;
            gameObjects[3].GetComponent<ApplyForceController>().ManuallyDisabledMovement = true;
        }
        else
        {
            gameObjects[3].GetComponent<ApplyForceToPlayer>().ManuallyDisabledMovement = false;
            gameObjects[3].GetComponent<ApplyForceTouch>().ManuallyDisabledMovement = false;
            gameObjects[3].GetComponent<ApplyForceController>().ManuallyDisabledMovement = false;
        }

    }
}