Пример #1
0
 public MapInitializer()
 {
     mapDBController = new MapsDBController();
     mapID = 0;
     difficulty = 0;
     startingResources = 0;
     startingLives = 0;
     mapTiles = new TileType[GRID_WIDTH, GRID_HEIGHT];
     strat = null;
     map = null;
 }
Пример #2
0
        /// <summary>
        /// Sets up the game map with all the map components
        /// </summary>
        /// <param name="diff">The maps difficulty</param>
        /// <param name="ID">The maps ID</param>
        /// <param name="type">The game type</param>
        /// <param name="startRes">The amount of starting resources</param>
        /// <param name="startLives">The amount of starting lives</param>
        /// <param name="mapSet">The array of tiles that are the map</param>
        /// <param name="strat">The strategy to be used to determine the total score calculation and win condition</param>
        public void Initialize(int diff, int ID, int type, int startRes, int startLives, TileType[,] mapTiles, AbstractGameStrategy strat)
        {
            difficulty = diff;
            mapID = ID;

            if (mapID == 0)
                highscore_controller = null;
            else
                highscore_controller = new HighScoresDBController();

            gameType = type;
            map = mapTiles;

            score = GameScore.GetInstance();
            score.Initialize(startingLives, startingResources, strat);
        }
Пример #3
0
 /// <summary>
 /// Initializes GameScore object with the starting values for the game as 
 /// well as the functions to calculate total score to check for the win condition
 /// </summary>
 /// <param name="lives">The amount of lives the player will start with</param>
 /// <param name="res">The amount of resources the player will start with</param>
 /// <param name="strat">The strategy to be used to calculate score and check for the win condition</param>
 public void Initialize(int lives, int res, AbstractGameStrategy strat)
 {
     livesRemaining = lives;
     resources = res;
     WinCheck = strat.GameWon;
     wavesCompleted = 1;
     TotalScoreCalc = strat.CalcTotalScore;
 }
Пример #4
0
        /// <summary>
        /// Sets the game type
        /// </summary>
        /// <param name="type">The game type</param>
        /// <param name="endRes">The amount of ending resources</param>
        /// <param name="endTime">The ending time</param>
        public bool SetGameType(int type, int endRes, long endTime)
        {
            gameType = type;
            bool success = false;

            switch (gameType)
            {
                case 1:
                    strat = new EndlessGameStrategy();
                    success = true;

                    break;
                case 2:
                    strat = new TimedGameStrategy(endTime);

                    if (endTime <= 0)
                    {
                        GeneralLogger.GetInstance().AddError("You must enter a valid time");
                    }
                    else
                        success = true;

                    break;
                case 3:
                    strat = new CollectXResourcesStrategy(endRes);

                    if (endRes <= startingResources)
                    {
                        GeneralLogger.GetInstance().AddError("Ending resources cannot be less than the starting resources for the map");
                    }
                    else
                        success = true;

                    break;
            }

            return success;
        }