Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        //--- stages for spring selection -----


        if (this.currentSelectionStage == springSelectionStage.selecting)
        {
            if (myMenu.targetOne != null)
            {
                // wait for the target two to be seleced.
                if (Input.GetMouseButtonDown(0))
                {
                    myMenu.targetTwo = myMenu.GetParticleAtPos();
                    Debug.Log("trying to set targetTwo");
                    targetTwoField.GetComponent <Text>().text = myMenu.targetTwo.name.ToString();
                    myMenu.targetTwo.GetComponent <Renderer>().material.SetColor("_Color", Color.green);
                    this.currentSelectionStage = springSelectionStage.finalizing;
                }
            }
        }
        if (this.currentSelectionStage == springSelectionStage.finalizing)
        {
            addSpringBntFeild.GetComponent <Text>().text = ("Finalize spring");
            finalizeSpring = true;
        }
    }
Beispiel #2
0
    public void clickCreateSpring()
    {
        if (myMenu.particle != null && finalizeSpring == false)
        {
            //set the seleted particle as target one
            myMenu.targetOne = myMenu.particle;
            targetOneField.GetComponent <Text>().text = myMenu.targetOne.name.ToString();
            myMenu.targetOne.GetComponent <Renderer>().material.SetColor("_Color", Color.green);
            currentSelectionStage = springSelectionStage.selecting;

            // the rest of the selection, is handin in the update -
        }

        //if two targets create spring
        if (finalizeSpring == true && myMenu.targetOne != null && myMenu.targetTwo != null)
        {
            Debug.Log("finalize was clicked");


            springStr  = strSlider.value;
            springRest = restSlider.value;
            springDamp = dampSlider.value;

            Debug.Log("str = " + springStr + ",  rest :" + springRest + ",  damp : " + springDamp);

            addNewSpring(myMenu.myParticleSystem, myMenu.targetOne, myMenu.targetTwo, springRest, springStr, springDamp);

            //Debug.Log(" spring added " + _particleSystem.springs);

            // change color unless they are pinne and thus red
            if (myMenu.targetOne.pinned == false)
            {
                myMenu.targetOne.GetComponent <Renderer>().material.SetColor("_Color", Color.white);
            }
            if (myMenu.targetTwo.pinned == false)
            {
                myMenu.targetTwo.GetComponent <Renderer>().material.SetColor("_Color", Color.white);
            }

            //change the text on the bnt back to normal and eixt finalize stage
            addSpringBntFeild.GetComponent <Text>().text = ("Create spring");
            this.currentSelectionStage = springSelectionStage.None;
            finalizeSpring             = false;
        }
    }