Exemplo n.º 1
0
        private void DrawCollectibles(LevelProgression levelProgression)
        {
            foreach (KeyValuePair <int, int> csv in collectiblesStateValues.ToList())
            {
                collectiblesStateValues[csv.Key] = csv.Value - 1;
            }

            foreach (Collectible collectible in level.Collectibles)
            {
                int id         = collectible.ID;
                int stateValue = collectibleMaximumValue;

                if (levelProgression.IsCollectibleAlreadyCollected(collectible))
                {
                    if (!collectiblesStateValues.ContainsKey(id))
                    {
                        collectiblesStateValues.Add(id, 60);
                    }

                    stateValue = collectiblesStateValues[id];
                }

                float halfCollectibleWidth = VisualValues.HalfCollectibleWidthHeight * 0.95f;

                float leftX  = collectible.Position.X - halfCollectibleWidth;
                float rightX = collectible.Position.X + halfCollectibleWidth;

                DrawCollectible(collectible, stateValue);
            }
        }
Exemplo n.º 2
0
        /*
         * public bool DoesPlayerCollideWithASolidObstacle(LevelProgression levelProgression)
         * {
         *      return DoesPlayerCollideWithASolidObstacle(levelProgression.CurrentPlayerPosition,
         *              levelProgression.IsPlayerStanding);
         * }
         *
         * private bool DoesPlayerCollideWithASolidObstacle(Vector2 playerPosition, bool isPlayerStanding)
         * {
         *      Hitbox playerHitbox = GetPlayerHitbox(playerPosition, isPlayerStanding);
         *
         *      foreach (Obstacle obstacle in level.SolidObstacles)
         *      {
         *              Hitbox obstacleHitbox = Hitboxes.GetObstacleHitbox(obstacle);
         *
         *              if (playerHitbox.CollidesWith(obstacleHitbox)) return true;
         *      }
         *
         *      return false;
         * }
         */

        public List <Collectible> GetPlayerCollectibleCollisions(LevelProgression levelProgression)
        {
            List <Collectible> collectedCollectibles = new List <Collectible>();

            Hitbox playerHitbox = GetPlayerHitbox(levelProgression.CurrentPlayerPosition, levelProgression.IsPlayerStanding);

            foreach (Collectible collectible in level.Collectibles)
            {
                if (levelProgression.IsCollectibleAlreadyCollected(collectible))
                {
                    continue;
                }

                Hitbox collectibleHitbox = Hitboxes.GetCollectibleHitbox(collectible);

                if (playerHitbox.CollidesWith(collectibleHitbox))
                {
                    collectedCollectibles.Add(collectible);
                }
            }

            return(collectedCollectibles);
        }