Ejemplo n.º 1
0
        private void PostProcessBeamTick(BeamController beam, SpeculativeRigidbody spec, float tickRate)
        {
            GameActor gameActor = spec.gameActor;

            if (!gameActor)
            {
                return;
            }

            PlayerController player = this.Owner;

            if (player.CurrentGun.PickupObjectId == 40)
            {
                beam.projectile.baseData.damage *= 1.003f;
            }

            BulletStatusEffectItem frostbullets = PickupObjectDatabase.GetById(278).GetComponent <BulletStatusEffectItem>();
            GameActorFreezeEffect  frostfreeze  = frostbullets.FreezeModifierEffect;

            if (player.CurrentGun.PickupObjectId == 464)
            {
                if (UnityEngine.Random.value < BraveMathCollege.SliceProbability(1f, tickRate))
                {
                    gameActor.ApplyEffect(frostfreeze, 0.015f, null);
                }
            }
        }
        private IEnumerator HandleDepartMotion()
        {
            Transform elevatorTransform           = elevatorAnimator.transform;
            Vector3   elevatorStartDepartPosition = elevatorTransform.position;
            float     elapsed         = 0f;
            float     duration        = 0.55f;
            float     yDistance       = 20f;
            bool      hasLayerSwapped = false;

            while (elapsed < duration)
            {
                if (elapsed > 0.15f && !crumblyBumblyAnimator.gameObject.activeSelf)
                {
                    crumblyBumblyAnimator.gameObject.SetActive(true);
                    crumblyBumblyAnimator.PlayAndDisableObject(string.Empty, null);
                }
                elapsed += BraveTime.DeltaTime;
                float t       = Mathf.SmoothStep(0f, 1f, elapsed / duration);
                float yOffset = BraveMathCollege.SmoothLerp(0f, -yDistance, t);
                if (yOffset < -2f && !hasLayerSwapped)
                {
                    hasLayerSwapped = true;
                    elevatorAnimator.gameObject.SetLayerRecursively(LayerMask.NameToLayer("BG_Critical"));
                }
                elevatorTransform.position = elevatorStartDepartPosition + new Vector3(0f, yOffset, 0f);
                if (facewallAnimator != null)
                {
                    facewallAnimator.Sprite.UpdateZDepth();
                }
                yield return(null);
            }
            yield break;
        }
Ejemplo n.º 3
0
 public void SpawnAdditionalProjectile(Projectile proj, SpeculativeRigidbody hitEnemy, bool fatal)
 {
     if (UnityEngine.Random.value <= 0.35f)
     {
         float      randomAngle   = UnityEngine.Random.Range(0f, 360f);
         Vector2    spawnPosition = hitEnemy.UnitCenter + BraveMathCollege.DegreesToVector(randomAngle, 3f);
         float      spawnAngle    = randomAngle - 180f;
         GameObject obj           = SpawnManager.SpawnProjectile(projectileToSpawn.gameObject, spawnPosition, Quaternion.Euler(0f, 0f, spawnAngle), true);
         Projectile proj2         = obj.GetComponent <Projectile>();
         if (proj2 != null)
         {
             proj2.Owner   = proj.Owner;
             proj2.Shooter = proj.Shooter;
             if (proj.sprite != null)
             {
                 proj2.shouldRotate           = proj.shouldRotate;
                 proj2.shouldFlipHorizontally = proj.shouldFlipHorizontally;
                 proj2.shouldFlipVertically   = proj.shouldFlipVertically;
                 proj2.sprite.SetSprite(proj.sprite.Collection, proj.sprite.spriteId);
                 Vector2 vector = proj2.transform.position.XY() - proj2.sprite.WorldCenter;
                 proj2.transform.position += vector.ToVector3ZUp(0f);
                 proj2.specRigidbody.Reinitialize();
             }
             proj2.baseData.damage = proj.baseData.damage;
             proj2.baseData.speed  = proj.baseData.speed;
             proj2.baseData.force  = proj.baseData.force;
         }
     }
 }
        private void UpdateReticlePosition()
        {
            PlayerController user = this.gun.GunPlayerOwner();

            if (user)
            {
                if (BraveInput.GetInstanceForPlayer(user.PlayerIDX).IsKeyboardAndMouse(false))
                {
                    Vector2 vector  = user.unadjustedAimPoint.XY();
                    Vector2 vector2 = vector - this.m_extantReticleQuad.GetBounds().extents.XY();
                    this.m_extantReticleQuad.transform.position = vector2;
                }
                else
                {
                    BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(user.PlayerIDX);
                    Vector2    vector3           = user.CenterPosition + (Quaternion.Euler(0f, 0f, this.m_currentAngle) * Vector2.right).XY() * this.m_currentDistance;
                    vector3               += instanceForPlayer.ActiveActions.Aim.Vector * 12f * BraveTime.DeltaTime;
                    this.m_currentAngle    = BraveMathCollege.Atan2Degrees(vector3 - user.CenterPosition);
                    this.m_currentDistance = Vector2.Distance(vector3, user.CenterPosition);
                    this.m_currentDistance = Mathf.Min(this.m_currentDistance, 100);
                    vector3                = user.CenterPosition + (Quaternion.Euler(0f, 0f, this.m_currentAngle) * Vector2.right).XY() * this.m_currentDistance;
                    Vector2 vector4 = vector3 - this.m_extantReticleQuad.GetBounds().extents.XY();
                    this.m_extantReticleQuad.transform.position = vector4;
                }
            }
        }
 public override void OnReloadPressedSafe(PlayerController player, Gun gun, bool manualReload)
 {
     if ((gun.ClipCapacity == gun.ClipShotsRemaining) || (gun.CurrentAmmo == gun.ClipShotsRemaining))
     {
         if (gun.CurrentAmmo >= 5)
         {
             if (this.m_extantReticleQuad) //If the cursor is there, then do the teleport
             {
                 gun.CurrentAmmo -= 5;
                 Vector2 worldCenter = this.m_extantReticleQuad.WorldCenter;
                 UnityEngine.Object.Destroy(this.m_extantReticleQuad.gameObject);
                 worldCenter += new Vector2(1.5f, 1.5f);
                 //worldCenter = new Vector2(Mathf.FloorToInt(worldCenter.x), Mathf.FloorToInt(worldCenter.y));
                 // UnityEngine.Object.Instantiate<GameObject>((PickupObjectDatabase.GetById(Pencil.pencilID) as Gun).DefaultModule.projectiles[0].gameObject, new Vector3(worldCenter.x, worldCenter.y), Quaternion.identity);
                 TeleportPlayerToCursorPosition.StartTeleport(player, worldCenter);
             }
             else //If the cursor is not there, make it
             {
                 GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.reticleQuad);
                 this.m_extantReticleQuad = gameObject.GetComponent <tk2dBaseSprite>();
                 this.m_currentAngle      = BraveMathCollege.Atan2Degrees(player.unadjustedAimPoint.XY() - player.CenterPosition);
                 this.m_currentDistance   = 5f;
                 this.UpdateReticlePosition();
             }
         }
     }
 }
        public string GetAnimationState(PlayerController interactor, out bool shouldBeFlipped)
        {
            shouldBeFlipped = false;
            Vector2 inVec = interactor.CenterPosition - specRigidbody.UnitCenter;

            switch (BraveMathCollege.VectorToQuadrant(inVec))
            {
            case 0:
                return("tablekick_down");

            case 1:
                shouldBeFlipped = true;
                return("tablekick_right");

            case 2:
                return("tablekick_up");

            case 3:
                return("tablekick_right");

            default:
                Debug.Log("fail");
                return("tablekick_up");
            }
        }
