Exemple #1
0
 public Wizard(TempleQuest game, Player player, int bound1, int bound2, Random random)
 {
     this.game     = game;
     this.bounds.X = bound1;
     this.bounds.Y = bound2;
     this.random   = random;
     fireball      = new Fireball(game, game.graphics, random.NextDouble(), random.NextDouble(), bounds.X, bounds.Y);
 }
Exemple #2
0
        public void Update(GameTime timeSpan)
        {
            float   speed = 500 * (float)timeSpan.ElapsedGameTime.TotalSeconds;
            Vector2 temp  = new Vector2(bounds.X, bounds.Y);

            temp    += speed * (velocity);
            bounds.X = temp.X;
            bounds.Y = temp.Y;

            if (bounds.Y < 0)
            {
                velocity.Y *= -1;
                float delta = 0 - bounds.Y;
                bounds.Y += 2 * delta;
            }

            if (bounds.Y > graphics.PreferredBackBufferHeight - 180)
            {
                velocity.Y *= -1;
                float delta = graphics.PreferredBackBufferHeight - 180 - bounds.Y;
                bounds.Y += 2 * delta;
            }

            if (bounds.X < 0)
            {
                velocity.X *= -1;
                float delta = 0 - bounds.X;
                bounds.X += 2 * delta;
                direction = false;
            }

            if (bounds.X > graphics.PreferredBackBufferWidth - 192)
            {
                velocity.X *= -1;
                float delta = graphics.PreferredBackBufferWidth - 192 - bounds.X;
                bounds.X += 2 * delta;
                direction = true;
            }
            timer += timeSpan.ElapsedGameTime;
            while (timer.TotalMilliseconds > ANIMATION_FRAME_RATE)
            {
                // increase by one frame
                frame++;
                // reduce the timer by one frame duration
                timer -= new TimeSpan(0, 0, 0, 0, ANIMATION_FRAME_RATE);
            }

            // Keep the frame within bounds (there are four frames)
            frame %= 4;

            if (level == 2)
            {
                if (!fireballloaded)
                {
                    fireball = new Fireball(game, game.graphics, random.NextDouble(), random.NextDouble(), bounds.X, bounds.Y);
                    fireball.LoadContent(content);
                    fireballloaded = true;
                }
                fireball.Update(timeSpan);
            }
            if (level == 3)
            {
                if (!fireball2loaded)
                {
                    fireball2 = new Fireball(game, game.graphics, random.NextDouble(), random.NextDouble(), bounds.X, bounds.Y);
                    fireball2.LoadContent(content);
                    fireball2loaded = true;
                }
                fireball.Update(timeSpan);
                fireball2.Update(timeSpan);
            }
        }