Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent <KiwiController>() != null)
        {
            KiwiController script = other.GetComponent <KiwiController>();
            script.feedKiwi(weight);
            script.setEating(true);
            script.RenderEatingSprite();
            //script.setEating(false);
            levelManager.PlayKiwiParticleAnimation(script.transform.position, script.transform.rotation);

            kiwifruitSoundEffect.Play();
            Debug.Log("PLAY SOUND");

            /*
             * ScoreManager.AddPoints(pointsToAdd);
             */
            Destroy(gameObject);

            //script.RenderNormalSprite();
        }

        /*
         * else {
         *  KiwiController script = other.GetComponent<KiwiController>();
         *  script.RenderNormalSprite();
         * }
         */
    }
Exemplo n.º 2
0
 void BounceDamage(KiwiController kiwi)
 {
     if (kiwi == null)
     {
         return;
     }
     if (kiwi.isBouncy())
     {
         --this.hp;
         SetTexture();
     }
 }
Exemplo n.º 3
0
    private void updateMassOfThisBasedOnCarried()
    {
        if (carriedObject != null)
        {
            KiwiController script            = carriedObject.gameObject.GetComponent <KiwiController>();
            int            weightOfKiwi      = script.totalWeight;
            float          newWeightOfPlayer = updateMassBasedOnNumKiwis(weightOfKiwi);

            if (newWeightOfPlayer > 0 && newWeightOfPlayer < 20)
            {
                GetComponent <Rigidbody2D>().mass = newWeightOfPlayer;
            }
            totalWeight = weightOfKiwi;
        }
    }
Exemplo n.º 4
0
    //runs every n times a frame
    void FixedUpdate()
    {
        grounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);
        //if carrying change ground check to the kiwi
        if (carriedObject != null && carriedObject.tag == "Kiwi")
        {
            KiwiController kiwiScript = carriedObject.GetComponent <KiwiController>();
            grounded = kiwiScript.kiwi_grounded;
        }
        else
        {
            groundCheck = initGroundCheck;
        }
        //if (grounded) anim.SetBool("Jumping", false);
        //anim.SetFloat("falling", GetComponent<Rigidbody2D>().velocity.y);

        //update RigidedBody2D as totalWeight increase
        updateMassOfThisBasedOnCarried();
    }