ThreeKingdomsSlingshot/Assets/VFX/GabrielAguiarProductions/Scripts/UniqueProjectiles/SpawnProjectilesScript.cs

212 lines
5.5 KiB
C#
Raw Permalink Normal View History

스킬 이펙트 작업 준비 — 스킬 테스트 씬 · WL 이펙트 이식 · 이펙트 표 · 보병·창·기병 슬링샷 공격 = WL 창 돌진 이펙트 시험(PD 2026-11-09) PD 「WL 프로젝트에서 스킬을 구현하던 방식과 동일하게 유닛 별 스킬 구현」 · 「테스트 목적: 보병, 창, 기병을 슬링샷으로 공격할 때 WL 창 돌진 공격 이펙트」 - 스킬 테스트 씬 Assets/Scenes/SkillTest.unity(SkillTestBootstrap · 메뉴 TKS/Skill Test/Build Scene): 영웅 목록 선택(heroes.csv 56) · 더미(죽지 않음 · 행동 토글 · 배치 표 Resources/Skills/skill_test.csv) · 슬링샷 · 액티브 버튼 · 쿨 무시 · 영웅 무적 · 이펙트 보기(에디터 · Assets/VFX 검색 → 영웅에 띄움) - 이펙트 표 Resources/Skills/skill_vfx.csv → Runtime/Skills/SkillVfx(키 = 스킬 id 또는 basic_<병종> · cast/travel/hit · f_every 반복 · 사본 Resources/Fx/TKS_Fx_*) · 훅 = SkillSystem Announce/BeginAction/EndAction/Hit/Instant - WL 이펙트 이식 Assets/VFX(약 640 MB · 빌트인 호환분만 · GUID 유지 · 도구 Tools/wl_vfx_import.py) · URP 셰이더 빌트인 이식 4종 Assets/VFX/_BuiltinPorts · com.unity.shadergraph 17.3.0 · 카메라 깊이 텍스처 켬(셰이더 그래프 소프트 파티클) - 시험: basic_infantry/spear/cavalry travel = TKS_Fx_SpearRush · SpearRushWrap · SpearRushDust(WL WLStaffEarth rushFx 1~3 값 환산) — 표 9행 삭제 = 원래대로 - 테스트 118/118 · console error 0 · 이 PC 첫 임포트 자동 재직렬화(png·tga .meta · UITheme · ProjectSettings · InputManager)는 제외 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:12:52 +00:00
//
//NOTES:
//This script is used for DEMONSTRATION porpuses of the Projectiles. I recommend everyone to create their own code for their own projects.
//This is just a basic example.
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SpawnProjectilesScript : MonoBehaviour {
public bool useTarget;
public bool use2D;
public bool cameraShake;
public Text effectName;
public RotateToMouseScript rotateToMouse;
public GameObject firePoint;
public GameObject cameras;
public GameObject target;
public List<GameObject> VFXs = new List<GameObject> ();
private int count = 0;
private float timeToFire = 0f;
private GameObject effectToSpawn;
private List<Camera> camerasList = new List<Camera> ();
private Camera singleCamera;
void Start () {
if (cameras.transform.childCount > 0) {
for (int i = 0; i < cameras.transform.childCount; i++) {
camerasList.Add (cameras.transform.GetChild (i).gameObject.GetComponent<Camera> ());
}
if(camerasList.Count == 0){
Debug.Log ("Please assign one or more Cameras in inspector");
}
} else {
singleCamera = cameras.GetComponent<Camera> ();
if (singleCamera != null)
camerasList.Add (singleCamera);
else
Debug.Log ("Please assign one or more Cameras in inspector");
}
if(VFXs.Count>0)
effectToSpawn = VFXs[0];
else
Debug.Log ("Please assign one or more VFXs in inspector");
if (effectName != null) effectName.text = effectToSpawn.name;
if (camerasList.Count > 0) {
rotateToMouse.SetCamera (camerasList [camerasList.Count - 1]);
if(use2D)
rotateToMouse.Set2D (true);
rotateToMouse.StartUpdateRay ();
}
else
Debug.Log ("Please assign one or more Cameras in inspector");
if (useTarget && target != null)
{
var collider = target.GetComponent<BoxCollider>();
if (!collider)
{
target.AddComponent<BoxCollider>();
}
}
}
void Update () {
if (Input.GetKey (KeyCode.Space) && Time.time >= timeToFire || Input.GetMouseButton (0) && Time.time >= timeToFire) {
timeToFire = Time.time + 1f / effectToSpawn.GetComponent<ProjectileMoveScript>().fireRate;
SpawnVFX ();
}
if (Input.GetKeyDown (KeyCode.D))
Next ();
if (Input.GetKeyDown (KeyCode.A))
Previous ();
if (Input.GetKeyDown (KeyCode.C))
SwitchCamera ();
if (Input.GetKeyDown (KeyCode.Alpha1))
CameraShake ();
if (Input.GetKeyDown (KeyCode.X))
ZoomIn ();
if (Input.GetKeyDown (KeyCode.Z))
ZoomOut ();
}
public void SpawnVFX () {
GameObject vfx;
var cameraShakeScript = cameras.GetComponent<CameraShakeSimpleScript> ();
if (cameraShake && cameraShakeScript != null)
cameraShakeScript.ShakeCamera ();
if (firePoint != null) {
vfx = Instantiate (effectToSpawn, firePoint.transform.position, Quaternion.identity);
if (!useTarget)
{
if (rotateToMouse != null)
{
vfx.transform.localRotation = rotateToMouse.GetRotation();
}
else Debug.Log("No RotateToMouseScript found on firePoint.");
}
else
{
if (target != null)
{
vfx.GetComponent<ProjectileMoveScript>().SetTarget(target, rotateToMouse);
rotateToMouse.RotateToMouse(vfx, target.transform.position);
}
else
{
Destroy(vfx);
Debug.Log("No target assigned.");
}
}
}
else
vfx = Instantiate (effectToSpawn);
}
public void Next () {
count++;
if (count > VFXs.Count)
count = 0;
for(int i = 0; i < VFXs.Count; i++){
if (count == i) effectToSpawn = VFXs [i];
if (effectName != null) effectName.text = effectToSpawn.name;
}
}
public void Previous () {
count--;
if (count < 0)
count = VFXs.Count;
for (int i = 0; i < VFXs.Count; i++) {
if (count == i) effectToSpawn = VFXs [i];
if (effectName != null) effectName.text = effectToSpawn.name;
}
}
public void CameraShake () {
cameraShake = !cameraShake;
}
public void ZoomIn () {
if (camerasList.Count > 0) {
if (!camerasList [0].orthographic) {
if (camerasList [0].fieldOfView < 101) {
for (int i = 0; i < camerasList.Count; i++) {
camerasList [i].fieldOfView += 5;
}
}
} else {
if (camerasList [0].orthographicSize < 10) {
for (int i = 0; i < camerasList.Count; i++) {
camerasList [i].orthographicSize += 0.5f;
}
}
}
}
}
public void ZoomOut () {
if (camerasList.Count > 0) {
if (!camerasList [0].orthographic) {
if (camerasList [0].fieldOfView > 20) {
for (int i = 0; i < camerasList.Count; i++) {
camerasList [i].fieldOfView -= 5;
}
}
} else {
if (camerasList [0].orthographicSize > 4) {
for (int i = 0; i < camerasList.Count; i++) {
camerasList [i].orthographicSize -= 0.5f;
}
}
}
}
}
public void SwitchCamera () {
if (camerasList.Count > 0) {
for (int i = 0; i < camerasList.Count; i++) {
if (camerasList [i].gameObject.activeSelf) {
camerasList [i].gameObject.SetActive (false);
if ((i + 1) == camerasList.Count) {
camerasList [0].gameObject.SetActive (true);
rotateToMouse.SetCamera (camerasList [0]);
break;
} else {
camerasList [i + 1].gameObject.SetActive (true);
rotateToMouse.SetCamera (camerasList [i + 1]);
break;
}
}
}
}
}
}