Ejemplo n.º 1
0
        private IEnumerator DoDistortionWaveLocal(Vector2 center, float distortionIntensity, float distortionRadius, float maxRadius, float duration)
        {
            Material distMaterial       = new Material(ShaderCache.Acquire("Brave/Internal/DistortionWave"));
            Vector4  distortionSettings = GetCenterPointInScreenUV(center, distortionIntensity, distortionRadius);

            distMaterial.SetVector("_WaveCenter", distortionSettings);
            Pixelator.Instance.RegisterAdditionalRenderPass(distMaterial);
            float elapsed = 0f;

            while (elapsed < duration)
            {
                elapsed += BraveTime.DeltaTime;
                float t = elapsed / duration;
                t = BraveMathCollege.LinearToSmoothStepInterpolate(0f, 1f, t);
                distortionSettings   = GetCenterPointInScreenUV(center, distortionIntensity, distortionRadius);
                distortionSettings.w = Mathf.Lerp(distortionSettings.w, 0f, t);
                distMaterial.SetVector("_WaveCenter", distortionSettings);
                float currentRadius = Mathf.Lerp(0f, maxRadius, t);
                distMaterial.SetFloat("_DistortProgress", currentRadius / maxRadius * (maxRadius / 33.75f));
                yield return(null);
            }
            Pixelator.Instance.DeregisterAdditionalRenderPass(distMaterial);
            Destroy(distMaterial);
            yield break;
        }
        /*private IEnumerator HandleDistort(Gun gun, Material distort)
         * {
         *  float currentRadius = 0f;
         *  while (currentRadius < 1)
         *  {
         *      currentRadius += BraveTime.DeltaTime;
         *
         *      Vector2 center = gun.sprite.WorldCenter;
         *      Vector3 vector = GameManager.Instance.MainCameraController.GetComponent<Camera>().WorldToViewportPoint(center.ToVector3ZUp(0f));
         *      Vector4 vec4 = new Vector4(vector.x, vector.y, distRadius, distIntensity);
         *
         *      distort.SetVector("_WaveCenter", vec4);
         *      distort.SetFloat("_DistortProgress", currentRadius);
         *
         *      yield return null;
         *  }
         *  if (Pixelator.Instance != null && distort != null)
         *  {
         *      Pixelator.Instance.DeregisterAdditionalRenderPass(distort);
         *      UnityEngine.Object.Destroy(distort);
         *  }
         *  yield break;
         * }
         * private static float distIntensity = 0.5f;
         * private static float distRadius = 1f;*/
        protected override void Update()
        {
            if (gun.CurrentOwner && gun.GunPlayerOwner())
            {
                if (m_timer > 0)
                {
                    this.m_timer -= BraveTime.DeltaTime;
                    float num = BraveMathCollege.LinearToSmoothStepInterpolate(0f, 20f, 1f - this.m_timer / 1.5f);

                    List <AIActor> activeEnemies = gun.GunPlayerOwner().CurrentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All);

                    if (activeEnemies != null)
                    {
                        for (int i = 0; i < activeEnemies.Count; i++)
                        {
                            AIActor aiactor = activeEnemies[i];

                            Vector2 unitCenter = aiactor.specRigidbody.GetUnitCenter(ColliderType.HitBox);

                            float num2 = Vector2.Distance(unitCenter, lastCenter);
                            if (num2 >= this.m_prevWaveDist - 0.25f && num2 <= num + 0.25f)
                            {
                                aiactor.behaviorSpeculator.Stun(2f);
                                if ((aiactor.healthHaver && aiactor.healthHaver.GetCurrentHealthPercentage() < 0.5f) || gun.GunPlayerOwner().PlayerHasActiveSynergy("Gorgun's Gaze"))
                                {
                                    if (EasyEnemyTypeLists.VanillaShotgunKin.Contains(aiactor.EnemyGuid))
                                    {
                                        UnityEngine.Object.Instantiate <GameObject>((PickupObjectDatabase.GetById(37) as Gun).DefaultModule.chargeProjectiles[0].Projectile.hitEffects.overrideMidairDeathVFX, aiactor.specRigidbody.UnitCenter, Quaternion.identity);
                                        aiactor.EraseFromExistenceWithRewards();
                                        UnityEngine.Object.Instantiate <GameObject>(BraveUtility.RandomElement(stoneShotgunKin), aiactor.specRigidbody.UnitBottomLeft, Quaternion.identity);
                                    }
                                    else if (ValidBulletKin.Contains(aiactor.EnemyGuid))
                                    {
                                        UnityEngine.Object.Instantiate <GameObject>((PickupObjectDatabase.GetById(37) as Gun).DefaultModule.chargeProjectiles[0].Projectile.hitEffects.overrideMidairDeathVFX, aiactor.specRigidbody.UnitCenter, Quaternion.identity);
                                        aiactor.EraseFromExistenceWithRewards();
                                        UnityEngine.Object.Instantiate <GameObject>(BraveUtility.RandomElement(stoneBulletKin), aiactor.specRigidbody.UnitBottomLeft, Quaternion.identity);
                                    }
                                }
                            }
                        }
                    }
                    this.m_prevWaveDist = num;
                }
            }
            base.Update();
            if (!gun.IsReloading && hasScreamed)
            {
                hasScreamed = false;
            }
        }