Esempio n. 1
0
        void Start()
        {
            m_Camera  = Camera.main.transform;
            camPos    = m_Camera.position;
            oldCamPos = camPos;
            length    = planes.Length;

            //cache plane offsets
            firstPlaneRelativeOffset = Mathf.Clamp01(firstPlaneRelativeOffset);
            lastPlaneRelativeOffset  = Mathf.Clamp01(lastPlaneRelativeOffset);
            float dKP = Mathf.Abs(lastPlaneRelativeOffset - firstPlaneRelativeOffset) / (length - 1);

            planeOfsset = new float[length];

            for (int i = 0; i < length; i++)
            {
                plane = planes[i];
                if (!plane)
                {
                    continue;
                }
                planeOfsset[i] = firstPlaneRelativeOffset + i * dKP;
            }

            if (infiniteMap)
            {
                for (int i = 0; i < length; i++)
                {
                    if (planes[i])
                    {
                        planes[i].CreateInfinitePlane(new Vector2(mapSizeX, mapSizeY), camPos);
                    }
                }
            }
        }
Esempio n. 2
0
        void Update()
        {
            camPos    = m_Camera.position;
            camOffset = camPos - oldCamPos;

            for (int i = 0; i < length; i++)
            {
                plane = planes[i];
                if (!plane)
                {
                    continue;
                }
                plane.transform.Translate(new Vector3(camOffset.x * planeOfsset[i], camOffset.y * planeOfsset[i], 0), Space.World);

                if (infiniteMap)
                {
                    plane.UpdateInfinitePlane(camPos);
                }
            }
            oldCamPos = camPos;
        }