bool setActiveNode() { if (mRotor.mChilds.Count > 0) { if ((STLevel.GetRootNode().activeNode != null) && (this != STLevel.GetRootNode().activeNode)) { STLevel.GetRootNode().activeNode.mVisual.HideRootNodeMark(); } STLevel.GetRootNode().SetActiveNode(this); } else { if (mParent != null) { if ((STLevel.GetRootNode().activeNode != null) && (mParent != STLevel.GetRootNode().activeNode)) { STLevel.GetRootNode().activeNode.mVisual.HideRootNodeMark(); } STLevel.GetRootNode().SetActiveNode(mParent); } else { if ((STLevel.GetRootNode().activeNode != null) && (this != STLevel.GetRootNode().activeNode)) { STLevel.GetRootNode().activeNode.mVisual.HideRootNodeMark(); } STLevel.GetRootNode().SetActiveNode(this); } } if (STLevel.GetRootNode().activeNode != null) { //Debug.Log (STLevel.GetRootNode().activeNode.transform.position); if (STLevel.GetRootNode().prevActiveNode != null) { // Debug.Log (STLevel.GetRootNode().prevActiveNode.transform.position); if (STLevel.GetRootNode().activeNode == STLevel.GetRootNode().prevActiveNode) { return(false); } } } if (STLevel.GetRootNode().prevActiveNode != null) { STNode prevActiveNode = STLevel.GetRootNode().prevActiveNode; prevActiveNode.transform.localPosition = new Vector3(prevActiveNode.transform.localPosition.x, prevActiveNode.transform.localPosition.y, prevActiveNode.zCoord); } STLevel.GetRootNode().prevAnimActiveNode = STLevel.GetRootNode().prevActiveNode; STLevel.GetRootNode().prevActiveNode = STLevel.GetRootNode().activeNode; return(true); }
void changeGameMode(bool isEditModeVal) { if (isEditModeVal == true) { STLevel.GetControl().ChangeEnabledState(false); STLevel.Solve(); STLevel.isEditMode = true; STLevel.GetRootNode().SetEditMode(true); STLevel.GetRootNode().SetEnableTouches(true); STLevel.GetNodesNet().ChangeNetNodesState(false); } else { STLevel.CalcTreeRects(); STLevel.GetRootNode().SaveSolution(); editNodesMode = false; STLevel.GetRootNode().SetEditMode(false); STLevel.GetNodesNet().ChangeNetNodesState(false); STLevel.GetControl().ChangeEnabledState(true); STLevel.isEditMode = false; STLevel.GetRootNode().SetEnableTouches(true); STLevel.StartLevel(); } }
void hideSelectAnimationFinishedFromLeaf() { leavesAnimationFinishedCount++; //transform.position = new Vector3 (transform.position.x, transform.position.y, - nodeDepth ); // Debug.Log (transform.position); // Debug.Log (STLevel.GetRootNode().prevActiveNode.transform.position); if (this == STLevel.GetRootNode().prevAnimActiveNode) { if (STLevel.GetRootNode().hideAnimationsCount == 0) { hideNodeSelection(); } // Debug.Log ("PAA"); } // Debug.Log("hide"); if (leavesAnimationFinishedCount == mRotor.mChilds.Count) { if (isSelected == true) { //Debug.Log ("hide"); setAnimatorForUnselectState(); // Debug.Log("hideSelectAnimationFinishedFromLeaf - 1"); hideNodeSelection(); } } }
public static void StartLevel() { activeTreeNodes.Clear(); STLevel.GetRootNode().GetTreeNodes(ref activeTreeNodes); STLevel.GetRootNode().SetAnimation(); }
public static List <STNode> GetTouchedNodesList(Vector3 touchPosition) { List <STNode> nodesList = new List <STNode> (); List <STNode> touchedNodesList = new List <STNode> (); STLevel.GetRootNode().GetTouchedNodes(ref nodesList, touchPosition); if (nodesList.Count == 0) { STLevel.GetRootNode().GetTouchedLinkNodes(ref nodesList, touchPosition); foreach (STNode node in nodesList) { if (node.CheckIfLinksTouched(touchPosition) == true) { touchedNodesList.Add(node); } //DebugDraw.DrawRect (node.minPoint, node.maxPoint, Color.red); //DebugDraw.DrawCrossMark (node.transform.position, 10, Color.cyan); } } else { foreach (STNode node in nodesList) { touchedNodesList.Add(node); DebugDraw.DrawCrossMark(node.transform.position, 10, Color.green); } } return(touchedNodesList); }
void loadNodes(STSerializedNode sNode) { mRotor.transform.rotation = new Quaternion(sNode.rotation.X, sNode.rotation.Y, sNode.rotation.Z, sNode.rotation.W); transform.localPosition = new Vector3(sNode.position.X, sNode.position.Y, sNode.position.Z); if (sNode.node_type == 1) { this.changeNodeType(); } if (sNode.children == null) { return; } foreach (STSerializedNode nodeChild in sNode.children) { STRootNode root = STLevel.GetRootNode(); STNode node = Instantiate(root.NodePref) as STNode; if (node != null) { node.transform.parent = mRotor.transform; node.mParent = this; mRotor.mChilds.Add(node); node.LoadNodes(nodeChild); } } }
void windowShowLoadDialog() { scrollPosition = GUILayout.BeginScrollView(scrollPosition); { foreach (string levelName in levelsArray) { GUILayout.BeginHorizontal(); { GUILayout.Label(levelName); if (GUILayout.Button("Load")) { editNodesMode = false; STLevel.LoadLevel(levelName); STLevel.GetNodesNet().ChangeNetNodesState(false); STLevel.GetRootNode().SetEnableTouches(true); } if (GUILayout.Button("Delete")) { STLevel.DeleteLevel(levelName); updateLevelsList(); } } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); }
public void SetAnimation() { if (mParent != null) { float linkLength = mLink.GetLength(mParent.transform.position, transform.position); // Debug.Log (linkLength); // float koef = 8.0f; if (linkLength < 130) { //mAnimator.speed = 1.0f * koef; animClip = 1; //nodeAnimationType = NODE_TYPE_ANIM.NODE1; } else if (linkLength < 250) { //mAnimator.speed = 0.75f * koef; animClip = 2; //nodeAnimationType = NODE_TYPE_ANIM.NODE2; } else if (linkLength < 360) { //mAnimator.speed = 0.5f * koef; animClip = 3; //nodeAnimationType = NODE_TYPE_ANIM.NODE3; } else if (linkLength < 480) { //mAnimator.speed = 0.25f * koef; animClip = 4; //nodeAnimationType = NODE_TYPE_ANIM.NODE4; } //mAnimator.SetInteger (ANIM_PNAME_ANIMSTATE, -1); //mAnimator.SetInteger (ANIM_PNAME_LINKLENGTH, animClip); mLink.transform.localPosition = new Vector3(0, linkLength - nodeSize / 2.2f, 1); float animSpeed = 1.0f; float unselectAnimSpeed = animSpeed * (STLevel.GetRootNode().treeDepth - nodeDepth + 1); float selectAnimSpeed = animSpeed * nodeDepth; animation["Unselect1"].speed = unselectAnimSpeed; animation["Unselect2"].speed = unselectAnimSpeed; animation["Unselect3"].speed = unselectAnimSpeed; animation["Unselect4"].speed = unselectAnimSpeed; animation["Select1"].speed = selectAnimSpeed; animation["Select2"].speed = selectAnimSpeed; animation["Select3"].speed = selectAnimSpeed; animation["Select4"].speed = selectAnimSpeed; } foreach (STNode node in mRotor.mChilds) { node.SetAnimation(); } }
void finishHideSelectAnimation() { STLevel.GetRootNode().hideAnimationsCount--; // if (isUnselectFromNode = true) mParent.hideSelectAnimationFinishedFromLeaf(); // else }
public void Rotate(float angleDeg) { if (STLevel.GetRootNode().activeNode != null) { STLevel.GetRootNode().activeNode.mRotor.transform.rotation = Quaternion.Euler(0, 0, angleDeg); // STLevel.GetRootNode().activeNode.UpdateLinkPosition(STLevel.GetRootNode().activeNode.transform.position); } }
void setActiveSelectionFlagsActive() { // Debug.Log (transform.position); STLevel.GetRootNode().activeNodesCount++; isSelectedActive = true; foreach (STNode node in mRotor.mChilds) { node.setActiveSelectionFlagsActive(); } }
void finishScaleAnimation() { setAnimationForSelectState(); STLevel.GetRootNode().scaleAnimationsCount--; // checkForFinishAnimation(); StartCoroutine(turnOffAnimatorWithDelay()); // setAnimatorForIdleState(); // animationNodeScale = mLink.lineSelSprite.transform.localScale; }
void nodeRotate(float angle, float time) { STLevel.HideOverlayedNodes(); if (STLevel.GetRootNode().activeNode != null) { rotAngle = STLevel.GetRootNode().activeNode.mRotor.transform.rotation.eulerAngles; } iTween.ValueTo(gameObject, iTween.Hash("from", 0, "to", angle, "looptype", "none", "time", time, "onUpdate", "angleRotateChange", "onComplete", "angleRotateChangeComplete")); }
void checkForPrevActiveFlags() { if (isSelectedActive == true) { STLevel.GetRootNode().activeNodesCount--; } foreach (STNode node in mRotor.mChilds) { node.checkForPrevActiveFlags(); } }
void startSelectAnimation() { // mLink.lineSelSprite.transform.localScale = animationNodeScale; //if (mRotor.mChilds.Count > 0) // Debug.Log( "Start select" ); STLevel.GetRootNode().showAnimationsCount++; isSelected = true; if (mParent != null) { mParent.leavesAnimationFinishedCount = 0; } }
void Start() { genBranchesCountStringsMin = new List <string> (); genBranchesStringMatchesMin = new List <bool> (); genBranchesCountStringsMax = new List <string> (); genBranchesStringMatchesMax = new List <bool> (); genBranchesLengthStringsMin = new List <string> (); genBranchesLengthMatchesMin = new List <bool> (); genBranchesLengthStringsMax = new List <string> (); genBranchesLengthMatchesMax = new List <bool> (); for (int i = 0; i < 6; i++) { genBranchesStringMatchesMin.Add(true); genBranchesStringMatchesMax.Add(true); genBranchesLengthMatchesMin.Add(true); genBranchesLengthMatchesMax.Add(true); } reg = new Regex("^[1-6]"); //regLength = new Regex ("^[1-4]"); scrollPosition = Vector2.zero; fileNameString = "puzzle"; depthLevelString = "3"; updateLevelsList(); oldToogleState = editMode; windowRect = new Rect(Screen.width * 0.75f / guiScale.x, 0, Screen.width * 0.25f / guiScale.x, Screen.height / guiScale.y); toogleRect = new Rect(Screen.width * 0.0f, Screen.width * 0.0f, Screen.width * 0.1f / guiScale.x, Screen.width * 0.075f / guiScale.y); toolBarRect = new Rect(Screen.width * 0.025f / guiScale.x, Screen.width / 10 / guiScale.y, Screen.width * 0.1f, Screen.width * 0.5f); scrollPosition = new Vector2(Screen.width, windowRect.y); //STLevel.GetNodesNet().ChangeNetNodesState(false); if (STScene.getMode() == SCENE_MODE.TEST_ANIM) { //changeGameMode (true); STLevel.isEditMode = false; STLevel.GetRootNode().SetEditMode(false); StartCoroutine(genLevelWithDelay()); } }
void RotateNode() { if (STLevel.GetRootNode().activeNode == null) { return; } rotAngle = STLevel.GetRootNode().activeNode.mRotor.transform.rotation.eulerAngles; // nodeRotatePosition = STLevel.GetRootNode().activeNode.transform.position; touchType = TouchType.move_t; STLevel.HideOverlayedNodes(); }
public static void HandleOverlayedNodes() { if (STLevel.GetRootNode().GetActiveNode() == null) { Debug.Log("root null"); return; } STLevel.GetRootNode().ClearOverlayedNodes(); SetOverlayedNodes(activeTreeNodes); }
public static void UpdateCameraPosition() { float time = 0.3f; Vector2 branchPos2D = new Vector2(); Vector3 branchPos = STLevel.GetRootNode().activeNode.transform.position; branchPos2D.x = branchPos.x; branchPos2D.y = branchPos.y; float maxBranchLength = STLevel.GetBranchSize(); STScene.Instance().moveCamera(branchPos2D, maxBranchLength, time); }
void setActiveSelectionLeafesFlags() { if (STLevel.GetRootNode().activeNode != null) { //if (STLevel.GetRootNode().selectionContainsActiveNodes == false) //STLevel.GetRootNode().activeNodesCount = 0; // != null) STLevel.GetRootNode().activeNodesCount = 0; //STLevel.GetRootNode().selectionContainsActiveNodes = false; STLevel.GetRootNode().activeNode.checkForPrevActiveFlags(); STLevel.GetRootNode().setActiveSelectionFlagsNonactive(); STLevel.GetRootNode().activeNode.setActiveSelectionFlagsActive(); } }
void hideBranchSelection() { STLevel.GetRootNode().hideAnimationsCount = 0; ; // STLevel.GetRootNode().finishSelectAnimationsCount = 0; setActiveSelectionLeafesFlags(); STLevel.GetRootNode().startHideAnimationFromLeafes(); if (STLevel.GetRootNode().activeNode != null) { if (STLevel.GetRootNode().activeNode.isSelected == true) { STLevel.GetRootNode().activeNode.setAnimatorForUnselectState(); } } }
public void GenNextNode(int N, int depth, int prevPattern, int curBranchLength) { if (N == 0) { return; } STPattern pattern = STPatternManager.GetPattern(depth); List <int> paternVects = new List <int>(); List <Vector3> vectPositions = STLevel.GetNodesNet().GetGenPositions(pattern, transform.position, prevPattern, paternVects, curBranchLength); int i = 0; if (vectPositions != null) { foreach (Vector3 nodePos in vectPositions) { STRootNode root = STLevel.GetRootNode(); STNode nodePref = Instantiate(root.NodePref) as STNode; if (nodePref != null) { nodePref.brenchLength = this.brenchLength + (((paternVects[i] - 1) / 8) + 1); nodePref.transform.parent = mRotor.transform; nodePref.mParent = this; nodePref.nodeDepth = depth; mRotor.mChilds.Add(nodePref); nodePref.transform.position = new Vector3(nodePos.x, nodePos.y, -depth); STLevel.GetRootNode().SetTreeDepth(depth); } i++; } } i = 0; foreach (STNode node in mRotor.mChilds) { node.GenNextNode(N - 1, depth + 1, paternVects[i], node.brenchLength); i++; } }
void OnMouseDown() { if (touchType != TouchType.none_t) { return; } if (Input.touchCount > 1) { return; } if (STLevel.isEditMode == false) { angleQueue.Clear(); delayTime = delayDist = 0; prevTouchPosition = getTouchPosition(); if (STLevel.GetRootNode().activeNode != null) { nodeRotatePosition = STLevel.GetRootNode().activeNode.transform.position; } touchBeginPosition = getTouchPosition(); beginVector = (touchBeginPosition - nodeRotatePosition); // Debug.Log ("MOUSE_DOWN - " + beginVector); prevRotVector = beginVector; touchType = TouchType.not_definded_t; } else { SelectNode(); if (currentTouchedObject < nodesList.Count) { nodesList [currentTouchedObject].onMouseDown(); } touchType = TouchType.move_t; } }
void showBranchSelection(STNode startNode) { // Debug.Log( "show branch selection" ); STLevel.GetRootNode().isShowingBranchAnimation = false; //if (mRotor.mChilds.Count != 0) //{ // if (startNode.isSelected == true) // { // //startNode.showAllBranchesAnimation(); // StartCoroutine(showBranchSelectionWithDelay(true)); showBranchSelectionWithDelay(true); //Debug.Log ("SELECTED"); // return; //} startNode.showTreeSelection(startNode, true); }
void finishSelectAnimation() { showTreeSelection(this, false); STLevel.GetRootNode().showAnimationsCount--; STLevel.GetRootNode().activeNodesCount--; // Debug.Log (STLevel.GetRootNode().activeNodesCount); if ((STLevel.GetRootNode().activeNodesCount == 1) && (mRotor.mChilds.Count == 0)) { //StartCoroutine(showBranchSelectionWithDelay(false)); showBranchSelectionWithDelay(false); } StartCoroutine(turnOffAnimatorWithDelay()); }
void guiNodesButton() { editNodesMode = !editNodesMode; if (editNodesMode == true) { STLevel.GetNodesNet().ChangeNetNodesState(true); STLevel.GetRootNode().SetEditMode(true); STLevel.GetRootNode().SetEnableTouches(false); } else { STLevel.GetNodesNet().ChangeNetNodesState(false); STLevel.GetRootNode().SetEditMode(true); STLevel.GetRootNode().SetEnableTouches(true); } }
public void onMouseDown() { if (STLevel.isEditMode == false) { return; } // showBranchSelection(); STLevel.GetRootNode().HideAllGUIS(); mUI.ShowGUI(true); // if (mParent != null) { STLevel.GetNodesNet().ShowElementNetNode(mParent.transform.position); } else { STLevel.GetNodesNet().ShowElementNetNode(this.transform.position); } }
public void MirrorLevel(STNode prevNode, bool isFlipped, bool isYMirror) { List <Vector3> positions = new List <Vector3> (); foreach (STNode node in mRotor.mChilds) { if (isFlipped == false) { if (isYMirror == true) { positions.Add(new Vector3(node.transform.position.x, -node.transform.position.y, node.transform.position.z)); } else { positions.Add(new Vector3(-node.transform.position.x, node.transform.position.y, node.transform.position.z)); } } else { positions.Add(new Vector3(-node.transform.position.x, -node.transform.position.y, node.transform.position.z)); } } int i = 0; foreach (Vector3 nodePos in positions) { STRootNode root = STLevel.GetRootNode(); STNode nodePref = Instantiate(root.NodePref) as STNode; nodePref.transform.position = nodePos; prevNode.mRotor.mChilds.Add(nodePref); nodePref.transform.parent = prevNode.mRotor.transform; nodePref.mParent = prevNode; if (mRotor.mChilds.Count > 0) { nodePref.nodeDepth = mRotor.mChilds[0].nodeDepth; } mRotor.mChilds[i].MirrorLevel(nodePref, isFlipped, isYMirror); i++; } }
void showBranchSelection() { // Debug.Log( "SHOW BRANCH" ); if (setActiveNode() == false) { // Debug.Log( "ACTIVE - FALSE" ); return; } hideBranchSelection(); //StartAnimator(); STNode activeNode = STLevel.GetRootNode().activeNode; activeNode.zCoord = activeNode.transform.localPosition.z; STLevel.GetRootNode().showAnimationsCount = 0; if (mRotor.mChilds.Count > 0) { showBranchSelection(this); } else { if (mParent != null) { showBranchSelection(mParent); } else { showBranchSelection(this); } } // STLevel.GetRootNode().prevActiveNode.mVisual.HideRootNodeMark(); }
void startShowAllBranchesAnimation(bool isSelected) { // Debug.Log (STLevel.GetRootNode().showAnimationsCount); if (STLevel.GetRootNode().isShowingBranchAnimation == true) { //Debug.Log ("IS SHOWING"); return; } if ((STLevel.GetRootNode().showAnimationsCount == 0) || (isSelected == true)) //if (true) { STLevel.GetRootNode().isShowingBranchAnimation = true; //Debug.Log ("SHOW"); if (STLevel.GetRootNode().activeNode != null) { STLevel.GetRootNode().scaleAnimationsCount = 0; STLevel.GetRootNode().activeNode.showAllBranchesAnimation(); } } }