void shufflePiece(Transform piece, Renderer pieceRanderer, PairGamePiece pieceScript) { isOverLap = false; piece.gameObject.SetActive(true); piece.localPosition = new Vector2(Random.Range(minXPos, maxXPos), Random.Range(minYPos, maxYPos)); for (int i = 0; i < activePiecesList.Count; i++) { if (piece.name != activePiecesList[i].name && activePiecesList[i].gameObject.activeSelf) { if (pieceRanderer.bounds.Intersects(activePiecesRenderersList[i].bounds)) { isOverLap = true; } } } if (isOverLap) { shufflePiece(piece, pieceRanderer, pieceScript); } else { tempDifficulty = RestrictionMap.findDifficulty(piece.position); if (tempDifficulty == 0) { pieceScript.setPieceActive(2); } else if (tempDifficulty == 1) { pieceScript.setPieceActive(3); } else if (tempDifficulty == 2) { pieceScript.setPieceActive(4); } else if (tempDifficulty == 3 || tempDifficulty == 4 || tempDifficulty == 5) { pieceScript.setPieceActive(1); } } }
private int getRestrictionStatusCount(int [,] level) { int count = 0; for (int i = 0; i < level.GetLength(1); i++) { for (int j = 0; j < level.GetLength(0); j++) { if (level[j, i] != -1) { Vector2 pipePosition = new Vector2(i * 2 - 9f, j * -2 + 4); if (RestrictionMap.findDifficulty(pipePosition) >= 4) { count++; } } } } return(count); }
private void CutHole(Vector2 imageSize, Vector2 imageLocalPosition, Vector2 mousePosition) { switch (GameManagerAraba.Instance.level) { case 0: levelDragType = DragDetectorAraba.DragTypeAraba.Horizontal; break; case 1: levelDragType = DragDetectorAraba.DragTypeAraba.Vertical; break; case 2: levelDragType = DragDetectorAraba.DragTypeAraba.Circular; break; case 3: levelDragType = DragDetectorAraba.DragTypeAraba.AllMotions; break; default: levelDragType = DragDetectorAraba.DragTypeAraba.None; break; } if (levelDragType == dragDetector.currentDragType) { int difficulty = RestrictionMap.findDifficulty(v); //print(difficulty); switch (difficulty) { case 1: restrictRatio = 0.5f; break; case 2: restrictRatio = 0.33f; break; case 3: restrictRatio = 0.5f; break; default: restrictRatio = 1.0f; break; } if (infoHasFeedbackText) { Text feedback = GameManagerAraba.Instance.feedbackText; switch (GameManagerAraba.Instance.level) { case 0: feedback.text = GameManagerAraba.Instance.wrongFeedbackTexts[0]; break; case 1: feedback.text = GameManagerAraba.Instance.wrongFeedbackTexts[1]; break; case 2: feedback.text = GameManagerAraba.Instance.wrongFeedbackTexts[2]; break; case 3: //feedback.text = "Herhangi bir hareketle aracý kurulamaya devam ediniz!"; feedback.text = GameManagerAraba.Instance.wrongFeedbackTexts[3]; break; default: feedback.text = "Herhangi bir hareketle araca cila atmaya devam ediniz!"; break; } infoHasFeedbackText = false; } dragDetector.lastRightDragTypeTime = Time.time; Rect textureRect = new Rect(0.0f, 0.0f, 1.0f, 1.0f); Rect positionRect = new Rect( (imageLocalPosition.x - 0.5f * EraserMaterial.mainTexture.width) / imageSize.x, (imageLocalPosition.y - 0.5f * EraserMaterial.mainTexture.height) / imageSize.y, EraserMaterial.mainTexture.width / imageSize.x, EraserMaterial.mainTexture.height / imageSize.y ); GL.PushMatrix(); GL.LoadOrtho(); if (EraserMaterial.color.a <= 2.5f) { EraserMaterial.color = new Color(EraserMaterial.color.r, EraserMaterial.color.g, EraserMaterial.color.b, restrictRatio + tex.GetPixel((int)mousePosition.x, (int)mousePosition.y).a); } for (int i = 0; i < EraserMaterial.passCount; i++) { EraserMaterial.SetPass(i); GL.Begin(GL.QUADS); GL.Color(new Color(0.1f, 0.1f, 0.1f, 1.0f)); GL.TexCoord2(textureRect.xMin, textureRect.yMax); GL.Vertex3(positionRect.xMin, positionRect.yMax, 0.0f); GL.TexCoord2(textureRect.xMax, textureRect.yMax); GL.Vertex3(positionRect.xMax, positionRect.yMax, 0.0f); GL.TexCoord2(textureRect.xMax, textureRect.yMin); GL.Vertex3(positionRect.xMax, positionRect.yMin, 0.0f); GL.TexCoord2(textureRect.xMin, textureRect.yMin); GL.Vertex3(positionRect.xMin, positionRect.yMin, 0.0f); GL.End(); } GL.PopMatrix(); } //else //{ // Text feedback = GameManagerAraba.Instance.feedbackText; // switch (GameManagerAraba.Instance.level) // { // case 0: // feedback.text = GameManagerAraba.Instance.feedbackTexts[0]; // break; // case 1: // feedback.text = GameManagerAraba.Instance.feedbackTexts[1]; // break; // case 2: // feedback.text = GameManagerAraba.Instance.feedbackTexts[2]; // break; // case 3: // //feedback.text = "Lütfen istediðiniz bir hareketle aracý kurulayýnýz!"; // feedback.text = GameManagerAraba.Instance.feedbackTexts[3]; // break; // default: // feedback.text = "Lütfen istediðiniz bir hareketle araca cila atýnýz!"; // break; // } //} }
public void shufflePosition(bool isStraightLine, bool isRotationChanging, bool isScaleChanging, bool isMathPiece, bool isAlone) { isStraightLineup = isStraightLine; if (targetPosition == Vector3.zero) { targetPosition = transform.position; shadowRotation = transform.rotation; initialPosition = targetPosition; } isOverlap = false; if (isScaleChanging) { if (Random.Range(0, 5) < 0.5f) { tempScale = Random.Range(0.6f, 0.9f); } else { tempScale = Random.Range(1.1f, 1.4f); } transform.localScale = new Vector3(tempScale, tempScale, 1); } else { isOnTrueScale = true; } if (isRotationChanging) { transform.localEulerAngles = new Vector3(0, 0, Random.Range(100, 260)); } else { isOnTrueRotation = true; } if (!isStraightLine) { if (!isMathPiece) { transform.localPosition = new Vector3(Random.Range(minRandomX, maxRandomX), Random.Range(minRandomY, maxRandomY), 0); } else { transform.localPosition = new Vector3(Random.Range(-6.0f, 6.0f), Random.Range(-2.5f, 2.5f), 0); } } else { //StraightLine random position PieceGame.Instance.pieceSlider.slidingPiecesList.Add(transform); } if (thisRenderer == null) { thisRenderer = transform.GetComponent <Renderer>(); } if (!isAlone) { foreach (Renderer child in PieceGame.Instance.pieceList.GetComponentsInChildren <Renderer>()) { if (child.gameObject.activeSelf && (child.name != transform.name) && child.name != "pieceText") { if (child.bounds.Intersects(thisRenderer.bounds)) { isOverlap = true; } } } } if (isOverlap) { shufflePosition(isStraightLineup, isRotationChanging, isScaleChanging, isMathPiece, isAlone); } else { if (!isStraightLineup && !PieceGame.Instance.isTooMuchRedArea && RestrictionMap.findDifficulty(transform.position) >= 4) { shufflePosition(isStraightLineup, isRotationChanging, isScaleChanging, isMathPiece, isAlone); } else { gameObject.SetActive(true); firstPosition = transform.position; shadowScript.position = targetPosition; shadowScript.rotation = shadowRotation; } } //if (isOverlap) // shufflePosition(isStraightLineup, isRotationChanging, isScaleChanging, isMathPiece, isAlone); //else //{ // if (!isStraightLineup) // { // tempDifficulty = RestrictionMap.findDifficulty(transform.position); // if (tempDifficulty >= 4) // { // if (PieceGame.Instance.redPieceCount < PieceGame.Instance.redPieceSlot) // { // PieceGame.Instance.redPieceCount++; // gameObject.SetActive(true); // firstPosition = transform.position; // shadowScript.position = targetPosition; // shadowScript.rotation = shadowRotation; // difficulty = 4; // } // else // shufflePosition(isStraightLineup, isRotationChanging, isScaleChanging, isMathPiece, isAlone); // } // else if (tempDifficulty == 3) // { // if (PieceGame.Instance.bluePieceCount < PieceGame.Instance.bluePieceSlot) // { // PieceGame.Instance.bluePieceCount++; // gameObject.SetActive(true); // firstPosition = transform.position; // shadowScript.position = targetPosition; // shadowScript.rotation = shadowRotation; // difficulty = 3; // } // else // shufflePosition(isStraightLineup, isRotationChanging, isScaleChanging, isMathPiece, isAlone); // } // else if (tempDifficulty == 2) // { // if (PieceGame.Instance.cyanPieceCount < PieceGame.Instance.cyanPieceSlot) // { // PieceGame.Instance.cyanPieceCount++; // gameObject.SetActive(true); // firstPosition = transform.position; // shadowScript.position = targetPosition; // shadowScript.rotation = shadowRotation; // difficulty = 2; // } // else // shufflePosition(isStraightLineup, isRotationChanging, isScaleChanging, isMathPiece, isAlone); // } // else if (tempDifficulty == 1) // { // if (PieceGame.Instance.greenPieceCount < PieceGame.Instance.greenPieceSlot) // { // PieceGame.Instance.greenPieceCount++; // gameObject.SetActive(true); // firstPosition = transform.position; // shadowScript.position = targetPosition; // shadowScript.rotation = shadowRotation; // difficulty = 1; // } // else // shufflePosition(isStraightLineup, isRotationChanging, isScaleChanging, isMathPiece, isAlone); // } // else if (tempDifficulty == 0) // { // if (PieceGame.Instance.yellowPieceCount < PieceGame.Instance.yellowPieceSlot) // { // PieceGame.Instance.yellowPieceCount++; // gameObject.SetActive(true); // firstPosition = transform.position; // shadowScript.position = targetPosition; // shadowScript.rotation = shadowRotation; // difficulty = 0; // } // else // shufflePosition(isStraightLineup, isRotationChanging, isScaleChanging, isMathPiece, isAlone); // } // } // else // { // gameObject.SetActive(true); // firstPosition = transform.position; // shadowScript.position = targetPosition; // shadowScript.rotation = shadowRotation; // } //} }