/// <summary>
        /// Draws all game objects.
        /// </summary>
        /// <param name="gameTime">Time parameters.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            _spriteBatch.Begin();
            _mode.Draw(_spriteBatch);
            _spriteBatch.End();

            base.Draw(gameTime);
        }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        Color[] screenBuf = new Color[64 * 64];
        if (currentMode != null)
        {
            currentMode.Update(Time.deltaTime);

            if (currentMode.IsComplete())
            {
                currentMode = currentMode.GetNextMode();
            }
            else
            {
                currentMode.Draw(screenBuf);
            }

            ScreenBuf.SetPixels(screenBuf);
            ScreenBuf.Apply();
        }
        else
        {
            // walk around city "mode"
            float dt = Time.deltaTime;

            City city = Globals.TheCity;

            city.Update(dt);
            city.portal.Update(dt);
            city.Jack.Update(dt);
            foreach (Beetle b in city.Beetles)
            {
                b.Update(dt);
            }
            foreach (Clue c in city.Clues)
            {
                c.Update(dt);
            }

            Vector2 camPos = city.Jack.Position;
            city.Render(camPos);

            city.portal.Draw(city.Pixels, camPos, city.scale);
            foreach (Beetle b in city.Beetles)
            {
                b.Draw(city.Pixels, camPos, city.scale);
            }
            foreach (Clue c in city.Clues)
            {
                c.Draw(city.Pixels, camPos, city.scale);
            }

            DrawPadlock(city.Pixels);
            city.Jack.Draw(city.Pixels, city.scale);

            ScreenBuf.SetPixels(city.Pixels);
            ScreenBuf.Apply();

            if (Input.GetKeyDown(KeyCode.H))
            {
                Globals.TheCity.Jack.ShowText("CHEAT");
                Globals.TheCity.Jack.hitPoints += 1;
            }

            if (city.portal.myState == Portal.State.Taken)
            {
                Globals.TheMission.stagesComplete += 1;
                if (Globals.TheMission.stagesComplete == 3)
                {
                    List <LineDesc> lines = CharacterTextMode.MakeMissionSuccessDialog();
                    currentMode = new CharacterTextMode(Globals.FontTex, lines);
                }
                else
                {
                    Globals.TheCity = new City();
                    Globals.TheCity.Start(3 + 2 * Globals.TheMission.stagesComplete);
                    List <LineDesc> lines = CharacterTextMode.MakeCitySuccessDialog();
                    currentMode = new CharacterTextMode(Globals.FontTex, lines);
                }
            }

            if (city.Jack.hitPoints == 0)
            {
                List <LineDesc> lines = CharacterTextMode.MakeJackDeathDialog();
                currentMode = new CharacterTextMode(Globals.FontTex, lines);
            }
        }
    }