public void CheckForPlatformCollision(IEnumerable <IBoundable> platforms) { Debug.WriteLine($"Checking collisions against {platforms.Count()} platforms"); if (verticalState != VerticalMovementState.Jumping) { verticalState = VerticalMovementState.Falling; foreach (Platform platform in platforms) { if (Bounds.CollidesWith(platform.Bounds)) { Position.Y = platform.Bounds.Y - 1; verticalState = VerticalMovementState.OnGround; } } } }
public int CheckForTokenCollision(IEnumerable <IBoundable> tokens) { int score = 0; Debug.WriteLine($"Checking collisions against {tokens.Count()} tokens"); foreach (Token token in tokens) { if (Bounds.CollidesWith(token.Bounds) && token.Active) { score++; token.Collect(); coinParticles.Emitter = new Vector2(token.Bounds.X + (token.Bounds.Width / 2), token.Bounds.Y + (token.Bounds.Height / 2)); coinParticles.SystemLife = 0.5f; } } return(score); }
public float CheckForPlatformCollision(IEnumerable <IBoundable> platforms, AxisList world, Random random, Sprite pix, float lastPlatfformY) { foreach (Platform platform in platforms) { if (Bounds.CollidesWith(platform.Bounds)) { Position.Y = platform.Bounds.Y - this.Bounds.Height - 21; Velocity.Y = 0; t = 0; isJumping = false; if (!seenPlatforms.ContainsKey(platform.Bounds.X + platform.Bounds.Y)) { seenPlatforms.Add(platform.Bounds.X + platform.Bounds.Y, 1); world.SpawnNewPlatforms(this, random, pix, (List <Platform>)platforms); return(platform.Bounds.Y); // } } } return(lastPlatfformY); // }