Esempio n. 1
0
    private void CreateChargingParticle()
    {
        if (currentCharge < 1)
        {
            Vector2 position = owner.transform.position;
            float   distance = Random.Range(0.5f, 1f);
            float   dir      = Random.Range(0, 2f * Mathf.PI);
            Vector2 dirVec   = new Vector2(Mathf.Cos(dir), Mathf.Sin(dir));

            BurstParticle bp = Instantiate(chargeSettings.chargingParticlePrefab).GetComponent <BurstParticle>();
            bp.transform.SetParent(owner.transform);
            bp.Setup(position - dirVec * distance, dirVec, 2f, distance * Random.Range(0.5f, 1f));
        }
        else
        {
            Vector2 position = owner.transform.position;
            float   distance = Random.Range(0.5f, 1f);
            float   dir      = Random.Range(0, 2f * Mathf.PI);
            Vector2 dirVec   = new Vector2(Mathf.Cos(dir), Mathf.Sin(dir));

            BurstParticle bp = Instantiate(chargeSettings.chargingParticlePrefab).GetComponent <BurstParticle>();
            bp.transform.SetParent(owner.transform);
            bp.Setup(position, dirVec, 2f, distance * Random.Range(0.5f, 1f));
        }
    }
Esempio n. 2
0
    private void CreateChargingParticle()
    {
        float ratio          = timer / runtime;
        float squareDistance = distanceCurve.Evaluate(ratio);

        Vector2 position = this.transform.position;
        float   distance = squareDistance + Random.Range(0.5f, 1f);
        float   dir      = Random.Range(0, 2f * Mathf.PI);
        Vector2 dirVec   = new Vector2(Mathf.Cos(dir), Mathf.Sin(dir));

        BurstParticle bp = Instantiate(chargingParticlePrefab).GetComponent <BurstParticle>();

        bp.transform.SetParent(this.transform);
        bp.Setup(position - dirVec * distance, dirVec, 2f, distance * Random.Range(0.5f, 1f));
    }
Esempio n. 3
0
    public void Burst(Vector2 _origin, Vector2 _collisionVelocity, Transform _parentTransform)
    {
        int numLines = Random.Range(4, 8);

        for (int i = 0; i < numLines; i++)
        {
            float   rotationDegrees = Random.Range(-60f, 60f);
            Vector2 direction       = _collisionVelocity.Rotate(rotationDegrees).normalized;

            float distanceToTravel = Random.Range(1, 3) * _collisionVelocity.magnitude / 8f;
            if (distanceToTravel < 0.5f)
            {
                distanceToTravel = Random.Range(0.5f, 1f);
            }

            float speed = distanceToTravel * Random.Range(3f, 4f);

            BurstParticle burstParticle = Instantiate(linePrefab).GetComponent <BurstParticle>();
            burstParticle.Setup(_origin, direction, speed, distanceToTravel);
            burstParticle.transform.SetParent(_parentTransform);
        }

        Destroy(this.gameObject);
    }