Ejemplo n.º 7
0
        private Vector2 ModVeloc(Vector2 inVel)
        {
            Vector2 vector = inVel;

            if (m_projectile.GetElapsedDistance() > (distanceLastChecked + 1))
            {
                float addition;
                if (recalcDriftPerCheck)
                {
                    addition = UnityEngine.Random.Range(minDriftPerTile, maxDriftPerTile);
                }
                else
                {
                    addition = staticAngle;
                }
                if (randomiseInverseEachCheck && UnityEngine.Random.value <= 0.5f)
                {
                    addition *= -1;
                }
                float targetAngle = inVel.ToAngle() + addition;

                vector = BraveMathCollege.DegreesToVector(targetAngle, inVel.magnitude);
                base.transform.rotation = Quaternion.Euler(0f, 0f, targetAngle);
                distanceLastChecked     = m_projectile.GetElapsedDistance();
            }
            return(vector);
        }
Ejemplo n.º 8
0
        public void OnTileCollision(CollisionData data)
        {
            if (this.bounces > 0)
            {
                Vector2 vector   = data.Normal;
                Vector2 velocity = data.MyRigidbody.Velocity;
                float   num2     = (-velocity).ToAngle();
                float   num3     = vector.ToAngle();
                float   num4     = BraveMathCollege.ClampAngle360(num2 + 2f * (num3 - num2));
                this.degrees = num4;
                this.bounces--;
            }
            else
            {
                //this.ForceBreak();

                /*CellData cellData2 = GameManager.Instance.Dungeon.data[data.TilePosition];
                 * cellData2.breakable = true;
                 * cellData2.occlusionData.overrideOcclusion = true;
                 * cellData2.occlusionData.cellOcclusionDirty = true;
                 * tk2dTileMap map = GameManager.Instance.Dungeon.DestroyWallAtPosition(data.TilePosition.x, data.TilePosition.y, true);
                 * this.m_owner.CurrentRoom.Cells.Add(cellData2.position);
                 * this.m_owner.CurrentRoom.CellsWithoutExits.Add(cellData2.position);
                 * this.m_owner.CurrentRoom.RawCells.Add(cellData2.position);
                 * if (map)
                 * {
                 *  GameManager.Instance.Dungeon.RebuildTilemap(map);
                 * }*/
                //base.StartCoroutine(this.HandleCombatRoomExpansion(this.Owner.CurrentRoom, this.Owner.CurrentRoom, null));
                this.ForceBreak();
            }
        }
