Ejemplo n.º 1
0
        private void Update()
        {
            if (manager.Player == null)
            {
                return;
            }
            if (langType == 0)
            {
                return;
            }

            Vector3 pos = manager.Player.position;

            pos -= StreamerManager.GetCurrentMove();

            int xPosCurrent = (xSceneSize != 0) ? (int)(Mathf.FloorToInt(pos.x / xTileSize)) : 0;
            int zPosCurrent = (zSceneSize != 0) ? (int)(Mathf.FloorToInt(pos.z / zTileSize)) : 0;

            if (xPosCurrent != xPos || zPosCurrent != zPos)
            {
                xPos = xPosCurrent;
                zPos = zPosCurrent;
                for (int z = -1; z < 2; z++)
                {
                    for (int x = -1; x < 2; x++)
                    {
                        GameObject obj = GetBillboardObject(xPos + x, zPos + z);
                        if (obj)
                        {
                            obj.SetActive(true);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void Update()
        {
            if (manager.Player == null)
            {
                return;
            }

            Vector3 pos = manager.Player.position;

            pos -= StreamerManager.GetCurrentMove();

            int xPosCurrent = (xSceneSize != 0) ? (int)(Mathf.FloorToInt(pos.x / xTileSize)) : 0;
            int zPosCurrent = (zSceneSize != 0) ? (int)(Mathf.FloorToInt(pos.z / zTileSize)) : 0;

            if (xPosCurrent != xPos || zPosCurrent != zPos || ForceRefresh)
            {
                xPos         = xPosCurrent;
                zPos         = zPosCurrent;
                ForceRefresh = false;

                Refresh();
            }
        }
Ejemplo n.º 3
0
        protected void SendParamsToShader()
        {
            if (mat == null || !mat.HasProperty(ot_NormalMap0))
            {
                return;
            }

            Shader.SetGlobalFloat(ot_OceanPosition, position);

            // Wave function animation

            //Shader.SetGlobalVector(ot_WaveScales, waveScales);
            //Shader.SetGlobalVector(ot_WaveLengths, waveLengths);
            //Shader.SetGlobalVector(ot_WaveExponents, waveExponents);
            //Shader.SetGlobalVector(ot_WaveOffsets, waveOffsets);
            //Shader.SetGlobalVector(ot_WaveDirection01, waveDirection01);
            //Shader.SetGlobalVector(ot_WaveDirection23, waveDirection23);
            //Shader.SetGlobalVector(ot_WaveConstants, waveConstants);
            //Shader.SetGlobalVector(ot_WaveDerivativeConstants, waveDerivativeConstants);

            Shader.SetGlobalVector(ot_WorldMove, StreamerManager.GetCurrentMove());

            // Texture animations
            Vector2 normalMapScale0 = mat.GetTextureScale(ot_NormalMap0);

            //Vector2 normalMapScale1 = mat.GetTextureScale(ot_NormalMap1);
            //Vector2 foamMapScale = mat.GetTextureScale(ot_FoamMap);

#if !UNITY_EDITOR
            mat.SetTextureOffset(ot_NormalMap0, VH.Mul(normalMapOffset0, normalMapScale0));
            //mat.SetTextureOffset(ot_NormalMap1, VH.Mul(normalMapOffset1, normalMapScale1));
            //mat.SetTextureOffset(ot_FoamMap, VH.Mul(foamMapOffset, foamMapScale));
#else
            if (Application.isPlaying)
            {
                mat.SetTextureOffset(ot_NormalMap0, VH.Mul(normalMapOffset0, normalMapScale0));
                //mat.SetTextureOffset(ot_NormalMap1, VH.Mul(normalMapOffset1, normalMapScale1));
                //mat.SetTextureOffset(ot_FoamMap, VH.Mul(foamMapOffset, foamMapScale));
            }
#endif

            // General
            Vector3 lightDir = Vector3.up;

            if (sun != null)
            {
                lightDir = -sun.transform.forward;
            }

            Shader.SetGlobalVector(ot_LightDir, lightDir);

            Vector4 dwColorUnlit = mat.GetColor(ot_DeepWaterColorUnlit);
            //float dwIntensityZenith = mat.GetFloat(ot_DeepWaterIntensityZenith);
            //float dwIntensityHorizon = mat.GetFloat(ot_DeepWaterIntensityHorizon);
            //float dwIntensityDark = mat.GetFloat(ot_DeepWaterIntensityDark);

            //float dwScalar = 0.0f;

            //if (lightDir.y >= 0.0f)
            //{
            //    dwScalar = Mathf.Lerp(dwIntensityHorizon, dwIntensityZenith, lightDir.y);
            //}
            //else
            //{
            //    dwScalar = Mathf.Lerp(dwIntensityHorizon, dwIntensityDark, -lightDir.y);
            //}

            //Shader.SetGlobalVector(ot_DeepWaterColor, dwColorUnlit * dwScalar);
            Shader.SetGlobalVector(ot_DeepWaterColor, dwColorUnlit);
        }
Ejemplo n.º 4
0
 private void OnDestroy()
 {
     Instance = null;
 }
Ejemplo n.º 5
0
 void Awake()
 {
     Instance = this;
 }
Ejemplo n.º 6
0
 public float GetPlayerDistanceSqr()
 {
     return(StreamerManager.GetPlayerDistanceSqr(transform.position));
 }
Ejemplo n.º 7
0
 public Vector3 GetPosition()
 {
     return(StreamerManager.GetRealPosition(transform.position));
 }
Ejemplo n.º 8
0
 public void SetPosition(Vector3 pos)
 {
     transform.position = StreamerManager.GetTilePosition(pos);
 }
Ejemplo n.º 9
0
 public void SetPosition(float x, float y, float z)
 {
     transform.position = StreamerManager.GetTilePosition(x, y, z);
 }