public void PlayBubbleSFX() { if (bubbleSFX != null && audioSources[1] != null) { CommonUtil.PlayOneShotClipAt(bubbleSFX, Vector3.zero, audioSources[1].volume); } }
/// <summary> /// Fade stars Coroutine. /// </summary> /// <returns>The stars.</returns> public IEnumerator FadeStars() { if (visible) { starsNumber = timer.progress.starsNumber; float delayBetweenStars = 0.5f; if (starsNumber == ShapesManager.Shape.StarsNumber.ONE) //Fade with One Star { if (effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume); } firstStarFading.SetTrigger("Running"); } else if (starsNumber == ShapesManager.Shape.StarsNumber.TWO) //Fade with Two Stars { if (effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume); } firstStarFading.SetTrigger("Running"); yield return(new WaitForSeconds(delayBetweenStars)); if (effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume); } secondStarFading.SetTrigger("Running"); } else if (starsNumber == ShapesManager.Shape.StarsNumber.THREE) //Fade with Three Stars { if (effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume); } firstStarFading.SetTrigger("Running"); yield return(new WaitForSeconds(delayBetweenStars)); if (effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume); } secondStarFading.SetTrigger("Running"); yield return(new WaitForSeconds(delayBetweenStars)); if (effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume); } thirdStarFading.SetTrigger("Running"); } } yield return(0); }
/// <summary> /// Go to the previous shape. /// </summary> public void PreviousShape() { if (ShapesManager.Shape.selectedShapeID > 0 && ShapesManager.Shape.selectedShapeID < ShapesManager.instance.shapes.Count) { ShapesManager.Shape.selectedShapeID--; CreateShape(); } else { //Play lock sound effectd if (lockedSFX != null && effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(lockedSFX, Vector3.zero, effectsAudioSource.volume); } } }
/// <summary> /// On shape completed event. /// </summary> private void OnShapeComplete() { DisableHand(); //brightEffect.GetComponent<ParticleEmitter> ().emit = false; Animator shapeAnimator = shape.GetComponent <Animator> (); shapeAnimator.SetBool(shape.name, false); shapeAnimator.SetTrigger("Completed"); ShapesManager.Shape.StarsNumber collectedStars = Progress.instance.starsNumber; AlphabetDataManager.SaveShapeStars(ShapesManager.Shape.selectedShapeID, collectedStars); if (ShapesManager.Shape.selectedShapeID + 1 < ShapesManager.instance.shapes.Count) { AlphabetDataManager.SaveShapeLockedStatus(ShapesManager.Shape.selectedShapeID + 1, false); } List <Transform> paths = CommonUtil.FindChildrenByTag(shape.transform.Find("Paths"), "Path"); int from, to; string [] slices; foreach (Transform p in paths) { slices = p.name.Split('-'); from = int.Parse(slices [1]); to = int.Parse(slices [2]); AlphabetDataManager.SaveShapePathColor(ShapesManager.Shape.selectedShapeID, from, to, CommonUtil.FindChildByTag(p, "Fill").GetComponent <Image> ().color); } timer.Stop(); Area.Show(); winDialog.Show(); GameObject.Find("NextButton").GetComponent <Animator> ().SetTrigger("Select"); winEffect.gameObject.SetActive(true); if (correctSFX != null && effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(completedSFX, Vector3.zero, effectsAudioSource.volume); } }
/// <summary> /// Go to the Next shape. /// </summary> public void NextShape() { if (ShapesManager.Shape.selectedShapeID >= 0 && ShapesManager.Shape.selectedShapeID < ShapesManager.instance.shapes.Count - 1) { //Get the next shape and check if it's locked , then do not load the next shape if (ShapesManager.Shape.selectedShapeID + 1 < ShapesManager.instance.shapes.Count) { if (AlphabetDataManager.IsShapeLocked(ShapesManager.Shape.selectedShapeID + 1)) { //Play lock sound effectd if (lockedSFX != null && effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(lockedSFX, Vector3.zero, effectsAudioSource.volume); } //Skip the next return; } } ShapesManager.Shape.selectedShapeID++; CreateShape(); //Create new shape } else { if (ShapesManager.Shape.selectedShapeID == ShapesManager.instance.shapes.Count - 1) { UIEvents.instance.LoadAlbumScene(); } else { //Play lock sound effectd if (lockedSFX != null && effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(lockedSFX, Vector3.zero, effectsAudioSource.volume); } } } }
/// <summary> /// Checks wehther path completed or not. /// </summary> private void CheckPathComplete() { if (fillAmount >= path.completeOffset) { path.completed = true; path.AutoFill(); path.SetNumbersVisibility(false); ReleasePath(); if (CheckShapeComplete()) { shape.completed = true; OnShapeComplete(); } else { if (correctSFX != null && effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(correctSFX, Vector3.zero, effectsAudioSource.volume); } } shape.ShowPathNumbers(shape.GetCurrentPathIndex()); hit2d = Physics2D.Raycast(GetCurrentPlatformClickPosition(Camera.main), Vector2.zero); if (hit2d.collider != null) { if (hit2d.transform.tag == "Start") { if (shape.IsCurrentPath(hit2d.transform.GetComponentInParent <Path> ())) { ResetPath(); OnStartHitCollider(hit2d); } } } } }
// Update is called once per frame void Update() { //Game Logic is here DrawHand(GetCurrentPlatformClickPosition(Camera.main)); DrawBrightEffect(GetCurrentPlatformClickPosition(Camera.main)); if (shape == null) { return; } if (shape.completed) { return; } if (Input.GetMouseButtonDown(0)) { //if (!shape.completed) //brightEffect.GetComponent<ParticleEmitter> ().emit = true; hit2d = Physics2D.Raycast(GetCurrentPlatformClickPosition(Camera.main), Vector2.zero); if (hit2d.collider != null) { if (hit2d.transform.tag == "Start") { OnStartHitCollider(hit2d); shape.CancelInvoke(); shape.DisableTracingHand(); EnableHand(); } else if (hit2d.transform.tag == "Collider") { shape.DisableTracingHand(); EnableHand(); } } } else if (Input.GetMouseButtonUp(0)) { //brightEffect.GetComponent<ParticleEmitter> ().emit = false; DisableHand(); shape.Invoke("EnableTracingHand", 1); ResetPath(); } if (!isRunning || path == null || pathFillImage == null) { return; } if (path.completed) { return; } hit2d = Physics2D.Raycast(GetCurrentPlatformClickPosition(Camera.main), Vector2.zero); if (hit2d.collider == null) { if (correctSFX != null && effectsAudioSource != null) { CommonUtil.PlayOneShotClipAt(wrongSFX, Vector3.zero, effectsAudioSource.volume); } ResetPath(); return; } if (path.fillMethod == Path.FillMethod.Radial) { RadialFill(); } else if (path.fillMethod == Path.FillMethod.Linear) { LinearFill(); } else if (path.fillMethod == Path.FillMethod.Point) { PointFill(); } }