Ejemplo n.º 1
0
        public override void LoadContent(ContentManager contentManager)
        {
            // Font
            font = contentManager.Load <SpriteFont>("Fonts/Joystix_32");

            // create rect texture
            rectTexture = new Texture2D(_graphicsDevice.GraphicsDevice, 1, 1);
            rectTexture.SetData(new[] { Color.White });
            rectOrigin = new Vector2(rectTexture.Height / 2f, rectTexture.Width / 2f);

            // Create text balloon
            balloon = new TextBalloon(_graphicsDevice, font);
            balloon.LoadContent(contentManager);

            // Save content manager for in game initialization
            this.contentManager = contentManager;

            // load sfx
            hitSfx            = contentManager.Load <SoundEffect>("Sounds/hit");
            hitSfxInst        = hitSfx.CreateInstance();
            hitSfxInst.Volume = 0.7f;

            //  Start the first Word
            if (LevelStorage.currentLevel == -1)
            {
                currentLevel = LevelStorage.GetNextLevel();
            }
            else
            {
                currentLevel = LevelStorage.GetCurrentLevel();
            }

            StartLevel(null);
        }
Ejemplo n.º 2
0
        /*
         * EVENTS
         */
        public virtual void HandleEvent(GameTime gameTime)
        {
            // Time frozen with texts
            if (frozen)
            {
                if (balloon.text == "")
                {
                    gameTime.TotalGameTime = TimeSpan.FromSeconds(freezeTime);
                    frozen    = false;
                    nextEvent = currentLevel.GetNextEvent();
                }
                return;
            }

            // End of the level
            if (nextEvent.time == 0 && nextEvent.text == "" &&
                nextEvent.number == 0 && nextEvent.decim == 0)
            {
                if (numbers.Count != 0)
                {
                    return; // wait for all numbers to disapear
                }
                currentLevel = LevelStorage.GetNextLevel();
                // End of the game
                if (currentLevel.word.Equals(""))
                {
                    SetWin();
                    return;
                }
                StartLevel(gameTime);
                return;
            }
            // Handle next event
            if (nextEvent.time <= gameTime.TotalGameTime.TotalSeconds)
            {
                if (nextEvent.text != "")
                {
                    if (numbers.Count != 0)
                    {
                        return;
                    }
                    // Print event
                    balloon.SetText(nextEvent.text);
                    frozen     = true;
                    freezeTime = gameTime.TotalGameTime.TotalSeconds;
                }
                else if (nextEvent.line != 0)
                {
                    // spawn event
                    SpawnNumber(nextEvent.number, nextEvent.decim, nextEvent.speed, nextEvent.line);
                    nextEvent = currentLevel.GetNextEvent();
                }
            }
        }
Ejemplo n.º 3
0
        public override void Initialize()
        {
            // cooldown
            Letter.cooldown = 0.5;
            // Numbers list
            numbers = new List <Number>();
            // Bullets list
            bullets = new List <Bullet>();

            // Load levels only if not already started
            if (!LevelStorage.generated)
            {
                LevelStorage.GenerateLevels();
            }
        }