Пример #1
0
 public void OnButtonPressed()
 {
     FindObjectOfType <TerminalLogic>().OnInputRecieved("connect " + Device.GetDeviceName());
 }
Пример #2
0
    public void Update()
    {
        text.text = "";
        Device    = TerminalNetwork.GetCurrentDevice();
        if (Device == null)
        {
            return;
        }

        NetworkNode node = Device.networkNode;

        AddText("Name: " + Device.GetDeviceName());

        if (node == null)
        {
            return;
        }

        if (node.PasswordProtected)
        {
            AddText(TerminalColourScheme.FormatText("Password: Protected", TerminalStyle.DANGER));
        }

        if (node.Ports.Count > 0)
        {
            AddText(TerminalColourScheme.FormatText("Ports:", TerminalStyle.INFO));
            for (int i = 0; i < node.Ports.Count; i++)
            {
                string color = node.Ports[i].Open ? "<color=green><u><b>" : "<color=red>";
                AddText("\t -" + node.Ports[i].portNumber + " : " + color + node.Ports[i].Open.ToString() + "</color></u></b>");
            }
        }

        if (node.FireWall != null)
        {
            string s = TerminalColourScheme.FormatText("Firewall Detected!", TerminalStyle.DANGER);
            AddText(s);
        }
        else
        {
            string s = TerminalColourScheme.FormatText("No Firewall Detected.", TerminalStyle.INFO);
            AddText(s);
        }

        if (Device.DeviceCommands.Count > 0)
        {
            AddText(TerminalColourScheme.FormatText("CMDS:", TerminalStyle.INFO));

            if (node.IsPortOpen(3389))
            {
                for (int i = 0; i < Device.DeviceCommands.Count; i++)
                {
                    Debug.Log(i);
                    AddText("\t -" + Device.DeviceCommands[i].KeyWord);

                    if (Device.DeviceCommands[i].SubCommands != null)
                    {
                        for (int j = 0; j < Device.DeviceCommands[i].SubCommands.Length; j++)
                        {
                            AddText("\t\t -<" + Device.DeviceCommands[i].SubCommands[j] + ">");
                        }
                    }
                }
            }
            else
            {
                AddText(TerminalPresetMessages.PortsRestricted);
            }
        }

        AddText("<b><u> Details: </b></u>");
        AddText(Device.GetData());
    }
Пример #3
0
    void PopulateNodes()
    {
        NetworkDevice currentDevice = TerminalNetwork.GetCurrentDevice();
        GameObject    current       = Instantiate(NetworkNodeView);

        current.transform.parent = Holder;

        current.GetComponent <RectTransform>().localScale    = Vector2.one;
        current.GetComponent <RectTransform>().localPosition = Vector2.one;
        //current.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
        //current.GetComponent<RectTransform>().position = Vector2.zero;

        Devices.Add(currentDevice, current);
        current.GetComponentInChildren <UnityEngine.UI.Text>().text = currentDevice.GetDeviceName();

        for (int i = 0; i < currentDevice.networkNode._nodes.Count; i++)
        {
            var node = currentDevice.networkNode._nodes[i];

            float spacing = 360f / (float)currentDevice.networkNode._nodes.Count;

            float x = UnityEngine.Random.Range(-300f, 300f);
            float y = UnityEngine.Random.Range(-300f, 300f);



            Vector2 pos = new Vector2(x, y);
            if (pos.magnitude < 100)
            {
                pos = pos.normalized * 100f;
            }

            GameObject go = Instantiate(NetworkNodeView);
            go.transform.parent        = Holder;
            go.transform.localPosition = Vector2.zero;
            go.GetComponent <RectTransform>().anchoredPosition = (pos);
            go.GetComponent <RectTransform>().localScale       = Vector2.one;
            UnityEngine.UI.Text text = go.GetComponentInChildren <UnityEngine.UI.Text>();

            go.GetComponent <Animator>().Play("Intro");

            text.text = currentDevice.networkNode._nodes[i].networkDevice.GetDeviceName();
            go.GetComponent <NodeViewButton>().Device = currentDevice.networkNode._nodes[i].networkDevice;

            GameObject line = Instantiate(NetworkNodeLine);
            Lines.Add(currentDevice.networkNode._nodes[i].networkDevice, line);
            line.transform.parent = Holder;
            line.GetComponent <RectTransform>().anchoredPosition = (pos).normalized * 150;
            var lPos = line.GetComponent <RectTransform>().localPosition;
            lPos.z = 0f;
            line.GetComponent <RectTransform>().localPosition = lPos;
            line.GetComponent <RectTransform>().localScale    = new Vector3(3f, 1f, 1f);
            Vector2 dir = pos;
            line.GetComponent <RectTransform>().right = (pos).normalized * 300f;
            line.GetComponent <RectTransform>().SetAsFirstSibling();
            Devices.Add(currentDevice.networkNode._nodes[i].networkDevice, go);
        }

        current.GetComponent <RectTransform>().localPosition    = Vector2.zero;
        current.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
    }