private void SpawnFace() { bool nearPlayer = true; int x = 0; int y = 0; while (nearPlayer) { x = ZombieRandom.Next(Game1.GameWidth); y = ZombieRandom.Next(Game1.GameHeight); //don't spawn near player Vector2 distanceFromPlayer = new Vector2(x - m_Player.Position.X, y - m_Player.Position.Y); if (distanceFromPlayer.LengthSquared() >= (150.0f * 150f)) { nearPlayer = false; } } Anubis z = new Anubis(); Vector2 temp = new Vector2(); temp.X = x; temp.Y = y; z.Position = temp; z.LoadContent(m_World); ObjectManager.AllGameObjects.Add(z); }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { if (content == null) { content = ScreenManager.Game.Content; } //gameFont = content.Load<SpriteFont>("GSMgamefont"); m_World = new World(new Vector2(0, 0)); ConvertUnits.SetDisplayUnitToSimUnitRatio(5); Player p = Player.Load(content); if (p == null) { Vector2 playerPosition = new Vector2(Game1.GameWidth / 2, Game1.GameHeight / 2); m_Player.Init(content, playerPosition); } else { m_Player = p; } //init object manager and set objects for it GlobalObjectManager.Init(m_Player, content, m_World); TextureBank.SetContentManager(content); SoundBank.SetContentManager(content); m_Player.LoadContent(m_World); UserInterface.LoadContent(content, Game1.GameWidth, Game1.GameHeight); GlobalObjectManager.LoadContent(); m_song = SoundBank.GetSong("PUNCHING-Edit"); UserInterface.SetTimeToDeath(m_Player.TimeToDeath); Zombie.LoadTextures(); Slime.LoadTextures(); Anubis.LoadTextures(); Viewport viewport = ScreenManager.GraphicsDevice.Viewport; backgroundTexture = new RenderTarget2D(ScreenManager.GraphicsDevice, viewport.Width, viewport.Height, false, SurfaceFormat.Color, DepthFormat.None, ScreenManager.GraphicsDevice.PresentationParameters.MultiSampleCount, RenderTargetUsage.PreserveContents); SpriteBatch spriteBatch = ScreenManager.SpriteBatch; GraphicsDevice device = ScreenManager.GraphicsDevice; device.SetRenderTarget(backgroundTexture); spriteBatch.Begin(); UserInterface.DrawBackground(spriteBatch); spriteBatch.End(); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); m_World.Step(0f); isLoaded = true; }