// 모든 총알 회수 public void AllBulletCollect() { for (int i = 0; i < BulletPoolSize; i++) { if (AllBullet[i].activeSelf == true) { P_Bullet temp = AllBullet[i].GetComponent <P_Bullet>(); temp.SetOff(); } } }
// 총알 발사 void Shoot() { // Pool에서 켜기 if (BulletPool.Count > 0) { NowWeapon._AmmoCount--; // 총알 1개 소모 // 부메랑 다 날리면 손에서 사라짐(보여지는 건 회수하는 부분에 있음) if (NowWeapon._W_Type == WeaponType.Boomerang) { if (NowWeapon._AmmoCount <= 0) { if (GunImage.enabled) { GunImage.enabled = false; } } } // TextUI 세팅 UpdateAmmoTextUI(); // Pool에서 뺌 GameObject tempBullet = BulletPool[0]; BulletPool.RemoveAt(0); // 총알 상세 설정 P_Bullet tempScript = tempBullet.GetComponent <P_Bullet>(); tempScript.SetAttribute(NowWeapon._Number, NowWeapon._W_Type, NowWeapon._BulletSpeed, NowWeapon._Power, NowWeapon._BulletTime); // 생김새 바꿔줌 tempBullet.GetComponentInChildren <SpriteRenderer>().sprite = NowWeapon._BulletSprite; // 크기 바꿔줌 tempBullet.transform.GetChild(0).localScale = NowWeapon._BulletSize; // 콜라이더 잡아줌 tempBullet.GetComponent <BoxCollider>().size = NowWeapon._BulletCollider; // 위치 잡아줌 if (NowWeapon._Number != 4 && NowWeapon._W_Type != WeaponType.TimeBomb) { // 일반 총알 tempBullet.transform.position = transform.position + transform.forward * 0.5f; // 약간 앞에서 발사 } else { // 큰 부메랑은 플레이어 몸에서 나가게(안 그러면 벽에 끼임) // 시한폭탄도 플레이어 몸에서 나가게 tempBullet.transform.position = transform.position; } // 총알 회전(시한폭탄은 필요없음) if (NowWeapon._W_Type != WeaponType.TimeBomb) { tempBullet.transform.LookAt(Target); // x축 회전 없앰 Vector3 tempAngle = tempBullet.transform.eulerAngles; tempAngle.x = 0; tempBullet.transform.eulerAngles = tempAngle; } // 쿨다운 시작 IsCooldown = true; // 총알 켬 tempBullet.SetActive(true); } else { Debug.Log("Player BulletPool 초과"); } }