private void OnTriggerStay2D(Collider2D collision) { PlayerBody pb = collision.gameObject.GetComponent <PlayerBody>(); if (collision.CompareTag("Player") && pb.Lying && pb.WhichPlayer != playerBody.WhichPlayer) { if (playerBody.do_time > 1) { if (pb.Trash > 0) { int temp = Mathf.CeilToInt(pb.Trash * (float)playerBody.Do_num / 100); pb.Loss_Garbage(temp); playerBody.Pick_Garbage(temp); playerBody.do_time = 0; pb.ShowEmoji(PlayerBody.Emojis.Bedo, 3f); playerBody.ShowEmoji(PlayerBody.Emojis.Do, 3f); AudioManager.Instance.SoundPlay("sfx/Do"); AudioManager.Instance.SoundPlay("sfx/BeDo"); } } else { playerBody.do_time += Time.deltaTime; } } }
void Fire() { PlayerBody.Loss_Garbage(damage); Vector3 dir = shoot_point.position - transform.position; dir.Normalize(); int sfx_index = Random.Range(0, 2); PlayerBody.SoundPlay("sfx/HitFromFar_" + sfx_index, 0.5f); Ammo am = GameObjectPoolManager.Instance.Pool_GarbageLitter.AllocateGameObject <Ammo>(GameBoardManager.Instance.GameBoardGarbagesCanvas.transform); am.transform.position = shoot_point.transform.position; am.transform.rotation = shoot_point.transform.rotation; am.Rigidbody2D.velocity = dir * shoot_speed; am.Initialize(PlayerBody.WhichPlayer, PlayerBody.WhichRobot); PlayerBody.ShootParticleSystem.gameObject.SetActive(true); PlayerBody.ShootParticleSystem.Play(); }