setNegativeButton() public method

public setNegativeButton ( int arg0, global arg1 ) : android.app.AlertDialog.Builder
arg0 int
arg1 global
return android.app.AlertDialog.Builder
Exemplo n.º 1
0
        void ProcessCollisions()
        {
            bool gameOver = false;
            int ai = 0;
            // check which asteroids are colliding with bullets
            while (ai < myAsteroids.Count)
            {
                Asteroid asteroid = myAsteroids[ai];
                int asteroidRadiusSquare = 16 * (1 << asteroid.Size);
                asteroidRadiusSquare *= asteroidRadiusSquare;
                bool collisionFound = false;
                for (int bi = 0; bi < myBullets.Count; bi++)
                {
                    PhysicsObject bullet = myBullets[bi];
                    Vector4f v = bullet.Location - asteroid.PhysicsObject.Location;
                    if (v.LengthSquare < asteroidRadiusSquare)
                    {
                        // remove the asteroid and bullet
                        collisionFound = true;
                        myAsteroids.RemoveAt(ai);
                        myBullets.RemoveAt(bi);

                        // split the asteroid into two if it's not tiny
                        if (asteroid.Size > 0)
                        {
                            Asteroid one = CreateAsteroid();
                            Asteroid two = CreateAsteroid();
                            one.Size = two.Size = asteroid.Size - 1;
                            one.CreationTime = two.CreationTime = asteroid.CreationTime;
                            one.PhysicsObject.Location = two.PhysicsObject.Location = asteroid.PhysicsObject.Location;
                            myAsteroids.Add(one);
                            myAsteroids.Add(two);
                        }
                        break;
                    }
                }

                // see if the asteroid is hitting the ship
                Vector4f sv = myShip.Location - asteroid.PhysicsObject.Location;
                if (sv.LengthSquare < asteroidRadiusSquare && System.Environment.TickCount - asteroid.CreationTime > AsteroidGracePeriod)
                    gameOver = true;

                // dont increment if we removed the asteroid
                if (!collisionFound)
                    ai++;
            }

            // if there zero asteroids, add one
            if (myAsteroids.Count == 0)
            {
                // reset the timer
                //myAsteroidTimer.Enabled = false;
                //myAsteroidTimer.Enabled = true;
                myAsteroids.Add(CreateAsteroid());
            }

            // show the gamer over form if the ship exploded
            if (gameOver)
            {
                if (!mIsDialogShowing)
                {
                    mIsDialogShowing = true;
                    mHandler.post(() =>
                    {
                        var b = new AlertDialog.Builder(this);
                        b.setTitle("Game Over!");
                        b.setMessage("Try again?");
                        b.setPositiveButton(global::[email protected], (d, which) => { mIsDialogShowing = false; ResetGame(); });
                        b.setNegativeButton(global::[email protected], (d, which) => { mIsDialogShowing = false; finish(); });
                        b.setCancelable(false);
                        b.create().show();
                    });
                }
            }
        }