public void StartOver() { body = TechTreeNode.firstBody; head = TechTreeNode.firstHead; respiratory = TechTreeNode.firstRespiratory; tail = TechTreeNode.firstTail; }
private void ConnectNodes(TechTreeNodeId parentId, TechTreeNodeId childId) { TechTreeNode parent = _nodes[parentId]; TechTreeNode child = _nodes[childId]; parent.AddChild(child); child.AddParent(parent); }
private void Start() { _node = Game.techTreeManager.GetNode(_id); transform.Find("Name").GetComponent <Text>().text = _node.name; _node.onStateChanged += OnNodeStateChanged; OnNodeStateChanged(_node.state); Game.techTreeManager.onResearchStarted += nodeId => _techTreeIsBusy = true; Game.techTreeManager.onResearchFinished += nodeId => _techTreeIsBusy = false; }
public void AddParent(TechTreeNode parent, Vector3 startPoint, Vector3 endPoint) { //parents.Add(parent); if (!LoadResources.arrow) { return; } float x = endPoint.x - startPoint.x; Arrow arrow; if (startPoint.y == endPoint.y) { GameObject arrowObject = ObjectPool.Instantiate(LoadResources.arrow, startPoint, Quaternion.identity, parent.transform); arrow = arrowObject.GetComponentInChildren <Arrow>(); arrow.line_0.SetPosition(0, new Vector3(-0.015F, 0, -0.1F)); arrow.line_0.SetPosition(1, new Vector3(x * 0.85F, 0, -0.1F)); arrow.line_0.SetWidth(0.1F, 0.1F); arrow.line_1.SetPosition(0, new Vector3(x * 0.85F, 0, -0.1F)); arrow.line_1.SetPosition(1, new Vector3(x, 0, -0.1F)); arrow.line_1.SetWidth(x * 0.15F, 0); arrow.corner_1.SetActive(false); arrow.corner_2.SetActive(false); arrow.line_2.gameObject.SetActive(false); arrow.line_3.gameObject.SetActive(false); } else { float y = endPoint.y - startPoint.y; GameObject arrowObject = ObjectPool.Instantiate(LoadResources.arrow, startPoint, Quaternion.identity, parent.transform); arrow = arrowObject.GetComponentInChildren <Arrow>(); arrow.line_0.SetPosition(0, new Vector3(-0.015F, 0, -0.1F)); arrow.line_0.SetPosition(1, new Vector3(x * 0.3F, 0, -0.1F)); arrow.line_0.SetWidth(0.1F, 0.1F); arrow.line_1.SetPosition(0, new Vector3(x * 0.3F, 0, -0.1F)); arrow.line_1.SetPosition(1, new Vector3(x * 0.7F, y, -0.1F)); arrow.line_1.SetWidth(0.1F, 0.1F); arrow.line_2.SetPosition(0, new Vector3(x * 0.7F, y, -0.1F)); arrow.line_2.SetPosition(1, new Vector3(x * 0.85F, y, -0.1F)); arrow.line_2.SetWidth(0.1F, 0.1F); arrow.line_3.SetPosition(0, new Vector3(x * 0.85F, y, -0.1F)); arrow.line_3.SetPosition(1, new Vector3(x, y, -0.1F)); arrow.line_3.SetWidth(x * 0.15F, 0); arrow.corner_1.transform.localPosition = new Vector3(x * 0.3F + 0.005F, y > 0 ? -0.005F : 0.005F, 0); arrow.corner_2.transform.localPosition = new Vector3(x * 0.7F - 0.005F, y - (y > 0 ? -0.005F : 0.005F), 0); } arrow.start = parent; arrow.end = this; }
public void AddParent(TechTreeNode parent) { _parents.Add(parent); parent.onStateChanged += parentState => { if (parentState == TechTreeNodeState.Researched) { TryChangeState(TechTreeNodeState.Hidden, TechTreeNodeState.Available); } }; }
public void AddParent(TechTreeNode parent, Vector3 startPoint, Vector3 endPoint) { //parents.Add(parent); if (!LoadResources.arrow) { return; } float x = endPoint.x - startPoint.x; Arrow arrow; if (startPoint.y == endPoint.y) { GameObject arrowObject = ObjectPool.Instantiate(LoadResources.arrow, startPoint, Quaternion.identity, parent.transform); arrow = arrowObject.GetComponentInChildren<Arrow>(); arrow.line_0.SetPosition(0, new Vector3(-0.015F, 0, -0.1F)); arrow.line_0.SetPosition(1, new Vector3(x * 0.85F, 0, -0.1F)); arrow.line_0.SetWidth(0.1F, 0.1F); arrow.line_1.SetPosition(0, new Vector3(x * 0.85F, 0, -0.1F)); arrow.line_1.SetPosition(1, new Vector3(x, 0, -0.1F)); arrow.line_1.SetWidth(x * 0.15F, 0); arrow.corner_1.SetActive(false); arrow.corner_2.SetActive(false); arrow.line_2.gameObject.SetActive(false); arrow.line_3.gameObject.SetActive(false); } else { float y = endPoint.y - startPoint.y; GameObject arrowObject = ObjectPool.Instantiate(LoadResources.arrow, startPoint, Quaternion.identity, parent.transform); arrow = arrowObject.GetComponentInChildren<Arrow>(); arrow.line_0.SetPosition(0, new Vector3(-0.015F, 0, -0.1F)); arrow.line_0.SetPosition(1, new Vector3(x * 0.3F, 0, -0.1F)); arrow.line_0.SetWidth(0.1F, 0.1F); arrow.line_1.SetPosition(0, new Vector3(x * 0.3F, 0, -0.1F)); arrow.line_1.SetPosition(1, new Vector3(x * 0.7F, y, -0.1F)); arrow.line_1.SetWidth(0.1F, 0.1F); arrow.line_2.SetPosition(0, new Vector3(x * 0.7F, y, -0.1F)); arrow.line_2.SetPosition(1, new Vector3(x * 0.85F, y, -0.1F)); arrow.line_2.SetWidth(0.1F, 0.1F); arrow.line_3.SetPosition(0, new Vector3(x * 0.85F, y, -0.1F)); arrow.line_3.SetPosition(1, new Vector3(x, y, -0.1F)); arrow.line_3.SetWidth(x * 0.15F, 0); arrow.corner_1.transform.localPosition = new Vector3(x * 0.3F + 0.005F, y > 0 ? -0.005F : 0.005F, 0); arrow.corner_2.transform.localPosition = new Vector3(x * 0.7F - 0.005F, y - (y > 0 ? -0.005F : 0.005F), 0); } arrow.start = parent; arrow.end = this; }
public void StartResearching(TechTreeNodeId nodeId) { if (_curResearchingNodeId.HasValue) { throw new Exception("Failed to start research " + nodeId + ": TechTreeManager already has research: " + _curResearchingNodeId.Value); } TechTreeNode node = _nodes[nodeId]; Process p = node.CreateResearchProcess(); p.onStarted += () => OnResearchStarted(nodeId); p.onFinished += () => OnResearchFinished(nodeId); Game.processesManager.StartProcess(p); }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { Game.Instance().techTree.SetActive(false); } if (current == null) { current = transform.GetChild(0).GetChild(0).GetChild(0).GetChild(0).GetComponent <TechTreeNode>(); current.GetComponent <Button>().Select(); } if (Input.GetKeyDown(KeyCode.A) && barHorizontal.value >= 0) { barHorizontal.value -= stepHorizontal; } else if (Input.GetKeyDown(KeyCode.D) && barHorizontal.value <= 1) { barHorizontal.value += stepHorizontal; } if (Input.GetKeyDown(KeyCode.W) && barVertical.value >= 0) { barVertical.value -= stepVertical; } else if (Input.GetKeyDown(KeyCode.S) && barVertical.value <= 1) { barVertical.value += stepVertical; } else { float v = Input.GetAxis("Mouse ScrollWheel"); if (v > 0) { barVertical.value -= stepVertical; } else if (v < 0) { barVertical.value += stepVertical; } } if (Input.GetKeyDown(KeyCode.Space)) { LightNode(); } }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { Game.Instance().techTree.SetActive(false); } if (current == null) { current = transform.GetChild(0).GetChild(0).GetChild(0).GetChild(0).GetComponent<TechTreeNode>(); current.GetComponent<Button>().Select(); } if (Input.GetKeyDown(KeyCode.A) && barHorizontal.value >= 0) { barHorizontal.value -= stepHorizontal; } else if (Input.GetKeyDown(KeyCode.D) && barHorizontal.value <= 1) { barHorizontal.value += stepHorizontal; } if (Input.GetKeyDown(KeyCode.W) && barVertical.value >= 0) { barVertical.value -= stepVertical; } else if (Input.GetKeyDown(KeyCode.S) && barVertical.value <= 1) { barVertical.value += stepVertical; } else { float v = Input.GetAxis("Mouse ScrollWheel"); if (v > 0) { barVertical.value -= stepVertical; } else if (v < 0) { barVertical.value += stepVertical; } } if (Input.GetKeyDown(KeyCode.Space)) { LightNode(); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); TechTreeNode node = (TechTreeNode)target; if (GUILayout.Button("设为起点")) { start = node; } if (GUILayout.Button("设为终点")) { end = node; if (start && start != end) { Vector3 startPoint = start.transform.position + new Vector3(1.5F, 0, -1); Vector3 endPoint = end.transform.position + new Vector3(-1.5F, 0, -1); if (endPoint.x > startPoint.x) { end.AddParent(start, startPoint, endPoint); } } } }
private void AddNode(TechTreeNode node) { _nodes.Add(node.id, node); }
public void AddChild(TechTreeNode child) { _children.Add(child); }