private void correctAnswer() { addScore(); currentLevel++; StartCoroutine(showResultCo()); MainSoundSrc.PlaySound("Signchange"); }
IEnumerator CountTimer() { GetComponent <Collider2D>().enabled = false; while (timer > 0) { timer -= TurtleCharacter.currentSpeed / 60.0f; yield return(null); } GetComponent <Collider2D>().enabled = true; MainSoundSrc.PlaySound("ThrowItem"); GetComponent <Animator>().Play("StarPop"); //play throw out animation Vector2 targetPos = this.transform.position; while (Mathf.Abs(this.transform.position.x - lenPosition) > 0.1f) { Vector2 pos = this.transform.position; targetPos = this.transform.position; targetPos.x = lenPosition; pos = Vector2.Lerp(pos, targetPos, Time.deltaTime * 10); this.transform.position = pos; yield return(null); } targetPos.x = lenPosition; this.transform.position = targetPos; }
private IEnumerator decreaseLifeCo() { yield return(new WaitForSeconds(1f)); MainSoundSrc.PlaySound("wrong"); gController.mBrokeCombo(); gController.mDecreaseLifeGuage(); }
private void addScore() { MainSoundSrc.PlaySound("right"); var score = levelContoller.GetScore(currentLevel, timeLeft); gController.mAddCombo(); gController.mAddScore(score); }
void AddWave() { MainSoundSrc.PlaySound("airplane"); airplane.GetComponent <Animator>().Play("AirplaneFly", -1, 0f); bird.GetComponent <Animator>().Play("bird_airplane", -1, 0f); timer = Game3_LvlingStat.GetLvling().airplaneDelayed; GameObject gobj = new GameObject("Wave"); ParashootWave wave = gobj.AddComponent <ParashootWave>(); wave.SetupWave(gameplayItem); }
IEnumerator BoostTimer() { MainSoundSrc.PlaySound("airplane"); while (boostTimer > 0) { boostTimer -= Time.deltaTime; yield return(null); } IsBoost = false; Booster.SetActive(false); }
private void wrongAnswer(Vector3 pos) { var hpNoti = Instantiate(HPNotifyPrefab); hpNoti.gameObject.SetActive(true); hpNoti.transform.position = pos; hpNoti.DecreaseLife(1); decreaseLife(); StartCoroutine(showResultCo()); MainSoundSrc.PlaySound("Signchange"); }
public void Damaged() { if (!IsStruggle) { //start Play Animation GetComponent <Animator>().Play("TurtleDamage"); MainSoundSrc.PlaySound("Wrong"); IsStruggle = true; StopCoroutine("StruggleRun"); StartCoroutine("StruggleRun"); } }
void OnTriggerExit2D(Collider2D other) { if (other.tag == "GameBound") { // Debug.Log("Item Lost"); MainSoundSrc.PlaySound("wrong"); Game3Global.BirdWrong(); Game3Global.DecreaseLife(); Game3Global.BrokeCombo(); Destroy(this.gameObject); } }
public void CheckPerfectWave() { if (parashootClear <= 0) { if (IsPerfect) { MainSoundSrc.PlaySound("right"); Game3Global.BirdOK(); Game3Global.AddScore(10000); } Destroy(gameObject); } }
void OnTriggerExit2D(Collider2D other) { if (other.tag == "GameBound") { MainSoundSrc.PlaySound("wrong"); Game3Global.BirdWrong(); Game3Global.DecreaseLife(); Game3Global.BrokeCombo(); Destroy(this.gameObject); } if (other.tag == "Trash") { IsEnterTrash = false; } }
private IEnumerator generateQuestion() { State = QuestionState.GenerateQuestion; currentQuestionType = (InfoSign.SignType)Random.Range(0, 5); setupActivateAnswer(getTotalAnswer(currentLevel)); Shuffle(activateAnswerList); var correctAnswer = answerLeft = getCorrectAnswer(currentLevel); startTime = timeLeft = getTimeToAnswer(currentLevel); infoSign.SwitchSign(currentQuestionType); cat.ChangeLevel(currentLevel, currentQuestionType); foreach (var answer in activateAnswerList) { if (correctAnswer > 0) { answer.Setup(currentQuestionType); correctAnswer--; } else { var randomAnswerType = (InfoSign.SignType)Random.Range(0, 5); while (randomAnswerType == currentQuestionType) { randomAnswerType = (InfoSign.SignType)Random.Range(0, 5); } answer.Setup(randomAnswerType); } } MainSoundSrc.PlaySound("Signchange2"); while (State != QuestionState.GenerateQuestion) { yield return(null); } State = QuestionState.WaitingForAnswer; }
IEnumerator userLockerCo(Tile target, bool toNextTurn = true) { var bg = target.RemoveBadGuy(); bg.die(); MainSoundSrc.PlaySound("jail"); var score = (bg is Rat)?levelController.GetKillRatScore():levelController.GetKillMoleScore(); addScore(score, bg.transform.position); yield return(new WaitForSeconds(1f)); Destroy(bg.gameObject); if (toNextTurn) { StartCoroutine(nextTurn()); } }
void Awake() { pGlobal = this; }
IEnumerator finishMove(Tile target, itemType it = itemType.None) { Tile[] similarTiles = null; var highestMatchLevel = 0; if (it == itemType.Magnifier) { var highLevel = target.GetCrossBuildingHighLevel(); foreach (var level in highLevel) { similarTiles = target.GetSimilarTile(level); if (similarTiles != null && similarTiles.Length >= 2) { highestMatchLevel = level; break; } } } else if (it == itemType.Oryor) { var temp = new List <Tile>(); temp.AddRange(target.GetSurroundTiles().Where(t => t.GetCurrentProductLevel() != 0)); if (target.GetCurrentProductLevel() != 0) { temp.Add(target); } similarTiles = temp.ToArray(); target.GetSurroundTiles().Where(t => t.GetBadGuy() != null).ToList().ForEach(b => StartCoroutine(userLockerCo(b, false))); if (target.GetBadGuy() != null) { StartCoroutine(userLockerCo(target, false)); } } else { similarTiles = target.GetSimilarTile(); } if (similarTiles != null && ((it == itemType.Oryor && similarTiles.Length > 0) || similarTiles.Length >= 2)) { sherDog.Combine(); gController.mAddCombo(); var sound2 = Random.Range(0, 20); var combineSoundName = (sound2 > 10)?"combine":"combine2"; MainSoundSrc.PlaySound(combineSoundName); //Score var score = levelController.GetCombineProductScore(similarTiles[0].GetCurrentProductLevel(), similarTiles.Length); oryorCharge += levelController.GetOryorChargingRate(similarTiles[0].GetCurrentProductLevel()); var formatGauge = oryorCharge / 100f; oryorGauge.fillAmount = formatGauge; //Combine foreach (var tile in similarTiles) { var removedProduct = tile.RemoveProduct(); removedProduct.MoveAndDestroy(target.transform.position, .25f); } yield return(new WaitForSeconds(.25f)); if (it == itemType.Magnifier) { var product = ProductFactory.GetInstance().CreateProduct(highestMatchLevel + 1, true); target.SetupProduct(product); } else if (it == itemType.Oryor) { score = (int)(score * levelController.GetOryorMultiplier()); } else { target.UpgradeProduct(); } addScore(score, target.transform.position); yield return(new WaitForSeconds(1f)); if (target.IsProductComplete()) { var removedProduct = target.RemoveProduct(); removedProduct.Capture(); yield return(new WaitForSeconds(1f)); Destroy(removedProduct.gameObject); /* Do not destroy bad guy after 6 combine * var badGuys = target.GetSurroundTiles().Select( t => t.RemoveBadGuy() ).ToList(); * * badGuys.ForEach( bg => {if(bg!=null)Destroy(bg.gameObject);} ); */ } yield return(StartCoroutine(finishMove(target))); } else { yield return(StartCoroutine(nextTurn())); } yield return(0); }
private IEnumerator nextTurn() { levelController.AddTurn(); var tileList = TileGenerator.GetTileList(); var ratTile = tileList.FindAll(t => t.GetBadGuy() is Rat).OrderBy(t => t.GetBadGuy().Life()); foreach (var ratT in ratTile) { if (ratT.GetBadGuy().DecreaseLife() <= 0) { Debug.Log("Deduct User Life"); var throwingProduct = sherDog.GetThrowableObject(); throwingProduct.SetActive(true); throwingProduct.transform.position = new Vector3(ratT.transform.position.x, ratT.transform.position.y, throwingProduct.transform.position.z); yield return(StartCoroutine(Util.SmoothMovement(throwingProduct.transform, sherDog.GetThrowingPosition(), 10f))); throwingProduct.SetActive(false); sherDog.Hit(); var ranSound = Random.Range(0, 20); var hitSoundname = (ranSound) > 10?"hit":"hit2"; MainSoundSrc.PlaySound(hitSoundname); gController.mDecreaseLifeGuage(); gController.mBrokeCombo(); yield return(new WaitForSeconds(1f)); //Destroy( ratT.RemoveBadGuy().gameObject ); ratT.GetBadGuy().SetLife(levelController.GetRatTurns()); } var availableTileList = ratT.GetCrossBuildableTileList(); if (availableTileList.Count() == 0) { continue; } var selectedIndex = (int)Random.Range(0f, availableTileList.Count() - 0.01f); var rat = ratT.RemoveBadGuy(); availableTileList[selectedIndex].AddBadGuy(rat); } var moleTile = tileList.FindAll(t => t.GetBadGuy() is Mole); var moleList = moleTile.Select(mt => mt.RemoveBadGuy() as Mole).OrderBy(m => m.Life()); var buildableTile = tileList.FindAll(t => t.IsBuildAble()); var buildableCount = buildableTile.Count; foreach (var mole in moleList) { if (mole.DecreaseLife() <= 0) { Debug.Log("Deduct User Life"); var throwingProduct = sherDog.GetThrowableObject(); throwingProduct.SetActive(true); throwingProduct.transform.position = new Vector3(mole.transform.position.x, mole.transform.position.y, throwingProduct.transform.position.z); yield return(StartCoroutine(Util.SmoothMovement(throwingProduct.transform, sherDog.GetThrowingPosition(), 10f))); throwingProduct.SetActive(false); sherDog.Hit(); var ranSound = Random.Range(0, 20); var hitSoundname = (ranSound) > 10?"hit":"hit2"; MainSoundSrc.PlaySound(hitSoundname); gController.mDecreaseLifeGuage(); gController.mBrokeCombo(); yield return(new WaitForSeconds(1f)); //Destroy( mole.gameObject ); mole.SetLife(levelController.GetMoleTurns()); } var newHomeIndex = (int)Random.Range(0f, buildableCount - 0.01f); buildableTile[newHomeIndex].AddBadGuy(mole); buildableCount--; buildableTile.RemoveAt(newHomeIndex); } //Create Mole var moleChance = levelController.GetMoleChance(tileList.Count(t => t.GetBadGuy() is Mole)); var ratChance = levelController.GetRatChance(tileList.Count(t => t.GetBadGuy() is Rat)); var chance = Random.Range(0, 100); if (buildableCount > 0 && chance < moleChance + ratChance) { BadGuy bg = null; if (chance < ratChance) { bg = Instantiate(ratPrefab) as BadGuy; bg.SetLife(levelController.GetRatTurns()); } else { bg = Instantiate(molePrefab) as BadGuy; bg.SetLife(levelController.GetMoleTurns()); } var newHomeIndex = (int)Random.Range(0f, buildableCount - 0.01f); buildableTile[newHomeIndex].AddBadGuy(bg, true); buildableCount--; buildableTile.RemoveAt(newHomeIndex); } yield return(new WaitForSeconds(0.5f)); if (buildableCount <= 0) { //Game Over Debug.Log("Game Over"); gController.mGameOver(); } else { var tileLeft = (float)buildableCount / TileGenerator.TotalSize; if (tileLeft <= 0.4f || gController.GetLife() == 1) { sherDog.SetTired(true); } else { sherDog.SetTired(false); } } //Check Game State if (!isGameOver) { if (oryorCharge < 100) { ProductFactory.GetInstance().GenerateProduct(tileList.Any(t => t.GetBadGuy() != null)); } else { oryorCharge = 0; oryorGauge.fillAmount = 0; ProductFactory.GetInstance().GenerateOryor(); MainSoundSrc.PlaySound("oryorready"); } } }
public virtual void Eat() { IsEat = true; GetComponent <Animator>().Play("StarEat"); MainSoundSrc.PlaySound("right"); }
void PlaySound() { MainSoundSrc.PlaySound("SButtonHome"); }
// Update is called once per frame void Update() { Vector2 pos = TouchInterface.GetTouchPosition(); bool isTouchDown = TouchInterface.GetTouchDown(); bool isTouchUp = TouchInterface.GetTouchUp(); if (isTouchDown && GetComponent <Collider2D>().OverlapPoint(pos)) { if (Game3Global.pGlobal.dragObject == null) { Game3Global.pGlobal.dragObject = this; IsTouch = true; } } if (isTouchUp && Game3Global.pGlobal.dragObject == this) { //calculate score if (Game3Global.pGlobal.boxObject != null) { if (Game3Global.pGlobal.boxObject.type == this.type) { //correct MainSoundSrc.PlaySound("right"); Game3Global.BirdOK(); Game3Global.AddScore(300); Game3Global.AddCombo(); Game3_LvlingStat.AddEXP(); parentWave.ParashootClear(); Destroy(this.gameObject); } else { MainSoundSrc.PlaySound("wrong"); Game3Global.BirdWrong(); Game3Global.BrokeCombo(); Game3Global.DecreaseLife(); parentWave.ParashootClear(false); Destroy(this.gameObject); } } Game3Global.pGlobal.dragObject = null; IsTouch = false; } if (IsTouch) { touchPos = pos; } else { if (IsEnterTrash) { if (type != ParashootType.PARA_OTHER) { MainSoundSrc.PlaySound("wrong"); Game3Global.BirdWrong(); Game3Global.BrokeCombo(); Game3Global.DecreaseLife(); parentWave.ParashootClear(false); } else { MainSoundSrc.PlaySound("bin"); parentWave.ParashootClear(); } Game3Global.TrashEnter(); Destroy(this.gameObject); } } UpdatePosition(); }