using System;
using System.IO;
using System.Drawing;
using System.Xml.Serialization;
using System.Collections;

using Icarus.Graphics.Animation;
using Icarus.Logic.GameEngine;
using Icarus.Logic.Physics;

namespace Icarus.Logic {
    /// <summary>
    /// Contains the necessary items used to describe a Game level.
    /// Holds the information about the current list of WorldObjects,
    /// the view background, the view terrain collision mask, and
    /// other necessary information used to play the game level.
    /// </summary>
    public class Level 
    {
    
        #region Instance Variables
        
        /// <summary>
        /// An array of all the stages this level contains.
        /// </summary>
        private Stage[] stages = null;

        /// <summary>
        /// The index of the current stage
        /// </summary>
        private int iCurrStageIndex = 0;

        #endregion
    
        #region Initialization
        /* -------------- */
        /* Initialization */
        /* -------------- */

        /// <summary>
        /// Makes a new level.
        /// </summary>
        public Level() 
        {
            stages = new Stage[GameSettings.Instance.sv_maxStages];

        }

        #endregion

        #region Acessing/Modifying
        
        /// <summary>
        /// The array of stages that belong to this level
        /// </summary>
        public Stage[] Stages
        {
            get { return this.stages; }
            set { this.stages = value; }
        }

        /// <summary>
        /// The current stage of this level
        /// </summary>
        [XmlIgnore]
        public Stage CurrStage
        {
            get { return this.stages[this.iCurrStageIndex]; }
            set  
            {
                for(int i = 0; i < GameSettings.Instance.sv_maxStages; i++)
                {
                    if(value.Equals(this.stages[i]))
                    {
                        //set the index for the stage that was passed in
                        this.CurrentStageIndex = i;
                        break;
                    }
                }
            }
        }

        /// <summary>
        /// The index of the current stage in the stages array
        /// </summary>
        public int CurrentStageIndex
        {
            get { return this.iCurrStageIndex; }
            set { this.iCurrStageIndex = value; }
        }


        #endregion
            
    }
}














