private void AttachGrainToPlayer(PollenGrain grain) { GrainCount++; SeekAvailableAnchor(); PlayerPollenColor = grain.GrainColor; grain.transform.parent = _availableAnchor; grain.AttachedToPlayer = true; grain.MovingTowardPlayer = true; }
private void DetachAllGrain() { GrainCount = 0; foreach (Transform child in PollenContainer.transform) { if (child.childCount != 0) { PollenGrain _grain = child.GetComponentInChildren <PollenGrain> (); _grain.AttachedToPlayer = false; _grain.tag = "Movable"; _grain.Fading = true; } } PlayerPollenColor = PollenColor.None; }
private void OnCollisionEnter2D(Collision2D other) { GameObject otherObject = other.gameObject; if (otherObject.GetComponent <FlowerController>()) { AudioManager.instance.Play("PollinateSound"); beeAnimator.SetTrigger("PollenPick"); bool equals = false; PollenColor flowerColor = PollenColor.NONE; switch (otherObject.tag) { case "BlueFlower": if (currentPollenColor == PollenColor.BLUE) { equals = true; } flowerColor = PollenColor.BLUE; break; case "RedFlower": if (currentPollenColor == PollenColor.RED) { equals = true; } flowerColor = PollenColor.RED; break; case "PurpleFlower": if (currentPollenColor == PollenColor.PURPLE) { equals = true; } flowerColor = PollenColor.PURPLE; break; } if (equals) { ; ; CurrentScore += 10; if (puns.Length > 0) { punText.text = puns[Random.Range(0, puns.Length)]; Invoke("RemovePun", 3); } currentPollenColor = PollenColor.NONE; beeAnimator.SetTrigger("DropPollen"); } else { currentPollenColor = flowerColor; switch (currentPollenColor) { case PollenColor.BLUE: beeAnimator.SetTrigger("Blue"); break; case PollenColor.PURPLE: beeAnimator.SetTrigger("Purple"); break; case PollenColor.RED: beeAnimator.SetTrigger("Red"); break; } } // lastFlower = otherObject; // Destroy(gameObject); Destroy(otherObject.GetComponent <FlowerController>()); } }