Ejemplo n.º 1
0
    void Start()
    {
        m_Player       = GameObject.FindObjectOfType <PlayerMove>().gameObject;
        m_FollowPlayer = GameObject.FindObjectOfType <FollowPlayer>().gameObject.GetComponent <FollowPlayer>();
        //TODO Later on, this should add the current level of the game, so that when you go to the next level in the game, it will create a new level.
        Random.InitState(m_Seed + LevelManager.instance.GetLevelNumber());
        SetupLevel();

        //TODO find all the Gameobjects with the tag "Hole" and add them to our list
        m_Holes.AddRange(GameObject.FindGameObjectsWithTag("Hole"));
        if (GameManager.instance.GetLastHoleName() != null)
        {
            m_Player.GetComponent <PlayerMove>().ReturnLastPos();
            for (int i = 0; i < m_Holes.Count; i++)
            {
                if (m_Holes[i].name == GameManager.instance.GetLastHoleName())
                {
                    GameObject currentListGameObject = m_Holes[i];
                    m_Player.transform.position = new Vector3(currentListGameObject.transform.position.x - 1, currentListGameObject.transform.position.y, 0f);
                    //send the player's transform to the resetCameraPos function, to use the player transform to help reset the camera's position.
                    m_FollowPlayer.ResetCameraPos(m_Player.transform.position);
                }
            }
        }
    }