Beispiel #1
0
        public void Update(GameTime gameTime)
        {
            // Update drops
            for (int i = Drops.Count - 1; i >= 0; i--)
            {
                Drop drop = Drops[i];

                // Use map to detect collisions
                drop.DetectCollisions(this);

                // Calc dist from drop tp player
                float distToPlayer = Vector2.Distance(drop.Position, Main.Player.Bounds.Center.ToVector2());

                if (distToPlayer < 2 * Tile.Size)
                {
                    // Pick up
                    Drops.Remove(drop);
                    Main.inventory.AddItems(drop.Type, 1);
                }
                else if (distToPlayer < Player.PickupRange * Tile.Size)
                {
                    // Move drop towards player
                    drop.MoveToPlayer(Main.Player);
                }

                // Will move it
                drop.Update(gameTime);
            }
        }