public TechTreeNode(TechTreeNodeId id, string name, string description, float researchTime) { this.id = id; this.name = name; this.description = description; this.researchTime = researchTime; }
private void ConnectNodes(TechTreeNodeId parentId, TechTreeNodeId childId) { TechTreeNode parent = _nodes[parentId]; TechTreeNode child = _nodes[childId]; parent.AddChild(child); child.AddParent(parent); }
private void OnResearchFinished(TechTreeNodeId nodeId) { _curResearchingNodeId = null; if (onResearchFinished != null) { onResearchFinished(nodeId); } }
private void OnResearchStarted(TechTreeNodeId nodeId) { _curResearchingNodeId = nodeId; if (onResearchStarted != null) { onResearchStarted(nodeId); } }
private void OnResearchFinished(TechTreeNodeId nodeId) { Action upgradeAction = null; if (_upgrades.TryGetValue(nodeId, out upgradeAction)) { upgradeAction(); } }
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); }
public TechTreeNode GetNode(TechTreeNodeId id) { return(_nodes[id]); }