public void resetCurrentQuestion() { touchEnabled = true; flowersLayer.transform.position = new Vector3(BWConstants.flowersLayerMinX, -350, -200); BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>(); layer.resetFlowersLayer(); if ((numberLineMax - numberLineMin) > BWConstants.numbersOnScreen) { enableScrolling = true; xvel = 0; lasty = 0; direction = BounceDirection.BounceDirectionStayingStill; } BWBee beeObj = bee.GetComponent <BWBee>(); beeObj.flipBee(dataManager.shouldFlipBee); flowerLayerToInitialNumber(initialNumber); beeToFlower(beeStartingPoint); setExpectedNumbers(beeStartingPoint, numberToFind); }
private void playTutorialAnimation() { BWTutorialLayer tutorialScript = tutorialLayer.GetComponent <BWTutorialLayer>(); if (tutorialScript.isPlayingTutorial) { return; } ArrayList positionArray = new ArrayList(); foreach (int _number in expectedNumbers) { BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>(); GameObject flower = layer.flowerWithNumber(_number); if (flower == null) { return; } Vector3 pos = new Vector3(flower.transform.position.x + 20F, flower.transform.position.y + 170F, -800F); positionArray.Add(pos); } tutorialScript.positions = positionArray; tutorialScript.playTutorial(); }
private void beeToFlower(int _flowerIndex) { if (flowersLayer == null) { return; } BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>(); GameObject flower = layer.flowerWithNumber(_flowerIndex); if (flower == null) { return; } Vector3 beePos = bee.transform.position; beePos.x = flower.transform.position.x; beePos.y = flower.transform.position.y + 320; BWBee beeObj = bee.GetComponent <BWBee>(); beeObj.moveToPoint(beePos); // bee.transform.position = beePos; }
public void nextQuestion() { gameState = BWGameState.BWGameStateResetting; enableScrolling = false; if (attempts > 0) { } attempts = 0; dataManager.fetchNextQuestionData(); numberLineMin = dataManager.numberLineMin; numberLineMax = dataManager.numberLineMax; initialNumber = dataManager.initialNumber; numberToFind = dataManager.numberToFind; string numberimg = string.Format("BW_NumberLine/Sprites/Referent/Referant_numbers{0}", AGGameState.modInt(numberToFind)); bubbleNumber.renderer.material.mainTexture = (Texture2D)Resources.Load(numberimg); if (numberToFind < 0) { bubbleSymbol.SetActive(true); } else { bubbleSymbol.SetActive(false); } //bubbleNumber.text = string.Format("{0}", numberToFind); //flowersLayer.transform.position = new Vector3(-640, -300, -200); BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>(); layer.setFlowersLayer(numberLineMin, numberLineMax, initialNumber); if ((numberLineMax - numberLineMin) > 7) { enableScrolling = true; xvel = 0; lasty = 0; direction = BounceDirection.BounceDirectionStayingStill; } flowerLayerToInitialNumber(initialNumber); beeToSky(); touchEnabled = true; playInstructionSound(); CancelInvoke("noInteraction"); Invoke("noInteraction", BWConstants.idleTime + 5.0f); }
public void resetCurrentQuestion() { BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>(); foreach (GameObject flower in layer.flowers) { BWFlower flowerObj = flower.GetComponent <BWFlower>(); flowerObj.setDisabled(); } }
public void destroyFlowerLayer() { //flower close anim gameState = BWGameState.BWGameStateResetting; BWFlowersLayer layerObj = flowersLayer.GetComponent <BWFlowersLayer>(); layerObj._delegate = this; layerObj.destroyFlowersLayer(); beeToSky(); //scroll reset // }
public void beeMoveFinished() { if (gameState == BWGameState.BWGameStateGuessed) { BWBee beeObj = bee.GetComponent <BWBee>(); beeObj.playYesAnimation(); if (dataManager.calculateResult(attempts, 1)) { beeObj.shouldPlayCelebration = true; dataManager.fetchLevelData(); } playSucess(); BWFlowersLayer layerObj = flowersLayer.GetComponent <BWFlowersLayer>(); GameObject flower = layerObj.flowerWithNumber(numberToFind); BWFlower flowerObj = flower.GetComponent <BWFlower>(); flowerObj.setPollinated(); } }
private void addTracingLine(GameObject preFlower, GameObject curFlower) { if (preFlower == null || curFlower == null) { return; } GameObject tracingLine = Instantiate(linePrefab) as GameObject; tracingLine.transform.parent = flowersLayer.transform; Vector3 pos = new Vector3(0, 0, 0); if (numberToFind > 0) { pos.x = preFlower.transform.localPosition.x + tracingLine.transform.localScale.x / 2.0f; pos.y = preFlower.transform.localPosition.y + 270; pos.z = 0; } else if (numberToFind < 0) { pos.x = curFlower.transform.localPosition.x + tracingLine.transform.localScale.x / 2.0f; pos.y = curFlower.transform.localPosition.y + 270; pos.z = 0; } else { DestroyObject(tracingLine); return; } tracingLine.transform.localPosition = pos; BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>(); layer.tracingLines.Add(tracingLine); BWFlower flowerObj = curFlower.GetComponent <BWFlower>(); flowerObj.setSelected(); }
private void updateScroll() { Vector3 pos = flowersLayer.transform.position; // positions for scrollLayer BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>(); float right = pos.x + layer.contentWidth; float left = pos.x; float minX = -640; float maxX = 640; float bounceTime = 0.2f; int frameRate = 60; if (!isDragging) { float friction = 0.96f; if (left > minX && direction != BounceDirection.BounceDirectionGoingLeft) { xvel = 0; direction = BounceDirection.BounceDirectionGoingLeft; } else if (right < maxX && direction != BounceDirection.BounceDirectionGoingRight) { xvel = 0; direction = BounceDirection.BounceDirectionGoingRight; } if (direction == BounceDirection.BounceDirectionGoingRight) { if (xvel >= 0) { float delta = (maxX - right); float yDeltaPerFrame = (delta / (bounceTime * frameRate)); xvel = yDeltaPerFrame; } if ((right + 0.5f) == maxX) { pos.x = right - layer.contentWidth; xvel = 0; direction = BounceDirection.BounceDirectionStayingStill; } } else if (direction == BounceDirection.BounceDirectionGoingLeft) { if (xvel <= 0) { float delta = (minX - left); float yDeltaPerFrame = (delta / (bounceTime * frameRate)); xvel = yDeltaPerFrame; } if ((left + 0.5f) == minX) { pos.x = left; xvel = 0; direction = BounceDirection.BounceDirectionStayingStill; } } else { xvel *= friction; //lasty = pos.x; } pos.x += xvel; backgroundLayer.moveBackground(pos.x - flowersLayer.transform.position.x); foregroundLayer.moveForeground(pos.x - flowersLayer.transform.position.x); flowersLayer.transform.position = pos; } else { if (left <= minX || right >= maxX) { direction = BounceDirection.BounceDirectionStayingStill; } if (direction == BounceDirection.BounceDirectionStayingStill) { xvel = (pos.x - lasty) / 2; lasty = pos.x; } } }
public void nextQuestion() { enableScrolling = false; isDragging = false; isSwiping = false; prevFlower = null; if (attempts > 0) { } attempts = 0; dataManager.fetchNextQuestionData(); numberLineMin = dataManager.numberLineMin; numberLineMax = dataManager.numberLineMax; initialNumber = dataManager.initialNumber; numberToFind = dataManager.numberToFind; beeStartingPoint = dataManager.beeStartingIndex; string numberimg = string.Format("BW_NumberLine/Sprites/Referent/Referant_numbers{0}", AGGameState.modInt(numberToFind)); bubbleNumber.renderer.material.mainTexture = (Texture2D)Resources.Load(numberimg); if (numberToFind < 0) { bubbleSymbol.renderer.material.mainTexture = (Texture2D)Resources.Load("BW_NumberLine/Sprites/Referent/Referant_exporterminus"); } else { bubbleSymbol.renderer.material.mainTexture = (Texture2D)Resources.Load("BW_NumberLine/Sprites/Referent/Referant_exporterPlus"); } flowersLayer.transform.position = new Vector3(BWConstants.flowersLayerMinX, -350, -200); BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>(); layer.setDiagonalFlowersLayer(numberLineMin, numberLineMax, initialNumber); if ((numberLineMax - numberLineMin) > BWConstants.numbersOnScreen) { enableScrolling = true; xvel = 0; lasty = 0; direction = BounceDirection.BounceDirectionStayingStill; } BWBee beeObj = bee.GetComponent <BWBee>(); beeObj.flipBee(dataManager.shouldFlipBee); flowerLayerToInitialNumber(initialNumber); beeToFlower(beeStartingPoint); setExpectedNumbers(beeStartingPoint, numberToFind); if (dataManager.currentLevel == 0) { Invoke("levelZeroTutorial", 3); } else { playInstructionSound(); } CancelInvoke("noInteraction"); Invoke("noInteraction", BWConstants.idleTime + 5.0f); touchEnabled = true; }
void FingerGestures_OnFingerDragEnd(int fingerIndex, Vector2 fingerPos) { if (!touchEnabled) { return; } CancelInvoke("noInteraction"); Invoke("noInteraction", BWConstants.idleTime); if (fingerIndex == dragFingerIndex) { dragFingerIndex = -1; isDragging = false; if (isSwiping) { //Swiping isSwiping = false; GameObject selection = PickObject(fingerPos); if (selection != null && (selection.name.StartsWith("Flower") || selection.name.StartsWith("Hive"))) { BWFlower flowerObj = selection.GetComponent <BWFlower>(); if (expectedNumbers.Count > 0 && flowerObj.getFlowerNumber() == (int)expectedNumbers[0] && swipingWentOut) { beeToFlower((int)expectedNumbers[0]); expectedNumbers.RemoveAt(0); addTracingLine(prevFlower, selection); prevFlower = selection; } else if (expectedNumbers.Count == 0 && swipingWentOut) { incorrectSwipingBeyondTarget(prevFlower, selection); } } } if (expectedNumbers.Count == 0) { if (currentAnswer == true) { prevFlower = null; CancelInvoke("noInteraction"); AGGameState.incrementStarCount(); attempts++; playSucess(); BWBee beeObj = bee.GetComponent <BWBee>(); beeObj.playYesAnimation(); if (dataManager.calculateResult(attempts, 1)) { beeObj.shouldPlayCelebration = true; dataManager.fetchLevelData(); } touchEnabled = false; BWFlowersLayer layerObj = flowersLayer.GetComponent <BWFlowersLayer>(); GameObject flower = layerObj.flowerWithNumber(beeStartingPoint + numberToFind); BWFlower flowerObj = flower.GetComponent <BWFlower>(); flowerObj.setPollinated(); } else { touchEnabled = false; attempts++; playWrongSound(0); BWBee beeObj = bee.GetComponent <BWBee>(); beeObj.playNoAnimation(); prevFlower = null; CancelInvoke("noInteraction"); Invoke("noInteraction", BWConstants.idleTime + 5.0f); } } else { if (prevFlower != null) { BWFlower flowerObj = prevFlower.GetComponent <BWFlower>(); int newStarting = flowerObj.getFlowerNumber(); setExpectedNumbers(newStarting, numberToFind - (newStarting - beeStartingPoint)); } } } if (prevFlower != null) { CancelInvoke("deduceResult"); Invoke("deduceResult", 3.0f); } }