Ejemplo n.º 1
0
 protected void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Ejemplo n.º 2
0
    public void Branch()
    {
        if (branches == null)
        {
            branches = new List <Scene_Particle> ();
        }

        if (mainScenario && branchInit == false)
        {
            branchInit            = true;
            p.cameraFollowOffset *= 4f;
        }

        Transform branchObject = Instantiate <Transform>(branchingParticlesTemplate);

        branchObject.position = transform.position;

        Scene_Particle branchParticle = branchObject.GetComponent <Scene_Particle>();

        branchParticle.branchingParticlesTemplate = branchingParticlesTemplate;
        branchParticle.vineTemplate = vineTemplate;

        branchParticle.level      = level + 1;
        branchParticle.p.maxLevel = p.maxLevel;

        Vector3 velocity = affectedParticle.RB.velocity;

        branchParticle.p.particleSpeed = velocity.magnitude / 10f;
        branchParticle.GetComponent <AffectedParticleRB> ().GetComponent <Rigidbody> ().AddForce(velocity * 2f, ForceMode.Impulse);

        branchParticle.direction.vector     = direction.vector;
        branchParticle.direction.coneRadius = direction.coneRadius / p.lifeDurationMultiplier;

        branchParticle.p.minBranchLifeDuration  = p.minBranchLifeDuration * p.lifeDurationMultiplier;
        branchParticle.p.maxBranchLifeDuration  = p.maxBranchLifeDuration * p.lifeDurationMultiplier;
        branchParticle.p.lifeDurationMultiplier = p.lifeDurationMultiplier;
        branchParticle.p.lifeDuration           = rand.Float(branchParticle.p.minBranchLifeDuration, branchParticle.p.maxBranchLifeDuration);

        branchParticle.transform.localScale = branchParticle.transform.localScale * p.lifeDurationMultiplier;

        branchParticle.branchInit      = true;
        branchParticle.p.vineShapeSize = p.vineShapeSize * p.levelShapeSizeMultiplier;

        branches.Add(branchParticle);
    }
Ejemplo n.º 3
0
    private IEnumerator ConvertBoidsToTemplateCoroutine(Transform template, float duration)
    {
        int   numBoids        = flock.boids.Count;
        float delay           = duration / numBoids;
        bool  templateUpdated = false;

        int countNulls = 0;

        for (int i = 0; i < numBoids; i++)
        {
            Boid boid = flock.boids[i];

            if (boid != null)
            {
                //SwitchMeshView.Apply ( boid.GetComponentInChildren<MeshFilter>().gameObject, template.gameObject );
                GameObject original = boid.GetComponentInChildren <MeshFilter>().gameObject;
                Instantiate(template, original.transform.parent);
                Destroy(original);
                Scene_Particle.AppearZoom(boid.gameObject, 0f);

                if (templateUpdated == false)
                {
                    flock.template = boid;
                }

                yield return(new WaitForSeconds(delay));
            }
            else
            {
                countNulls++;
            }
        }

        Debug.LogFormat("Null boids = {0}", countNulls);
        yield return(null);
    }