2023-12-17 19:50:44 +00:00
|
|
|
using System;
|
2023-12-15 07:19:02 +00:00
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
|
|
namespace BlueWaterProject
|
|
|
|
{
|
|
|
|
public class Cannon : MonoBehaviour
|
|
|
|
{
|
2023-12-17 19:50:44 +00:00
|
|
|
[Title("초기화 방식")]
|
|
|
|
[SerializeField] private bool autoInit = true;
|
|
|
|
|
|
|
|
[Title("캐논 변수")]
|
2023-12-15 07:19:02 +00:00
|
|
|
[SerializeField] private GameObject projectileObj;
|
|
|
|
[SerializeField] private Transform firePos;
|
2023-12-17 19:50:44 +00:00
|
|
|
[SerializeField] private float speed = 2000f;
|
2023-12-15 07:19:02 +00:00
|
|
|
|
2023-12-17 19:50:44 +00:00
|
|
|
[Title("캐논 발사 카메라 효과")]
|
|
|
|
[SerializeField] private float cameraShakePower = 0.5f;
|
|
|
|
[SerializeField] private float cameraShakeDuration = 0.5f;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
if (autoInit)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
}
|
2023-12-15 07:19:02 +00:00
|
|
|
|
|
|
|
[Button("셋팅 초기화")]
|
|
|
|
private void Init()
|
|
|
|
{
|
|
|
|
projectileObj = Utils.LoadFromFolder<GameObject>("Assets/05.Prefabs/Particles/GrenadeFire", "GrenadeFireOBJ", ".prefab");
|
|
|
|
firePos = transform.Find("FirePos");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Fire(float chargingGauge)
|
|
|
|
{
|
2023-12-17 19:50:44 +00:00
|
|
|
VisualFeedbackManager.Inst.CameraShake(CameraManager.Inst.OceanCamera.BaseShipCam, cameraShakePower, cameraShakeDuration);
|
2023-12-15 07:19:02 +00:00
|
|
|
var projectile = Instantiate(projectileObj, firePos.position, Quaternion.identity);
|
|
|
|
projectile.GetComponent<Rigidbody>().AddForce(transform.forward * (chargingGauge * speed));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|