예제 #1
0
 public void setBullet(Obstacle obstacle)
 {
     _obstacles.Add(obstacle);
 }
예제 #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            _bullets = new List<Bullet>();
            _obstacles = new List<Obstacle>();
            enemy = new Enemy(new Vector3(0, -3f, -30));
            plyr = new Player(new Vector3(0, 0, 120));
            radar = new Radar();

            //obstacles spawn in random locations
            Random rand = new Random();
#if (!DEBUG_PATHS || !DEBUG )
            for (int num = 0; num < 50; num++)
            {
               
                int x = rand.Next(-300, 500);
                int z = rand.Next(-300, 500);
                
                //draw obstacle if it does not spawn on an enemy or the player
                Obstacle tempObstacle = (new Obstacle(new Vector3(x, 0, z)));
                tempObstacle.LoadContent();
                if (!tempObstacle.collidesWith(enemy.getBoundingSphere(), enemy.getWorld()) && !tempObstacle.collidesWith(plyr.getBoundingSphere(), plyr.getWorld()))
                {
                    _obstacles.Add(tempObstacle);
                }
            }
#else
            Obstacle tmp = new Obstacle(new Vector3(7,0,-65));
            _obstacles.Add(tmp);
#endif

#if DEBUG
            currentState = ScreenState.Play;
#else
            currentState = ScreenState.Start;
#endif
            lastKeyState = Keyboard.GetState();
            lastpadState = GamePad.GetState(PlayerIndex.One);
            base.Initialize();
        }