Ejemplo n.º 1
0
        /// <summary>
        /// Constructs a new gem.
        /// </summary>
        public Gem(Level level, Vector2 position)
        {
            this.level = level;
            this.basePosition = position;

            LoadContent();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructors a new player.
        /// </summary>
        public Player(Level level, Vector2 position)
        {
            this.level = level;

            LoadContent();

            Reset(position);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructs a new Enemy.
        /// </summary>
        public Enemy(Level level, Vector2 position, string spriteSet)
        {
            this.level = level;
            this.position = position;
            this.IsAlive = true;

            LoadContent(spriteSet);
        }
Ejemplo n.º 4
0
        /// <summary>      
        /// Constructor      
        /// </summary>      
        /// <param name="level">The level this platform belongs to.</param>      
        /// <param name="position">Where the platform is in the level.</param>      
        /// <param name="faceDirection">The direction it is moving.</param>      
        /// <param name="moveSpeed">How fast it is moving.</param>      
        /// <param name="maxWaitTime">How long it will wait before turning around.</param>      
        public GlidingPlatform(Level level, Vector2 position, FaceDirection faceDirection,
            float moveSpeed, float maxWaitTime, TileMovement glidermovement, string name)
        {
            this.level = level;                 //We need to know what level the platform is in.
            Position = position;                //We need to know its position in that level.
            this.direction = faceDirection;     //We need to know what direction it will be moving.
            this.moveSpeed = moveSpeed;         //We need to know how fast it moves.
            this.maxWaitTime = maxWaitTime;     //We need to know how long it waits before changing directions.
            this.glidermovement = glidermovement;
            this.name = name;
            //Equiped with these different fields, we can create a variety of glidingPlatforms with minimal effort.
            //We can create slow platforms, fast platforms, and platforms moving different directions.

            LoadContent();
        }
Ejemplo n.º 5
0
        private void LoadNextLevel()
        {
            // Find the path of the next level.
            string levelPath;

            // Loop here so we can try again when we can't find a level.
            while (true)
            {
                // Try to find the next level. They are sequentially numbered txt files.
                levelPath = String.Format("Levels/{0}.txt", ++levelIndex);
                levelPath = Path.Combine(StorageContainer.TitleLocation, "Content/" + levelPath);
                if (File.Exists(levelPath))
                    break;

                // If there isn't even a level 0, something has gone wrong.
                if (levelIndex == 0)
                    throw new Exception("No levels found.");

                // Whenever we can't find a level, start over again at 0.
                levelIndex = -1;
            }

            // Unloads the content for the current level before loading the next one.
            if (level != null)
                level.Dispose();

            // Load the level.
            level = new Level(Services, levelPath);
        }