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(); * } */ }
void BounceDamage(KiwiController kiwi) { if (kiwi == null) { return; } if (kiwi.isBouncy()) { --this.hp; SetTexture(); } }
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; } }
//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(); }