Ejemplo n.º 1
0
 public void SetInputPopup(Enum popup)
 {
     if (inputKind == InputKind.Terrain)
     {
         inputTerrain = (InputTerrain)popup;
     }
     else if (inputKind == InputKind.Noise)
     {
         inputNoise = (InputNoise)popup;
     }
     else if (inputKind == InputKind.Shape)
     {
         inputShape = (InputShape)popup;
     }
     else if (inputKind == InputKind.File)
     {
         inputFile = (InputFile)popup;
     }
     else if (inputKind == InputKind.Current)
     {
         inputCurrent = (InputCurrent)popup;
     }
     else if (inputKind == InputKind.Portal)
     {
         inputPortal = (InputPortal)popup;
     }
 }
Ejemplo n.º 2
0
    void OnMouseDown()
    {
        if (!pause)
        {
            //Debug.Log("pause" + pause);
            var v3 = Input.mousePosition;
            v3.z = distance;
            pos  = Camera.main.ScreenToWorldPoint(v3);
            if (pos.x > 0)
            {
                pos.x = Mathf.Round((int)pos.x / 2) * 2 + 1;
            }
            if (pos.x <= 0)
            {
                pos.x = Mathf.Round((int)pos.x / 2) * 2 - 1;
            }
            if (pos.y < 0)
            {
                pos.y = Mathf.Round((int)pos.y / 2) * 2 - 1;
            }
            if (pos.y >= 0)
            {
                pos.y = Mathf.Round((int)pos.y / 2) * 2 + 1;
            }
            //Debug.Log("OnMouseDown " + pos);
            mouseDown = true;
            if (isSafePlant((int)pos.x, (int)pos.y))
            {
                if (input)
                {
                    GameObject obj = (GameObject)Instantiate(backgroundIn, pos, Quaternion.identity);
                    // obj.AddComponent<RemovePortal>();
                    obj.AddComponent <PortalId>();
                    obj.GetComponent <Renderer>().material.color = portalColor;
                    //obj.GetComponent<Renderer>().material.mainTexture = inPortal;
                    obj.GetComponent <SpriteRenderer>().sprite = inPortal;
                    inPos = pos;
                    //Debug.Log("inPos: " + pos);

                    PortalId idOfNewPortal = obj.GetComponent <PortalId>();
                    idOfNewPortal.setId(id);
                    por = new InputPortal(id);
                    por.InputPortalGO = obj;
                    input             = false;
                }
                else
                {
                    currentOutputPortal = (GameObject)Instantiate(backgroundOut, pos, Quaternion.identity);
                    //currentOutputPortal.AddComponent<RemovePortal>();
                    currentOutputPortal.AddComponent <PortalId>();
                    currentOutputPortal.GetComponent <Renderer>().material.color = portalColor;
                    currentOutputPortal.GetComponent <SpriteRenderer>().sprite   = inPortal;
                    PortalId idOfNewPortal = currentOutputPortal.GetComponent <PortalId>();
                    idOfNewPortal.setId(id);
                    outputPortal = true;
                    input        = true;
                }
            }
        }
    }
Ejemplo n.º 3
0
 protected override Variable CalculateOutput(string name)
 {
     if (IsInput)
     {
         return(GetInput(name));
     }
     else
     {
         if (InputPortal != null)
         {
             return(InputPortal.CalculateOutput(name));
         }
     }
     return(new Variable(Type));
 }
