Exemplo n.º 1
0
 public void SetFollowPlayer(bool isFollowingPlayer, CameraBorder cameraBorder)
 {
     _smoothedPositionX = transform.position.x;
     _smoothedPositionY = transform.position.y;
     _cameraBorder      = cameraBorder;
     _isFollowingPlayer = isFollowingPlayer;
 }
Exemplo n.º 2
0
    void Awake()
    {
        if (!m_FollowTransform)
        {
            Debug.LogError("CameraFollow is missing its follow transform!");
            enabled = false;
            return;
        }
        var borders = GetComponentsInChildren <CameraBorder>();

        if (borders.Length > 0)
        {
            for (int i = 0; i < borders.Length; i++)
            {
                m_Borders.Add(borders[i]);
            }

            for (int write = 0; write < m_Borders.Count; write++)
            {
                for (int sort = 0; sort < m_Borders.Count - 1; sort++)
                {
                    if (m_Borders[sort].m_ID > m_Borders[sort + 1].m_ID)
                    {
                        CameraBorder temp = m_Borders[sort];
                        m_Borders[sort]     = m_Borders[sort + 1];
                        m_Borders[sort + 1] = temp;
                    }
                }
            }

            float offset = 1.0f;

            for (int i = 0; i < m_Borders.Count; i++)
            {
                switch (i)
                {
                case 0:
                    m_Borders[i].transform.position = new Vector2(transform.position.x, transform.position.y + (Camera.main.orthographicSize - offset));
                    break;

                case 1:
                    m_Borders[i].transform.position = new Vector2(transform.position.x + (Camera.main.orthographicSize - offset) * Camera.main.aspect, transform.position.y);
                    break;

                case 2:
                    m_Borders[i].transform.position = new Vector2(transform.position.x, transform.position.y - (Camera.main.orthographicSize - offset));
                    break;

                case 3:
                    m_Borders[i].transform.position = new Vector2(transform.position.x - (Camera.main.orthographicSize - offset) * Camera.main.aspect, transform.position.y);
                    break;
                }
            }
        }
    }