コード例 #1
0
    void Update()
    {
        if (NetworkOrderController.ORDER_NAME != null &&
            !NetworkOrderController.ORDER_NAME.Equals(GameManager.Instance().PLAYER.USER_NAME))
        {
            return;
        }
        float   cameraHalfWdith  = (Camera.main.orthographicSize * Screen.width / Screen.height);
        float   cameraHalfHeight = (cameraHalfWdith * Screen.height / Screen.width);
        Vector3 pos      = m_camera.transform.position;
        Vector3 checkPos = Vector3.zero;

        //Left Map  -- RightMap 일 경우
        if (m_leftMap.transform.position.x <= m_rightMap.transform.position.x)
        {
            // LEFT Check
            checkPos = m_leftMapLeftLimit.transform.position;
            if (pos.x - cameraHalfWdith <= checkPos.x)
            {
                m_rightMap.transform.localPosition = new Vector3(
                    m_leftMap.transform.localPosition.x - 50, 0, 0);
                NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonPlanetInfoSend(
                                                               m_mapName, m_leftMap.transform.localPosition.x, m_leftMap.transform.localPosition.x - 50));
            }

            // Right Check
            checkPos = m_rightMapRightLimit.transform.position;
            if (pos.x + cameraHalfWdith >= checkPos.x)
            {
                m_leftMap.transform.localPosition = new Vector3(
                    m_rightMap.transform.localPosition.x + 50, 0, 0);
                NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonPlanetInfoSend(
                                                               m_mapName, m_rightMap.transform.localPosition.x + 50, m_rightMap.transform.localPosition.x));
            }
        }
        // Right Map -- Left Map 일 경우
        else if (m_leftMap.transform.position.x >= m_rightMap.transform.position.x)
        {
            // LEFT Check
            checkPos = m_rightMapLeftLimit.transform.position;
            if (pos.x - cameraHalfWdith <= checkPos.x)
            {
                m_leftMap.transform.localPosition = new Vector3(
                    m_rightMap.transform.localPosition.x - 50, 0, 0);
                NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonPlanetInfoSend(
                                                               m_mapName, m_rightMap.transform.localPosition.x - 50, m_rightMap.transform.localPosition.x));
            }
            // Right Check
            checkPos = m_leftMapRightLimit.transform.position;
            if (pos.x + cameraHalfWdith >= checkPos.x)
            {
                m_rightMap.transform.localPosition = new Vector3(
                    m_leftMap.transform.localPosition.x + 50, 0, 0);
                NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonPlanetInfoSend(
                                                               m_mapName, m_leftMap.transform.localPosition.x, m_leftMap.transform.localPosition.x + 50));
            }
        }
    }