Example #1
0
    public override void Run()
    {
        Asteroid a = ag.GenerateAsteroid(MineralType.Whatium, 2, Random.Range(int.MinValue, int.MaxValue));

        a.transform.position = (Vector2)PlayerShip.instance.transform.position + Random.insideUnitCircle * 300f;
        a.gameObject.SetActive(true);
    }
Example #2
0
    public override void Die()
    {
        Destroy(gameObject, 0);

        if (chunk != null)
        {
            if (!flagged)
            {
                chunk.FlagAsteroid(this);
                flagged = true;
            }

            chunk.RemoveAsteroid(this);
        }

        if (sizeClass > 0 && gen != null)
        {
            if (chunk != null)
            {
                Random.seed = chunk.chunkSeed + id;
            }
            float numAsteroids = Random.Range(sizeClass, sizeClass + 3);

            float angleStep  = 360 / numAsteroids;
            float startAngle = Random.Range(0, 360);

            for (int i = 0; i < numAsteroids; i++)
            {
                gen.transform.position = transform.position + (Vector3) new Vector2(Mathf.Cos(Mathf.Deg2Rad * (startAngle + angleStep * i)),
                                                                                    Mathf.Sin(Mathf.Deg2Rad * (startAngle + angleStep * i))) * (sizeClass + 1) * 2;
                Asteroid clone = gen.GenerateAsteroid(mineral, sizeClass - 1, Random.Range(int.MinValue, int.MaxValue) + id);

                clone.chunk = chunk;

                if (chunk != null)
                {
                    chunk.AddAsteroid(clone);
                }
                else
                {
                    clone.gameObject.SetActive(true);
                }

                clone.rigidbody2D.AddForce(((Vector2)gen.transform.position - lastColPoint).normalized * 10 * sizeClass, ForceMode2D.Impulse);
            }
        }

        if (mineral != MineralType.Blank)
        {
            Mineral drop = gen.GenerateMineral(mineral);
            drop.transform.position = transform.position;
        }

        if (deathFX.Length > 0)
        {
            Instantiate(deathFX[(int)Mathf.Clamp(sizeClass, 0, deathFX.Length - 1)], transform.position + new Vector3(0, 0, -5), transform.rotation);
        }
    }
Example #3
0
    void SpawnAsteroidFromData(AsteroidData ad)
    {
        gen.transform.position = new Vector3(ad.posx, ad.posy, gen.transform.position.z);
        Asteroid clone = gen.GenerateAsteroid(ad.mineral, ad.size, chunkSeed + ad.index);

        clone.gen     = gen;
        clone.chunk   = this;
        clone.id      = ad.index;
        clone.flagged = true;

        asteroids.Add(clone.id, clone);
    }
Example #4
0
        int counter = 0;        //-1000;


        public void CrearObjetos()
        {
            flag = new Flag(new Vector3(-4, 10, -4), "OGL.jpg");
            flag.Create();
            plaza.Create();
            plaza.CrearColisiones();
            Sprite.Create();
            //Collision.GhostMode = true;
            road = new Road();
            road.Create();
            //
            star.CreateStars(450);
            spaceShip.Create();
            Asteroid.Crear();
            //
            AsteroidGenerator.GenerateAsteroid(35, true);
            SpcShipGenerator.Generate(9, true);
        }