Esempio n. 1
0
    public void Restart()
    {
        Debug.Log("initspawn trigger: " + initspawn.GetComponent <SpawnPos>().GetTrigger());
        Debug.Log("cp1 trigger: " + cpoint1.GetComponent <Cpoint> ().GetTriggerState());
        Debug.Log("cp2 trigger: " + cpoint2.GetComponent <Cpoint> ().GetTriggerState());
        if (initspawn.GetComponent <SpawnPos> ().GetTrigger())
        {
            rstpp.SetSpawnPoint(initspawn);
            Debug.Log("initSpawn");
        }
        else if (cpoint1.GetComponent <Cpoint> ().GetTriggerState())
        {
            rstpp.SetSpawnPoint(cpoint1);
            Debug.Log("1st cpoint");
        }
        else if (cpoint2.GetComponent <Cpoint> ().GetTriggerState())
        {
            rstpp.SetSpawnPoint(cpoint2);
            Debug.Log("2nd cpoint");
        }
        Debug.Log("spawnpoint is " + rstpp.GetSpawnPoint());

        resetMngr.ResetScene();
        Time.timeScale = 1f;
    }
Esempio n. 2
0
    public void ResetScene()
    {
        rp = player.GetComponent <ResetPlayerParameters> () as ResetPlayerParameters;
        Debug.Log("Is rp null? = " + (rp == null));
        spawnIndex = rp.GetSpawnPoint();
        dontReset  = new List <GameObject> ();

        if (spawnIndex == "SpawnPos")
        {
            spawn0 = true;
            dontReset.Add(new GameObject());
        }
        else if (spawnIndex == "Checkpoint1")
        {
            dontReset.AddRange(GameObject.Find("Checkpoint1").GetComponent <Cpoint>().GetNonResettable());
        }
        else if (spawnIndex == "Checkpoint2")
        {
            dontReset.AddRange(GameObject.Find("Checkpoint2").GetComponent <Cpoint>().GetNonResettable());
        }
        dr = dontReset.ToArray();


        resetscrobj = FindObjectsOfType(typeof(ResetObject)) as ResetObject[];


        for (int i = 0; i < resetscrobj.Length; i++)
        {
            allDiff = true;
            for (int j = 0; j < dr.Length; j++)
            {
                if (resetscrobj[i].gameObject.name == dr[j].name)
                {
                    allDiff = false;
                    break;
                }
            }
            if (allDiff)
            {
                resetscrobj [i].Reset();
            }
        }


        for (int i = 0; i < _resetScripts.Length; i++)
        {
            if (resetscrobj[i].gameObject.tag == "Button")
            {
                resetscrobj [i].gameObject.GetComponent <GameButton> ().OnResetting();

                if (resetscrobj[i].gameObject.tag == "Player")
                {
                    resetscrobj [i].gameObject.GetComponent <PlayerMovement> ().OnResetting();
                }
            }
        }
    }