Exemple #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        SourceGlobal     sourceGlobal     = dozor.GetComponent <SourceGlobal>();
        DestroyAsteroids destroyAsteroids = destroyAsterroids1.GetComponent <DestroyAsteroids>();


        switch (collision.tag)
        {
        case ("Asteroids"):
            Time.timeScale = 0;
            destroyAsteroids.RandomObject(collision);
            Instantiate(LoseGame);
            break;

        case "Coints":
            sourceGlobal.Source += 10;
            destroyAsteroids.RandomObject(collision);
            break;

        case "Bonus":
            sourceGlobal.DNK++;
            //if (sourceGlobal.speed >0.085)
            //sourceGlobal.speed *= 0.9f;
            //else sourceGlobal.speed = 0.085f;
            destroyAsteroids.RandomObject(collision);

            break;

        case ("BossAmmo"):
            Time.timeScale = 0;
            Destroy(collision.gameObject);
            Instantiate(LoseGame);
            break;
        }
    }
Exemple #2
0
        private static void CheckAsteroidEscaped(IEnumerable <Asteroid> asteroids, DestroyAsteroids destroyAsteroids, IMassive barycenter)
        {
            List <Asteroid> doomedAsteroids = new List <Asteroid>();

            foreach (Asteroid asteroid in asteroids)
            {
                if ((Math.Abs(asteroid.Vel.Origin.X) > 300 || Math.Abs(asteroid.Vel.Origin.Y) > 300) && Physics.GetEscapeVelocity(asteroid.Vel.Origin, barycenter) <= asteroid.Vel.Length)
                {
                    doomedAsteroids.Add(asteroid);
                }
            }
            destroyAsteroids(doomedAsteroids, false);
        }
Exemple #3
0
        public static void CheckShotAsteroidCollision(IEnumerable <Shot> shots, IEnumerable <Asteroid> asteroids, DestroyShots destroyShots, DestroyAsteroids destroyAsteroids) // 50 * 30 = 1500 / 2082
        {
            List <Shot>     doomedShots     = new List <Shot>();
            List <Asteroid> doomedAsteroids = new List <Asteroid>();

            foreach (Shot shot in shots)
            {
                foreach (Asteroid asteroid in asteroids)
                {
                    if (checkCoordinatePolygonCollision(shot.Vel.Origin, asteroid))
                    {
                        doomedShots.Add(shot);
                        doomedAsteroids.Add(asteroid);
                    }
                }
            }
            destroyShots(doomedShots);
            destroyAsteroids(doomedAsteroids, true);
        }
Exemple #4
0
 public static void HandleCollisions(IEnumerable <Shot> shots, IEnumerable <Asteroid> asteroids, IEnumerable <Planet> planets, IEnumerable <Ship> ships, IMassive barycenter, DestroyShots destroyShots, DestroyShips destroyShips, DestroyAsteroids destroyAsteroids, int maxShots, int maxAsteroids)
 {
     CheckShotEscaped(shots, destroyShots, barycenter);
     CheckAsteroidEscaped(asteroids, destroyAsteroids, barycenter);
     CheckShipEscaped(ships, destroyShips);
     CheckShotAsteroidCollision(shots, asteroids, destroyShots, destroyAsteroids);
     CheckShotShipCollision(shots, ships, destroyShots, destroyShips);
     CheckShotPlanetCollision(shots, planets, destroyShots);
     CheckAsteroidShipCollision(asteroids, ships, destroyAsteroids, destroyShips);
     CheckAsteroidPlanetCollision(asteroids, planets, destroyAsteroids);
     CheckShipPlanetCollision(ships, planets, destroyShips);
     CheckMaxShots(shots, maxShots);
     CheckMaxAsteroids(asteroids, maxAsteroids);
 }
Exemple #5
0
        public static void CheckAsteroidPlanetCollision(IEnumerable <Asteroid> asteroids, IEnumerable <Planet> planets, DestroyAsteroids destroyAsteroids) // 30 * 3 = 90 / 2082
        {
            List <Asteroid> doomedAsteroids = new List <Asteroid>();

            foreach (Asteroid asteroid in asteroids)
            {
                foreach (Planet planet in planets)
                {
                    if (checkPolygonCircleCollision(asteroid, planet))
                    {
                        doomedAsteroids.Add(asteroid);
                    }
                }
            }
            destroyAsteroids(doomedAsteroids, true);
        }
Exemple #6
0
        public static void CheckAsteroidShipCollision(IEnumerable <Asteroid> asteroids, IEnumerable <Ship> ships, DestroyAsteroids destroyAsteroids, DestroyShips destroyShips) // 30 * 4 = 120 / 2082
        {
            List <Asteroid> doomedAsteroids = new List <Asteroid>();
            List <Ship>     doomedShips     = new List <Ship>();

            foreach (Asteroid asteroid in asteroids)
            {
                foreach (Ship ship in ships)
                {
                    if (!ship.Destroyed)
                    {
                        if (checkMultiplePolygonCollision(asteroid, ship))
                        {
                            doomedAsteroids.Add(asteroid);
                            doomedShips.Add(ship);
                        }
                    }
                }
            }
            destroyAsteroids(doomedAsteroids, true);
            destroyShips(doomedShips);
        }