/** *<summary> * Takes a <see cref="NodePosition"/> and, if the position is in range and unoccupied, instantiates a node prefab * at that position and inserts it into the Nodes array *</summary> */ void spawnNode(NodePosition nodePos) { if (nodePos.inRange) { //Exit if there is already a Node at the given input position if (getNode(nodePos) != null) { return; } //Exits if the player doesn't have enough energy to spawn a node if (EnergyPollutionManager.energyValue < energyCostPerTile) { messageInterface.DisplayMessage("Not enough energy. Try growing your population to increase energy!", 4f); return; } nodeCreateEvent(nodePos, energyCostPerTile); GameObject newNode = Instantiate(nodePrefab, nodePos.position, Quaternion.identity) as GameObject; NodeModel newNodeModel = newNode.GetComponent <NodeModel>(); //Null test //Should only pop if the Prefabs get messed up if (newNodeModel == null) { Debug.LogError("The nodePrefab does not have a nodeModel component"); Destroy(newNode); return; } //Puts the new node's NodeModel in the node array //and updates activeNode nodes[nodePos.xIndex, nodePos.zIndex] = newNodeModel; newNodeModel.init(nodePos, new int[10], true); activeNode = nodePos; activeNodeUpdateEvent(activeNode); } }
void OnNodeCreateEvent(NodePosition nodePos, int nodeCost) { incrementEnergyValue(-nodeCost); }
/** *<summary> * Returns an integer representing how many characters will go unfed and 'die' this tick for a given <see cref="NodePosition"/> *</summary> */ public int getNodePollutionData(NodePosition nodePos) { return(pollutionData[nodePos.xIndex, nodePos.zIndex]); }
/** *<summary> * Sets the position of the attached GameObject from a given <see cref="NodePosition"/> on the XZ plane w/ an offset on the Y-Axis * The y-offset is given by the exposed inspector property <see cref="indicatorHeight"/> *</summary> */ public void setIndicatorPosition(NodePosition nodePos) { transform.position = new Vector3(nodePos.position.x, indicatorHeight, nodePos.position.z); }
/** *<summary> * Responds to <see cref="NodeManager.activeNodeUpdateEvent"/>. Called (at most once per frame)periodically based on user input * Updates the position of the game object based on active node location *</summary> */ void OnActiveNodeUpdateEvent(NodePosition nodePos) { setIndicatorPosition(nodePos.position); }
/** *<summary> * Returns the integer representing deficit surplus for a tile at a given <see cref="NodePositions"/> * A positive number for surplus, a negative for a deficit, a 0 for neither *</summary> */ public int getNodeData(NodePosition nodePos) { return(tickData[nodePos.xIndex, nodePos.zIndex]); }
/** *<summary> * Responds to <see cref="NodeManager.nodeDeleteEvent"/>. * Deactivates the active tile indicator *</summary> */ void OnNodeDeleteEvent(NodePosition nodePos) { active = false; }
/** *<summary> * Responds to <see cref="NodeManager.activeNodeUpdateEvent"/> * Updates the active node <see cref="NodePosition"/> *</summary> */ void OnActiveNodeUpdate(NodePosition nodePos) { activeNode = nodePos; control.controlEnabled = true; setSliderValue(NodeManager.getNode(nodePos).creatureAmounts[statIndex]); }
/** *<summary> * Responds to <see cref="NodeManager.nodeDeleteEvent"/> * Updates the active node <see cref="NodePosition"/> *</summary> */ void OnNodeDelete(NodePosition nodePos) { control.controlEnabled = false; setSliderValue(0); }
/** *<summary> * Updates the ActiveNode label to reflect the active node *</summary> */ public void updateActiveNodeLabel(NodePosition newActiveNode) { activeNodeLabel.text = newActiveNode.ToString(); }
void OnNodeDeleteEvent(NodePosition nodePos) { int[] newValues = new int[10]; updateStatsLabel(newValues); activeNodeLabel.text = "--"; }