public override ContinuousBehaviorResult ContinuousUpdate()
        {
            base.ContinuousUpdate();

            if (this.ContinuesOnPathComplete)
            {
                this.m_aiAnimator.OverrideIdleAnimation = "idle_shoot";
            }

            if (this.m_remainingDuration <= 0f || !this.m_aiActor.TargetRigidbody || (this.m_aiActor.PathComplete && !this.ContinuesOnPathComplete))
            {
                return(ContinuousBehaviorResult.Finished);
            }

            float remainingPercentage = 1f - this.m_remainingDuration / this.m_totalDuration;

            float baseAngle = remainingPercentage * (float)this.SprayIterations % 2f;

            float angle = (this.m_aiActor.TargetRigidbody.GetUnitCenter(ColliderType.HitBox) - this.m_aiShooter.volleyShootPosition.position.XY()).ToAngle();

            angle  = BraveMathCollege.QuantizeFloat(angle, 45f);
            angle += -this.SprayAngle / 2f + Mathf.PingPong(baseAngle * this.SprayAngle, this.SprayAngle);

            this.m_aiShooter.ShootInDirection(Quaternion.Euler(0f, 0f, angle) * Vector2.right, this.OverrideBulletName);

            return(ContinuousBehaviorResult.Continue);
        }
Beispiel #2
0
 // Token: 0x06004CA9 RID: 19625 RVA: 0x00199234 File Offset: 0x00197434
 public override void EffectTick(GameActor actor, RuntimeGameActorEffectData effectData)
 {
     if (actor.FreezeAmount > 0f)
     {
         actor.FreezeAmount = Mathf.Max(0f, actor.FreezeAmount - BraveTime.DeltaTime * actor.FreezeDispelFactor);
         if (!actor.IsFrozen)
         {
             if (actor.FreezeAmount > 100f && actor.healthHaver.IsAlive)
             {
                 actor.FreezeAmount = 100f;
                 if (this.FreezeCrystals.Count > 0)
                 {
                     if (effectData.vfxObjects == null)
                     {
                         effectData.vfxObjects = new List <global::Tuple <GameObject, float> >();
                     }
                     int num = this.crystalNum;
                     if (effectData.actor && effectData.actor.specRigidbody && effectData.actor.specRigidbody.HitboxPixelCollider != null)
                     {
                         float num2 = effectData.actor.specRigidbody.HitboxPixelCollider.UnitDimensions.x * effectData.actor.specRigidbody.HitboxPixelCollider.UnitDimensions.y;
                         num = Mathf.Max(this.crystalNum, (int)((float)this.crystalNum * (0.5f + num2 / 4f)));
                     }
                     for (int i = 0; i < num; i++)
                     {
                         GameObject prefab  = BraveUtility.RandomElement <GameObject>(this.FreezeCrystals);
                         Vector2    vector  = actor.specRigidbody.HitboxPixelCollider.UnitCenter;
                         Vector2    vector2 = BraveUtility.RandomVector2(-this.crystalVariation, this.crystalVariation);
                         vector += vector2;
                         float      num3       = BraveMathCollege.QuantizeFloat(vector2.ToAngle(), 360f / (float)this.crystalRot);
                         Quaternion rotation   = Quaternion.Euler(0f, 0f, num3);
                         GameObject gameObject = SpawnManager.SpawnVFX(prefab, vector, rotation, true);
                         gameObject.transform.parent = actor.transform;
                         tk2dSprite component = gameObject.GetComponent <tk2dSprite>();
                         if (component)
                         {
                             actor.sprite.AttachRenderer(component);
                             component.HeightOffGround = 0.1f;
                         }
                         if (effectData.actor && effectData.actor.specRigidbody && effectData.actor.specRigidbody.HitboxPixelCollider != null)
                         {
                             Vector2 unitCenter = effectData.actor.specRigidbody.HitboxPixelCollider.UnitCenter;
                             float   num4       = (float)i * (360f / (float)num);
                             Vector2 normalized = BraveMathCollege.DegreesToVector(num4, 1f).normalized;
                             normalized.x *= effectData.actor.specRigidbody.HitboxPixelCollider.UnitDimensions.x / 2f;
                             normalized.y *= effectData.actor.specRigidbody.HitboxPixelCollider.UnitDimensions.y / 2f;
                             float   magnitude = normalized.magnitude;
                             Vector2 vector3   = unitCenter + normalized;
                             vector3 += (unitCenter - vector3).normalized * (magnitude * UnityEngine.Random.Range(0.15f, 0.85f));
                             gameObject.transform.position = vector3.ToVector3ZUp(0f);
                             gameObject.transform.rotation = Quaternion.Euler(0f, 0f, num4);
                         }
                         effectData.vfxObjects.Add(global::Tuple.Create <GameObject, float>(gameObject, num3));
                     }
                 }
                 if (this.ShouldVanishOnDeath(actor))
                 {
                     actor.StealthDeath = true;
                 }
                 if (actor.behaviorSpeculator)
                 {
                     if (actor.behaviorSpeculator.IsInterruptable)
                     {
                         actor.behaviorSpeculator.InterruptAndDisable();
                     }
                     else
                     {
                         actor.behaviorSpeculator.enabled = false;
                     }
                 }
                 if (actor is AIActor)
                 {
                     AIActor aiactor = actor as AIActor;
                     aiactor.ClearPath();
                     aiactor.BehaviorOverridesVelocity = false;
                 }
                 actor.IsFrozen = true;
             }
         }
         else if (actor.IsFrozen)
         {
             if (actor.FreezeAmount <= 0f)
             {
                 return;
             }
             if (actor.IsFalling)
             {
                 if (effectData.vfxObjects != null && effectData.vfxObjects.Count > 0)
                 {
                     this.DestroyCrystals(effectData, false);
                 }
                 if (actor.aiAnimator)
                 {
                     actor.aiAnimator.FpsScale = 1f;
                 }
             }
         }
     }
     if (!actor.healthHaver.IsDead)
     {
         float num5 = (!actor.healthHaver.IsBoss) ? 100f : 75f;
         float num6 = (!actor.IsFrozen) ? Mathf.Clamp01((100f - actor.FreezeAmount) / 100f) : 0f;
         float num7 = (!actor.IsFrozen) ? Mathf.Clamp01(actor.FreezeAmount / num5) : 1f;
         if (actor.aiAnimator)
         {
             actor.aiAnimator.FpsScale = ((!actor.IsFalling) ? num6 : 1f);
         }
         if (actor.aiShooter)
         {
             actor.aiShooter.AimTimeScale = num6;
         }
         if (actor.behaviorSpeculator)
         {
             actor.behaviorSpeculator.CooldownScale = num6;
         }
         if (actor.bulletBank)
         {
             actor.bulletBank.TimeScale = num6;
         }
         if (this.AppliesTint)
         {
             float num8          = actor.FreezeAmount / actor.FreezeDispelFactor;
             Color overrideColor = this.TintColor;
             if (num8 < 0.1f)
             {
                 overrideColor = Color.black;
             }
             else if (num8 < 0.2f)
             {
                 overrideColor = Color.white;
             }
             overrideColor.a *= num7;
             actor.RegisterOverrideColor(overrideColor, this.effectIdentifier);
         }
     }
 }
        private Vector2 GetDashDirection()
        {
            float[] directions = GetDirections();
            Vector2 lhs        = Vector2.zero;
            Vector2 unitCenter = m_aiActor.specRigidbody.GetUnitCenter(ColliderType.Ground);

            for (int i = 0; i < directions.Length; i++)
            {
                bool          flag   = false;
                bool          flag2  = false;
                Vector2       vector = BraveMathCollege.DegreesToVector(directions[i], 1f);
                RaycastResult raycastResult;
                bool          flag3 = PhysicsEngine.Instance.Raycast(unitCenter, vector, dashDistance, out raycastResult, true, true, int.MaxValue, new CollisionLayer?(CollisionLayer.EnemyCollider), false, null, m_aiActor.specRigidbody);
                RaycastResult.Pool.Free(ref raycastResult);
                float num = 0.25f;
                while (num <= dashDistance && !flag && !flag3)
                {
                    Vector2 vector2 = unitCenter + num * vector;
                    if (!GameManager.Instance.Dungeon.CellExists(vector2))
                    {
                        flag = true;
                    }
                    else if (GameManager.Instance.Dungeon.ShouldReallyFall(vector2))
                    {
                        flag = true;
                    }
                    num += 0.25f;
                }
                num = 0.25f;
                while (num <= dashDistance && !flag && !flag2 && !flag3)
                {
                    IntVector2 intVector = (unitCenter + num * vector).ToIntVector2(VectorConversions.Floor);
                    if (!GameManager.Instance.Dungeon.CellExists(intVector))
                    {
                        flag2 = true;
                    }
                    else if (GameManager.Instance.Dungeon.data.CheckInBoundsAndValid(intVector) && GameManager.Instance.Dungeon.data[intVector].isExitCell)
                    {
                        flag2 = true;
                    }
                    num += 0.25f;
                }
                if (avoidTarget && m_behaviorSpeculator.TargetRigidbody && !flag && !flag2 && !flag3)
                {
                    Vector2 unitCenter2 = m_aiActor.specRigidbody.GetUnitCenter(ColliderType.HitBox);
                    Vector2 vector3     = m_behaviorSpeculator.TargetRigidbody.GetUnitCenter(ColliderType.HitBox) - unitCenter2;
                    float   num2        = dashDistance + 2f;
                    if (vector3.magnitude < num2 && BraveMathCollege.AbsAngleBetween(vector3.ToAngle(), directions[i]) < 80f)
                    {
                        flag3 = true;
                    }
                    if (GameManager.Instance.CurrentGameType == GameManager.GameType.COOP_2_PLAYER && !flag3)
                    {
                        PlayerController playerController = m_aiActor.PlayerTarget as PlayerController;
                        if (playerController)
                        {
                            PlayerController otherPlayer = GameManager.Instance.GetOtherPlayer(playerController);
                            if (otherPlayer && otherPlayer.healthHaver.IsAlive)
                            {
                                vector3 = otherPlayer.specRigidbody.GetUnitCenter(ColliderType.HitBox) - unitCenter2;
                                if (vector3.magnitude < num2 && BraveMathCollege.AbsAngleBetween(vector3.ToAngle(), directions[i]) < 80f)
                                {
                                    flag3 = true;
                                }
                            }
                        }
                    }
                }
                if (!flag3 && !flag && !flag2)
                {
                    lhs = vector; break;
                }
            }
            if (lhs != Vector2.zero)
            {
                return(lhs.normalized);
            }
            if (directions.Length > 0)
            {
                return(BraveMathCollege.DegreesToVector(directions[directions.Length - 1], 1f));
            }
            float num3 = UnityEngine.Random.Range(0f, 360f);

            if (quantizeDirection > 0f)
            {
                BraveMathCollege.QuantizeFloat(num3, quantizeDirection);
            }
            return(BraveMathCollege.DegreesToVector(num3, 1f));
        }
 private float[] GetDirections()
 {
     float[] array = new float[0];
     if (dashDirection == DashDirection.PerpendicularToTarget)
     {
         float num = (m_aiActor.TargetRigidbody.GetUnitCenter(ColliderType.Ground) - m_aiActor.specRigidbody.UnitCenter).ToAngle();
         array = new float[] { num + 90f, num - 90f };
         BraveUtility.RandomizeArray(array, 0, -1);
     }
     else if (dashDirection == DashDirection.KindaTowardTarget)
     {
         float num2 = (m_aiActor.TargetRigidbody.GetUnitCenter(ColliderType.Ground) - m_aiActor.specRigidbody.UnitCenter).ToAngle();
         array = new float[] { num2, (num2 - quantizeDirection), (num2 + quantizeDirection) };
         BraveUtility.RandomizeArray(array, 1, -1);
     }
     else if (dashDirection == DashDirection.TowardTarget)
     {
         float num3 = (m_aiActor.TargetRigidbody.GetUnitCenter(ColliderType.Ground) - m_aiActor.specRigidbody.UnitCenter).ToAngle();
         array = new float[] { num3 };
     }
     else if (dashDirection == DashDirection.Random)
     {
         if (quantizeDirection <= 0f)
         {
             array = new float[16];
             for (int i = 0; i < array.Length; i++)
             {
                 array[i] = UnityEngine.Random.Range(0f, 360f);
             }
         }
         else
         {
             int num4 = Mathf.RoundToInt(360f / quantizeDirection);
             array = new float[num4];
             for (int j = 0; j < array.Length; j++)
             {
                 array[j] = (j * quantizeDirection);
             }
             BraveUtility.RandomizeArray(array, 0, -1);
         }
     }
     else if (dashDirection == DashDirection.Random)
     {
         if (quantizeDirection <= 0f)
         {
             array = new float[16];
             for (int k = 0; k < array.Length; k++)
             {
                 array[k] = UnityEngine.Random.Range(0f, 360f);
             }
         }
         else
         {
             int num5 = Mathf.RoundToInt(360f / quantizeDirection);
             array = new float[num5];
             for (int l = 0; l < array.Length; l++)
             {
                 array[l] = (l * quantizeDirection);
             }
             BraveUtility.RandomizeArray(array, 0, -1);
         }
     }
     if (quantizeDirection > 0f)
     {
         for (int m = 0; m < array.Length; m++)
         {
             array[m] = BraveMathCollege.QuantizeFloat(array[m], quantizeDirection);
         }
     }
     return(array);
 }