private void Stun() { SetSprite(stunnedSprite); if (currentNestPiece != null) { currentNestPiece.IsDropped(); currentNestPiece = null; } }
private void PickupNestPiece(Collider2D target) { NestPiece targetPiece = target.gameObject.GetComponentInParent <NestPiece>(); if (targetPiece != null && currentNestPiece == null) { targetPiece.SetHeld(beakObject); currentNestPiece = targetPiece; if (soundManager != null) { soundManager.PlaySpawnPieceClip(); } } }
private void DepositNestPiece(Collider2D target) { Transform targetNest = target.transform; if (targetNest != null && nest == targetNest && currentNestPiece != null) { // INCREMENT SCORE score++; // DISPATCH EVENT if (OnScoreChange != null) { OnScoreChange(); } soundManager.PlayScoreClip(); // DELETE NEST PIECE Destroy(currentNestPiece.gameObject); currentNestPiece = null; } }
private void Spawn() { GameObject newInstance = Instantiate(nestPiecePrefab); NestPiece nestPiece = newInstance.GetComponent <NestPiece>(); if (nestPiece != null) { // RANDOMIZE POSITION float newX = Random.value * spawnWidth - (spawnWidth / 2); float newY = transform.position.y; float rotation = Random.value * 360f; nestPiece.transform.position = new Vector2(newX, newY); nestPiece.transform.eulerAngles = new Vector3(0, 0, rotation); nestPiece.GetComponent <Rigidbody2D>().AddTorque(2); // INCREMENT COUNT count++; // DECREMENT COUNT ON REMOVE nestPiece.OnRemoved += () => count--; } }