Beispiel #1
0
    /**
     * This Awake method block is the heart of a singleton. Don't play with.
     */
    void Awake()
    {
        if (!instance)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            gameControllerScript = UnityUtils.FindComponentOn("ZombieController");

            playerManager = gameObject.GetComponent <PlayerManager>();

            //ugly hack?
            stateManager = gameObject.GetComponent <StateManager>();
            stateManager.DetermineScene();
            stateManager.SetState();
            if (stateManager.currentState == StateManager.gameState.GAMEPLAY)
            {
                vehicle = stateManager.LoadVehicle();
            }

            playerManager.stateManager = stateManager;

            levelController = GetComponent <LevelController>();

            zombWaveController = GetComponent <ZombWaveController>();
            analyticsManager   = gameObject.GetComponent <AnalyticsManager>();
        }
        else
        {
            Destroy(gameObject);
        }
    }
Beispiel #2
0
    /**
     * We don't need to see debug print lines every frame all the time.
     * Toggle on/off by selecting "ZombieController" in hierarchy and setting checkmark in inspector on the "GameControllerScript" component
     */
    public void print(object obj)
    {
        ZombieSpawnOnceController script = SingletonGodController.instance.gameControllerScript;

        if (script != null && script.printDebugInfo)
        {
            MonoBehaviour.print(obj);
        }
    }
    //TODO: refactor this, desire to generalize
    public static ZombieSpawnOnceController FindComponentOn(string nameGameObject)
    {
        GameObject find = GameObject.Find(nameGameObject);
        ZombieSpawnOnceController findComponent = null;

        if (find != null)
        {
            findComponent = find.GetComponent <ZombieSpawnOnceController>();
        }
        return(findComponent);
    }