Esempio n. 1
0
 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;
             }
         }
     }
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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); //
        }