コード例 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Width">Unit width of the maze</param>
        /// <param name="Height">Unit height of the maze</param>
        /// <param name="ScaleX">Unit width of maze cell</param>
        /// <param name="ScaleY">Unit height of maze cell</param>
        /// <param name="Seconds">Time required to complete</param>
        public Level(int Width, int Height, int ScaleX, int ScaleY, int Seconds)
        {
            unitWidth  = Width;
            unitHeight = Height;
            cellWidth  = ScaleX;
            cellHeight = ScaleY;
            combo      = 0;
            MaxCombo   = 0;
            discovered = 0;
            death      = 0;
            List <MazeBlock> walkables = new List <MazeBlock>();

            UpdateList = new List <GameObject>();
            UpdateList = new List <GameObject>();
            DrawList   = new List <GameObject>();

            while (walkables.Count() < 1)
            {
                MazeGenerator levelRef = new MazeGenerator(unitWidth, unitHeight, ScaleX, ScaleY);
                walkables   = new List <MazeBlock>();
                UpdateList  = new List <GameObject>();
                radar       = new Radar(levelRef.maze);
                levelWidth  = levelRef.MazeWidth();
                levelHeight = levelRef.MazeHeight();

                foreach (GameObject Obj in levelRef.maze)
                {
                    if (Obj == null)
                    {
                        continue;
                    }
                    MazeBlock temp = Obj as MazeBlock;
                    if (temp.Walkable)
                    {
                        walkables.Add(temp);
                        walkableSpace++;
                        InsertGameObjectDraw(Obj);
                    }
                    InsertGameObject(Obj);
                }
            }

            firstPosition = walkables.ElementAt <MazeBlock>(0).kinetics.position;
            treasure      = new Treasure(walkables.ElementAt <MazeBlock>(walkables.Count - 1));
            InsertGameObject(treasure);
            walkables.RemoveAt(0);

            PlaceEnemies(walkables, 10);
            timeLeft   = new Timer(Seconds, true);
            comboTimer = new Timer(1);
        }