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); }
// 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)); } } }
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(); } }
// Token: 0x06004B93 RID: 19347 RVA: 0x00191F90 File Offset: 0x00190190 public override BehaviorResult Update() { this.m_startingAngle = BraveMathCollege.ClampAngle360(BraveUtility.RandomElement <float>(this.startingAngles)); this.m_aiActor.BehaviorOverridesVelocity = true; this.m_aiActor.BehaviorVelocity = BraveMathCollege.DegreesToVector(this.m_startingAngle, this.m_aiActor.MovementSpeed); this.m_isBouncing = true; return(BehaviorResult.RunContinuousInClass); }
// Token: 0x060048A1 RID: 18593 RVA: 0x00179164 File Offset: 0x00177364 public override ContinuousBehaviorResult ContinuousUpdate() { for (int i = this.m_bulletPositions.Count - 1; i >= 0; i--) { float num = this.m_bulletPositions[i].Second + this.m_deltaTime * (float)this.BulletCircleSpeed; this.m_bulletPositions[i].Second = num; Projectile first = this.m_bulletPositions[i].First; if (!(first == null)) { if (!first) { this.m_bulletPositions[i] = null; } else { Vector2 bulletPosition = this.GetBulletPosition(num); first.specRigidbody.Velocity = (bulletPosition.ToVector3XUp() - first.transform.position) / BraveTime.DeltaTime; if (first.shouldRotate) { first.transform.rotation = Quaternion.Euler(0f, 0f, 180f + (Quaternion.Euler(0f, 0f, 90f) * (this.ShootPoint.position.XY() - bulletPosition)).XY().ToAngle()); } first.ResetDistance(); } } } if (this.State == WizardSpinShootBehavior2.SpinShootState.Spawn) { while (this.m_stateTimer <= 0f && this.State == WizardSpinShootBehavior2.SpinShootState.Spawn) { AIBulletBank.Entry bullet = (EnemyDatabase.GetOrLoadByGuid("c4fba8def15e47b297865b18e36cbef8").bulletBank.GetBullet("default")); GameObject bulletObject = bullet.BulletObject; float num2 = 0f; if (this.m_bulletPositions.Count > 0) { num2 = BraveMathCollege.ClampAngle360(this.m_bulletPositions[this.m_bulletPositions.Count - 1].Second - this.BulletAngleDelta); } GameObject gameObject = SpawnManager.SpawnProjectile(bulletObject, this.GetBulletPosition(num2), Quaternion.Euler(0f, 0f, 0f), true); Projectile component = gameObject.GetComponent <Projectile>(); if (bullet != null && bullet.OverrideProjectile) { component.baseData.SetAll(bullet.ProjectileData); } component.Shooter = this.m_aiActor.specRigidbody; component.specRigidbody.Velocity = Vector2.zero; component.ManualControl = true; component.specRigidbody.CollideWithTileMap = false; component.collidesWithEnemies = this.m_isCharmed; component.UpdateCollisionMask(); this.m_bulletPositions.Add(Tuple.Create <Projectile, float>(component, num2)); this.m_stateTimer += this.SpawnDelay; if (this.m_bulletPositions.Count >= this.NumBullets) { this.bottleowhiskey(SpinShootState.Prefire); } } } else if (this.State == WizardSpinShootBehavior2.SpinShootState.Prefire) { if (this.m_stateTimer <= 0f) { this.bottleowhiskey(SpinShootState.Fire); } } else if (this.State == WizardSpinShootBehavior2.SpinShootState.Fire) { if (this.m_behaviorSpeculator.TargetBehaviors != null && this.m_behaviorSpeculator.TargetBehaviors.Count > 0) { this.m_behaviorSpeculator.TargetBehaviors[0].Update(); } if (this.m_bulletPositions.All((Tuple <Projectile, float> t) => t.First == null)) { return(ContinuousBehaviorResult.Finished); } while (this.m_stateTimer <= 0f) { Vector2 vector = this.ShootPoint.position.XY(); Vector2 b = vector + ((!this.m_aiActor.TargetRigidbody) ? Vector2.zero : (this.m_aiActor.TargetRigidbody.UnitCenter - vector)).normalized * this.BulletCircleRadius; int num3 = -1; float num4 = float.MaxValue; for (int j = 0; j < this.m_bulletPositions.Count; j++) { Projectile first2 = this.m_bulletPositions[j].First; if (!(first2 == null)) { float sqrMagnitude = (first2.specRigidbody.UnitCenter - b).sqrMagnitude; if (sqrMagnitude < num4) { num4 = sqrMagnitude; num3 = j; } } } if (num3 >= 0) { Projectile first3 = this.m_bulletPositions[num3].First; first3.ManualControl = false; first3.specRigidbody.CollideWithTileMap = true; if (this.m_aiActor.TargetRigidbody) { Vector2 unitCenter = this.m_aiActor.TargetRigidbody.specRigidbody.GetUnitCenter(ColliderType.HitBox); float speed = first3.Speed; float d = Vector2.Distance(first3.specRigidbody.UnitCenter, unitCenter) / speed; Vector2 b2 = unitCenter + this.m_aiActor.TargetRigidbody.specRigidbody.Velocity * d; Vector2 a = Vector2.Lerp(unitCenter, b2, this.LeadAmount); first3.SendInDirection(a - first3.specRigidbody.UnitCenter, true, true); } first3.transform.rotation = Quaternion.Euler(0f, 0f, first3.specRigidbody.Velocity.ToAngle()); this.m_bulletPositions[num3].First = null; } else { Debug.LogError("WizardSpinShootBehaviour.ContinuousUpdate(): This shouldn't happen!"); } this.m_stateTimer += this.FireDelay; if (this.m_bulletPositions.All((Tuple <Projectile, float> t) => t.First == null)) { return(ContinuousBehaviorResult.Finished); } } } return(ContinuousBehaviorResult.Continue); }
public void OnRigidbodyCollision(CollisionData data) { if ((data.OtherRigidbody.aiActor != null || data.OtherRigidbody.minorBreakable != null || data.OtherRigidbody.majorBreakable != null || data.OtherRigidbody.majorBreakable != null)) { if (this.penetration <= 0 || data.OtherRigidbody.majorBreakable != null) { if (data.OtherRigidbody.aiActor != null) { if (data.OtherRigidbody.aiActor.healthHaver != null) { this.HandleEnemyDamage(data.OtherRigidbody, data.OtherPixelCollider); } } else if (data.OtherRigidbody.minorBreakable != null) { data.OtherRigidbody.minorBreakable.Break(); } else if (data.OtherRigidbody.majorBreakable != null) { MajorBreakable majorBreakable = data.OtherRigidbody.majorBreakable; float num = 1f; if (!majorBreakable.IsSecretDoor || !(this.m_owner.CurrentGun != null) || !this.m_owner.CurrentGun.InfiniteAmmo) { float num2 = this.damage; if (num2 <= 0f && GameManager.Instance.InTutorial) { majorBreakable.ApplyDamage(1.5f, this.m_owner.specRigidbody.Velocity, false, false, false); } else { majorBreakable.ApplyDamage(num2 * num, this.m_owner.specRigidbody.Velocity, false, false, false); } } } if (data.OtherRigidbody.aiActor == null && 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(); } } } else { 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(); } } }