Ejemplo n.º 4
0
        static public void ClickMenuInput(object obj)
        {
            int    instanceID;
            string command = TD.ObjectToCommandAndInstanceID(obj, out instanceID);

            TC_Node node = EditorUtility.InstanceIDToObject(instanceID) as TC_Node;

            if (node != null)
            {
                int    index     = command.IndexOf("/");
                string inputKind = command.Substring(0, index);
                string input     = command.Substring(index + 1);
                bool   changed   = false;

                InputKind oldInputKind = node.inputKind;
                node.inputKind = (InputKind)Enum.Parse(typeof(InputKind), inputKind);

                if (node.inputKind != oldInputKind)
                {
                    changed = true;
                }

                if (inputKind == "Terrain")
                {
                    InputTerrain oldInputTerrain = node.inputTerrain;
                    node.inputTerrain = (InputTerrain)Enum.Parse(typeof(InputTerrain), input);
                    if (node.inputTerrain != oldInputTerrain)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Noise")
                {
                    InputNoise oldInputNoise = node.inputNoise;
                    node.inputNoise = (InputNoise)Enum.Parse(typeof(InputNoise), input);
                    if (node.inputNoise != oldInputNoise)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Shape")
                {
                    InputShape oldInputShape = node.inputShape;
                    node.inputShape = (InputShape)Enum.Parse(typeof(InputShape), input);
                    if (node.inputShape != oldInputShape)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "File")
                {
                    InputFile oldInputFile = node.inputFile;
                    node.inputFile = (InputFile)Enum.Parse(typeof(InputFile), input);
                    if (node.inputFile != oldInputFile)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Current")
                {
                    InputCurrent oldInputCurrent = node.inputCurrent;
                    node.inputCurrent = (InputCurrent)Enum.Parse(typeof(InputCurrent), input);
                    if (node.inputCurrent != oldInputCurrent)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Portal")
                {
                    InputPortal oldInputPortal = node.inputPortal;
                    node.inputPortal = (InputPortal)Enum.Parse(typeof(InputPortal), input);
                    if (node.inputPortal != oldInputPortal)
                    {
                        changed = true;
                    }
                }

                if (changed)
                {
                    node.Init();
                    TC.RefreshOutputReferences(node.outputId, true);
                }
            }
        }
Ejemplo n.º 5
0
 public Tuple(InputPortal inp, OutputPortal outp)
 {
     inputPortal = inp;
     outputPortal = outp;
 }
Ejemplo n.º 6
0
    void OnMouseDown()
    {
        if (!pause)
        {

            //Debug.Log("pause" + pause);
            var v3 = Input.mousePosition;
            v3.z = distance;
            pos = Camera.main.ScreenToWorldPoint(v3);
            if (pos.x > 0) pos.x = Mathf.Round((int)pos.x / 2) * 2 + 1;
            if (pos.x <= 0) pos.x = Mathf.Round((int)pos.x / 2) * 2 - 1;
            if (pos.y < 0) pos.y = Mathf.Round((int)pos.y / 2) * 2 - 1;
            if (pos.y >= 0) pos.y = Mathf.Round((int)pos.y / 2) * 2 + 1;
            //Debug.Log("OnMouseDown " + pos);
            mouseDown = true;
            if (isSafePlant((int)pos.x, (int)pos.y))
            {
                if (input)
                {
                    GameObject obj = (GameObject)Instantiate(backgroundIn, pos, Quaternion.identity);
                    // obj.AddComponent<RemovePortal>();
                    obj.AddComponent<PortalId>();
                    obj.GetComponent<Renderer>().material.color = portalColor;
                    //obj.GetComponent<Renderer>().material.mainTexture = inPortal;
                    obj.GetComponent<SpriteRenderer>().sprite = inPortal;
                    inPos = pos;
                    //Debug.Log("inPos: " + pos);

                    PortalId idOfNewPortal = obj.GetComponent<PortalId>();
                    idOfNewPortal.setId(id);
                    por = new InputPortal(id);
                    por.InputPortalGO = obj;
                    input = false;
                }
                else
                {
                    currentOutputPortal = (GameObject)Instantiate(backgroundOut, pos, Quaternion.identity);
                    //currentOutputPortal.AddComponent<RemovePortal>();
                    currentOutputPortal.AddComponent<PortalId>();
                    currentOutputPortal.GetComponent<Renderer>().material.color = portalColor;
                    currentOutputPortal.GetComponent<SpriteRenderer>().sprite = inPortal;
                    PortalId idOfNewPortal = currentOutputPortal.GetComponent<PortalId>();
                    idOfNewPortal.setId(id);
                    outputPortal = true;
                    input = true;
                }
            }
        }
    }
Ejemplo n.º 7
0
 public Tuple(InputPortal inp, OutputPortal outp)
 {
     inputPortal  = inp;
     outputPortal = outp;
 }