Пример #1
0
        public Bonus(Texture2D inputTexture)
        {
            state = Bonusstate.Traverse;

            bonusTexture = inputTexture;

            bonus = new Rectangle(0, 0, 49, 49);

            color = Color.White;
            effects = SpriteEffects.None;

            velocity = 4;
            scale = 1;

            bonusPosition = new Vector2(0 - bonus.Width, Helper.Rng(Game.HEIGHT - bonus.Height));
            rotationOffset = new Vector2(24.5F, 24.5F);

            // Animation timer.
            scaleTimer = new Stopwatch();
            scaleTimer.Start();
            // Respawn timer.
            halt = new Stopwatch();

            if (Game.DEBUG)
            {
                dString1 = dString2 = "";
                dPosition1 = dPosition2 = new Vector2(0, 0);
            }
        }
Пример #2
0
        private void Halt()
        {
            if (!halt.IsRunning)
                halt.Start();

            if (Helper.Rng(31337) % 2 == 0)
                type = Bonustype.Nuke;
            else
                type = Bonustype.Life;

            bonusPosition.X = Game.WIDTH + bonus.Width;
            bonusPosition.Y = Helper.Rng(Game.HEIGHT - bonus.Height);

            haltDuration = Helper.Rng2(10000,20000);

            // Check if it needs to be drawn.
            if (halt.ElapsedMilliseconds > haltDuration)
            {
                state = Bonusstate.Traverse;
                halt.Reset();
            }
        }
Пример #3
0
        private void Traverse()
        {
            Animate();

            if (Game.DEBUG)
            {
                dString1 = "Type: " + type;
                dString2 = "X: " + bonusPosition.X + " " + "Y: " + bonusPosition.Y;

                dPosition1 = new Vector2(bonusPosition.X + bonus.Width - 20, bonusPosition.Y - 22);
                dPosition2 = new Vector2(bonusPosition.X + bonus.Width - 20, bonusPosition.Y - 7);
            }

            // Traverse left.
            bonusPosition.X -= velocity;

            // Check if it needs to be drawn.
            if (bonusPosition.X + bonus.Width < 0)
                state = Bonusstate.Halted;
        }
Пример #4
0
 public void State(int newState)
 {
     if (newState == 1)
         state = Bonusstate.Traverse;
     if (newState == 2)
         state = Bonusstate.Halted;
 }