Esempio n. 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            AudioController.LoadContent(Content);

            gameMap = Content.Load <Map>("testmap");

            enemyManager.LoadContent(Content, GraphicsDevice);
            itemManager.LoadContent(Content, GraphicsDevice);
            projectileManager.LoadContent(Content);
            particleManager.LoadContent(Content);
            gameHud = new HUD(GraphicsDevice.Viewport);
            gameHud.LoadContent(Content);

            parallaxManager = new ParallaxManager(GraphicsDevice.Viewport);
            parallaxManager.Layers.Add(new ParallaxLayer(Content.Load <Texture2D>("bg/bg0"), new Vector2(0, 0), 0.25f, false, Color.White * 0.75f));
            parallaxManager.Layers.Add(new ParallaxLayer(Content.Load <Texture2D>("bg/bg1"), new Vector2(0, 0), 0.15f, false, Color.White * 0.75f));

            for (int i = 0; i < NUM_SECTORS; i++)
            {
                WalkableLayers.Add(i, gameMap.GetLayer("Walkable" + i) as MapObjectLayer);
            }

            gameHero = new Robot(Helper.PtoV((gameMap.GetLayer("Spawn") as MapObjectLayer).Objects[0].Location.Center), true);
            gameHero.LoadContent(Content, GraphicsDevice);

            gameCamera = new Camera(GraphicsDevice.Viewport, gameMap);

            skyTex   = Content.Load <Texture2D>("sky");
            titleTex = Content.Load <Texture2D>("title");

            font = Content.Load <SpriteFont>("font");

            ResetGame();

            currentSectorColor = sectorColors[0];

            showingTitleScreen = true;
        }
