Exemple #1
0
        public RedHead(Game game, Vector3 pos, Level l)
            : base(game, pos, l)
        {
            //Parameters for this specific enemy
            life = 5;
            textures = new Texture2D[life];
            Damage = 5;
            this.level = l;
            this.position = pos;
            RotationSpeed = 0.1f;
            ForwardSpeed = 6f;
            boxMin = new Vector3(-0.235f, 0, -0.235f);
            boxMax = new Vector3(0.235f, 0.8f, 0.235f);
            boundingBox = new BoundingBox(position + boxMin, position + boxMax);
            //Different textures for each life count
            textures[4] = ContentPreImporter.GetTexture("RedHead");
            textures[3] = ContentPreImporter.GetTexture("RedHead4");
            textures[2] = ContentPreImporter.GetTexture("RedHead3");
            textures[1] = ContentPreImporter.GetTexture("RedHead2");
            textures[0] = ContentPreImporter.GetTexture("RedHead1");
            hurtSound = ContentPreImporter.GetSound("enemyHurt");

            billboard = new Billboard(game, textures[life - 1], Vector2.One / 2);
            billboard.Move(position + new Vector3(0, 0.25f, 0));
            billboard.ForceUpdate();
            target = pos;
            //Set new values for the fog if required
            billboard.OverrideFog(GlobalSettings.FogEnabled, GlobalSettings.FogColor, GlobalSettings.FogStart, GlobalSettings.FogEnd * 2.1f);
        }
Exemple #2
0
        public Enemy(Game game, Vector3 pos, Level l)
            : base(game)
        {
            this.level = l;
            this.position = pos;

            boxMin = new Vector3(-0.235f, 0, -0.235f);
            boxMax = new Vector3(0.235f, 0.8f, 0.235f);
            boundingBox = new BoundingBox(position + boxMin, position + boxMax);
        }
Exemple #3
0
        public GameLevel(Game game, GamePlayState gameState, string levenName)
            : base(game)
        {
            this.gameState = gameState;
            levelRaw = ContentPreImporter.GetLevel(levenName);
            levelRend = new LevelRenderer(game, levelRaw);
            levelCollisions = new LevelCollisions(game, levelRaw);
            font = ContentPreImporter.GetFont("TextFont");

            Vector3 playerPos = Vector3.Zero;
            int enemyFound = 0;
            //Build the game level creating the enemies, player and pickups
            for (int y = 0; y < levelRaw.Depth; y++)
            {
                for (int x = 0; x < levelRaw.Width; x++)
                {
                    if (levelRaw.GetAt(x, y).ToString().ToLower() == "p")
                        player = new Player(game, new Vector3(x, 0, y));
                    else if (levelRaw.GetAt(x, y).ToString().ToLower() == "e")
                    {
                        //Depending on the difficulty only add certain enemies
                        enemyFound++;
                        if ((enemyFound % GlobalSettings.EnemyFrequency) == 0)
                        {
                            objects.Add(new RedHead(game, new Vector3(x, 0, y), levelRaw));
                            enemies++;
                        }
                    }
                    else if (levelRaw.GetAt(x, y).ToString().ToLower() == "g")
                    {
                        enemyFound++;
                        if ((enemyFound % GlobalSettings.EnemyFrequency) == 0)
                        {
                            objects.Add(new GreenGhost(game, new Vector3(x, 0, y), levelRaw));
                            enemies++;
                        }
                    }
                    else if (levelRaw.GetAt(x, y).ToString().ToLower() == "h")
                    {
                        objects.Add(new Health(game, new Vector3(x, 0, y)));
                    }
                }
            }

            skybox = new Skybox(Game, 50, ContentPreImporter.GetTexture("grimmnight_small"));
            //Corner of the box if front left, so to place player in right place we need to add .5 to the left and .5 to the front
            objects.Add(player);
            // TODO: Construct any child components here
        }
Exemple #4
0
 public LevelRenderer(Game game, Level levFile)
     : base(game)
 {
     level = levFile;
     //Textures for the different surfaces
     brickTexture = ContentPreImporter.GetTexture("bricks");
     floorTexture = ContentPreImporter.GetTexture("floor");
     ceilingTexture = ContentPreImporter.GetTexture("ceiling");
     effect = new BasicEffect(Game.GraphicsDevice);
     //Enable fog if required
     effect.FogEnabled = GlobalSettings.FogEnabled;
     effect.FogColor = GlobalSettings.FogColor;
     effect.FogStart = GlobalSettings.FogStart;
     effect.FogEnd = GlobalSettings.FogEnd;
 }
 public LevelCollisions(Game game, Level lev)
     : base(game)
 {
     level = lev;
     //Add a collision box for each wall
     for (int y = 0; y < level.Depth; y++)
     {
         for (int x = 0; x < level.Width; x++)
         {
             if (level.GetAt(x, y) == '#')
             {
                 levelBoxes.Add(new BoundingBox(
                         new Vector3(0.0f + x - 0.5f, 0.0f, 0.0f + y - 0.5f),
                         new Vector3(1.0f + x - 0.5f, 1.0f, 1.0f + y - 0.5f)
                     ));
             }
         }
     }
 }