+ 기본적인 배에서 포쏘는 로직 완료 우클릭 - 발사 모드 온/오프 좌클릭 Hold - 발사 게이지 충전 좌클릭 중단 - 발사 + 대포 발사시 카메라 흔들림 효과 추가 + 대포 재장선시 UI 추가 + 대포 재장전시 공격하면 사운드 및 UI 흔들림 효과 추가 + 카메라 고정으로 변경
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using System;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class Cannon : MonoBehaviour
|
|
{
|
|
[Title("초기화 방식")]
|
|
[SerializeField] private bool autoInit = true;
|
|
|
|
[Title("캐논 변수")]
|
|
[SerializeField] private GameObject projectileObj;
|
|
[SerializeField] private Transform firePos;
|
|
[SerializeField] private float speed = 2000f;
|
|
|
|
[Title("캐논 발사 카메라 효과")]
|
|
[SerializeField] private float cameraShakePower = 0.5f;
|
|
[SerializeField] private float cameraShakeDuration = 0.5f;
|
|
|
|
private void Awake()
|
|
{
|
|
if (autoInit)
|
|
{
|
|
Init();
|
|
}
|
|
}
|
|
|
|
[Button("셋팅 초기화")]
|
|
private void Init()
|
|
{
|
|
projectileObj = Utils.LoadFromFolder<GameObject>("Assets/05.Prefabs/Particles/GrenadeFire", "GrenadeFireOBJ", ".prefab");
|
|
firePos = transform.Find("FirePos");
|
|
}
|
|
|
|
public void Fire(float chargingGauge)
|
|
{
|
|
VisualFeedbackManager.Inst.CameraShake(CameraManager.Inst.OceanCamera.BaseShipCam, cameraShakePower, cameraShakeDuration);
|
|
var projectile = Instantiate(projectileObj, firePos.position, Quaternion.identity);
|
|
projectile.GetComponent<Rigidbody>().AddForce(transform.forward * (chargingGauge * speed));
|
|
}
|
|
}
|
|
}
|