コード例 #1
0
ファイル: Asteroid.cs プロジェクト: juanibiapina/Asteroids
    void Destroy()
    {
        // create explosion
        explosion = Instantiate(explosion, transform.position, Quaternion.identity);
        explosion.transform.localScale = transform.localScale / 4;

        // spawn children
        if (spec.numberOfChildren > 0)
        {
            for (int i = 0; i < spec.numberOfChildren; i++)
            {
                Vector3 pos = Random.insideUnitCircle * (spec.size / 2);
                spawner.SpawnAsteroid(transform.position + pos, spec.childSpec);
            }
        }

        // emit event
        eventSystem.AsteroidDestroyed?.Invoke(gameObject);

        // destroy self
        Destroy(gameObject);
    }
コード例 #2
0
 void Spawn(Asteroid.Size size)
 {
     spawner.SpawnAsteroid(
         CameraBounds.getRandomPointInsideBounds(0),
         size);
 }
コード例 #3
0
    bool EventAsteroidIntro()
    {
        if (firstRunOfEvent)
        {
            consoleScreen.Clear();
            consoleScreen.StartMessage("Objects\ndetected\nin path!\n\nusing\nweapons\nsystems\nadvised!");
            firstRunOfEvent  = false;
            routineReference = StartCoroutine(BlinkObject(switchGuide, 2.5f));
        }

        if (!consoleScreen.isWriting && EvaluateConsoleSwitched())
        {
            StopCoroutine(routineReference);
            switchGuide.SetActive(false);
            StartCoroutine(BlinkObject(asteroidGuide, 0f));

            asteroidSpawner.SpawnAsteroid();
            asteroidSpawner.SpawnAsteroid();

            return(true);
        }
        return(false);
    }
コード例 #4
0
    public void SpawnAsteroid()
    {
//		float randomUpDown = Random.Range (-AsteroidSpawner.transform.localScale.y, AsteroidSpawner.transform.localScale.y);

        float oneOfThree = Random.Range(0, 6);

        if (oneOfThree == 0)
        {
            // Middle Opening
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 1, AsteroidPrefabs[5]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 2, AsteroidPrefabs[6]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 3, AsteroidPrefabs[7]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 1, AsteroidPrefabs[3]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 2, AsteroidPrefabs[2]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 3, AsteroidPrefabs[1]));
            AsteroidsCount += 6;
        }
        else if (oneOfThree == 1)
        {
            // Bottom Opening
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(0.0f, AsteroidPrefabs[4]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y, AsteroidPrefabs[3]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 2, AsteroidPrefabs[2]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 3, AsteroidPrefabs[1]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 4, AsteroidPrefabs[0]));
            AsteroidsCount += 5;
        }
        else if (oneOfThree == 2)
        {
            // Top Opening
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y, AsteroidPrefabs[5]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 2, AsteroidPrefabs[6]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 3, AsteroidPrefabs[7]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 4, AsteroidPrefabs[8]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(0.0f, AsteroidPrefabs[4]));
            AsteroidsCount += 5;
        }
        else if (oneOfThree == 3)
        {
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y, AsteroidPrefabs[5]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 2, AsteroidPrefabs[6]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 3, AsteroidPrefabs[7]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 1, AsteroidPrefabs[3]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 2, AsteroidPrefabs[2]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 3, AsteroidPrefabs[1]));
            AsteroidsCount += 6;
        }
        else if (oneOfThree == 4)
        {
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 1, AsteroidPrefabs[5]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 2, AsteroidPrefabs[6]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 3, AsteroidPrefabs[7]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 0, AsteroidPrefabs[4]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 2, AsteroidPrefabs[3]));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(-AsteroidSpawner.transform.position.y * 3, AsteroidPrefabs[2]));
            AsteroidsCount += 6;
        }
        else
        {
//			Asteroids.Enqueue (AsteroidSpawner.SpawnAsteroid (AsteroidSpawner.transform.position.y*.5f));
//			Asteroids.Enqueue (AsteroidSpawner.SpawnAsteroid (AsteroidSpawner.transform.position.y*2));
            Asteroids.Enqueue(AsteroidSpawner.SpawnAsteroid(AsteroidSpawner.transform.position.y * 0, AsteroidPrefabs[4]));
//			Asteroids.Enqueue (AsteroidSpawner.SpawnAsteroid (-AsteroidSpawner.transform.position.y*.5f));
//			Asteroids.Enqueue (AsteroidSpawner.SpawnAsteroid (-AsteroidSpawner.transform.position.y*2));
//			Asteroids.Enqueue (AsteroidSpawner.SpawnAsteroid (-AsteroidSpawner.transform.position.y*3));
            AsteroidsCount += 1;
        }
    }