예제 #1
0
        public void Update(GameTime gameTime)
        {
            //Do titan spawning
            if (activeTitan == null)
            {
                float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;


                if (titanTimer < titanSpawnTimerMax)
                {
                    titanTimer += elapsed;

                    if (titanTimer >= titanSpawnTimerMax)
                    {
                        if (Game1.RandomObject.Next(0, titanSpawnRate + 1) == 0)
                        {
                            //Spawn a titan
                            switch (Game1.RandomObject.Next(0, numTitans))
                            {
                            //Spawn Tyche, the Sundered
                            case 0:
                                activeTitan = new Titan(Graphics.Titan_Tyche[0], new Vector2(viewport.Bounds.Left - Graphics.Titan_Tyche[0].Width * Game1.PIXEL_SCALE, 50), 0.125f, Graphics.Titan_Tyche, true);
                                break;

                            //Spawn Nemesis, Annihilator
                            case 1:
                                activeTitan = new Titan(Graphics.Titan_Nemesis[0], new Vector2(viewport.Bounds.Right, 50), -1f, Graphics.Titan_Nemesis, false);
                                break;
                            }
                        }

                        titanTimer = 0f;
                    }
                }
            }
            else
            {
                activeTitan.Update(gameTime);

                if (activeTitan.FacingRight && activeTitan.Rect.X > viewport.Bounds.Right)
                {
                    activeTitan = null;
                }
                else if (!activeTitan.FacingRight && activeTitan.Rect.Right > viewport.Bounds.Left)
                {
                    activeTitan = null;
                }
            }
        }
예제 #2
0
 public void Reset()
 {
     activeTitan = null;
     titanTimer  = 0f;
 }