Esempio n. 1
0
    //ON COLLISSION WITH PARTICLE
    private void OnCollisionEnter(Collision other)
    {
        var pos = other.transform.position;
        var tag = other.gameObject.tag;

        if (tag == "Particle" && other.collider.GetType() == typeof(MeshCollider))
        {
            var particleScript = other.gameObject.GetComponent <ParticleScript>();
            var particleType   = particleScript.particleType;
            var particleMass   = particleScript.particleMass;

            if (particleType == ParticleType.grow)
            {
                SetTargetMass(targetMass + particleMass);
                RuntimeDataManager.value.normalParticlesCollected++;
                RuntimeDataManager.value.gainedMass += particleMass;
                SoundScript.ExplosionLarge();
                particleScript.Destroy(true, true, false, false);
            }
            else if (particleType == ParticleType.shrink)
            {
                SetTargetMass(targetMass - particleMass);
                RuntimeDataManager.value.shrinkParticlesCollected++;
                RuntimeDataManager.value.lossMass += particleMass;
                SoundScript.Shrink();
                particleScript.Destroy(true, true, false, true);
            }
            else if (particleType == ParticleType.gold)
            {
                RuntimeDataManager.value.goldParticlesCollected++;
                RuntimeDataManager.value.goldMassCollected += Mathf.CeilToInt(particleMass);
                GoldFeedbackSpawn.instance.NewGoldFeedback(pos, Mathf.CeilToInt(particleMass));
                SoundScript.Gold();
                particleScript.Destroy(true, true, false, true);
            }

            playerMeshGenerator.NewCollision(pos);
        }
    }