Пример #1
0
 /// <summary>
 /// grabs the unique instance of ItemManager
 /// </summary>
 public static ItemManager GetInstance()
 {
     if (uniqueInstance == null)
     {
         uniqueInstance = new ItemManager();
     }
     return uniqueInstance;
 }
Пример #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            Console.WriteLine("Choose what to test");
            Console.WriteLine("-------------------");
            Console.WriteLine("0. None");
            Console.WriteLine("1. Item branch");
            Console.WriteLine("2. Player branch");
            Console.WriteLine("3. Level branch");
            Console.WriteLine("4. Engine branch");
            Console.WriteLine("5. Enemy branch");
            Console.WriteLine("-------------------");
            //String choice = Console.ReadLine();
            String choice = "4";

            Vector2 screenSize = new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            if (choice.Equals("1"))
            {
                Dictionary<String, Item> possibleItems = new Dictionary<String, Item>();
                itemManager = new ItemManagerTest(this, possibleItems);
            }
            else
            {
                Dictionary<String, Item> possibleItems = new Dictionary<String, Item>();
                possibleItems.Add("healthPotion", new Item("healthPotion", null, false, Content.Load<Texture2D>("healthpotion"), 32, 32, new Vector2(0, 0), screenSize));
                possibleItems.Add("drugPotion", new Item("drugPotion", null, false, Content.Load<Texture2D>("drugpotion"), 32, 32, new Vector2(0,0), screenSize));
                // add stuff here
                itemManager = new ItemManager(this, possibleItems);
            }

            if (choice.Equals("2"))
            {
                Console.WriteLine("Testing player");
                player = new PlayerTest(Content.Load<Texture2D>("player"), 32, 32, new Vector2(32,32), screenSize, this);
            }
            else
            {

                player = new Player(Content.Load<Texture2D>("player"), 32, 32, new Vector2(48, 48), screenSize, this);
            }

            if (choice.Equals("3"))
            {
                Dictionary<String, Block> possibleBlocks = new Dictionary<String, Block>();
                level = new LevelTest(this, possibleBlocks);

            }
            else
            {
                Dictionary<String, Block> possibleBlocks = new Dictionary<String, Block>();
                level = new Level(this, possibleBlocks);
            }

            if (choice.Equals("4"))
            {
                engine = new EngineTest(this);
            }
            else
            {
                engine = new Engine(this);
            }

            if (choice.Equals("5"))
            {
                //enemyManager = new TestEnemyManager(this);
            }
            else
            {
                //enemyManager = new EnemyManager(this);
            }

            base.Initialize();
        }