wangguan
2020-11-06 eca45a7dbaed666a174e1d69177e06157ec98beb
修改材质球速度,增加一个简单的改变速度的方法
7 files modified
63 ■■■■ changed files
Assets/Materials/PVPTD/TowerMat/FireMat/fire_oppo_attackMat.mat 2 ●●●●● patch | view | raw | blame | history
Assets/Materials/PVPTD/TowerMat/FireMat/fire_oppo_waitMat.mat 4 ●●● patch | view | raw | blame | history
Assets/Materials/PVPTD/TowerMat/FireMat/fire_self_waitMat.mat 3 ●●●● patch | view | raw | blame | history
Assets/Materials/PVPTD/TowerMat/WoodMat/wood_oppo_waitMat.mat 3 ●●●● patch | view | raw | blame | history
Assets/Materials/PVPTD/TowerMat/WoodMat/wood_self_waitMat.mat 3 ●●●● patch | view | raw | blame | history
Assets/Materials/Shader/TexAnimation.shader 24 ●●●● patch | view | raw | blame | history
Assets/Scripts/TowerDefense/Towers/TowerLevel.cs 24 ●●●● patch | view | raw | blame | history
Assets/Materials/PVPTD/TowerMat/FireMat/fire_oppo_attackMat.mat
@@ -57,6 +57,7 @@
        m_Offset: {x: 0, y: 0}
    m_Floats:
    - _BumpScale: 1
    - _ChangeTime: 0
    - _Cutoff: 0.5
    - _DetailNormalMapScale: 1
    - _DstBlend: 0
@@ -66,6 +67,7 @@
    - _HorizontalAmount: 4
    - _Metallic: 0
    - _Mode: 0
    - _MyTime: 0
    - _OcclusionStrength: 1
    - _Parallax: 0.02
    - _SmoothnessTextureChannel: 0
Assets/Materials/PVPTD/TowerMat/FireMat/fire_oppo_waitMat.mat
@@ -57,6 +57,7 @@
        m_Offset: {x: 0, y: 0}
    m_Floats:
    - _BumpScale: 1
    - _ChangeTime: 0
    - _Cutoff: 0.5
    - _DetailNormalMapScale: 1
    - _DstBlend: 0
@@ -66,11 +67,12 @@
    - _HorizontalAmount: 4
    - _Metallic: 0
    - _Mode: 0
    - _MyTime: 0
    - _OcclusionStrength: 1
    - _Parallax: 0.02
    - _SmoothnessTextureChannel: 0
    - _SpecularHighlights: 1
    - _Speed: 10
    - _Speed: 8
    - _SrcBlend: 1
    - _UVSec: 0
    - _VerticalAmount: 1
Assets/Materials/PVPTD/TowerMat/FireMat/fire_self_waitMat.mat
@@ -57,6 +57,7 @@
        m_Offset: {x: 0, y: 0}
    m_Floats:
    - _BumpScale: 1
    - _ChangeTime: 0
    - _Cutoff: 0.5
    - _DetailNormalMapScale: 1
    - _DstBlend: 0
@@ -70,7 +71,7 @@
    - _Parallax: 0.02
    - _SmoothnessTextureChannel: 0
    - _SpecularHighlights: 1
    - _Speed: 10
    - _Speed: 8
    - _SrcBlend: 1
    - _UVSec: 0
    - _VerticalAmount: 1
Assets/Materials/PVPTD/TowerMat/WoodMat/wood_oppo_waitMat.mat
@@ -57,6 +57,7 @@
        m_Offset: {x: 0, y: 0}
    m_Floats:
    - _BumpScale: 1
    - _ChangeTime: 0
    - _Cutoff: 0.5
    - _DetailNormalMapScale: 1
    - _DstBlend: 0
@@ -70,7 +71,7 @@
    - _Parallax: 0.02
    - _SmoothnessTextureChannel: 0
    - _SpecularHighlights: 1
    - _Speed: 10
    - _Speed: 8
    - _SrcBlend: 1
    - _UVSec: 0
    - _VerticalAmount: 1
Assets/Materials/PVPTD/TowerMat/WoodMat/wood_self_waitMat.mat
@@ -57,6 +57,7 @@
        m_Offset: {x: 0, y: 0}
    m_Floats:
    - _BumpScale: 1
    - _ChangeTime: 0
    - _Cutoff: 0.5
    - _DetailNormalMapScale: 1
    - _DstBlend: 0
