Exemple #1
0
    private void instantiateSparks(Collision2D col)
    {
        if (col.gameObject.layer != Consts.FloorLayer)
        {
            return;
        }
        var kmPerH = CalculateUtils.UnitsPerSecondToKmPerH(rb.velocity.magnitude);

        if (kmPerH < 5)
        {
            return;
        }
        float angle = CalculateUtils.Vector2ToAngle(rb.velocity);

        if (Time.time > lastTime + SPARKS_INSTANTIATE_PERIOD)
        {
            lastTime = Time.time;
            for (int i = 0; i < col.contactCount; i++)
            {
                sparksParticle = particleSystemContainer.NextAndPlay();
                var emission = sparksParticle.emission;
                emission.rateOverTime = kmPerH * EMISSION_RATE;
                sparksParticle.transform.localScale = new Vector3(kmPerH * SCALE_RATE, 1, 1);
                sparksParticle.transform.position   = new Vector3(col.GetContact(i).point.x, col.GetContact(i).point.y, Z_POSSITION);
                sparksParticle.transform.rotation   = Quaternion.Euler(0, 0, angle);
            }
        }
    }
Exemple #2
0
    void OnJointBreak2D(Joint2D brokenJoint)
    {
        var center = (SpriteUtils.GetWolrdPositions(brokenJoint.attachedRigidbody.GetComponent <SpriteRenderer>()).Center + SpriteUtils.GetWolrdPositions(spriteRenderer).Center) / 2;
        var ps     = particleSystemContainer.NextAndPlay();

        ps.transform.position = new Vector3(center.x, center.y, Z_POSSITION);
    }
Exemple #3
0
    public override void Play(EffectData effectData)
    {
        BurnInfo burnInfo = (BurnInfo)effectData.Map["burnInfo"];

        if (Time.time > lastTime + FrequencyMillis / 1000f)
        {
            var ps       = particleSystemContainer.NextAndPlay();
            var emission = ps.emission;
            emission.rateOverTimeMultiplier = 100 * burnInfo.Power;
            var main = ps.main;
            main.startSizeMultiplier = burnInfo.Power;
            ps.transform.position    = new Vector3(burnInfo.Point.x, burnInfo.Point.y, Z_POSSITION);
            lastTime = Time.time;
        }
    }
Exemple #4
0
    public override void Play(EffectData effectData)
    {
        var ps = particleSystemContainer.NextAndPlay();

        ps.transform.position = new Vector3(effectData.Position.x, effectData.Position.y, Z_POSSITION);
    }