Esempio n. 2
0
        public int Spawn(Map gameMap, Camera gameCamera, List<int> levelSectors, Robot gameHero)
        {
            int numSpawned = 0;
            // Left or right side?

            bool weaponspawned = false;

            for (int num = 0; num < 1 + rand.Next(gameHero.Sector+2); num++)
            {
                if (numSpawned > largestNumberSpawned) break;

                int side = rand.Next(2);
                if (side == 0) side = -1;

                // Actual X spawn position
                Vector2 spawnPos = new Vector2(gameCamera.Position.X + (((gameCamera.Width / 2) + 50f + ((float)rand.NextDouble() * 100f)) * side), gameCamera.Position.Y - (gameCamera.Width / 2));

                // Detect a Y position
                bool spawned = false;
                for (float y = spawnPos.Y; y < spawnPos.Y + gameCamera.Height; y += 15f)
                {
                    if (!spawned)
                    {
                        for (int i = 0; i < levelSectors.Count; i++)
                        {
                            MapObjectLayer walkableLayer = gameMap.GetLayer("Walkable" + levelSectors[i].ToString()) as MapObjectLayer;
                            foreach (MapObject o in walkableLayer.Objects)
                            {
                                if (!spawned && Helper.IsPointInShape(new Vector2(spawnPos.X - ((gameMap.Width * gameMap.TileWidth) * i), y), o.LinePoints))
                                {
                                    if (rand.Next(3) == 1)
                                    {
                                        numSpawned++;
                                        spawned = true;

                                        Robot r = new Robot(new Vector2(spawnPos.X, y), false);

                                        if ((rand.Next(5) == 0 || spawnsWithoutWeapon == 3) && !weaponspawned)
                                        {
                                            spawnsWithoutWeapon = 0;
                                            ItemManager.Instance.Spawn(r);
                                            weaponspawned = true;
                                        }
                                        else spawnsWithoutWeapon++;

                                        r.LoadContent(skeletonRenderer, blankTex, AtlasDict["robo"], JsonDict["robo"]);
                                        Enemies.Add(r);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (numSpawned > largestNumberSpawned) largestNumberSpawned = numSpawned;

            return numSpawned;
        }
Esempio n. 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            AudioController.LoadContent(Content);

            gameMap = Content.Load<Map>("testmap");

            enemyManager.LoadContent(Content, GraphicsDevice);
            itemManager.LoadContent(Content, GraphicsDevice);
            projectileManager.LoadContent(Content);
            particleManager.LoadContent(Content);
            gameHud = new HUD(GraphicsDevice.Viewport);
            gameHud.LoadContent(Content);

            parallaxManager = new ParallaxManager(GraphicsDevice.Viewport);
            parallaxManager.Layers.Add(new ParallaxLayer(Content.Load<Texture2D>("bg/bg0"), new Vector2(0, 0), 0.25f, false, Color.White * 0.75f));
            parallaxManager.Layers.Add(new ParallaxLayer(Content.Load<Texture2D>("bg/bg1"), new Vector2(0, 0), 0.15f, false, Color.White * 0.75f));

            for (int i = 0; i < NUM_SECTORS; i++)
            {
                WalkableLayers.Add(i, gameMap.GetLayer("Walkable" + i) as MapObjectLayer);
            }

            gameHero = new Robot(Helper.PtoV((gameMap.GetLayer("Spawn") as MapObjectLayer).Objects[0].Location.Center), true);
            gameHero.LoadContent(Content, GraphicsDevice);

            gameCamera = new Camera(GraphicsDevice.Viewport, gameMap);

            skyTex = Content.Load<Texture2D>("sky");
            titleTex = Content.Load<Texture2D>("title");

            font = Content.Load<SpriteFont>("font");

            ResetGame();

            currentSectorColor = sectorColors[0];

            showingTitleScreen = true;
        }
Esempio n. 4
0
        public int Spawn(Map gameMap, Camera gameCamera, List <int> levelSectors, Robot gameHero)
        {
            int numSpawned = 0;
            // Left or right side?

            bool weaponspawned = false;

            for (int num = 0; num < 1 + rand.Next(gameHero.Sector + 2); num++)
            {
                if (numSpawned > largestNumberSpawned)
                {
                    break;
                }

                int side = rand.Next(2);
                if (side == 0)
                {
                    side = -1;
                }

                // Actual X spawn position
                Vector2 spawnPos = new Vector2(gameCamera.Position.X + (((gameCamera.Width / 2) + 50f + ((float)rand.NextDouble() * 100f)) * side), gameCamera.Position.Y - (gameCamera.Width / 2));

                // Detect a Y position
                bool spawned = false;
                for (float y = spawnPos.Y; y < spawnPos.Y + gameCamera.Height; y += 15f)
                {
                    if (!spawned)
                    {
                        for (int i = 0; i < levelSectors.Count; i++)
                        {
                            MapObjectLayer walkableLayer = gameMap.GetLayer("Walkable" + levelSectors[i].ToString()) as MapObjectLayer;
                            foreach (MapObject o in walkableLayer.Objects)
                            {
                                if (!spawned && Helper.IsPointInShape(new Vector2(spawnPos.X - ((gameMap.Width * gameMap.TileWidth) * i), y), o.LinePoints))
                                {
                                    if (rand.Next(3) == 1)
                                    {
                                        numSpawned++;
                                        spawned = true;

                                        Robot r = new Robot(new Vector2(spawnPos.X, y), false);

                                        if ((rand.Next(5) == 0 || spawnsWithoutWeapon == 3) && !weaponspawned)
                                        {
                                            spawnsWithoutWeapon = 0;
                                            ItemManager.Instance.Spawn(r);
                                            weaponspawned = true;
                                        }
                                        else
                                        {
                                            spawnsWithoutWeapon++;
                                        }

                                        r.LoadContent(skeletonRenderer, blankTex, AtlasDict["robo"], JsonDict["robo"]);
                                        Enemies.Add(r);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (numSpawned > largestNumberSpawned)
            {
                largestNumberSpawned = numSpawned;
            }

            return(numSpawned);
        }