Exemplo n.º 1
0
    public MySpring(MyParticleSystem parnetParticleSystem, MyParticle targetOne, MyParticle targetTwo, float restLength, float strength, float damping)
    {
        if (parnetParticleSystem == null)
        {
            throw new System.ArgumentNullException("particleSystem", "Cannot supply null as ParticleSystem to CustomSpring");
        }
        if (targetOne == null)
        {
            throw new System.ArgumentNullException("particle1", "Cannot supply null as Particle1 to CustomSpring");
        }
        if (targetTwo == null)
        {
            throw new System.ArgumentNullException("particle2", "Cannot supply null as Particle2 to CustomSpring");
        }

        //add the string to the particle system
        this.parnetParticleSystem = parnetParticleSystem;
        this.parnetParticleSystem.springs.Add(this);

        this.targetOne = targetOne;
        this.targetTwo = targetTwo;

        this.rest     = restLength;
        this.strength = strength;
        this.damping  = damping;

        lineRender          = targetOne.gameObject.AddComponent <LineRenderer>();
        lineRender.material = new Material(Shader.Find("Particles/Additive"));
        lineRender.SetWidth(0.2F, 0.2F);
    }
Exemplo n.º 2
0
        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            Winners.Visibility          = Visibility.Collapsed;
            MyParticleSystem.Visibility = Visibility.Collapsed;
            MyParticleSystem.Stop();

            if (organizerWindow != null)
            {
                organizerWindow.Close();
            }
        }
Exemplo n.º 3
0
    public void ClickNewParticle()
    {
        if (myParticleSystem == null)
        {
            var particleSystemGo = Instantiate(particleSystemPrefab) as GameObject;
            myParticleSystem = particleSystemGo.GetComponent <MyParticleSystem>().Initialize(_startGravity, _startDrag);
        }

        var newParticlePrefab = Instantiate(particlePrefab) as GameObject;
        var newParticle       = newParticlePrefab.GetComponent <MyParticle>();

        newParticle.Initialize(myParticleSystem, _startMass, _startPosition, _startVelocity, false, 0);

        // note  Initialize(MyParticleSystem parrnetParticleSystem, float startMass, Vector3 startPosition, Vector3 startVelocity, bool setPinned, float setLifeSpan)
    }
Exemplo n.º 4
0
    public MyParticle Initialize(MyParticleSystem parrnetParticleSystem, float startMass, Vector3 startPosition, Vector3 startVelocity, bool setPinned, float setLifeSpan)
    {
        this.targetParticleSystem = parrnetParticleSystem;
        this.targetParticleSystem.particles.Add(this);

        this.mass     = startMass;
        this.position = startPosition;
        this.velocity = startVelocity;
        this.pinned   = setPinned;
        this.lifespan = setLifeSpan;
        this.age      = 0f;

        this.transform.SetParent(this.targetParticleSystem.transform);
        this.name = "Particle " + this.targetParticleSystem.particles.IndexOf(this).ToString();

        return(this);
    }
Exemplo n.º 5
0
 public void CompleteAnimation()
 {
     MyParticleSystem.Visibility = Visibility.Visible;
     MyParticleSystem.Start();
 }
Exemplo n.º 6
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     MyParticleSystem.Start();
 }
Exemplo n.º 7
0
 private MySpring addNewSpring(MyParticleSystem _particleSystem, MyParticle targetOne, MyParticle targetTwo, float springRest, float springStr, float springDamp)
 {
     return(new MySpring(_particleSystem, targetOne, targetTwo, springRest, springStr, springDamp));
 }