public void resetInputController() { qAttempts = 0; wrongAttempts = 0; breakJoints = null; ickyAnim.ickyStates = NF_IckyAnimationStates.icky_idle; ickyAnim.setIckyPosition(); }
void checkHitOnObject(Vector2 fingerPos) { RaycastHit hit; Ray ray; ray = Camera.main.ScreenPointToRay(fingerPos); if (Physics.Raycast(ray, out hit, 10000)) { if (hit.collider.tag == "tag_Fruits") { if (fruitObj != hit.collider.transform.gameObject) { fruitObj = hit.collider.transform.gameObject; qAttempts++; } if (hit.collider.name == questionTitle) { NF_SoundManager.playSFX(ropeCutSFx); isWrongAnswer = false; selectedFruit = hit.transform.gameObject; createTickSign(); StartCoroutine(destroyCreatedObject(qTickObj, 0.2f)); Transform rope = selectedFruit.transform.parent; breakJoints = rope.GetComponent <NF_BreakRopeJoints>(); GameObject destroyedFood = Instantiate(EmptyFruit) as GameObject; destroyedFood.transform.localScale = breakJoints._hangingObject.transform.localScale; destroyedFood.renderer.material.mainTexture = breakJoints._hangingObject.renderer.material.mainTexture; destroyedFood.transform.position = breakJoints._hangingObject.transform.position; breakJoints.breakRopeNow(); ickyCorrentAnswer(destroyedFood); StartCoroutine(breakJoints.deleteRopeCutUp(1.0f)); _totalAnswersCount--; Debug.Log("answerCount:" + _totalAnswersCount); } else if (hit.collider.name != questionTitle) { isTouchEnabled = false; isWrongAnswer = true; createCrossSign(); ickyWrongAnswer(); StartCoroutine(destroyCreatedObject(qCrossObj, 0.2f)); } } else if (hit.collider.tag == "RopeCollider") { GameObject ropeSwiped = hit.collider.gameObject.transform.parent.gameObject; NF_BreakRopeJoints ropeObj = ropeSwiped.GetComponent <NF_BreakRopeJoints>(); if (fruitObj != ropeObj._hangingObject) { fruitObj = hit.collider.transform.gameObject; qAttempts++; } if (ropeObj._hangingObject.name == questionTitle) { NF_SoundManager.playSFX(ropeCutSFx); isWrongAnswer = false; selectedFruit = hit.transform.gameObject; createTickSign(); StartCoroutine(destroyCreatedObject(qTickObj, 0.2f)); Transform rope = selectedFruit.transform.parent; breakJoints = rope.GetComponent <NF_BreakRopeJoints>(); GameObject destroyedFood = Instantiate(EmptyFruit) as GameObject; destroyedFood.transform.localScale = breakJoints._hangingObject.transform.localScale; destroyedFood.renderer.material.mainTexture = breakJoints._hangingObject.renderer.material.mainTexture; destroyedFood.transform.position = breakJoints._hangingObject.transform.position; breakJoints.breakRopeNow(); ickyCorrentAnswer(destroyedFood); StartCoroutine(breakJoints.deleteRopeCutUp(1.0f)); _totalAnswersCount--; Debug.Log("answerCount:" + _totalAnswersCount); } else if (hit.collider.name != questionTitle) { isTouchEnabled = false; isWrongAnswer = true; createCrossSign(); ickyWrongAnswer(); StartCoroutine(destroyCreatedObject(qCrossObj, 0.2f)); } } } }
void FingureGestures_OnTap(Vector2 fingurePos, int tapCount) { if (isTouchEnabled == false && isTouchesEnable_2 == false) { return; } RaycastHit hit; Ray ray; ray = Camera.main.ScreenPointToRay(fingurePos); if (Physics.Raycast(ray, out hit, 10000)) { CancelInvoke("playInstructionalVO"); if (hit.collider.tag == "tag_Fruits") { qAttempts++; Debug.Log("QuestionAttempts:" + qAttempts); if (hit.collider.name == questionTitle) { NF_SoundManager.playSFX(ropeCutSFx); isWrongAnswer = false; selectedFruit = hit.transform.gameObject; createTickSign(); StartCoroutine(destroyCreatedObject(qTickObj, 0.2f)); Transform rope = selectedFruit.transform.parent; breakJoints = rope.GetComponent <NF_BreakRopeJoints>(); GameObject destroyedFood = Instantiate(EmptyFruit) as GameObject; destroyedFood.transform.localScale = breakJoints._hangingObject.transform.localScale; destroyedFood.renderer.material.mainTexture = breakJoints._hangingObject.renderer.material.mainTexture; destroyedFood.transform.position = breakJoints._hangingObject.transform.position; breakJoints.breakRopeNow(); ickyCorrentAnswer(destroyedFood); StartCoroutine(breakJoints.deleteRopeCutUp(1.0f)); _totalAnswersCount--; if (_totalAnswersCount <= 0) { isTouchEnabled = false; switchToNextQuestion(); } } else if (hit.collider.name != questionTitle) { isWrongAnswer = true; wrongAttempts++; createCrossSign(); ickyWrongAnswer(); StartCoroutine(destroyCreatedObject(qCrossObj, 0.2f)); if (wrongAttempts == 5) { isTouchEnabled = false; gameController.loadNextQuestion(0); } } } else if (hit.collider.gameObject.name.Equals("Icky_Model")) { ickyGiggleAnimation(); } } Invoke("playInstructionalVO", 10.0f); }
public void resetInputController() { qAttempts=0; wrongAttempts=0; breakJoints = null; ickyAnim.ickyStates = NF_IckyAnimationStates.icky_idle; ickyAnim.setIckyPosition(); }
void FingureGestures_OnTap(Vector2 fingurePos, int tapCount) { if(isTouchEnabled==false && isTouchesEnable_2==false){ return; } RaycastHit hit; Ray ray; ray = Camera.main.ScreenPointToRay(fingurePos); if(Physics.Raycast(ray, out hit,10000)){ CancelInvoke("playInstructionalVO"); if(hit.collider.tag=="tag_Fruits"){ qAttempts++; Debug.Log("QuestionAttempts:" +qAttempts); if(hit.collider.name == questionTitle){ NF_SoundManager.playSFX(ropeCutSFx); isWrongAnswer=false; selectedFruit = hit.transform.gameObject; createTickSign(); StartCoroutine(destroyCreatedObject(qTickObj,0.2f)); Transform rope = selectedFruit.transform.parent; breakJoints = rope.GetComponent<NF_BreakRopeJoints>(); GameObject destroyedFood = Instantiate(EmptyFruit) as GameObject; destroyedFood.transform.localScale = breakJoints._hangingObject.transform.localScale; destroyedFood.renderer.material.mainTexture = breakJoints._hangingObject.renderer.material.mainTexture; destroyedFood.transform.position = breakJoints._hangingObject.transform.position; breakJoints.breakRopeNow(); ickyCorrentAnswer(destroyedFood); StartCoroutine(breakJoints.deleteRopeCutUp(1.0f)); _totalAnswersCount--; if(_totalAnswersCount<=0){ isTouchEnabled=false; switchToNextQuestion(); } } else if(hit.collider.name != questionTitle){ isWrongAnswer=true; wrongAttempts++; createCrossSign(); ickyWrongAnswer(); StartCoroutine(destroyCreatedObject(qCrossObj,0.2f)); if(wrongAttempts==5){ isTouchEnabled=false; gameController.loadNextQuestion(0); } } } else if (hit.collider.gameObject.name.Equals("Icky_Model")) { ickyGiggleAnimation(); } } Invoke("playInstructionalVO",10.0f); }
void checkHitOnObject(Vector2 fingerPos) { RaycastHit hit; Ray ray; ray = Camera.main.ScreenPointToRay(fingerPos); if(Physics.Raycast(ray, out hit,10000)){ if(hit.collider.tag=="tag_Fruits"){ if(fruitObj != hit.collider.transform.gameObject){ fruitObj = hit.collider.transform.gameObject; qAttempts++; } if(hit.collider.name == questionTitle){ NF_SoundManager.playSFX(ropeCutSFx); isWrongAnswer =false; selectedFruit = hit.transform.gameObject; createTickSign(); StartCoroutine(destroyCreatedObject(qTickObj,0.2f)); Transform rope = selectedFruit.transform.parent; breakJoints = rope.GetComponent<NF_BreakRopeJoints>(); GameObject destroyedFood = Instantiate(EmptyFruit) as GameObject; destroyedFood.transform.localScale = breakJoints._hangingObject.transform.localScale; destroyedFood.renderer.material.mainTexture =breakJoints._hangingObject.renderer.material.mainTexture; destroyedFood.transform.position = breakJoints._hangingObject.transform.position; breakJoints.breakRopeNow(); ickyCorrentAnswer(destroyedFood); StartCoroutine(breakJoints.deleteRopeCutUp(1.0f)); _totalAnswersCount--; Debug.Log("answerCount:"+_totalAnswersCount); } else if(hit.collider.name != questionTitle){ isTouchEnabled=false; isWrongAnswer =true; createCrossSign(); ickyWrongAnswer(); StartCoroutine(destroyCreatedObject(qCrossObj,0.2f)); } } else if (hit.collider.tag == "RopeCollider"){ GameObject ropeSwiped = hit.collider.gameObject.transform.parent.gameObject; NF_BreakRopeJoints ropeObj = ropeSwiped.GetComponent<NF_BreakRopeJoints>(); if(fruitObj != ropeObj._hangingObject){ fruitObj = hit.collider.transform.gameObject; qAttempts++; } if(ropeObj._hangingObject.name == questionTitle){ NF_SoundManager.playSFX(ropeCutSFx); isWrongAnswer=false; selectedFruit = hit.transform.gameObject; createTickSign(); StartCoroutine(destroyCreatedObject(qTickObj,0.2f)); Transform rope = selectedFruit.transform.parent; breakJoints = rope.GetComponent<NF_BreakRopeJoints>(); GameObject destroyedFood = Instantiate(EmptyFruit) as GameObject; destroyedFood.transform.localScale = breakJoints._hangingObject.transform.localScale; destroyedFood.renderer.material.mainTexture =breakJoints._hangingObject.renderer.material.mainTexture; destroyedFood.transform.position = breakJoints._hangingObject.transform.position; breakJoints.breakRopeNow(); ickyCorrentAnswer(destroyedFood); StartCoroutine(breakJoints.deleteRopeCutUp(1.0f)); _totalAnswersCount--; Debug.Log("answerCount:"+_totalAnswersCount); } else if(hit.collider.name != questionTitle){ isTouchEnabled=false; isWrongAnswer =true; createCrossSign(); ickyWrongAnswer(); StartCoroutine(destroyCreatedObject(qCrossObj,0.2f)); } } } }
public void generateRopeForQuestion(int questionCount, string loadedQuestionTitle, ArrayList availableShapes, int currentCategoryID, int gameMode, string questionTitleToShow) { GameObject rope = null; GameObject hangingObj = null; GameObject objText = null; _generatedRopes = new List <GameObject>(); _ropePositions = new ArrayList(); fruitPosition = new ArrayList(); positionForMonkey = new ArrayList(); monkeyList = new List <GameObject>(); totalQuestionCount = questionCount; questionTitle = loadedQuestionTitle; Debug.Log("Answer:" + questionTitle); Debug.Log("GeneratedRopes Count:" + questionCount); getPathOfTheCategory(currentCategoryID); // calculate positions of Rope for (int i = 0; i < totalQuestionCount; i++) { int xPos = (1280 / (totalQuestionCount + 1)); int yPos = 780; if (i % 2 == 0) { yPos = 750; } Vector3 ropePosition = new Vector3((xPos + xPos * i) - 640, yPos, 750); _ropePositions.Add(ropePosition); } for (int i = 0; i < availableShapes.Count; i++) { Debug.Log(availableShapes[i]); } if (totalQuestionCount > 0) { for (int i = 0; i < totalQuestionCount; i++) { if (AGGameState.currentGameIndex == (int)AGGameIndex.k_NamingFruits) { if (currentCategoryID == (int)NamingFruits_CategoryID.id_Food) { rope = Instantiate(_ropeWitOutTextPrefab, (Vector3)_ropePositions[i], Quaternion.identity) as GameObject; hangingObj = rope.transform.FindChild("Object").gameObject; hangingObj.renderer.material.mainTexture = Resources.Load(pathForObjectResource + availableShapes[i]) as Texture; hangingObj.name = (string)availableShapes[i]; _breakRopeJoints = rope.GetComponent <NF_BreakRopeJoints>(); _breakRopeJoints._hangingObject = hangingObj; } else if (currentCategoryID == (int)NamingFruits_CategoryID.id_AlplabeticOrder) { rope = Instantiate(_ropePrefab, (Vector3)_ropePositions[i], Quaternion.identity) as GameObject; hangingObj = rope.transform.FindChild("Object").gameObject; objText = rope.transform.FindChild("ObjectText").gameObject; hangingObj.renderer.material.mainTexture = Resources.Load(pathForObjectResource + availableShapes[i]) as Texture; objText.renderer.material.mainTexture = Resources.Load(NF_Constants._fruitsTextPath + availableShapes[i]) as Texture; hangingObj.name = (string)availableShapes[i]; objText.name = (string)availableShapes[i]; _breakRopeJoints = rope.GetComponent <NF_BreakRopeJoints>(); _breakRopeJoints._hangingObject = hangingObj; _breakRopeJoints._hangingObjectText = objText; _breakRopeJoints.showTextAccordingToCategory(currentCategoryID); } if (hangingObj.name.Equals(loadedQuestionTitle)) { _breakRopeJoints.setPropertiesOfObject(loadedQuestionTitle); correctRopeRef = rope; } } else if (AGGameState.currentGameIndex == (int)AGGameIndex.k_2DShapesColors) { rope = Instantiate(_ropeWitOutTextPrefab, (Vector3)_ropePositions[i], Quaternion.identity) as GameObject; hangingObj = rope.transform.FindChild("Object").gameObject; hangingObj.transform.localScale = new Vector3(125, 127, 1); hangingObj.renderer.material.mainTexture = Resources.Load(pathForObjectResource + availableShapes[i]) as Texture; if (currentCategoryID == (int)SimpleColors_CategoryID.id_2DShapes) { Debug.Log("Loaded questionTitle: " + questionTitleToShow); string nameOfShape = (string)availableShapes[i]; if (nameOfShape.Contains(questionTitleToShow)) { hangingObj.name = questionTitleToShow; } else { hangingObj.name = (string)availableShapes[i]; } } else { hangingObj.name = (string)availableShapes[i]; } _breakRopeJoints = rope.GetComponent <NF_BreakRopeJoints>(); _breakRopeJoints._hangingObject = hangingObj; if (hangingObj.name.Equals(questionTitleToShow)) { _breakRopeJoints.setPropertiesOfObject(questionTitleToShow); correctRopeRef = rope; } } rope.transform.parent = _ropesParent; _generatedRopes.Add(rope); fruitPosition.Add(hangingObj.transform.position); positionForMonkey.Add(new Vector3(rope.transform.position.x, rope.transform.position.y - 300, 720)); } totalQuestionCount--; } playRopeFallingAnimation(); }