private void GenerateOutputNodeUI() { int numNodes = outputNodes.Count(x => !x.IsDeviceNode); HorizontalLayoutGroup layout = outputsLayout.GetComponentInChildren <HorizontalLayoutGroup>(); float cellSizeX = nodeCellSize.x; float layoutWidth = inputsLayout.rect.width; float spacing = (layoutWidth - cellSizeX * numNodes) / numNodes; layout.spacing = spacing; foreach (HackingNode node in outputNodes) { if (node.IsDeviceNode) { continue; } GameObject nodeUIObject = Instantiate(outputHackingNodeUIPrefab, outputsLayout.transform); RectTransform nodeRect = nodeUIObject.transform as RectTransform; nodeRect.sizeDelta = nodeCellSize; GUI_HackingNode nodeGUI = nodeUIObject.GetComponent <GUI_HackingNode>(); nodeGUI.SetHackingNode(node); outputNodeUIObjects.Add(nodeGUI); nodeUIObjects.Add(nodeGUI); } }
private void UpdateWiresFromConnectionList() { DeleteOldWires(); foreach (int[] connection in connectionList) { if (connection.Length != 2) { return; } int outputIndex = connection[0]; int inputIndex = connection[1]; if (hackNodes.ElementAtOrDefault(connection[0]) == null || hackNodes[connection[0]] == null) { return; } if (hackNodes.ElementAtOrDefault(connection[1]) == null || hackNodes[connection[1]] == null) { return; } GUI_HackingNode outputUINode = GetUIComponentOfNode(hackNodes[outputIndex]); GUI_HackingNode inputUINode = GetUIComponentOfNode(hackNodes[inputIndex]); GameObject connectingWire = Instantiate(connectingWireUIPrefab, transform); GUI_HackingWire GUIWire = connectingWire.GetComponent <GUI_HackingWire>(); GUIWire.SetStartUINode(outputUINode); GUIWire.SetEndUINode(inputUINode); GUIWire.PositionWireBody(); hackingWires.Add(GUIWire); } }
public void SetStartUINode(GUI_HackingNode startNode) { this.startNode = startNode; RectTransform nodeRectTransform = startNode.GetComponent <RectTransform>(); RectTransform wireStartRectTransform = wireStart.GetComponent <RectTransform>(); wireStartRectTransform.sizeDelta = nodeRectTransform.sizeDelta * 0.7f; wireStartRectTransform.position = nodeRectTransform.position; }
public void SetEndUINode(GUI_HackingNode endNode) { this.endNode = endNode; RectTransform nodeRectTransform = endNode.GetComponent <RectTransform>(); RectTransform wireEndRectTransform = wireEnd.GetComponent <RectTransform>(); wireEndRectTransform.sizeDelta = nodeRectTransform.sizeDelta * 0.7f; wireEndRectTransform.position = nodeRectTransform.position; }
private void GenerateDeviceNodeUI() { foreach (ItemSlot itemSlot in hackProcess.ItemStorage.GetItemSlots()) { HackingDevice device = itemSlot.Item != null?itemSlot.Item.GetComponent <HackingDevice>() : null; if (device == null) { continue; } GameObject devicePanel = Instantiate(hackingDeviceUIPrefab, hackingDeviceLayout); RectTransform deviceRect = devicePanel.transform as RectTransform; deviceRect.sizeDelta = deviceCellSize; GUI_HackingDevice GUIDevice = devicePanel.GetComponent <GUI_HackingDevice>(); GUIDevice.SetHackingDevice(device); ForceLayoutGroupUpdates(); /////////////////////////Adding Input Node For Device///////////////////////// GameObject inputNodeUIObject = Instantiate(inputHackingNodeUIPrefab, GUIDevice.transform); RectTransform inNodeRect = inputNodeUIObject.transform as RectTransform; inNodeRect.sizeDelta = deviceNodeCellSize; inputNodeUIObject.transform.position = (Vector2)devicePanel.transform.position - new Vector2(0, deviceCellSize.y / 3); GUI_HackingNode inputNodeGUI = inputNodeUIObject.GetComponent <GUI_HackingNode>(); inputNodeGUI.SetHackingNode(device.InputNode); inputNodeUIObjects.Add(inputNodeGUI); nodeUIObjects.Add(inputNodeGUI); ///////////////////////////////////////////////////////////////////////////// /////////////////////////Adding Output Node For Device///////////////////////// GameObject outputNodeUIObject = Instantiate(outputHackingNodeUIPrefab, GUIDevice.transform); RectTransform outNodeRect = outputNodeUIObject.transform as RectTransform; outNodeRect.sizeDelta = deviceNodeCellSize; outputNodeUIObject.transform.position = (Vector2)devicePanel.transform.position + new Vector2(0, deviceCellSize.y / 3); GUI_HackingNode outputNodeGUI = outputNodeUIObject.GetComponent <GUI_HackingNode>(); outputNodeGUI.SetHackingNode(device.OutputNode); outputNodeUIObjects.Add(outputNodeGUI); nodeUIObjects.Add(outputNodeGUI); ///////////////////////////////////////////////////////////////////////////// hackingDevices.Add(GUIDevice); } }
public void FinishAddingWire(GUI_HackingNode inputNode) { newWireInput = inputNode; newWireOutput.HackNode.AddConnectedNode(newWireInput.HackNode); if (!IsServer) { int outIndex = hackNodes.IndexOf(newWireOutput.HackNode); int inIndex = hackNodes.IndexOf(newWireInput.HackNode); int[] connectionToAdd = { outIndex, inIndex }; AddHackingConnection.Send(PlayerManager.LocalPlayerScript.gameObject, hackProcess.gameObject, connectionToAdd); } isAddingWire = false; }
private void GenerateNodeConnections() { foreach (HackingNode node in outputNodes) { foreach (HackingNode subNode in node.ConnectedInputNodes) { GUI_HackingNode outputUINode = GetUIComponentOfNode(node); GUI_HackingNode inputUINode = GetUIComponentOfNode(subNode); GameObject connectingWire = Instantiate(connectingWireUIPrefab, transform); GUI_HackingWire GUIWire = connectingWire.GetComponent <GUI_HackingWire>(); GUIWire.SetStartUINode(outputUINode); GUIWire.SetEndUINode(inputUINode); GUIWire.PositionWireBody(); hackingWires.Add(GUIWire); } } }
private void UpdateWiresFromConnectionList() { DeleteOldWires(); foreach (int[] connection in connectionList) { int outputIndex = connection[0]; int inputIndex = connection[1]; GUI_HackingNode outputUINode = GetUIComponentOfNode(hackNodes[outputIndex]); GUI_HackingNode inputUINode = GetUIComponentOfNode(hackNodes[inputIndex]); GameObject connectingWire = Instantiate(connectingWireUIPrefab, transform); GUI_HackingWire GUIWire = connectingWire.GetComponent <GUI_HackingWire>(); GUIWire.SetStartUINode(outputUINode); GUIWire.SetEndUINode(inputUINode); GUIWire.PositionWireBody(); hackingWires.Add(GUIWire); } }
public void BeginAddingWire(GUI_HackingNode outputNode) { newWireOutput = outputNode; isAddingWire = true; }