Ejemplo n.º 1
0
    // 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;
            }
        }
    }
Ejemplo n.º 2
0
    private IEnumerator EggHatched()
    {
        GetComponent <Animator>().SetTrigger("hatch");
        yield return(new WaitForSeconds(Resources.Load <AnimationClip>("anims/EggHatching").length));

        ChickenSortEvents.HatchEgg(this.gameObject);
    }
Ejemplo n.º 3
0
    /** 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();
            }
        }
    }
Ejemplo n.º 4
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Coop")
     {
         if (!this.CheckCoopMatchingAndDestroy(other.transform.parent.gameObject))
         {
             this.ChickenAngry();
             ChickenSortEvents.MultiplierReset();
         }
     }
 }
Ejemplo n.º 5
0
 public void PauseGame()
 {
     if (this.paused)
     {
         ChickenSortEvents.UnpauseGame();
     }
     else
     {
         ChickenSortEvents.PauseGame();
     }
 }
Ejemplo n.º 6
0
    private bool CheckCoopMatchingAndDestroy(GameObject coop)
    {
        CoopLogic cl = coop.GetComponent <CoopLogic>();

        if (this.DoesColorFit(cl))
        {
            cl.Wobble();
            ChickenSortEvents.CaptureChicken(this.gameObject);
            return(true);
        }
        return(false);
    }
Ejemplo n.º 7
0
 /** 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);
         }
     }
 }
Ejemplo n.º 8
0
 void OnMouseUpAsButton()
 {
     this.GetComponent <SoundManager>().PlayAudio("pickup", false, 0.2f);
     ChickenSortEvents.CollectEgg(this.gameObject);
 }