Exemple #1
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);

            parallax.Update(deltaTime);
            deltaTimes = deltaTime;
            time      += deltaTime;
            // Make it shoot the bullets from the ai at the player
            if (time >= 1.5)
            {
                if (tank2.tankObject != null && tank2.ammo > 0)
                {
                    Bullet bullet = new Bullet();
                    bullet.SetUpAI(tank2, tank);
                    bullets2.AddObject(bullet);
                    tank2.ammo -= 1;
                }
                time = 0;
            }

            // End Of Test

            if (tank2.tankObject != null)
            {
                bullets2.Update(deltaTime);
                tank2.MoveAI(deltaTime, tank, ammoBox);
                bullets2.Update(deltaTime);
                bullets2.Des(ref tank);
                if (ammoBox.IsOnAmmo(tank2.collider))
                {
                    tank2.ammo += ammoBox.ammo;
                    ammoBox     = new AmmoBox(1, 30);
                    ammoBox.Inits();
                }
            }
            else
            {
                if (!explodedTank2 && !tankAni.isActive)

                {
                    // Loads win level
                    if (aniTime >= 1)
                    {
                        ChangeLevel("02");
                    }
                    else
                    {
                        aniTime += deltaTime;
                    }
                }
                if (tankAni.isActive)
                {
                    explodedTank2 = true;
                }
            }
            if (tank.tankObject != null)
            {
                tank.Move(deltaTime);

                bullets.Des(ref tank2);
                bullets.Update(deltaTime);
                if (ammoBox.IsOnAmmo(tank.collider))
                {
                    tank.ammo += ammoBox.ammo;
                    ammoBox    = new AmmoBox(1, 30);
                    ammoBox.Inits();
                }
            }
            else
            {
                if (!explodedTank && !tankAni.isActive)
                {
                    // Loads win level
                    if (aniTime >= 1)
                    {
                        ChangeLevel("lose");
                    }
                    else
                    {
                        aniTime += deltaTime;
                    }
                }
                if (tankAni.isActive)
                {
                    explodedTank = true;
                }
            }
            if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON) && !tank.stopTank)
            {
                if (tank.tankObject != null && tank.ammo > 0)
                {
                    Bullet bullet = new Bullet();

                    bullet.SetUp(tank);
                    bullets.AddObject(bullet);
                    tank.ammo -= 1;
                }
            }
        }