Пример #1
0
    public static void MarkForDestruction(SgtBeltGroup group)
    {
        if (group != null)
        {
            group.Belt = null;

            group.gameObject.SetActive(true);
        }
    }
Пример #2
0
    public static SgtBeltModel Create(SgtBeltGroup group)
    {
        var model = SgtComponentPool<SgtBeltModel>.Pop("Model", group.gameObject.layer, group.transform);

        model.Group = group;

        group.Models.Add(model);

        return model;
    }
Пример #3
0
    public static void Pool(SgtBeltGroup group)
    {
        if (group != null)
        {
            group.Belt      = null;
            group.MainTex   = null;
            group.HeightTex = null;
            group.Material  = null;

            for (var i = group.Models.Count - 1; i >= 0; i--)
            {
                SgtBeltModel.Pool(group.Models[i]);
            }

            group.Models.Clear();

            SgtComponentPool<SgtBeltGroup>.Add(group);
        }
    }
    protected abstract void CalculateAsteroids(out List <SgtBeltAsteroid> asteroids, out bool pool);    // pool == true when they are temporary

    protected virtual void UpdateGroupMaterial(SgtBeltGroup group)
    {
        if (group.Material == null)
        {
            group.Material = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "Belt");
        }

        var scale       = transform.lossyScale.x;
        var color       = SgtHelper.Brighten(Color, Brightness);
        var renderQueue = (int)RenderQueue + RenderQueueOffset;
        var lightCount  = SgtHelper.WriteLights(Lights, 2, transform.position, null, null, group.Material);
        var shadowCount = SgtHelper.WriteShadows(Shadows, 2, group.Material);

        SgtHelper.WriteLightKeywords(Lights.Count > 0, lightCount, keywords);
        SgtHelper.WriteShadowKeywords(shadowCount, keywords);

        group.Material.renderQueue = renderQueue;
        group.Material.SetTexture("_MainTex", group.MainTex);
        group.Material.SetTexture("_HeightTex", group.HeightTex);
        group.Material.SetColor("_Color", color);
        group.Material.SetFloat("_Scale", scale);
        group.Material.SetFloat("_Age", Age);
    }
Пример #5
0
    protected virtual void UpdateGroupMaterial(SgtBeltGroup group)
    {
        if (group.Material == null) group.Material = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "Belt");

        var scale       = transform.lossyScale.x;
        var color       = SgtHelper.Brighten(Color, Brightness);
        var renderQueue = (int)RenderQueue + RenderQueueOffset;
        var lightCount  = SgtHelper.WriteLights(Lights, 2, transform.position, null, null, group.Material);
        var shadowCount = SgtHelper.WriteShadows(Shadows, 2, group.Material);

        SgtHelper.WriteLightKeywords(Lights.Count > 0, lightCount, keywords);
        SgtHelper.WriteShadowKeywords(shadowCount, keywords);

        group.Material.renderQueue = renderQueue;
        group.Material.SetTexture("_MainTex", group.MainTex);
        group.Material.SetTexture("_HeightTex", group.HeightTex);
        group.Material.SetColor("_Color", color);
        group.Material.SetFloat("_Scale", scale);
        group.Material.SetFloat("_Age", Age);
    }