Ejemplo n.º 9
0
        private void BuildMeshAlongCurve(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, float zOffset)
        {
            Vector3[] vertices = m_vertices;
            Vector2?  vector   = null;
            Vector2   v        = p3 - p0;
            Vector2   vector2  = (Quaternion.Euler(0f, 0f, 90f) * v).XY();

            for (int i = 0; i < 10; i++)
            {
                Vector2 vector3 = BraveMathCollege.CalculateBezierPoint(i / 9f, p0, p1, p2, p3);
                Vector2?vector4 = (i != 9) ? new Vector2?(BraveMathCollege.CalculateBezierPoint(i / 9f, p0, p1, p2, p3)) : null;
                Vector2 a       = Vector2.zero;
                if (vector != null)
                {
                    a += (Quaternion.Euler(0f, 0f, 90f) * (vector3 - vector.Value)).XY().normalized;
                }
                if (vector4 != null)
                {
                    a += (Quaternion.Euler(0f, 0f, 90f) * (vector4.Value - vector3)).XY().normalized;
                }
                a = a.normalized;
                float d = Mathf.Lerp(StartWidth, EndWidth, i / 9f);
                vector3            += vector2.normalized * Mathf.Sin(Time.realtimeSinceStartup * SinSpeed + i * WavelengthMod) * AmplitudeMod * (i / 9f);
                vertices[i * 2]     = (vector3 + a * d).ToVector3ZisY(zOffset);
                vertices[i * 2 + 1] = (vector3 + -a * d).ToVector3ZisY(zOffset);
                vector = new Vector2?(vector3);
            }
        }
Ejemplo n.º 10
0
 // Token: 0x0600489E RID: 18590 RVA: 0x00178EB0 File Offset: 0x001770B0
 private void OnTriggerCollision(SpeculativeRigidbody specRigidbody, SpeculativeRigidbody sourceSpecRigidbody, CollisionData collisionData)
 {
     if ((this.State == WizardSpinShootBehavior2.SpinShootState.Spawn || this.State == WizardSpinShootBehavior2.SpinShootState.Prefire) && collisionData.MyPixelCollider == this.m_bulletCatcher && collisionData.OtherRigidbody != null && collisionData.OtherRigidbody.projectile != null)
     {
         Projectile projectile = collisionData.OtherRigidbody.projectile;
         bool       flag       = (!this.m_isCharmed) ? (projectile.Owner is PlayerController) : (projectile.Owner is AIActor);
         if (flag && projectile.CanBeCaught)
         {
             projectile.specRigidbody.DeregisterSpecificCollisionException(projectile.Owner.specRigidbody);
             projectile.Shooter = this.m_aiActor.specRigidbody;
             projectile.Owner   = this.m_aiActor;
             projectile.specRigidbody.Velocity = Vector2.zero;
             projectile.ManualControl          = true;
             projectile.baseData.SetAll(EnemyDatabase.GetOrLoadByGuid("c4fba8def15e47b297865b18e36cbef8").bulletBank.GetBullet("default").ProjectileData);
             projectile.UpdateSpeed();
             projectile.specRigidbody.CollideWithTileMap = false;
             projectile.ResetDistance();
             projectile.collidesWithEnemies = this.m_isCharmed;
             projectile.collidesWithPlayer  = true;
             projectile.UpdateCollisionMask();
             projectile.sprite.color = new Color(1f, 0.1f, 0.1f);
             projectile.MakeLookLikeEnemyBullet(true);
             projectile.RemovePlayerOnlyModifiers();
             float second = BraveMathCollege.ClampAngle360((collisionData.Contact - this.ShootPoint.position.XY()).ToAngle());
             this.m_bulletPositions.Insert(Mathf.Max(0, this.m_bulletPositions.Count - 1), Tuple.Create <Projectile, float>(projectile, second));
         }
     }
 }
Ejemplo n.º 11
0
        public static Vector2 AdjustInputVector(Vector2 rawInput, float cardinalMagnetAngle, float ordinalMagnetAngle)
        {
            float num  = BraveMathCollege.ClampAngle360(BraveMathCollege.Atan2Degrees(rawInput));
            float num2 = num % 90f;
            float num3 = (num + 45f) % 90f;
            float num4 = 0f;

            if (cardinalMagnetAngle > 0f)
            {
                if (num2 < cardinalMagnetAngle)
                {
                    num4 = -num2;
                }
                else if (num2 > 90f - cardinalMagnetAngle)
                {
                    num4 = 90f - num2;
                }
            }
            if (ordinalMagnetAngle > 0f)
            {
                if (num3 < ordinalMagnetAngle)
                {
                    num4 = -num3;
                }
                else if (num3 > 90f - ordinalMagnetAngle)
                {
                    num4 = 90f - num3;
                }
            }
            num += num4;
            return((Quaternion.Euler(0f, 0f, num) * Vector3.right).XY() * rawInput.magnitude);
        }
        private void UpdatePosition(AIActor targetActor = null)
        {
            Vector2 unitBottomLeft = m_room.area.UnitBottomLeft;
            Vector2 unitTopRight   = m_room.area.UnitTopRight;

            if (TracksRandomEnemy)
            {
                if (targetActor != null && targetActor.healthHaver != null)
                {
                    if (!targetActor.healthHaver.IsDead)
                    {
                        if (targetActor.specRigidbody)
                        {
                            m_LastKnownPosition = targetActor.specRigidbody.GetUnitCenter(ColliderType.Ground);
                        }
                        else
                        {
                            m_LastKnownPosition = targetActor.sprite.WorldCenter;
                        }
                    }
                }
            }
            else
            {
                m_LastKnownPosition = m_targetPlayer.CenterPosition;
            }
            m_LastKnownPosition = BraveMathCollege.ClampToBounds(m_LastKnownPosition, unitBottomLeft + Vector2.one, unitTopRight - Vector2.one);
            transform.position  = (m_LastKnownPosition - m_targetOffset).Quantize(0.0625f);
            TargetAnimator.sprite.UpdateZDepth();
            sprite.UpdateZDepth();
        }
