/// <summary> /// Determines which set of snowman accessories to set active in the world base on the current snowman node. Also /// sets the selection flag on the approprate scene node /// </summary> private void UpdateSceneObjects() { SnowmanNodes currentNode = snowmanNodes[currentNodeIndex]; BaseAccessories.SetActive(false); TorsoAccessories.SetActive(false); HeadAccessories.SetActive(false); switch (currentNode) { case SnowmanNodes.BASE: BaseAccessories.SetActive(true); break; case SnowmanNodes.TORSO: TorsoAccessories.SetActive(true); break; case SnowmanNodes.HEAD: HeadAccessories.SetActive(true); break; } BaseNode.UpdateSelections(currentNode); }
/// <summary> /// Get the current snowman scene node object /// </summary> /// <returns></returns> private SceneNode GetSnowmanSceneNode() { SnowmanNodes currentNodeType = snowmanNodes[currentNodeIndex]; SceneNode sceneNode = BaseNode.GetSnowmanNode(currentNodeType); if (sceneNode == null) { Debug.LogError("Unable to get current scene node: " + GetSnowmanNodeName(currentNodeType)); } return(sceneNode); }
/// <summary> /// Set the selected flag for the scene node /// </summary> /// <param name="selected"></param> public void UpdateSelections(SnowmanNodes selectedNode) { selected = selectedNode == node; foreach (Transform child in transform) { SceneNode childNode = child.GetComponent <SceneNode>(); if (childNode != null) { childNode.UpdateSelections(selectedNode); } } }
/// <summary> /// Get the display name of a given snowman scene node /// </summary> /// <param name="node"></param> /// <returns></returns> private string GetSnowmanNodeName(SnowmanNodes node) { switch (node) { case SnowmanNodes.BASE: return("Base"); case SnowmanNodes.TORSO: return("Torso"); case SnowmanNodes.HEAD: return("Head"); default: return(string.Empty); } }
/// <summary> /// Get the appropriate snowman scene node based on the provided scene node level provided /// </summary> /// <param name="desiredNode"></param> /// <returns></returns> public SceneNode GetSnowmanNode(SnowmanNodes desiredNode) { if (node == desiredNode) { return(this); } SceneNode nodeFound = null; foreach (Transform child in transform) { SceneNode childNode = child.GetComponent <SceneNode>(); if (childNode != null) { nodeFound = childNode.GetSnowmanNode(desiredNode); if (nodeFound != null) { break; } } } return(nodeFound); }