// Update is called once per frame void Update() { if (!paused) { if (b_idling && idle_switch_counter++ > idle_switch_counter_max) { StartWalking(); } if (b_walking) { transform.Translate(movement * Time.deltaTime * 0.5f); if (idle_direction_counter++ == 20) { movement = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); idle_direction_counter = 0; } if (idle_switch_counter++ > idle_switch_counter_max) { StopWalking(); } } FlipSpriteOnMoveDirection(); growthTimer += Time.deltaTime; if (growthTimer > growUpTime) { ChickenSortEvents.ChickGrowsUp(this.gameObject); this.paused = true; } } }
private IEnumerator EggHatched() { GetComponent <Animator>().SetTrigger("hatch"); yield return(new WaitForSeconds(Resources.Load <AnimationClip>("anims/EggHatching").length)); ChickenSortEvents.HatchEgg(this.gameObject); }
/** GAME LOOP **/ private void Update() { /** get menu **/ if (Input.GetKeyDown(KeyCode.Escape)) { if (!this.paused) { ChickenSortEvents.PauseGame(); } else { ChickenSortEvents.UnpauseGame(); } } /** chicken spawn checker **/ if (!this.paused) { this.chickenSpawnTimer += Time.deltaTime; if (this.chickens.Count < Mathf.Min((Mathf.Pow(this.level, 2) + 1), 10) && this.chickenSpawnTimer > chickenSpawnInterval) { this.chickenSpawnInterval += 0.02f; this.chickenSpawnTimer = 0; SpawnChicken(); } } }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Coop") { if (!this.CheckCoopMatchingAndDestroy(other.transform.parent.gameObject)) { this.ChickenAngry(); ChickenSortEvents.MultiplierReset(); } } }
public void PauseGame() { if (this.paused) { ChickenSortEvents.UnpauseGame(); } else { ChickenSortEvents.PauseGame(); } }
private bool CheckCoopMatchingAndDestroy(GameObject coop) { CoopLogic cl = coop.GetComponent <CoopLogic>(); if (this.DoesColorFit(cl)) { cl.Wobble(); ChickenSortEvents.CaptureChicken(this.gameObject); return(true); } return(false); }
/** Increases Score, updates score text and checks wether a new level is reached **/ public void IncreaseScore(int by, bool checkLevelUp = true) { this.score += by; this.scoreText.text = "Score: " + score; if (checkLevelUp) { if (this.score > Mathf.Pow(this.level * 2 + 1, 2)) { ChickenSortEvents.LevelChange(this.level + 1); } } }
void OnMouseUpAsButton() { this.GetComponent <SoundManager>().PlayAudio("pickup", false, 0.2f); ChickenSortEvents.CollectEgg(this.gameObject); }