Ejemplo n.º 1
0
        public void constructEnemies(int counter, Maps maps)
        {
            enemies = new List<Enemy>();
            for (int i = 0; i < maps.maps[counter].Enemies.Count; i++)
            {
                Enemy temp = new Enemy(maps.maps[counter].Enemies[i].id, "Object",
                    maps.maps[counter].Enemies[i].XLoc, maps.maps[counter].Enemies[i].YLoc,
                    maps.maps[counter].Enemies[i].Width, maps.maps[counter].Enemies[i].Height,
                    maps.maps[counter].Enemies[i].Horizontal, maps.maps[counter].Enemies[i].Left,
                    maps.maps[counter].Enemies[i].Up, maps.maps[counter].Enemies[i].Speed);
                if (temp._horizontal)
                {
                    if (temp._left)
                    {
                        temp.direction = Direction.LEFT;
                    }
                    else
                    {
                        temp.direction = Direction.RIGHT;
                    }
                }
                else
                {
                    if (temp._up)
                    {
                        temp.direction = Direction.UP;
                    }
                    else
                    {
                        temp.direction = Direction.DOWN;
                    }
                }

                enemies.Add(temp);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // initialise sound for camera
            wallCollisionAudio = Content.Load<SoundEffect>("Sounds/wallcollision_sound");
            leftFootStepSound = Content.Load<SoundEffect>("Sounds/leftfootstep_sound");
            rightFootStepSound = Content.Load<SoundEffect>("Sounds/rightfootstep_sound");

            // Setup camera
            camera = new Camera(
                new Vector3(0.5f, 0.5f, 0.5f),
                0,
                GraphicsDevice.Viewport.AspectRatio,
                0.05f,
                100f, wallCollisionAudio,
                leftFootStepSound,
                rightFootStepSound);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch( GraphicsDevice );

            // Load shader and set defaults
            effect = Content.Load<Effect>("shader");
            effect.Parameters["material"].StructureMembers["ambient"].SetValue(new Vector4(0.65f, 0.65f, 0.6f, 1.0f));
            effect.Parameters["fog"].StructureMembers["FogEnabled"].SetValue(false);
            effect.Parameters["light"].StructureMembers["radius"].SetValue(0.1f);

            // Load sound effects
            wallCollisionAudio = Content.Load<SoundEffect>("Sounds/wallcollision_sound");
            leftFootStepSound = Content.Load<SoundEffect>("Sounds/leftfootstep_sound");
            rightFootStepSound = Content.Load<SoundEffect>("Sounds/rightfootstep_sound");

            musicDay = Content.Load<SoundEffect>("Sounds/medievil_music");
            musicNight = Content.Load<SoundEffect>("Sounds/medievil_music2");
            currentMusic = musicDay.CreateInstance();
            currentMusic.Volume = 1f;
            currentMusic.IsLooped = true;
            music = true;

            maze.LoadContent(Content);

            // Setup camera
            camera = new Camera(
                new Vector3(0.5f, 0.5f, 0.5f),
                0,
                GraphicsDevice.Viewport.AspectRatio,
                0.05f,
                100f,
                wallCollisionAudio,
                leftFootStepSound,
                rightFootStepSound);

            enemy = new Enemy(this, GraphicsDevice,
                Content.Load<Model>("enemy"),
                new Vector3(2.5f, 0, 2.5f),
                leftFootStepSound,
                rightFootStepSound);
            enemy.Apply3DAudio(listener, enemy.Position, currentMusic);
            currentMusic.Play();
        }