Ejemplo n.º 13
0
        private static void DealDamageToEnemiesInArc(PlayerController owner, Vector2 arcOrigin, float arcAngle, float arcRadius, float overrideDamage, float overrideForce, List <GameActorEffect> statusEffects, float jammedDMGMult, float bossDMGMult, float slashDimensions, List <SpeculativeRigidbody> alreadyHit = null)
        {
            RoomHandler roomHandler = owner.CurrentRoom;

            if (roomHandler == null)
            {
                return;
            }
            List <AIActor> activeEnemies = roomHandler.GetActiveEnemies(RoomHandler.ActiveEnemyType.All);

            if (activeEnemies == null)
            {
                return;
            }

            for (int i = 0; i < activeEnemies.Count; i++)
            {
                AIActor aiactor = activeEnemies[i];
                if (aiactor && aiactor.specRigidbody && aiactor.IsNormalEnemy && !aiactor.IsGone && aiactor.healthHaver)
                {
                    if (alreadyHit == null || !alreadyHit.Contains(aiactor.specRigidbody))
                    {
                        for (int j = 0; j < aiactor.healthHaver.NumBodyRigidbodies; j++)
                        {
                            SpeculativeRigidbody bodyRigidbody       = aiactor.healthHaver.GetBodyRigidbody(j);
                            PixelCollider        hitboxPixelCollider = bodyRigidbody.HitboxPixelCollider;
                            if (hitboxPixelCollider != null)
                            {
                                Vector2 vector = BraveMathCollege.ClosestPointOnRectangle(arcOrigin, hitboxPixelCollider.UnitBottomLeft, hitboxPixelCollider.UnitDimensions);
                                float   num    = Vector2.Distance(vector, arcOrigin);
                                if (ObjectWasHitBySlash(vector, arcOrigin, arcAngle, arcRadius, slashDimensions))
                                {
                                    bool          flag    = true;
                                    int           rayMask = CollisionMask.LayerToMask(CollisionLayer.HighObstacle, CollisionLayer.BulletBlocker, CollisionLayer.BulletBreakable);
                                    RaycastResult raycastResult;
                                    if (PhysicsEngine.Instance.Raycast(arcOrigin, vector - arcOrigin, num, out raycastResult, true, true, rayMask, null, false, null, null) && raycastResult.SpeculativeRigidbody != bodyRigidbody)
                                    {
                                        flag = false;
                                    }
                                    RaycastResult.Pool.Free(ref raycastResult);
                                    if (flag)
                                    {
                                        float damage = DealSwordDamageToEnemy(owner, aiactor, arcOrigin, vector, arcAngle, overrideDamage, overrideForce, statusEffects, bossDMGMult, jammedDMGMult);
                                        if (alreadyHit != null)
                                        {
                                            if (alreadyHit.Count == 0)
                                            {
                                                StickyFrictionManager.Instance.RegisterSwordDamageStickyFriction(damage);
                                            }
                                            alreadyHit.Add(aiactor.specRigidbody);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
            // Token: 0x060003CB RID: 971 RVA: 0x00023570 File Offset: 0x00021770
            private void Attack()
            {
                bool flag  = this.Owner == null;
                bool flag2 = flag;

                if (flag2)
                {
                    this.Owner = this.m_aiActor.GetComponent <Winpetster.WinpetsterBehavior>().Owner;
                }
                float          num           = -1f;
                List <AIActor> activeEnemies = this.Owner.CurrentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All);
                bool           flag3         = activeEnemies == null | activeEnemies.Count <= 0;
                bool           flag4         = !flag3;

                if (flag4)
                {
                    AIActor nearestEnemy = this.GetNearestEnemy(activeEnemies, this.m_aiActor.sprite.WorldCenter, out num, null);
                    bool    flag5        = nearestEnemy && num < 10f;
                    bool    flag6        = flag5;
                    if (flag6)
                    {
                        bool flag7 = this.IsInRange(nearestEnemy);
                        bool flag8 = flag7;
                        if (flag8)
                        {
                            bool flag9  = !nearestEnemy.IsHarmlessEnemy && nearestEnemy.IsNormalEnemy && !nearestEnemy.healthHaver.IsDead && nearestEnemy != this.m_aiActor;
                            bool flag10 = flag9;
                            if (flag10)
                            {
                                Vector2    unitCenter  = this.m_aiActor.specRigidbody.UnitCenter;
                                Vector2    unitCenter2 = nearestEnemy.specRigidbody.HitboxPixelCollider.UnitCenter;
                                float      z           = BraveMathCollege.Atan2Degrees((unitCenter2 - unitCenter).normalized);
                                Projectile projectile  = ((Gun)ETGMod.Databases.Items[1]).DefaultModule.projectiles[0];
                                GameObject gameObject  = SpawnManager.SpawnProjectile(projectile.gameObject, this.m_aiActor.sprite.WorldCenter, Quaternion.Euler(0f, 0f, z), true);
                                Projectile component   = gameObject.GetComponent <Projectile>();
                                bool       flag11      = component != null;
                                bool       flag12      = flag11;
                                bool       flag13      = flag12;
                                if (flag13)
                                {
                                    component.Owner   = this.Owner;
                                    component.Shooter = this.m_aiActor.specRigidbody;
                                    bool flag14 = this.Owner.HasPickupID(402) || this.Owner.HasPickupID(1);
                                    if (flag14)
                                    {
                                        component.baseData.damage           = 4f;
                                        component.AdditionalScaleMultiplier = 2f;
                                    }
                                    else
                                    {
                                        component.baseData.damage = 2.5f;
                                    }
                                    component.baseData.force     = 1f;
                                    component.collidesWithPlayer = false;
                                }
                            }
                        }
                    }
                }
            }
 public void Update()
 {
     if (!m_isActive && SetState(null) == ExpandHammerState.Gone)
     {
         return;
     }
     if (m_isActive && SetState(null) == ExpandHammerState.Gone)
     {
         Vector2 unitBottomLeft = m_room.area.UnitBottomLeft;
         Vector2 unitTopRight   = m_room.area.UnitTopRight;
         int     num            = 0;
         for (int i = 0; i < GameManager.Instance.AllPlayers.Length; i++)
         {
             PlayerController playerController = GameManager.Instance.AllPlayers[i];
             if (playerController && playerController.healthHaver.IsAlive)
             {
                 Vector2 centerPosition = playerController.CenterPosition;
                 if (BraveMathCollege.AABBContains(unitBottomLeft - Vector2.one, unitTopRight + Vector2.one, centerPosition))
                 {
                     num++;
                 }
             }
         }
         if (num == 0)
         {
             Deactivate();
         }
     }
     m_timer = Mathf.Max(0f, m_timer - LocalDeltaTime);
     UpdateState(SetState(null));
 }
        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);
        }
        protected override void DoEffect(PlayerController player)
        {
            Vector2 vector    = player.unadjustedAimPoint.XY() - player.CenterPosition;
            float   zRotation = BraveMathCollege.Atan2Degrees(vector);

            player.StartCoroutine(this.HandleSwing(player, vector, 1f, 20f));
        }
Ejemplo n.º 18
0
        public IEnumerator HandleDash(PlayerController target, Projectile projectile)
        {
            float duration = 1f;
            float elapsed  = -BraveTime.DeltaTime;
            float angle    = gun.CurrentOwner.CurrentGun.CurrentAngle;
            float adjSpeed = 100;

            this.gun.CanBeDropped = false;
            target.inventory.GunLocked.SetOverride("Nen Dash", true, null);
            target.ReceivesTouchDamage = false;
            target.SetIsFlying(true, "nen fist", true, false);
            duration = .15f;
            adjSpeed = 90;
            SpeculativeRigidbody specRigidbody = target.specRigidbody;

            specRigidbody.OnPreRigidbodyCollision = (SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate)Delegate.Combine(specRigidbody.OnPreRigidbodyCollision, new SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate(this.OnPreCollision));
            target.healthHaver.IsVulnerable       = false;

            while (elapsed < duration)
            {
                elapsed += BraveTime.DeltaTime;
                gun.CurrentOwner.specRigidbody.Velocity = BraveMathCollege.DegreesToVector(angle).normalized *adjSpeed;
                yield return(null);
            }
            target.ReceivesTouchDamage = true;
            this.gun.CanBeDropped      = true;
            target.inventory.GunLocked.RemoveOverride("Nen Dash");
            if (adjSpeed == 90)
            {
                target.healthHaver.IsVulnerable = true;
                SpeculativeRigidbody specRigidbody2 = target.specRigidbody;
                specRigidbody2.OnPreRigidbodyCollision = (SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate)Delegate.Remove(specRigidbody2.OnPreRigidbodyCollision, new SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate(this.OnPreCollision));
            }
            target.SetIsFlying(false, "nen fist", true, false);
        }
Ejemplo n.º 19
0
        public string GetAnimationState(PlayerController interactor, out bool shouldBeFlipped)
        {
            shouldBeFlipped = false;
            Vector2 inVec = interactor.CenterPosition - specRigidbody.UnitCenter;

            switch (BraveMathCollege.VectorToQuadrant(inVec))
            {
            case 0:
                return("tablekick_down");

            case 1:
                shouldBeFlipped = true;
                return("tablekick_right");

            case 2:
                return("tablekick_up");

            case 3:
                return("tablekick_right");

            default:
                Debug.Log("[ExpandKickableObject] Failed to find table animation state. Using fall back 'tablekick_up' instead.");
                return("tablekick_up");
            }
        }
Ejemplo n.º 20
0
        private void AimAt(GameObject obj, Vector2 point)
        {
            Vector2 v = point - obj.transform.position.XY();
            float   currentAimTarget = BraveMathCollege.Atan2Degrees(v);

            obj.transform.rotation = Quaternion.Euler(0f, 0f, currentAimTarget);
        }
        public static bool PositionBetweenRelativeValidAngles(this Vector2 positionToCheck, Vector2 startPosition, float centerAngle, float range, float validAngleVariation)
        {
            if (Vector2.Distance(positionToCheck, startPosition) < range)
            {
                float num7           = BraveMathCollege.Atan2Degrees(positionToCheck - startPosition);
                float minRawAngle    = Math.Min(validAngleVariation, -validAngleVariation);
                float maxRawAngle    = Math.Max(validAngleVariation, -validAngleVariation);
                bool  isInRange      = false;
                float actualMaxAngle = centerAngle + maxRawAngle;
                float actualMinAngle = centerAngle + minRawAngle;

                if (num7.IsBetweenRange(actualMinAngle, actualMaxAngle))
                {
                    isInRange = true;
                }
                if (actualMaxAngle > 180)
                {
                    float Overflow = actualMaxAngle - 180;
                    if (num7.IsBetweenRange(-180, (-180 + Overflow)))
                    {
                        isInRange = true;
                    }
                }
                if (actualMinAngle < -180)
                {
                    float Underflow = actualMinAngle + 180;
                    if (num7.IsBetweenRange((180 + Underflow), 180))
                    {
                        isInRange = true;
                    }
                }
                return(isInRange);
            }
            return(false);
        }
Ejemplo n.º 22
0
        private IEnumerator HandleFireShortBeam(Projectile projectileToSpawn, float duration)
        {
            float          elapsed  = 0f;
            float          num2     = -1f;
            AIActor        aiactor2 = this.m_extantOrbital.transform.position.GetAbsoluteRoom().GetNearestEnemy(this.m_extantOrbital.GetComponent <tk2dBaseSprite>().WorldCenter, out num2, true, true);
            BeamController beam     = this.BeginFiringBeam(projectileToSpawn, this.m_owner, BraveMathCollege.Atan2Degrees(aiactor2.sprite.WorldCenter - this.m_extantOrbital.GetComponent <tk2dSprite>().WorldCenter),
                                                           this.m_extantOrbital.GetComponent <tk2dBaseSprite>().WorldCenter);

            yield return(null);

            while (elapsed < duration)
            {
                if (!this || !this.m_extantOrbital || this.m_extantOrbital.transform.position.GetAbsoluteRoom() == null)
                {
                    break;
                }
                float   num     = -1f;
                AIActor aiactor = this.m_extantOrbital.transform.position.GetAbsoluteRoom().GetNearestEnemy(this.m_extantOrbital.GetComponent <tk2dBaseSprite>().WorldCenter, out num, true, true);
                if (aiactor == null)
                {
                    break;
                }
                elapsed += BraveTime.DeltaTime;
                this.ContinueFiringBeam(beam, BraveMathCollege.Atan2Degrees(aiactor.sprite.WorldCenter - this.m_extantOrbital.GetComponent <tk2dSprite>().WorldCenter), this.m_extantOrbital.GetComponent <tk2dBaseSprite>().WorldCenter);
                yield return(null);
            }
            this.CeaseBeam(beam);
            yield break;
        }
Ejemplo n.º 23
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;
        }
Ejemplo n.º 24
0
        private IEnumerator HandleFiringBeam(BeamController beam)
        {
            float elapsed = 0f;

            yield return(null);

            while (m_Player && m_Player.IsFiring && this && m_AIActor.sprite && m_AIActor.healthHaver && !m_IsDisconnected)
            {
                elapsed += BraveTime.DeltaTime;
                if (!m_AIActor.TargetRigidbody)
                {
                    m_AIActor.PlayerTarget = m_Player;
                }
                if (!m_MirrorGunToggle)
                {
                    beam.CeaseAttack();
                    beam.DestroyBeam();
                    yield break;
                }
                if (m_AIActor.CurrentGun)
                {
                    beam.Origin = m_AIActor.CurrentGun.sprite.WorldCenter;
                    beam.LateUpdatePosition(m_AIActor.CurrentGun.sprite.WorldCenter);
                }
                else
                {
                    beam.Origin = m_AIActor.specRigidbody.UnitCenter;
                    beam.LateUpdatePosition(m_AIActor.specRigidbody.UnitCenter);
                }
                // beam.Origin = m_AIActor.specRigidbody.UnitCenter;
                // beam.LateUpdatePosition(m_AIActor.specRigidbody.UnitCenter);
                if (m_Player)
                {
                    float angle = ((m_AIActor.TargetRigidbody.GetUnitCenter(ColliderType.HitBox) - m_AIActor.specRigidbody.UnitCenter).ToAngle());
                    if (m_AIActor.CurrentGun)
                    {
                        angle = ((m_AIActor.TargetRigidbody.GetUnitCenter(ColliderType.HitBox) - m_AIActor.CurrentGun.sprite.WorldCenter).ToAngle());
                    }
                    if (m_InvertSweepAngle)
                    {
                        angle = (angle + m_BeamSweepAngle);
                    }
                    else
                    {
                        angle = (angle - m_BeamSweepAngle);
                    }
                    beam.Direction = BraveMathCollege.DegreesToVector(angle, 1);
                    if (m_Player.IsDodgeRolling)
                    {
                        beam.CeaseAttack();
                        beam.DestroyBeam();
                        yield break;
                    }
                }
                yield return(null);
            }
            beam.CeaseAttack();
            beam.DestroyBeam();
            yield break;
        }
Ejemplo n.º 25
0
        private static bool ObjectWasHitBySlash(Vector2 ObjectPosition, Vector2 SlashPosition, float slashAngle, float SlashRange, float SlashDimensions)
        {
            if (Vector2.Distance(ObjectPosition, SlashPosition) < SlashRange)
            {
                float num7           = BraveMathCollege.Atan2Degrees(ObjectPosition - SlashPosition);
                float minRawAngle    = Math.Min(SlashDimensions, -SlashDimensions);
                float maxRawAngle    = Math.Max(SlashDimensions, -SlashDimensions);
                bool  isInRange      = false;
                float actualMaxAngle = slashAngle + maxRawAngle;
                float actualMinAngle = slashAngle + minRawAngle;

                if (num7.IsBetweenRange(actualMinAngle, actualMaxAngle))
                {
                    isInRange = true;
                }
                if (actualMaxAngle > 180)
                {
                    float Overflow = actualMaxAngle - 180;
                    if (num7.IsBetweenRange(-180, (-180 + Overflow)))
                    {
                        isInRange = true;
                    }
                }
                if (actualMinAngle < -180)
                {
                    float Underflow = actualMinAngle + 180;
                    if (num7.IsBetweenRange((180 + Underflow), 180))
                    {
                        isInRange = true;
                    }
                }
                return(isInRange);
            }
            return(false);
        }
Ejemplo n.º 26
0
        void Update()
        {
            if (projectile)
            {
                Vector2 position            = projectile.specRigidbody.UnitCenter;
                Vector2 direction           = projectile.LastVelocity.normalized;
                int     thePointOfTheMaskIs = CollisionMask.LayerToMask(CollisionLayer.HighObstacle, CollisionLayer.BulletBlocker, CollisionLayer.EnemyHitBox, CollisionLayer.BulletBreakable);
                PhysicsEngine.Instance.Raycast(position, direction, 100f, out RaycastResult result, true, true, thePointOfTheMaskIs);
                if (result != null && result.Contact != null)
                {
                    tk2dTiledSprite component = SpawnManager.SpawnVFX(linkVFXPrefab, false).GetComponent <tk2dTiledSprite>();
                    PostBeamRender(component);

                    Vector2 unitCenter  = position;
                    Vector2 unitCenter2 = result.Contact;
                    component.transform.position = unitCenter;
                    Vector2 vector = unitCenter2 - unitCenter;
                    float   num    = BraveMathCollege.Atan2Degrees(vector.normalized);
                    int     num2   = Mathf.RoundToInt(vector.magnitude / 0.0625f);
                    component.dimensions         = new Vector2((float)num2, component.dimensions.y);
                    component.transform.rotation = Quaternion.Euler(0f, 0f, num);
                    component.UpdateZDepth();

                    ETGMod.StartGlobalCoroutine(doTimerMagic(component.gameObject, wait));
                    OnBeamHit(result.Contact, projectile);
                }
                projectile.DieInAir();
            }
        }
        protected override void DoEffect(PlayerController player)
        {
            if (numberOfUses == 2)
            {
                Vector2 vector    = player.unadjustedAimPoint.XY() - player.CenterPosition;
                float   zRotation = BraveMathCollege.Atan2Degrees(vector);
                player.StartCoroutine(this.HandleSwing(player, vector, 0f, 20f));
            }
            if (numberOfUses == 1)
            {
                player.CurrentStoneGunTimer = 1f;

                player.MovementModifiers -= this.NoMotionModifier;
                player.IsStationary       = false;
                modifierController        = 0;
                player.IsEthereal         = false;

                if (host != null)
                {
                    host.healthHaver.ApplyDamage(99999, Vector2.zero, "unbound", CoreDamageTypes.Magic, DamageCategory.Unstoppable, true, null, false);
                    host = null;
                }

                player.SetIsStealthed(false, "cause they just are");
                PassiveItem.DecrementFlag(player, typeof(LiveAmmoItem));
                this.LastOwner.stats.RecalculateStats(LastOwner, true);
                CamToggle = 0;
                GameManager.Instance.MainCameraController.StartTrackingPlayer();
                GameManager.Instance.MainCameraController.SetManualControl(false, true);
            }
        }
        public void SpawnShards(Vector2 direction, float minAngle, float maxAngle, float verticalSpeed, float minMagnitude, float maxMagnitude)
        {
            Vector3 position = specRigidbody.GetUnitCenter(ColliderType.HitBox);

            if (shardClusters != null && shardClusters.Length > 0)
            {
                int num = Random.Range(0, 10);
                for (int i = 0; i < shardClusters.Length; i++)
                {
                    ShardCluster shardCluster = shardClusters[i];
                    int          num2         = Random.Range(shardCluster.minFromCluster, shardCluster.maxFromCluster + 1);
                    int          num3         = Random.Range(0, shardCluster.clusterObjects.Length);
                    for (int j = 0; j < num2; j++)
                    {
                        float lowDiscrepancyRandom = BraveMathCollege.GetLowDiscrepancyRandom(num);
                        num++;
                        float      z          = Mathf.Lerp(minAngle, maxAngle, lowDiscrepancyRandom);
                        Vector3    vector     = Quaternion.Euler(0f, 0f, z) * (direction.normalized * Random.Range(minMagnitude, maxMagnitude)).ToVector3ZUp(verticalSpeed);
                        int        num4       = (num3 + j) % shardCluster.clusterObjects.Length;
                        GameObject gameObject = SpawnManager.SpawnDebris(shardCluster.clusterObjects[num4].gameObject, position, Quaternion.identity);
                        tk2dSprite component  = gameObject.GetComponent <tk2dSprite>();
                        if (sprite.attachParent != null && component != null)
                        {
                            component.attachParent    = sprite.attachParent;
                            component.HeightOffGround = sprite.HeightOffGround;
                        }
                        DebrisObject component2 = gameObject.GetComponent <DebrisObject>();
                        vector = Vector3.Scale(vector, shardCluster.forceAxialMultiplier) * shardCluster.forceMultiplier;
                        component2.Trigger(vector, heightOffGround, shardCluster.rotationMultiplier);
                    }
                }
            }
        }
Ejemplo n.º 29
0
        protected override void DoActiveEffect(PlayerController user)
        {
            base.DoActiveEffect(user);
            if (user.healthHaver != null)
            {
                user.healthHaver.TriggerInvulnerabilityPeriod(0.5f);
            }
            this.m_currentlyHeldEnemy.Dismount();
            AIActor       aiActor       = this.m_currentlyHeldEnemy;
            KnockbackDoer knockbackDoer = aiActor.knockbackDoer;

            if (aiActor)
            {
                if (aiActor.specRigidbody != null)
                {
                    aiActor.specRigidbody.AddCollisionLayerOverride(CollisionMask.LayerToMask(CollisionLayer.EnemyHitBox));
                    aiActor.specRigidbody.OnPreRigidbodyCollision += new SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate(this.HandleHitEnemyHitEnemy);
                    aiActor.specRigidbody.OnPreTileCollision      += new SpeculativeRigidbody.OnPreTileCollisionDelegate(this.HandleHitTile);
                }
            }
            if (knockbackDoer)
            {
                BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(GameManager.Instance.PrimaryPlayer.PlayerIDX);
                bool       flag2             = instanceForPlayer == null;
                if (!flag2)
                {
                    Vector2 vector    = GameManager.Instance.PrimaryPlayer.unadjustedAimPoint.XY() - user.CenterPosition;
                    Vector2 direction = BraveMathCollege.DegreesToVector(BraveMathCollege.Atan2Degrees(vector), 1);
                    knockbackDoer.ApplyKnockback(direction, 800f, true);
                }
            }
            this.m_currentlyHeldEnemy = null;
        }
        public override BehaviorResult Update()
        {
            SpeculativeRigidbody targetRigidbody = this.m_aiActor.TargetRigidbody;

            if (!(targetRigidbody != null))
            {
                return(BehaviorResult.Continue);
            }

            float desiredCombatDistance = this.m_aiActor.DesiredCombatDistance;

            if (this.StopWhenInRange && this.m_aiActor.DistanceToTarget <= desiredCombatDistance)
            {
                this.m_aiActor.ClearPath();

                return(BehaviorResult.Continue);
            }

            if (this.m_repathTimer <= 0f)
            {
                Vector2 targetPosition;

                if (!this.m_otherBro)
                {
                    m_otherBro = ExpandWesternBroController.GetOtherWesternBros(this.m_aiActor).FirstOrDefault();
                }

                if (!this.m_otherBro)
                {
                    targetPosition = targetRigidbody.UnitCenter;
                }
                else
                {
                    Vector2 unitCenter  = this.m_aiActor.TargetRigidbody.specRigidbody.GetUnitCenter(ColliderType.HitBox);
                    Vector2 unitCenter2 = this.m_aiActor.specRigidbody.UnitCenter;
                    Vector2 unitCenter3 = this.m_otherBro.specRigidbody.UnitCenter;
                    float   num         = (unitCenter2 - unitCenter).ToAngle();
                    float   num2        = (unitCenter3 - unitCenter).ToAngle();
                    float   num3        = (num + num2) / 2f;
                    float   angle;

                    if (BraveMathCollege.ClampAngle180(num - num3) > 0f)
                    {
                        angle = num3 + 90f;
                    }
                    else
                    {
                        angle = num3 - 90f;
                    }

                    targetPosition = unitCenter + BraveMathCollege.DegreesToVector(angle, 1f) * this.DesiredCombatDistance;
                }

                this.m_aiActor.PathfindToPosition(targetPosition, null, true, null, null, null, false);
                this.m_repathTimer = this.PathInterval;
            }

            return(BehaviorResult.SkipRemainingClassBehaviors);
        }