Beispiel #1
0
    public static ResultsHolder instance()
    {
        // if the instance is already created, we return the reference
        if (_instance != null)
        {
            return(_instance);
        }

        // Check if there is no object off the same type in the scene to preserve singleton
        _instance = FindObjectOfType <ResultsHolder>();
        if (_instance == null)
        {
            // Find the object holding this script stored in the resources folder and if sucessfull, instantiate in the scene
            GameObject resourceObject = Resources.Load("ResultsHolder") as GameObject;
            if (resourceObject != null)
            {
                GameObject instantiatedObject = Instantiate(resourceObject);
                _instance = instantiatedObject.GetComponent <ResultsHolder>();
                DontDestroyOnLoad(instantiatedObject);
            }
            else
            {
                Debug.Log("ResultsHolder prefab not founded on resources");
            }
        }

        return(_instance);
    }
Beispiel #2
0
    void Awake()
    {
        instance = this;

        //Force creation off an resultsholder object
        ResultsHolder.instance();
    }
Beispiel #3
0
    private void CountTime()
    {
        time -= 0.01f;

        // Game over
        if (time <= 0f)
        {
            // Fill the object with important data and change scene
            ResultsHolder.instance().score           = score;
            ResultsHolder.instance().treesDestroyed  = treesDestroyed;
            ResultsHolder.instance().trunksDestroyed = trunksDestroyed;

            sceneController.LoadResuls();
        }
        else
        {
            VisualController.instance.UpdateTimeValue(time);
        }
    }
Beispiel #4
0
 public void ShowResults(object sender, ResultsHolder e)
 {
     Console.WriteLine("-> - {0} -- {1}", e.Name, e.Score);
 }
Beispiel #5
0
 void Awake()
 {
     holder = ResultsHolder.instance();
 }