예제 #1
0
            public void Update()
            {
                if (!renderer)
                {
                    if (itemFollower && itemFollower.followerInstance)
                    {
                        renderer = itemFollower.followerInstance.GetComponentInChildren <Renderer>();
                    }
                }

                if (blinkTimer > 0f)
                {
                    blinkTimer -= Time.deltaTime;
                    if (blinkTimer <= 0f)
                    {
                        if (renderer)
                        {
                            renderer.shadowCastingMode = ShadowCastingMode.On;
                            renderer.enabled           = true;

                            EffectManager.SpawnEffect(blinkEffect, new EffectData
                            {
                                origin = renderer.transform.position
                            }, false);

                            TemporaryOverlay temporaryOverlay = renderer.gameObject.AddComponent <TemporaryOverlay>();
                            temporaryOverlay.duration              = flashTimer = flashDuration;
                            temporaryOverlay.destroyObjectOnEnd    = false;
                            temporaryOverlay.destroyComponentOnEnd = true;
                            temporaryOverlay.originalMaterial      = materialFlash;
                            temporaryOverlay.alphaCurve            = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
                            temporaryOverlay.animateShaderAlpha    = true;
                            temporaryOverlay.SetupMaterial();

                            var materials = renderer.materials;
                            HG.ArrayUtils.ArrayAppend(ref materials, temporaryOverlay.materialInstance);
                            renderer.materials = materials;
                            materialInstance   = renderer.materials.Last();
                        }
                    }
                }

                if (flashTimer > 0f)
                {
                    flashTimer -= Time.deltaTime;
                    if (flashTimer <= 0f)
                    {
                        if (renderer && materialInstance)
                        {
                            var materials = renderer.materials;
                            var index     = System.Array.IndexOf(materials, materialInstance);
                            if (index != -1)
                            {
                                HG.ArrayUtils.ArrayRemoveAtAndResize(ref materials, index);
                            }
                            renderer.materials = materials;
                        }
                    }
                }
            }
예제 #2
0
            public override void Update()
            {
                base.Update();

                if (!started)
                {
                    var parent = transform.parent;
                    if (parent)
                    {
                        started = true;

                        modelLocator = parent.GetComponent <ModelLocator>();
                        if (modelLocator && modelLocator.modelTransform)
                        {
                            temporaryOverlay                  = modelLocator.modelTransform.gameObject.AddComponent <TemporaryOverlay>();
                            temporaryOverlay.duration         = duration;
                            temporaryOverlay.originalMaterial = Main.AssetBundle.LoadAsset <Material>("Assets/Equipment/From Omar With Love/matOmarHackToolVFXOverlay.mat");
                            //temporaryOverlay.alphaCurve = AnimationCurve.EaseInOut(0f, 0f, 0.2f, 1f);
                            //temporaryOverlay.animateShaderAlpha = true;
                            temporaryOverlay.destroyComponentOnEnd = false;
                            temporaryOverlay.destroyObjectOnEnd    = false;
                            temporaryOverlay.SetupMaterial();

                            renderer = modelLocator.modelTransform.GetComponentInChildren <Renderer>();
                            if (renderer)
                            {
                                var materials = renderer.materials;
                                HG.ArrayUtils.ArrayAppend(ref materials, temporaryOverlay.materialInstance);
                                renderer.materials = materials;
                                materialInstance   = renderer.materials.Last();
                            }
                        }
                    }
                }

                if (age >= duration && !ended)
                {
                    ended = true;

                    if (renderer && materialInstance)
                    {
                        var materials = renderer.materials;
                        var index     = System.Array.IndexOf(materials, materialInstance);
                        if (index != -1)
                        {
                            HG.ArrayUtils.ArrayRemoveAtAndResize(ref materials, index);
                        }
                        renderer.materials = materials;
                    }
                }
            }
예제 #3
0
            public override void Update()
            {
                base.Update();
                if (age >= shatterTime && !shatterFlag)
                {
                    shatterFlag = true;
                    if (pickupDisplay && pickupDisplay.modelObject)
                    {
                        var childLocator = pickupDisplay.modelObject.GetComponent <ChildLocator>();
                        if (!childLocator)
                        {
                            childLocator = pickupDisplay.modelObject.AddComponent <ChildLocator>();
                        }
                        if (childLocator.transformPairs == null)
                        {
                            childLocator.transformPairs = new ChildLocator.NameTransformPair[] { }
                        }
                        ;
                        var transformPair = new ChildLocator.NameTransformPair
                        {
                            name      = "ShatterOrigin",
                            transform = pickupDisplay.modelObject.transform
                        };
                        HGArrayUtilities.ArrayAppend(ref childLocator.transformPairs, ref transformPair);

                        TemporaryOverlay temporaryOverlay = pickupDisplay.modelObject.AddComponent <TemporaryOverlay>();
                        temporaryOverlay.duration                 = 0.5f;
                        temporaryOverlay.destroyObjectOnEnd       = true;
                        temporaryOverlay.originalMaterial         = LegacyResourcesAPI.Load <Material>("Materials/matShatteredGlass");
                        temporaryOverlay.destroyEffectPrefab      = (GameObject)LegacyResourcesAPI.Load <GameObject>("Prefabs/Effects/BrittleDeath");
                        temporaryOverlay.destroyEffectChildString = "ShatterOrigin";
                        temporaryOverlay.alphaCurve               = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
                        temporaryOverlay.animateShaderAlpha       = true;
                        temporaryOverlay.SetupMaterial();

                        var renderer = pickupDisplay.modelRenderer;
                        if (renderer)
                        {
                            var materials = renderer.materials;
                            HGArrayUtilities.ArrayAppend(ref materials, ref temporaryOverlay.materialInstance);
                            renderer.materials = materials;
                        }
                    }
                }
                if (age >= duration)
                {
                    Object.Destroy(gameObject);
                }
            }
        }
예제 #4
0
            public void TriggerFlash()
            {
                if (flashTimer <= 0f)
                {
                    TemporaryOverlay temporaryOverlay = gameObject.AddComponent <TemporaryOverlay>();
                    temporaryOverlay.duration = flashDuration;
                    flashTimer = flashDuration;
                    temporaryOverlay.destroyObjectOnEnd    = false;
                    temporaryOverlay.destroyComponentOnEnd = true;
                    temporaryOverlay.originalMaterial      = material;
                    temporaryOverlay.alphaCurve            = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
                    temporaryOverlay.animateShaderAlpha    = true;
                    temporaryOverlay.SetupMaterial();

                    if (renderer)
                    {
                        var materials = renderer.materials;
                        HG.ArrayUtils.ArrayAppend(ref materials, temporaryOverlay.materialInstance);
                        renderer.materials = materials;
                        materialInstance   = renderer.materials.Last();
                    }
                }
            }