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);

            // TODO: use this.Content to load your game content here
            entities = new Entity[population];

            for (int i = 0; i < population-1; i++)
                entities[i] = new Human();

            whiteRectangle = new Texture2D(GraphicsDevice, 1, 1);
            whiteRectangle.SetData(new[] { Color.White });

            //Zombie
            entities[population - 1] = new Zombie();

            redRectangle = new Texture2D(GraphicsDevice, 1, 1);
            redRectangle.SetData(new[] { Color.Red });
        }
Esempio n. 2
0
        /// <summary>
        /// Allows the game to run logic such as updatingmothe world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
                this.Exit();

            //if (gameTime.ElapsedGameTime.Milliseconds % 100 == 0)
            for (int i = 0; i < population; i++)
                entities[i].action();

            for (int i = 0; i < population; i++)
            {
                if (entities[i].GetType() == typeof(Human))
                {
                    foreach (Entity j in entities)
                    {
                        if (j.GetType() == typeof(Zombie) && entities[i].getPos() == j.getPos())
                            entities[i] = new Zombie();
                    }
                }
            }

            //Console.WriteLine(gameTime.ElapsedGameTime.);

            base.Update(gameTime);
        }