@@ -70,7 +71,7 @@
    - _Parallax: 0.02
    - _SmoothnessTextureChannel: 0
    - _SpecularHighlights: 1
    - _Speed: 10
    - _Speed: 8
    - _SrcBlend: 1
    - _UVSec: 0
    - _VerticalAmount: 1
Assets/Materials/Shader/TexAnimation.shader
@@ -8,6 +8,8 @@
        _HorizontalAmount("Horizontal Amount",Float) = 8
        _VerticalAmount("Vertical Amount",Float) = 8
        _Speed("Speed",Range(1,150)) = 30
        _ChangeTime("ChangeTime",Float) = 0
    }
    SubShader
    {
@@ -20,9 +22,9 @@
            Blend SrcAlpha OneMinusSrcAlpha
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
      // 两条非常重要的编译指令
            #pragma vertex vert// 定点着色器
            #pragma fragment frag// 片元着色器
            #include "Lighting.cginc"
            fixed4 _Color;
@@ -31,6 +33,8 @@
            float _HorizontalAmount;
            float _VerticalAmount;
            float _Speed;
            float _ChangeTime;
            struct a2v
            {
@@ -54,9 +58,17 @@
            fixed4 frag(v2f i) :SV_Target
            {
                float time = floor(_Time.y * _Speed);
                float row = floor(time / _HorizontalAmount);
                float column = time - row * _HorizontalAmount;
                //_Time    float4    Time (t/20, t, t*2, t*3), use to animate things inside the shaders.
                //_SinTime    float4    Sine of time: (t/8, t/4, t/2, t).
                //_CosTime    float4    Cosine of time: (t/8, t/4, t/2, t).
                //unity_DeltaTime    float4    Delta time: (dt, 1/dt, smoothDt, 1/smoothDt).
                //_ProjectionParams    float4    x is 1.0 (or –1.0 if currently rendering with a flipped projection matrix), y is the camera’s near plane, z is the camera’s far plane and w is 1/FarPlane.
                //_ScreenParams    float4    x is the current render target width in pixels, y is the current render target height in pixels, z is 1.0 + 1.0/width and w is 1.0 + 1.0/height.
                //这里的 t 得到的时间单位是——秒
                float time = floor((_Time.y - _ChangeTime) * _Speed);//对输入参数向下取整。例如 floor(float(1.3)) 返回的值为 1.0;但是 floor(float(-1.3))返回的值为-2.0。
                float row = floor(time / _HorizontalAmount);//行
                float column = time - row * _HorizontalAmount;//列
                //--
                    //half2 uv = float2(i.uv.x / _HorizontalAmount, i.uv.y / _VerticalAmount);
                    //uv.x += column / _HorizontalAmount;
Assets/Scripts/TowerDefense/Towers/TowerLevel.cs
@@ -139,6 +139,8 @@
        }
        private Transform mat;
        private MeshRenderer myRender;
        Vector3 normalScale;
        private Vector3 fireScale = new Vector3(1.92f, 1.92f, 2.208f);
@@ -152,6 +154,7 @@
        private void Awake()
        {
            mat = transform.Find("Cube");
            myRender = mat.GetComponent<MeshRenderer>();
            normalScale = new Vector3(1.5f, 1.5f, 1.5f);
        }
@@ -173,12 +176,12 @@
        {
            if (isFast && isAttack)
            {
                mat.GetComponent<MeshRenderer>().material.SetFloat("_Speed", 40);
                myRender.material.SetFloat("_Speed", 40);
            }
            else
            {
                //还原10
                mat.GetComponent<MeshRenderer>().material.SetFloat("_Speed", 8);
                myRender.material.SetFloat("_Speed", 8);
            }
        }
        /// <summary>
@@ -228,8 +231,23 @@
            if (material == null) return;
            this.isAttack = isAttack;
            mat.GetComponent<MeshRenderer>().material = material;
            myRender.material = material;
            if (isAttack)
            {
                if (transform.name.StartsWith("GrowUpTower") || transform.name.StartsWith("BlinkTower"))
                {
                    float t = Mathf.Floor(Time.time);
                    float offect = t % 8;
                    myRender.material.SetFloat("_ChangeTime", Mathf.Floor(Time.time - offect));
                }
            }
            else
            {
                myRender.material.SetFloat("_ChangeTime", Mathf.Floor(Time.time));
            }
            //Debug.Log("当前时间Time.time:"+Time.time);
            // if (transform.name.StartsWith("GrowUpTower") && mat.localPosition != fireOffectp)
            // {
            //     mat.localPosition = fireOffectp;