private void HookEnemyToSlope(IPhysicsObj enemy, TerrainObj terrain) { Vector2 vector; Vector2 vector2; if (terrain.Width > terrain.Height) { vector = CollisionMath.UpperLeftCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero); vector2 = CollisionMath.UpperRightCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero); } else if (terrain.Rotation > 0f) { vector = CollisionMath.LowerLeftCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero); vector2 = CollisionMath.UpperLeftCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero); } else { vector = CollisionMath.UpperRightCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero); vector2 = CollisionMath.LowerRightCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero); } float num = vector2.X - vector.X; float num2 = vector2.Y - vector.Y; float x = vector.X; float y = vector.Y; float x2 = enemy.X; float num3 = y + (x2 - x) * (num2 / num); enemy.UpdateCollisionBoxes(); num3 -= (float)enemy.Bounds.Bottom - enemy.Y + 5f * (enemy as GameObj).ScaleX; enemy.Y = (float)Math.Round((double)num3, MidpointRounding.ToEven); }
public override void CollisionResponse(CollisionBox thisBox, CollisionBox otherBox, int collisionResponseType) { IPhysicsObj absParent = otherBox.AbsParent as IPhysicsObj; if (collisionResponseType == Consts.COLLISIONRESPONSE_FIRSTBOXHIT) { if ((absParent.CollisionTypeTag == GameTypes.CollisionType_PLAYER || absParent.CollisionTypeTag == GameTypes.CollisionType_GLOBAL_DAMAGE_WALL || absParent.CollisionTypeTag == GameTypes.CollisionType_GLOBAL_DAMAGE_WALL && IsWeighted) && (!(otherBox.AbsParent is RogueAPI.Projectiles.ProjectileObj) && m_invincibleCounter <= 0f || otherBox.AbsParent is RogueAPI.Projectiles.ProjectileObj && (m_invincibleCounterProjectile <= 0f || (otherBox.AbsParent as RogueAPI.Projectiles.ProjectileObj).IgnoreInvincibleCounter)) ) { //Show demented question mark and return if (IsDemented) { m_invincibleCounter = InvincibilityTime; m_invincibleCounterProjectile = InvincibilityTime; RogueAPI.Effects.QuestionMarkEffect.Display(this); //m_levelScreen.ImpactEffectPool.DisplayQuestionMark(new Vector2(X, Bounds.Top)); return; } int damage; if (absParent is RogueAPI.Projectiles.ProjectileObj) { damage = (absParent as RogueAPI.Projectiles.ProjectileObj).Damage; } else { damage = (absParent as IDealsDamageObj).Damage; } //Apply critical damage bool isPlayer = absParent == m_target; if (isPlayer) { if (CDGMath.RandomFloat(0f, 1f) <= m_target.TotalCritChance && !NonKillable) { RogueAPI.Effects.CriticalTextEffect.Display(this); //m_levelScreen.ImpactEffectPool.DisplayCriticalText(new Vector2(X, Bounds.Top)); damage = (int)(damage * m_target.TotalCriticalDamage); } m_invincibleCounter = InvincibilityTime; } //Destroy projectile var projectileObj = otherBox.AbsParent as RogueAPI.Projectiles.ProjectileObj; if (projectileObj != null) { m_invincibleCounterProjectile = InvincibilityTime; if (projectileObj.DestroysWithEnemy && !NonKillable) { projectileObj.RunDestroyAnimation(false); } } if (projectileObj != null || absParent.CollisionTypeTag != GameTypes.CollisionType_GLOBAL_DAMAGE_WALL || absParent.CollisionTypeTag == GameTypes.CollisionType_GLOBAL_DAMAGE_WALL && IsWeighted) { var allow = true; if (projectileObj != null) { var kbAmount = CanBeKnockedBack && !IsPaused ? (KnockBack != Vector2.Zero ? KnockBack : m_target.EnemyKnockBack) : Vector2.Zero; allow = projectileObj != null?projectileObj.OnCollision(this, false, kbAmount) : true; } if (allow) { Point center = (thisBox.AbsRotation != 0f || otherBox.AbsRotation != 0f) ? Rectangle.Intersect(thisBox.AbsParent.Bounds, otherBox.AbsParent.Bounds).Center : Rectangle.Intersect(thisBox.AbsRect, otherBox.AbsRect).Center; HitEnemy(damage, new Vector2(center.X, center.Y), isPlayer); } } ////Apply shout knockback //if (projectileObj != null && projectileObj.Spell == SpellType.Shout) //{ // if (CanBeKnockedBack && !IsPaused) // { // float inertia = 3f; // var knockback = KnockBack != Vector2.Zero ? KnockBack : m_target.EnemyKnockBack; // CurrentSpeed = 0f; // AccelerationX = knockback.X * (X >= m_target.X ? inertia : -inertia); // AccelerationY = -knockback.Y * inertia; // } //} //else if (projectileObj != null || absParent.CollisionTypeTag != GameTypes.CollisionType_GLOBAL_DAMAGE_WALL || absParent.CollisionTypeTag == GameTypes.CollisionType_GLOBAL_DAMAGE_WALL && IsWeighted) //{ // Point center = (thisBox.AbsRotation != 0f || otherBox.AbsRotation != 0f) // ? Rectangle.Intersect(thisBox.AbsParent.Bounds, otherBox.AbsParent.Bounds).Center // : Rectangle.Intersect(thisBox.AbsRect, otherBox.AbsRect).Center; // HitEnemy(damage, new Vector2(center.X, center.Y), isPlayer); //} } } else if (collisionResponseType == Consts.COLLISIONRESPONSE_TERRAIN) { if ((absParent.CollisionTypeTag == GameTypes.CollisionType_WALL || absParent.CollisionTypeTag == GameTypes.CollisionType_WALL_FOR_ENEMY || absParent.CollisionTypeTag == GameTypes.CollisionType_GLOBAL_DAMAGE_WALL) && CollisionTypeTag != GameTypes.CollisionType_ENEMYWALL) { Vector2 vector2 = CollisionMath.CalculateMTD(thisBox.AbsRect, otherBox.AbsRect); if (CurrentSpeed != 0f && vector2.X != 0f && Math.Abs(vector2.X) > 10f && (vector2.X > 0f && absParent.CollidesRight || vector2.X < 0f && absParent.CollidesLeft)) { CurrentSpeed = 0f; } if (m_numTouchingGrounds <= 1 && CurrentSpeed != 0f && vector2.Y < 0f && !CanFallOffLedges) { if (Bounds.Left < absParent.Bounds.Left && HeadingX < 0f) { X = absParent.Bounds.Left + (AbsX - Bounds.Left); CurrentSpeed = 0f; } else if (Bounds.Right > absParent.Bounds.Right && HeadingX > 0f) { X = absParent.Bounds.Right - (Bounds.Right - AbsX); CurrentSpeed = 0f; } m_isTouchingGround = true; } if (AccelerationX != 0f && m_isTouchingGround) { AccelerationX = 0f; } bool flag1 = false; if (Math.Abs(vector2.X) < 10f && vector2.X != 0f && Math.Abs(vector2.Y) < 10f && vector2.Y != 0f) { flag1 = true; } if (m_isTouchingGround && !absParent.CollidesBottom && absParent.CollidesTop && absParent.TerrainBounds.Top < TerrainBounds.Bottom - 30) { flag1 = true; } if (!absParent.CollidesRight && !absParent.CollidesLeft && absParent.CollidesTop && absParent.CollidesBottom) { flag1 = true; } Vector2 vector22 = CollisionMath.RotatedRectIntersectsMTD(thisBox.AbsRect, thisBox.AbsRotation, Vector2.Zero, otherBox.AbsRect, otherBox.AbsRotation, Vector2.Zero); if (!flag1) { base.CollisionResponse(thisBox, otherBox, collisionResponseType); } if (vector22.Y < 0f && otherBox.AbsRotation != 0f && IsWeighted) { X -= vector22.X; } } } }
private void CheckGroundCollision() { this.m_previousIsTouchingGround = this.m_isTouchingGround; this.m_isTouchingGround = false; this.m_collidingLeft = (this.m_collidingRight = false); this.m_collidingLeftOnly = (this.m_collidingRightOnly = false); bool flag = false; IPhysicsObj physicsObj = null; float num = 3.40282347E+38f; IPhysicsObj physicsObj2 = null; float num2 = 3.40282347E+38f; Rectangle rectangle = new Rectangle(this.TerrainBounds.Left, this.TerrainBounds.Bottom - 78, this.TerrainBounds.Width, 88); foreach (IPhysicsObj current in base.PhysicsMngr.ObjectList) { if (((Game.PlayerStats.Traits.X != 33f && Game.PlayerStats.Traits.Y != 33f) || !(current is PhysicsObj) || current is HazardObj) && current != this && current.Visible && current.IsCollidable && (current.CollidesTop || current.CollidesLeft || current.CollidesRight) && current.HasTerrainHitBox && (current.CollisionTypeTag == 1 || current.CollisionTypeTag == 10 || current.CollisionTypeTag == 5 || current.CollisionTypeTag == 4) && (!current.CollidesTop || current.CollidesBottom || (base.State != 7 && base.State != 9)) && (!current.CollidesTop || !current.CollidesBottom || current.CollidesLeft || current.CollidesRight)) { HazardObj hazardObj = current as HazardObj; if (current.Rotation == 0f || hazardObj != null) { Rectangle rectangle2 = current.TerrainBounds; if (hazardObj != null) { rectangle2 = current.Bounds; } Vector2 vector = CollisionMath.CalculateMTD(rectangle, rectangle2); Rectangle rectA = new Rectangle(this.TerrainBounds.X, this.TerrainBounds.Y, this.TerrainBounds.Width, this.TerrainBounds.Height); Vector2 intersectionDepth = CollisionMath.GetIntersectionDepth(rectA, rectangle2); Rectangle left = new Rectangle(rectangle.X - 10, rectangle.Y, rectangle.Width + 20, rectangle.Height); Vector2 vector2 = CollisionMath.CalculateMTD(left, rectangle2); if (vector2.X > 0f && current.CollidesRight) { this.m_collidingLeft = true; } if (vector2.X < 0f && current.CollidesLeft) { this.m_collidingRight = true; } Vector2 vector3 = CollisionMath.CalculateMTD(this.TerrainBounds, rectangle2); if (vector3.X > 0f) { this.m_collidingLeftOnly = true; } else if (vector3.X < 0f) { this.m_collidingRightOnly = true; } else if (vector3.Y != 0f) { flag = true; } if (flag) { this.m_collidingRightOnly = (this.m_collidingLeftOnly = false); } if (current.CollidesBottom || Math.Abs(rectangle2.Top - this.TerrainBounds.Bottom) <= 20 || base.AccelerationY >= 1100f) { int num3 = (int)Math.Abs(intersectionDepth.X); int num4 = (int)Math.Abs(intersectionDepth.Y); if ((num3 <= 1 || num3 >= num4) && ((!this.m_isJumping && base.AccelerationY >= 0f) || (this.m_isJumping && base.AccelerationY >= 0f)) && (vector.Y < 0f || (vector.Y == 0f && vector.X != 0f && rectangle2.Top > this.TerrainBounds.Top && current.Y > base.Y))) { int num5 = Math.Abs(rectangle2.Top - this.TerrainBounds.Bottom); if ((float)num5 < num) { physicsObj = current; num = (float)num5; this.m_closestGround = physicsObj; } } } } else if (((!this.m_isJumping && base.AccelerationY >= 0f) || (this.m_isJumping && base.AccelerationY >= 0f)) && !(current is HazardObj)) { Vector2 vector4 = CollisionMath.RotatedRectIntersectsMTD(rectangle, base.Rotation, Vector2.Zero, current.TerrainBounds, current.Rotation, Vector2.Zero); if (vector4.Y < 0f) { float y = vector4.Y; if (y < num2) { physicsObj2 = current; num2 = y; } } } } } if (physicsObj != null && base.State != 9) { if (this.m_dropThroughGroundTimer > 0f && !physicsObj.CollidesBottom && physicsObj.CollidesTop) { this.m_isTouchingGround = false; } else { this.m_isTouchingGround = true; } } if (physicsObj2 != null && base.State != 9) { this.HookToSlope(physicsObj2); this.m_isTouchingGround = true; } if (this.m_isTouchingGround) { if (base.State == 2 || base.State == 7 || base.State == 3) { if (Game.PlayerStats.Traits.X == 6f || Game.PlayerStats.Traits.Y == 6f) { SoundManager.PlaySound("Player_Land_Low"); if (base.AccelerationY > 1400f) { SoundManager.PlaySound("TowerLand"); this.AttachedLevel.ImpactEffectPool.DisplayDustEffect(new Vector2((float)this.TerrainBounds.Left, (float)this.Bounds.Bottom)); this.AttachedLevel.ImpactEffectPool.DisplayDustEffect(new Vector2((float)this.TerrainBounds.X, (float)this.Bounds.Bottom)); this.AttachedLevel.ImpactEffectPool.DisplayDustEffect(new Vector2((float)this.TerrainBounds.Right, (float)this.Bounds.Bottom)); } } if (Game.PlayerStats.Traits.X == 7f || Game.PlayerStats.Traits.Y == 7f) { SoundManager.PlaySound("Player_Land_High"); } else { SoundManager.PlaySound("Player_Land"); } } if (base.State == 3) { this.m_invincibleCounter = (int)(this.InvincibilityTime * 1000f); } if (this.IsAirAttacking) { this.IsAirAttacking = false; this.CancelAttack(); } base.AccelerationX = 0f; this.m_flightCounter = this.TotalFlightTime; if (base.State != 4) { this.m_airDashCount = 0; base.AccelerationYEnabled = true; } this.NumAirBounces = 0; this.m_isFlying = false; base.DisableGravity = false; if (base.State == 8) { base.CurrentSpeed = 0f; } this.m_isJumping = false; this.m_doubleJumpCount = 0; if (base.State != 6 && base.State != 8 && base.State != 4) { base.State = 0; } if (base.State != 6 && base.State != 8 && base.State != 4 && physicsObj != null && !this.ControlsLocked && (((Game.GlobalInput.Pressed(18) || Game.GlobalInput.Pressed(19)) && (Game.GlobalInput.JustPressed(10) || Game.GlobalInput.JustPressed(11))) || (Game.GameConfig.QuickDrop && (Game.GlobalInput.JustPressed(18) || Game.GlobalInput.JustPressed(19)))) && !physicsObj.CollidesBottom && base.State != 8) { base.AccelerationY = 0f; base.Y += 15f; this.m_isTouchingGround = false; this.m_isJumping = true; this.m_dropThroughGroundTimer = this.m_dropThroughGroundDuration; } } }
private void HookToSlope(IPhysicsObj collisionObj) { base.UpdateCollisionBoxes(); Rectangle terrainBounds = this.TerrainBounds; terrainBounds.Height += 100; float num = base.X; if (CollisionMath.RotatedRectIntersectsMTD(terrainBounds, base.Rotation, Vector2.Zero, collisionObj.TerrainBounds, collisionObj.Rotation, Vector2.Zero).Y < 0f) { bool flag = false; Vector2 vector; Vector2 vector2; if (collisionObj.Width > collisionObj.Height) { vector = CollisionMath.UpperLeftCorner(collisionObj.TerrainBounds, collisionObj.Rotation, Vector2.Zero); vector2 = CollisionMath.UpperRightCorner(collisionObj.TerrainBounds, collisionObj.Rotation, Vector2.Zero); if (collisionObj.Rotation > 0f) { num = (float)this.TerrainBounds.Left; } else { num = (float)this.TerrainBounds.Right; } if (num > vector.X && num < vector2.X) { flag = true; } } else if (collisionObj.Rotation > 0f) { vector = CollisionMath.LowerLeftCorner(collisionObj.TerrainBounds, collisionObj.Rotation, Vector2.Zero); vector2 = CollisionMath.UpperLeftCorner(collisionObj.TerrainBounds, collisionObj.Rotation, Vector2.Zero); num = (float)this.TerrainBounds.Right; if (num > vector.X && num < vector2.X) { flag = true; } } else { vector = CollisionMath.UpperRightCorner(collisionObj.TerrainBounds, collisionObj.Rotation, Vector2.Zero); vector2 = CollisionMath.LowerRightCorner(collisionObj.TerrainBounds, collisionObj.Rotation, Vector2.Zero); num = (float)this.TerrainBounds.Left; if (num > vector.X && num < vector2.X) { flag = true; } } if (flag) { float num2 = vector2.X - vector.X; float num3 = vector2.Y - vector.Y; float x = vector.X; float y = vector.Y; float num4 = y + (num - x) * (num3 / num2); num4 -= (float)this.TerrainBounds.Bottom - base.Y - 2f; base.Y = (float)((int)num4); } } }
public override void Dispose() { if (!base.IsDisposed) { if (this.m_currentLogicSet.IsActive) { this.m_currentLogicSet.Stop(); } this.m_currentLogicSet = null; this.m_standingAttack3LogicSet.Dispose(); this.m_standingAttack3LogicSet = null; this.m_airAttackLS.Dispose(); this.m_airAttackLS = null; this.m_debugInputMap.Dispose(); this.m_debugInputMap = null; this.m_playerHead = null; this.m_playerLegs = null; this.m_walkDownSound.Dispose(); this.m_walkDownSound = null; this.m_walkUpSound.Dispose(); this.m_walkUpSound = null; this.m_walkDownSoundLow.Dispose(); this.m_walkDownSoundLow = null; this.m_walkUpSoundLow.Dispose(); this.m_walkUpSoundLow = null; this.m_walkDownSoundHigh.Dispose(); this.m_walkDownSoundHigh = null; this.m_walkUpSoundHigh.Dispose(); this.m_walkUpSoundHigh = null; if (this.m_externalLS != null) { this.m_externalLS.Dispose(); } this.m_externalLS = null; this.m_lastTouchedTeleporter = null; this.m_flightDurationText.Dispose(); this.m_flightDurationText = null; this.m_game = null; this.m_translocatorSprite.Dispose(); this.m_translocatorSprite = null; this.m_swearBubble.Dispose(); this.m_swearBubble = null; this.m_flipTween = null; this.m_wizardSpellList.Clear(); this.m_wizardSpellList = null; this.m_closestGround = null; this.m_rapidDaggerProjData.Dispose(); this.m_axeProjData.Dispose(); base.Dispose(); } }