#11 Mouse cursor change

This commit is contained in:
M1_IDMhan 2023-08-31 15:46:13 +09:00
parent 09c56b52f9
commit 9384999047
25 changed files with 959 additions and 735 deletions

View File

@ -16961,7 +16961,7 @@ MonoBehaviour:
- {fileID: 21300000, guid: d7aae5ed9e4924be4ac2fe09b2f729a9, type: 3}
- {fileID: 21300000, guid: 9180a011ac08440f89deb0b7aa2820f2, type: 3}
- {fileID: 21300000, guid: 9180a011ac08440f89deb0b7aa2820f2, type: 3}
cursorTexture: {fileID: 2800000, guid: c617a5b08493842c3833527a458fd612, type: 3}
cursorTexture: {fileID: 2800000, guid: 3a146044a282641d99ba04c33b8c2bbf, type: 3}
--- !u!4 &107190135
Transform:
m_ObjectHideFlags: 0
@ -34764,6 +34764,87 @@ Transform:
- {fileID: 847870679}
m_Father: {fileID: 106415425}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &222471351
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 155222, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_Name
value: Toon Queen Worm - Pink (1)
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalScale.x
value: 10
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalScale.y
value: 10
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalScale.z
value: 10
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalPosition.x
value: -71.3
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalPosition.y
value: -13.5
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalPosition.z
value: -1.3
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalRotation.w
value: -0.6878803
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalRotation.y
value: -0.7258242
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: -266.925
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_ConstrainProportionsScale
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 155222, guid: 3ed5d7842716c504d8dd3ea20c75a637,
type: 3}
insertIndex: -1
addedObject: {fileID: 451666486}
- targetCorrespondingSourceObject: {fileID: 155222, guid: 3ed5d7842716c504d8dd3ea20c75a637,
type: 3}
insertIndex: -1
addedObject: {fileID: 451666485}
m_SourcePrefab: {fileID: 100100000, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
--- !u!1 &222537145
GameObject:
m_ObjectHideFlags: 0
@ -70795,6 +70876,62 @@ SkinnedMeshRenderer:
m_Center: {x: -0.06254879, y: 0.024880677, z: 0.00000011920929}
m_Extent: {x: 0.5167997, y: 0.27444458, z: 0.7707152}
m_DirtyAABB: 0
--- !u!1 &451666484 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 155222, guid: 3ed5d7842716c504d8dd3ea20c75a637,
type: 3}
m_PrefabInstance: {fileID: 222471351}
m_PrefabAsset: {fileID: 0}
--- !u!54 &451666485
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 451666484}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!136 &451666486
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 451666484}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 1
m_Height: 4
m_Direction: 1
m_Center: {x: 0, y: 1.9, z: 0}
--- !u!1 &451981707
GameObject:
m_ObjectHideFlags: 0
@ -74235,8 +74372,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 176cfac66084d4bfb9b4c9f11c4b137f, type: 3}
m_Name:
m_EditorClassIdentifier:
maxSpeed: 5
acceleration: 2
maxSpeed: 10
acceleration: 4
deceleration: 2
turnSpeed: 1
characterSpeed: 2
@ -86739,7 +86876,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!1 &550717941
GameObject:
m_ObjectHideFlags: 0
@ -182771,7 +182908,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalPosition.x
value: -7.3424807
value: -1.9
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalPosition.y
@ -182779,7 +182916,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalPosition.z
value: 15.353005
value: 15.7
objectReference: {fileID: 0}
- target: {fileID: 452206, guid: 3ed5d7842716c504d8dd3ea20c75a637, type: 3}
propertyPath: m_LocalRotation.w
@ -190839,50 +190976,6 @@ SkinnedMeshRenderer:
m_Center: {x: -0.06498811, y: 0.020641163, z: 0.00000014901161}
m_Extent: {x: 0.5143604, y: 0.28673673, z: 0.7707151}
m_DirtyAABB: 0
--- !u!1 &1234264506
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1234264508}
- component: {fileID: 1234264507}
m_Layer: 0
m_Name: InputSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1234264507
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1234264506}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 977b3558370da85488b8199c446577a0, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1234264508
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1234264506}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -187.1454, y: 12.477399, z: -121.38537}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1234566403
GameObject:
m_ObjectHideFlags: 0
@ -244929,7 +245022,7 @@ MonoBehaviour:
IsHidden: 0
- Type: 0
Name:
GameObject: {fileID: 1234264506}
GameObject: {fileID: 0}
Ordinal: 4
Priority: 0
IconType: 1000
@ -338576,7 +338669,6 @@ SceneRoots:
- {fileID: 1540310984}
- {fileID: 1228753929}
- {fileID: 107190135}
- {fileID: 1234264508}
- {fileID: 2105062291}
- {fileID: 1560348101}
- {fileID: 476261175}
@ -338587,6 +338679,7 @@ SceneRoots:
- {fileID: 1545641374}
- {fileID: 1188875250}
- {fileID: 1178452038}
- {fileID: 222471351}
- {fileID: 1994033914}
- {fileID: 342641572}
- {fileID: 99817019}

View File

@ -1,89 +1,91 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BlueWaterProject;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations;
using UnityEngine.UI;
public class Boat : MonoBehaviour
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
private NavMeshAgent agent;
private LineRenderer lineRenderer;
private GameObject spot; //도착지점 표시 이미지
private Coroutine draw; //경로 그리기 코루틴
private Transform typeCard;
public SpriteRenderer TypeCardSprite { get; private set; }
private LookAtConstraint typeCardLookAtConstraint;
public Vector3 Target { get; set; }
public string CardIndex { get; set; }
public delegate void LandedEventHandler(string cardIndex, AttackerType attackerType, Vector3 assignPos);
public event LandedEventHandler OnLanded;
private void Awake()
public class Boat : MonoBehaviour
{
agent = GetComponent<NavMeshAgent>();
lineRenderer = GetComponent<LineRenderer>();
lineRenderer.startWidth = 0.1f;
lineRenderer.endWidth = 0.1f;
lineRenderer.material.color = Color.yellow;
lineRenderer.enabled = false;
private NavMeshAgent agent;
private LineRenderer lineRenderer;
private GameObject spot; //도착지점 표시 이미지
private Coroutine draw; //경로 그리기 코루틴
private Transform typeCard;
public SpriteRenderer TypeCardSprite { get; private set; }
private LookAtConstraint typeCardLookAtConstraint;
public Vector3 Target { get; set; }
public string CardIndex { get; set; }
public delegate void LandedEventHandler(string cardIndex, AttackerType attackerType, Vector3 assignPos);
public event LandedEventHandler OnLanded;
private void Awake()
{
agent = GetComponent<NavMeshAgent>();
lineRenderer = GetComponent<LineRenderer>();
lineRenderer.startWidth = 0.1f;
lineRenderer.endWidth = 0.1f;
lineRenderer.material.color = Color.yellow;
lineRenderer.enabled = false;
spot = Instantiate(DataManager.Inst.mouseSpot);
typeCard = transform.Find("TypeCard");
TypeCardSprite = typeCard.GetComponent<SpriteRenderer>();
typeCardLookAtConstraint = typeCard.GetComponent<LookAtConstraint>();
}
spot = Instantiate(DataManager.Inst.mouseSpot);
typeCard = transform.Find("TypeCard");
TypeCardSprite = typeCard.GetComponent<SpriteRenderer>();
typeCardLookAtConstraint = typeCard.GetComponent<LookAtConstraint>();
}
private void Start()
{
agent.SetDestination(Target);
spot.gameObject.SetActive(true);
spot.transform.position = Target;
if (draw != null) StopCoroutine(draw);
draw = StartCoroutine(DrawPath());
typeCardLookAtConstraint.SetSources(new List<ConstraintSource>
private void Start()
{
new ConstraintSource
agent.SetDestination(Target);
spot.gameObject.SetActive(true);
spot.transform.position = Target;
if (draw != null) StopCoroutine(draw);
draw = StartCoroutine(DrawPath());
typeCardLookAtConstraint.SetSources(new List<ConstraintSource>
{
sourceTransform = Camera.main.transform,
weight = 1
}
});
}
new ConstraintSource
{
sourceTransform = Camera.main.transform,
weight = 1
}
});
}
private void Update()
{
if (!(agent.remainingDistance < 0.1f && !agent.pathPending)) return;
spot.gameObject.SetActive(false);
lineRenderer.enabled = false;
if (draw != null) StopCoroutine(draw);
OnLanded?.Invoke(CardIndex, AttackerType.OFFENSE, Target);
Destroy(gameObject);
}
private IEnumerator DrawPath()
{
lineRenderer.enabled = true;
yield return null;
while (true)
private void Update()
{
var count = agent.path.corners.Length;
lineRenderer.positionCount = count;
for (var i = 0; i < count; i++)
{
lineRenderer.SetPosition(i, agent.path.corners[i] + new Vector3(0,1,0));
}
if (!(agent.remainingDistance < 0.1f && !agent.pathPending)) return;
spot.gameObject.SetActive(false);
lineRenderer.enabled = false;
if (draw != null) StopCoroutine(draw);
OnLanded?.Invoke(CardIndex, AttackerType.OFFENSE, Target);
Destroy(gameObject);
}
private IEnumerator DrawPath()
{
lineRenderer.enabled = true;
yield return null;
while (true)
{
var count = agent.path.corners.Length;
lineRenderer.positionCount = count;
for (var i = 0; i < count; i++)
{
lineRenderer.SetPosition(i, agent.path.corners[i] + new Vector3(0,1,0));
}
yield return null;
}
}
}
}

View File

@ -1,136 +1,138 @@
using System;
using System.Collections;
using _02.Scripts.WaterAndShip;
using BlueWaterProject;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class DraggableCard : MonoBehaviour, IPointerDownHandler, IDragHandler, IPointerUpHandler
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
[Title("Card")]
private Vector3 originalPosition;
private Vector3 originalScale;
private CanvasGroup canvasGroup;
private GameObject border;
public Card card;
public class DraggableCard : MonoBehaviour, IPointerDownHandler, IDragHandler, IPointerUpHandler
{
[Title("Card")]
private Vector3 originalPosition;
private Vector3 originalScale;
private CanvasGroup canvasGroup;
private GameObject border;
public Card card;
[Title("Child Object")]
private Image typeImage;
[Title("Child Object")]
private Image typeImage;
[InfoBox("카드가 작아지는 속도 입니다. 높을수록 천천히 작아집니다.")] [Range(0f, 1000f)]
public float maxDistance = 500f;
[InfoBox("카드가 작아지는 속도 입니다. 높을수록 천천히 작아집니다.")] [Range(0f, 1000f)]
public float maxDistance = 500f;
private Coroutine scaleDown;
private Coroutine scaleDown;
private void Awake()
{
border = transform.Find("Border").gameObject;
typeImage = transform.Find("Type").GetComponent<Image>();
}
private void Start()
{
canvasGroup = GetComponent<CanvasGroup>();
}
public void CardInit()
{
var cardInfo = DataManager.Inst.GetUnitDictionaryKey(card.UnitIdx);
typeImage.sprite = DataManager.Inst.cardType[(int)cardInfo.UnitType];
}
public void OnPointerDown(PointerEventData eventData)
{
var transform1 = transform;
originalPosition = transform1.position;
originalScale = transform1.localScale;
canvasGroup.alpha = 0.5f;
//transform1.localScale = new Vector3(0.3f, 0.3f, 1f);
if (scaleDown != null) StopCoroutine(scaleDown);
scaleDown = StartCoroutine(ScaleDown());
}
public void OnDrag(PointerEventData eventData)
{
transform.position = Input.mousePosition;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit) && hit.collider.CompareTag("Ground"))
private void Awake()
{
// 마우스가 Ground 위에 있을 때
border.SetActive(true);
}
else
{
// 마우스가 Ground 위에 없을 때
border.SetActive(false);
}
}
public void OnPointerUp(PointerEventData eventData)
{
// 지형에 올바르게 드롭되지 않으면
if (IsDroppedOnTarget()) return;
if (scaleDown != null)
{
StopCoroutine(scaleDown);
scaleDown = null;
border = transform.Find("Border").gameObject;
typeImage = transform.Find("Type").GetComponent<Image>();
}
var transform1 = transform;
transform1.position = originalPosition;
transform1.localScale = originalScale;
canvasGroup.alpha = 1;
}
private void Start()
{
canvasGroup = GetComponent<CanvasGroup>();
}
private bool IsDroppedOnTarget()
{
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
public void CardInit()
{
var cardInfo = DataManager.Inst.GetUnitDictionaryKey(card.UnitIdx);
typeImage.sprite = DataManager.Inst.cardType[(int)cardInfo.UnitType];
}
if (!Physics.Raycast(ray, out hit)) return false;
if (!hit.collider.CompareTag("Ground")) return false;
Destroy(gameObject);
var obj = Instantiate(DataManager.Inst.boat, GameManager.Inst.player.transform.position,
Quaternion.identity);
public void OnPointerDown(PointerEventData eventData)
{
var transform1 = transform;
originalPosition = transform1.position;
originalScale = transform1.localScale;
canvasGroup.alpha = 0.5f;
//transform1.localScale = new Vector3(0.3f, 0.3f, 1f);
if (scaleDown != null) StopCoroutine(scaleDown);
scaleDown = StartCoroutine(ScaleDown());
}
public void OnDrag(PointerEventData eventData)
{
transform.position = Input.mousePosition;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit) && hit.collider.CompareTag("Ground"))
{
// 마우스가 Ground 위에 있을 때
border.SetActive(true);
}
else
{
// 마우스가 Ground 위에 없을 때
border.SetActive(false);
}
}
public void OnPointerUp(PointerEventData eventData)
{
// 지형에 올바르게 드롭되지 않으면
if (IsDroppedOnTarget()) return;
if (scaleDown != null)
{
StopCoroutine(scaleDown);
scaleDown = null;
}
var transform1 = transform;
transform1.position = originalPosition;
transform1.localScale = originalScale;
canvasGroup.alpha = 1;
}
private bool IsDroppedOnTarget()
{
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (!Physics.Raycast(ray, out hit)) return false;
if (!hit.collider.CompareTag("Ground")) return false;
Destroy(gameObject);
var obj = Instantiate(DataManager.Inst.boat, GameManager.Inst.player.transform.position,
Quaternion.identity);
var boat = obj.GetComponent<Boat>();
boat.TypeCardSprite.sprite = typeImage.sprite;
boat.Target = hit.point;
boat.CardIndex = card.Idx;
boat.OnLanded += UnitManager.Inst.CreateAndAssign;
var boat = obj.GetComponent<Boat>();
boat.TypeCardSprite.sprite = typeImage.sprite;
boat.Target = hit.point;
boat.CardIndex = card.Idx;
boat.OnLanded += UnitManager.Inst.CreateAndAssign;
return true;
return true;
}
}
private IEnumerator ScaleDown()
{
var originalScale = transform.localScale;
var targetScale = new Vector3(0.3f, 0.3f, 1f);
while (true)
private IEnumerator ScaleDown()
{
// 현재 위치와 원래 위치 사이의 거리를 계산
var distance = Vector3.Distance(originalPosition, transform.position);
var originalScale = transform.localScale;
var targetScale = new Vector3(0.3f, 0.3f, 1f);
// 비율을 계산 (0 = 같은 위치, 1 = maxDistance만큼나 이상 떨어져 있음)
var ratio = Mathf.Min(distance / maxDistance, 1f);
while (true)
{
// 현재 위치와 원래 위치 사이의 거리를 계산
var distance = Vector3.Distance(originalPosition, transform.position);
// SmoothStep 사용하면, 천천히 시작해서 점차 빠르게 변화
// float의 경우만 사용할 수 있으므로, Vector3의 모든 요소에 일일이 적용
var newScale = new Vector3(
Mathf.SmoothStep(originalScale.x, targetScale.x, ratio),
Mathf.SmoothStep(originalScale.y, targetScale.y, ratio),
Mathf.SmoothStep(originalScale.z, targetScale.z, ratio)
);
// 비율을 계산 (0 = 같은 위치, 1 = maxDistance만큼나 이상 떨어져 있음)
var ratio = Mathf.Min(distance / maxDistance, 1f);
// 조정한 스케일을 적용
transform.localScale = newScale;
// SmoothStep 사용하면, 천천히 시작해서 점차 빠르게 변화
// float의 경우만 사용할 수 있으므로, Vector3의 모든 요소에 일일이 적용
var newScale = new Vector3(
Mathf.SmoothStep(originalScale.x, targetScale.x, ratio),
Mathf.SmoothStep(originalScale.y, targetScale.y, ratio),
Mathf.SmoothStep(originalScale.z, targetScale.z, ratio)
);
yield return null;
// 조정한 스케일을 적용
transform.localScale = newScale;
yield return null;
}
}
}
}

View File

@ -1,105 +1,106 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Cinemachine;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.InputSystem;
public class CameraController : MonoBehaviour
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
[Title("Dredge Cam")]
[Required("드렛지 카메라를 넣어주세요.")]
public CinemachineVirtualCamera dredgeCam;
private CinemachineOrbitalTransposer dredgeCamOrbitalTransposer;
[Range(0,1000)]
public int rotateSpeed = 10;
[Required("습격모드 카메라를 넣어주세요.")]
public CinemachineVirtualCamera assaultCam;
[Required("보트내부 카메라를 넣어주세요.")]
public CinemachineVirtualCamera InShipCam;
[Required("조준 카메라를 넣어주세요.")]
public CinemachineFreeLook takeAimCam;
public float sensitivity = 0.01f;
[MinMaxSlider(2, 50, true)]
public Vector2 heightLimits = new Vector2(2, 50);
private void Start()
public class CameraController : MonoBehaviour
{
dredgeCamOrbitalTransposer = dredgeCam.GetCinemachineComponent<CinemachineOrbitalTransposer>();
}
private void Update()
{
TakeCamMovement();
DredgeCamRotate();
}
public void CamAssaultMode()
{
assaultCam.Priority = 1;
dredgeCam.Priority = 0;
InShipCam.Priority = 0;
}
[Title("Dredge Cam")]
[Required("드렛지 카메라를 넣어주세요.")]
public CinemachineVirtualCamera dredgeCam;
private CinemachineOrbitalTransposer dredgeCamOrbitalTransposer;
[Range(0,1000)]
public int rotateSpeed = 10;
public void CamDredgeMode()
{
dredgeCam.Priority = 1;
assaultCam.Priority = 0;
InShipCam.Priority = 0;
}
[Required("습격모드 카메라를 넣어주세요.")]
public CinemachineVirtualCamera assaultCam;
public void CamInShipMode()
{
InShipCam.Priority = 1;
dredgeCam.Priority = 0;
assaultCam.Priority = 0;
}
private void TakeCamMovement()
{
Vector2 mouseDelta = Mouse.current.delta.ReadValue();
Vector3 newPosition = takeAimCam.transform.position;
newPosition.y += mouseDelta.y * sensitivity;
newPosition.y = Mathf.Clamp(newPosition.y, heightLimits.x, heightLimits.y);
newPosition.x = GameManager.Inst.player.transform.position.x;
newPosition.z = GameManager.Inst.player.transform.position.z;
takeAimCam.transform.position = newPosition;
// Rotate around Y axis (Up direction)
takeAimCam.transform.RotateAround(takeAimCam.transform.position, Vector3.up, mouseDelta.x * sensitivity);
}
public void CamTakeAim(bool isTakeAim)
{
takeAimCam.Priority = isTakeAim ? 2 : 0;
float yRotation = dredgeCam.transform.rotation.eulerAngles.y;
takeAimCam.transform.rotation =
Quaternion.Euler(takeAimCam.transform.rotation.eulerAngles.x, yRotation, takeAimCam.transform.rotation.eulerAngles.z);
}
[Required("보트내부 카메라를 넣어주세요.")]
public CinemachineVirtualCamera InShipCam;
public void DredgeCamRotate()
{
if (Input.GetMouseButtonDown(1))
[Required("조준 카메라를 넣어주세요.")]
public CinemachineFreeLook takeAimCam;
public float sensitivity = 0.01f;
[MinMaxSlider(2, 50, true)]
public Vector2 heightLimits = new Vector2(2, 50);
private void Start()
{
//dredgeCam의 X Axis의 Speed를 변경
dredgeCamOrbitalTransposer.m_XAxis.m_MaxSpeed = rotateSpeed;
dredgeCamOrbitalTransposer.m_XAxis.m_InputAxisName = "Mouse X";
dredgeCamOrbitalTransposer.m_RecenterToTargetHeading.m_enabled = false;
dredgeCamOrbitalTransposer = dredgeCam.GetCinemachineComponent<CinemachineOrbitalTransposer>();
}
else if (Input.GetMouseButtonUp(1))
private void Update()
{
//dredgeCam의 X Axis의 Speed를 원래대로
dredgeCamOrbitalTransposer.m_XAxis.m_MaxSpeed = 0;
dredgeCamOrbitalTransposer.m_XAxis.m_InputAxisName = "";
dredgeCamOrbitalTransposer.m_RecenterToTargetHeading.m_enabled = true;
TakeCamMovement();
DredgeCamRotate();
}
public void CamAssaultMode()
{
assaultCam.Priority = 1;
dredgeCam.Priority = 0;
InShipCam.Priority = 0;
}
public void CamDredgeMode()
{
dredgeCam.Priority = 1;
assaultCam.Priority = 0;
InShipCam.Priority = 0;
}
public void CamInShipMode()
{
InShipCam.Priority = 1;
dredgeCam.Priority = 0;
assaultCam.Priority = 0;
}
private void TakeCamMovement()
{
Vector2 mouseDelta = Mouse.current.delta.ReadValue();
Vector3 newPosition = takeAimCam.transform.position;
newPosition.y += mouseDelta.y * sensitivity;
newPosition.y = Mathf.Clamp(newPosition.y, heightLimits.x, heightLimits.y);
newPosition.x = GameManager.Inst.player.transform.position.x;
newPosition.z = GameManager.Inst.player.transform.position.z;
takeAimCam.transform.position = newPosition;
// Rotate around Y axis (Up direction)
takeAimCam.transform.RotateAround(takeAimCam.transform.position, Vector3.up, mouseDelta.x * sensitivity);
}
public void CamTakeAim(bool isTakeAim)
{
takeAimCam.Priority = isTakeAim ? 2 : 0;
float yRotation = dredgeCam.transform.rotation.eulerAngles.y;
takeAimCam.transform.rotation =
Quaternion.Euler(takeAimCam.transform.rotation.eulerAngles.x, yRotation, takeAimCam.transform.rotation.eulerAngles.z);
}
public void DredgeCamRotate()
{
if (Input.GetMouseButtonDown(1))
{
//dredgeCam의 X Axis의 Speed를 변경
dredgeCamOrbitalTransposer.m_XAxis.m_MaxSpeed = rotateSpeed;
dredgeCamOrbitalTransposer.m_XAxis.m_InputAxisName = "Mouse X";
dredgeCamOrbitalTransposer.m_RecenterToTargetHeading.m_enabled = false;
}
else if (Input.GetMouseButtonUp(1))
{
//dredgeCam의 X Axis의 Speed를 원래대로
dredgeCamOrbitalTransposer.m_XAxis.m_MaxSpeed = 0;
dredgeCamOrbitalTransposer.m_XAxis.m_InputAxisName = "";
dredgeCamOrbitalTransposer.m_RecenterToTargetHeading.m_enabled = true;
}
}
}
}

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using _02.Scripts.WaterAndShip;
using UnityEngine;
// ReSharper disable once CheckNamespace

View File

@ -1,77 +1,79 @@
using System.Collections.Generic;
using _02.Scripts.WaterAndShip;
using BlueWaterProject;
using Sirenix.OdinInspector;
using UnityEngine;
public class DataManager : Singleton<DataManager>
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
[field: Title("Scriptable Object")]
[field: SerializeField] public AiViewDataSo AiViewDataSo { get; private set; }
private Dictionary<string, AiView> aiViewDictionary;
[field: SerializeField] public AiStatDataSo AiStatDataSo { get; private set; }
private Dictionary<string, AiStat> aiStatDictionary;
[field: SerializeField] public UnitDataSo UnitDataSo { get; private set; }
private Dictionary<string, Unit> unitDictionary;
[field: SerializeField] public UnitDataSo EnemyUnitDataSo { get; private set; }
private Dictionary<string, Unit> enemyUnitDictionary;
[field: SerializeField] public CardDataSo CardDataSo { get; private set; }
private Dictionary<string, Card> cardDictionary;
[field: Title("DataBase")]
[field: SerializeField] public List<string> CardList { get; private set; } = new(GlobalValue.CARD_DATA_CAPACITY);
[Title("DataBase", "GameObject")]
public GameObject mouseSpot;
public GameObject boat;
public GameObject assaultCard;
[Title("DataBase", "Sprites")]
public Sprite[] cardType;
public Texture2D cursorTexture;
protected override void OnAwake()
public class DataManager : Singleton<DataManager>
{
InitDictionary();
}
private void InitDictionary()
{
aiViewDictionary = CreateDictionaryFromList(AiViewDataSo.aiViewDataList, GlobalValue.AI_VIEW_DATA_CAPACITY);
aiStatDictionary = CreateDictionaryFromList(AiStatDataSo.aiStatDataList, GlobalValue.AI_STAT_DATA_CAPACITY);
unitDictionary = CreateDictionaryFromList(UnitDataSo.unitDataList, GlobalValue.UNIT_DATA_CAPACITY);
cardDictionary = CreateDictionaryFromList(CardDataSo.cardDataList, GlobalValue.CARD_DATA_CAPACITY);
}
[field: Title("Scriptable Object")]
[field: SerializeField] public AiViewDataSo AiViewDataSo { get; private set; }
private Dictionary<string, AiView> aiViewDictionary;
/// <summary>
/// Dictionary 초기화 함수
/// </summary>
private Dictionary<string, T> CreateDictionaryFromList<T>(List<T> list, int capacity) where T : IIdx
{
var newDictionary = new Dictionary<string, T>(capacity);
foreach (var item in list)
[field: SerializeField] public AiStatDataSo AiStatDataSo { get; private set; }
private Dictionary<string, AiStat> aiStatDictionary;
[field: SerializeField] public UnitDataSo UnitDataSo { get; private set; }
private Dictionary<string, Unit> unitDictionary;
[field: SerializeField] public UnitDataSo EnemyUnitDataSo { get; private set; }
private Dictionary<string, Unit> enemyUnitDictionary;
[field: SerializeField] public CardDataSo CardDataSo { get; private set; }
private Dictionary<string, Card> cardDictionary;
[field: Title("DataBase")]
[field: SerializeField] public List<string> CardList { get; private set; } = new(GlobalValue.CARD_DATA_CAPACITY);
[Title("DataBase", "GameObject")]
public GameObject mouseSpot;
public GameObject boat;
public GameObject assaultCard;
[Title("DataBase", "Sprites")]
public Sprite[] cardType;
public Texture2D cursorTexture;
protected override void OnAwake()
{
newDictionary.Add(item.Idx, item);
InitDictionary();
}
return newDictionary;
}
private void InitDictionary()
{
aiViewDictionary = CreateDictionaryFromList(AiViewDataSo.aiViewDataList, GlobalValue.AI_VIEW_DATA_CAPACITY);
aiStatDictionary = CreateDictionaryFromList(AiStatDataSo.aiStatDataList, GlobalValue.AI_STAT_DATA_CAPACITY);
unitDictionary = CreateDictionaryFromList(UnitDataSo.unitDataList, GlobalValue.UNIT_DATA_CAPACITY);
cardDictionary = CreateDictionaryFromList(CardDataSo.cardDataList, GlobalValue.CARD_DATA_CAPACITY);
}
public AiView GetAiViewDictionaryKey(string idx) => aiViewDictionary[idx] != null ? aiViewDictionary[idx] : null;
public AiStat GetAiStatDictionaryKey(string idx) => aiStatDictionary[idx] != null ? aiStatDictionary[idx] : null;
public Unit GetUnitDictionaryKey(string idx) => unitDictionary[idx] != null ? unitDictionary[idx] : null;
public Unit GetEnemyUnitDictionaryKey(string idx) => enemyUnitDictionary[idx] != null ? enemyUnitDictionary[idx] : null;
public Card GetCardDictionaryFromKey(string idx) => cardDictionary[idx] != null ? cardDictionary[idx] : null;
/// <summary>
/// Dictionary 초기화 함수
/// </summary>
private Dictionary<string, T> CreateDictionaryFromList<T>(List<T> list, int capacity) where T : IIdx
{
var newDictionary = new Dictionary<string, T>(capacity);
foreach (var item in list)
{
newDictionary.Add(item.Idx, item);
}
return newDictionary;
}
public AiView GetAiViewDictionaryKey(string idx) => aiViewDictionary[idx] != null ? aiViewDictionary[idx] : null;
public AiStat GetAiStatDictionaryKey(string idx) => aiStatDictionary[idx] != null ? aiStatDictionary[idx] : null;
public Unit GetUnitDictionaryKey(string idx) => unitDictionary[idx] != null ? unitDictionary[idx] : null;
public Unit GetEnemyUnitDictionaryKey(string idx) => enemyUnitDictionary[idx] != null ? enemyUnitDictionary[idx] : null;
public Card GetCardDictionaryFromKey(string idx) => cardDictionary[idx] != null ? cardDictionary[idx] : null;
#if UNITY_EDITOR
public AiView GetAiViewSoKey(string idx) => AiViewDataSo.aiViewDataList.Find(item => item.Idx == idx);
public AiStat GetAiStatSoKey(string idx) => AiStatDataSo.aiStatDataList.Find(item => item.Idx == idx);
public Unit GetUnitSoKey(string idx) => UnitDataSo.unitDataList.Find(item => item.Idx == idx);
public Unit GetEnemyUnitSoKey(string idx) => EnemyUnitDataSo.unitDataList.Find(item => item.Idx == idx);
public AiView GetAiViewSoKey(string idx) => AiViewDataSo.aiViewDataList.Find(item => item.Idx == idx);
public AiStat GetAiStatSoKey(string idx) => AiStatDataSo.aiStatDataList.Find(item => item.Idx == idx);
public Unit GetUnitSoKey(string idx) => UnitDataSo.unitDataList.Find(item => item.Idx == idx);
public Unit GetEnemyUnitSoKey(string idx) => EnemyUnitDataSo.unitDataList.Find(item => item.Idx == idx);
#endif
}
}

View File

@ -1,50 +1,51 @@
using System;
using System.Collections;
using System.Collections.Generic;
using _02.Scripts.WaterAndShip;
using BlueWaterProject;
using Sirenix.OdinInspector;
using UnityEngine;
public class GameManager : Singleton<GameManager>
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
[Title("Controller")]
public CameraController CameraController { get; private set; }
public Player player;
public List<Boat> boats = new List<Boat>(10);
[Range(0f, 1f)]
[SerializeField] private float slowSpeed = 0.1f;
private void Init()
public class GameManager : Singleton<GameManager>
{
CameraController = FindObjectOfType<CameraController>();
player = FindObjectOfType<Player>();
}
protected override void OnAwake()
{
Init();
}
[Title("Controller")]
public CameraController CameraController { get; private set; }
public Player player;
public List<Boat> boats = new List<Boat>(10);
private void Start()
{
Cursor.lockState = CursorLockMode.Confined;
}
[Range(0f, 1f)]
[SerializeField] private float slowSpeed = 0.1f;
public void testPrint()
{
print("Boat가 목표에 도착해서 이 함수를 호출합니다");
}
private void Init()
{
CameraController = FindObjectOfType<CameraController>();
player = FindObjectOfType<Player>();
}
protected override void OnAwake()
{
Init();
}
public void SlowSpeedMode()
{
Time.timeScale = slowSpeed;
Time.fixedDeltaTime = 0.02f * Time.timeScale;
}
private void Start()
{
Cursor.lockState = CursorLockMode.Confined;
}
public void testPrint()
{
print("Boat가 목표에 도착해서 이 함수를 호출합니다");
}
public void SlowSpeedMode()
{
Time.timeScale = slowSpeed;
Time.fixedDeltaTime = 0.02f * Time.timeScale;
}
public void DefaultSpeedMode()
{
Time.timeScale = 1f;
Time.fixedDeltaTime = 0.02f;
public void DefaultSpeedMode()
{
Time.timeScale = 1f;
Time.fixedDeltaTime = 0.02f;
}
}
}

View File

@ -0,0 +1,7 @@
namespace BlueWaterProject
{
public interface IDamageable2
{
public void TakeDamage(float damage);
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4fdb6e266dc14508a1b2645a7783193c
timeCreated: 1693456465

View File

@ -2,7 +2,8 @@ using System;
using BlueWaterProject;
using UnityEngine;
namespace _02.Scripts.WaterAndShip
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
[Serializable]
public class Card : IIdx

View File

@ -1,10 +1,10 @@
using Cinemachine;
using Blobcreate.ProjectileToolkit;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.InputSystem;
using Blobcreate. ProjectileToolkit;
namespace _02.Scripts.WaterAndShip
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(PlayerInput))]
@ -31,6 +31,11 @@ namespace _02.Scripts.WaterAndShip
[Tooltip("캐릭터의 이동 속도")]
public float characterSpeed = 10f;
[Title("레이더")]
public Collider[] radar = new Collider[10];
public Transform[] inCameraRadar = new Transform[10];
public Transform target;
public bool IsAssaultMode { get; set; }
public bool IsInShipMode { get; set; }
public bool IsDredgeMode { get; set; }

View File

@ -1,66 +1,67 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Doozy.Runtime.Reactor.Animations;
using Doozy.Runtime.Reactor.Animators;
using Sirenix.OdinInspector;
using UnityEngine;
public class UiManager : Singleton<UiManager>
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
[Title("Card")]
private Transform cardLayoutGroup;
public UIAnimator CardLayoutGroupAnimator { get; set; }
public class UiManager : Singleton<UiManager>
{
[Title("Card")]
private Transform cardLayoutGroup;
public UIAnimator CardLayoutGroupAnimator { get; set; }
[Title("TakeAim")]
private GameObject takeAim;
private Texture2D cursorTexture;
private bool isTakeAim;
[Title("TakeAim")]
private GameObject takeAim;
private Texture2D cursorTexture;
private bool isTakeAim;
private void Init()
{
cardLayoutGroup = transform.Find("CardLayoutGroup");
CardLayoutGroupAnimator = cardLayoutGroup.GetComponent<UIAnimator>();
takeAim = transform.Find("Aim").gameObject;
}
protected override void OnAwake()
{
Init();
}
private void Start()
{
CursorTextureChange();
AssaultCardInit();
}
public void AddCard() //TODO Test button and function, delete later
{
Instantiate(DataManager.Inst.assaultCard, cardLayoutGroup);
}
public void AimOnOff(bool isOn)
{
takeAim.SetActive(isOn);
isTakeAim = isOn;
}
private void CursorTextureChange()
{
cursorTexture = DataManager.Inst.cursorTexture;
var hotSpot = new Vector2(cursorTexture.width / 2f, cursorTexture.height / 2f);
Cursor.SetCursor(cursorTexture, hotSpot, CursorMode.Auto);
}
private void AssaultCardInit()
{
for (int i = 0; i < DataManager.Inst.CardList.Count; i++)
private void Init()
{
var obj = Instantiate(DataManager.Inst.assaultCard, cardLayoutGroup);
var draggableCard = obj.GetComponent<DraggableCard>();
draggableCard.card = DataManager.Inst.GetCardDictionaryFromKey(DataManager.Inst.CardList[i]);
draggableCard.CardInit();
cardLayoutGroup = transform.Find("CardLayoutGroup");
CardLayoutGroupAnimator = cardLayoutGroup.GetComponent<UIAnimator>();
takeAim = transform.Find("Aim").gameObject;
}
protected override void OnAwake()
{
Init();
}
private void Start()
{
CursorTextureChange();
AssaultCardInit();
}
public void AddCard() //TODO Test button and function, delete later
{
Instantiate(DataManager.Inst.assaultCard, cardLayoutGroup);
}
public void AimOnOff(bool isOn)
{
takeAim.SetActive(isOn);
isTakeAim = isOn;
}
private void CursorTextureChange()
{
cursorTexture = DataManager.Inst.cursorTexture;
//var hotSpot = new Vector2(cursorTexture.width / 2f, cursorTexture.height / 2f);
var hotSpot = Vector2.zero;
Cursor.SetCursor(cursorTexture, hotSpot, CursorMode.Auto);
}
private void AssaultCardInit()
{
for (int i = 0; i < DataManager.Inst.CardList.Count; i++)
{
var obj = Instantiate(DataManager.Inst.assaultCard, cardLayoutGroup);
var draggableCard = obj.GetComponent<DraggableCard>();
draggableCard.card = DataManager.Inst.GetCardDictionaryFromKey(DataManager.Inst.CardList[i]);
draggableCard.CardInit();
}
}
}
}

View File

@ -1,25 +1,29 @@
public class GlobalValue
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public const int CARD_DATA_CAPACITY = 50;
public const int AI_VIEW_DATA_CAPACITY = 50;
public const int AI_STAT_DATA_CAPACITY = 50;
public const int UNIT_DATA_CAPACITY = 50;
public const int ISLAND_DATA_CAPACITY = 50;
public const int ONE_UNIT_CAPACITY = 16;
public const int AI_ANIMATOR_CAPACITY = 10;
public enum UnitType
public class GlobalValue
{
NONE = -1,
ARCHER_E,
SPEAR_KNIGHT_E,
SPEARMAN_E,
SWORD_KNIGHT_E,
SWORDMAN_E,
ARCHER_P,
AXEMAN_P,
SPEARMAN_P,
SWORD_KNIGHT_P,
SWORDMAN_P
public const int CARD_DATA_CAPACITY = 50;
public const int AI_VIEW_DATA_CAPACITY = 50;
public const int AI_STAT_DATA_CAPACITY = 50;
public const int UNIT_DATA_CAPACITY = 50;
public const int ISLAND_DATA_CAPACITY = 50;
public const int ONE_UNIT_CAPACITY = 16;
public const int AI_ANIMATOR_CAPACITY = 10;
public enum UnitType
{
NONE = -1,
ARCHER_E,
SPEAR_KNIGHT_E,
SPEARMAN_E,
SWORD_KNIGHT_E,
SWORDMAN_E,
ARCHER_P,
AXEMAN_P,
SPEARMAN_P,
SWORD_KNIGHT_P,
SWORDMAN_P
}
}
}

View File

@ -1,49 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class Floater : MonoBehaviour
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
private GerstnerWave waveGenerator;
[InfoBox("배가 얼마나 물에 잠길지 정합니다. 낮을수록 물에 잠깁니다.")]
public float boatOffset = 0.0f; // new variable
private Rigidbody rb;
private void Start()
[RequireComponent(typeof(Rigidbody))]
public class Floater : MonoBehaviour
{
waveGenerator = FindObjectOfType<GerstnerWave>();
rb = GetComponent<Rigidbody>();
}
private GerstnerWave waveGenerator;
[InfoBox("배가 얼마나 물에 잠길지 정합니다. 낮을수록 물에 잠깁니다.")]
public float boatOffset = 0.0f; // new variable
private Rigidbody rb;
void FixedUpdate()
{
var waveNumber = 2.0f * Mathf.PI / waveGenerator.waveLength;
var phaseConstant = waveGenerator.speed * waveNumber;
private void Start()
{
waveGenerator = FindObjectOfType<GerstnerWave>();
rb = GetComponent<Rigidbody>();
}
// Convert the boat's world position to the wave's local position
var localPosition = waveGenerator.transform.InverseTransformPoint(rb.position);
var dotProduct = Vector2.Dot(new Vector2(localPosition.x, localPosition.z), waveGenerator.direction);
void FixedUpdate()
{
var waveNumber = 2.0f * Mathf.PI / waveGenerator.waveLength;
var phaseConstant = waveGenerator.speed * waveNumber;
var wavePhase = waveNumber * dotProduct + phaseConstant * Time.time;
// Convert the boat's world position to the wave's local position
var localPosition = waveGenerator.transform.InverseTransformPoint(rb.position);
var dotProduct = Vector2.Dot(new Vector2(localPosition.x, localPosition.z), waveGenerator.direction);
// Calculate the new height
var newY = waveGenerator.amplitude * Mathf.Sin(wavePhase) + boatOffset;
localPosition.y = newY;
var wavePhase = waveNumber * dotProduct + phaseConstant * Time.time;
// Convert the position back to world coordinates
rb.MovePosition(waveGenerator.transform.TransformPoint(localPosition));
// Calculate the new height
var newY = waveGenerator.amplitude * Mathf.Sin(wavePhase) + boatOffset;
localPosition.y = newY;
// Calculate the wave's normal at the boat's position
var normal = new Vector3(
-waveGenerator.amplitude * waveNumber * waveGenerator.direction.x * Mathf.Cos(wavePhase),
1.0f,
-waveGenerator.amplitude * waveNumber * waveGenerator.direction.y * Mathf.Cos(wavePhase)
).normalized;
// Convert the position back to world coordinates
rb.MovePosition(waveGenerator.transform.TransformPoint(localPosition));
// Rotate the boat to align with the wave's normal
var targetRotation = Quaternion.FromToRotation(transform.up, normal) * transform.rotation;
rb.MoveRotation(Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * waveGenerator.speed));
// Calculate the wave's normal at the boat's position
var normal = new Vector3(
-waveGenerator.amplitude * waveNumber * waveGenerator.direction.x * Mathf.Cos(wavePhase),
1.0f,
-waveGenerator.amplitude * waveNumber * waveGenerator.direction.y * Mathf.Cos(wavePhase)
).normalized;
// Rotate the boat to align with the wave's normal
var targetRotation = Quaternion.FromToRotation(transform.up, normal) * transform.rotation;
rb.MoveRotation(Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * waveGenerator.speed));
}
}
}

View File

@ -1,61 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
public class GerstnerWave : MonoBehaviour
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
[InfoBox("파도의 길이를 결정, 값이 클수록 파도 간의 간격이 커짐")]
public float waveLength = 0.1f;
[InfoBox("파도의 높이를 결정, 값이 클수록 파도의 높이가 커짐")]
public float amplitude = 0.1f;
[InfoBox("파도의 속도를 결정, 값이 클수록 파도의 속도가 오름")]
public float speed = 1f;
[InfoBox("파도의 방향을 결정")]
public Vector2 direction = new Vector2(1.0f, 0.0f);
private void FixedUpdate()
public class GerstnerWave : MonoBehaviour
{
var mesh = GetComponent<MeshFilter>().mesh;
var vertices = mesh.vertices;
var normals = mesh.normals;
[InfoBox("파도의 길이를 결정, 값이 클수록 파도 간의 간격이 커짐")]
public float waveLength = 0.1f;
[InfoBox("파도의 높이를 결정, 값이 클수록 파도의 높이가 커짐")]
public float amplitude = 0.1f;
[InfoBox("파도의 속도를 결정, 값이 클수록 파도의 속도가 오름")]
public float speed = 1f;
[InfoBox("파도의 방향을 결정")]
public Vector2 direction = new Vector2(1.0f, 0.0f);
var waveNumber = 2.0f * Mathf.PI / waveLength;
var phaseConstant = speed * waveNumber;
for (var i = 0; i < vertices.Length; i++)
private void FixedUpdate()
{
var vertex = vertices[i];
var dotProduct = Vector2.Dot(new Vector2(vertex.x, vertex.z), direction);
var wavePhase = waveNumber * dotProduct + phaseConstant * Time.time;
vertex.y = amplitude * Mathf.Sin(wavePhase);
vertices[i] = vertex;
var mesh = GetComponent<MeshFilter>().mesh;
var vertices = mesh.vertices;
var normals = mesh.normals;
// Calculate the normal at the vertex
var cosPhase = Mathf.Cos(wavePhase);
var dx = -waveNumber * amplitude * direction.x * cosPhase;
var dz = -waveNumber * amplitude * direction.y * cosPhase;
normals[i] = new Vector3(dx, 1.0f, dz).normalized;
var waveNumber = 2.0f * Mathf.PI / waveLength;
var phaseConstant = speed * waveNumber;
for (var i = 0; i < vertices.Length; i++)
{
var vertex = vertices[i];
var dotProduct = Vector2.Dot(new Vector2(vertex.x, vertex.z), direction);
var wavePhase = waveNumber * dotProduct + phaseConstant * Time.time;
vertex.y = amplitude * Mathf.Sin(wavePhase);
vertices[i] = vertex;
// Calculate the normal at the vertex
var cosPhase = Mathf.Cos(wavePhase);
var dx = -waveNumber * amplitude * direction.x * cosPhase;
var dz = -waveNumber * amplitude * direction.y * cosPhase;
normals[i] = new Vector3(dx, 1.0f, dz).normalized;
}
mesh.vertices = vertices;
mesh.normals = normals;
}
mesh.vertices = vertices;
mesh.normals = normals;
}
public Vector3 GetWaveNormal(Vector3 position)
{
var waveNumber = 2.0f * Mathf.PI / waveLength;
var phaseConstant = speed * waveNumber;
var dotProduct = Vector2.Dot(new Vector2(position.x + transform.position.x, position.z + transform.position.z), direction);
var wavePhase = waveNumber * dotProduct + phaseConstant * Time.time;
public Vector3 GetWaveNormal(Vector3 position)
{
var waveNumber = 2.0f * Mathf.PI / waveLength;
var phaseConstant = speed * waveNumber;
var dotProduct = Vector2.Dot(new Vector2(position.x + transform.position.x, position.z + transform.position.z), direction);
var wavePhase = waveNumber * dotProduct + phaseConstant * Time.time;
var cosPhase = Mathf.Cos(wavePhase);
var cosPhase = Mathf.Cos(wavePhase);
// We differentiate the wave function to get the slope at the current point
var dx = -waveNumber * amplitude * direction.x * cosPhase;
var dz = -waveNumber * amplitude * direction.y * cosPhase;
// We differentiate the wave function to get the slope at the current point
var dx = -waveNumber * amplitude * direction.x * cosPhase;
var dz = -waveNumber * amplitude * direction.y * cosPhase;
var normal = new Vector3(dx, 1.0f, dz).normalized;
return normal;
var normal = new Vector3(dx, 1.0f, dz).normalized;
return normal;
}
}
}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 9be5d028954e34a15b3129993935f16d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,133 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-8597644214347470203
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 7
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: cha_03_front
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 2800000, guid: 34aa7a8380a65426b86643fc3f7dbd50, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 34aa7a8380a65426b86643fc3f7dbd50, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 7099ab9e7778140b789b0edd4d6a2dbe
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -0,0 +1,124 @@
fileFormatVersion: 2
guid: 590154def7f1447b7901d2416764ee39
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -0,0 +1,124 @@
fileFormatVersion: 2
guid: 3a146044a282641d99ba04c33b8c2bbf
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 32
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -97,7 +97,7 @@ NavMeshAgent:
m_Enabled: 1
m_AgentTypeID: -1372625422
m_Radius: 0.5
m_Speed: 3.5
m_Speed: 5
m_Acceleration: 8
avoidancePriority: 50
m_AngularSpeed: 500

View File

@ -13,6 +13,7 @@ Material:
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- DR_GRADIENT_ON
- DR_OUTLINE_ON
- DR_RIM_ON
- _CELPRIMARYMODE_SINGLE
- _DETAILMAPBLENDINGMODE_MULTIPLY
@ -24,8 +25,7 @@ Material:
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- SRPDEFAULTUNLIT
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
@ -144,7 +144,7 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _OutlineDepthOffset: 0
- _OutlineEnabled: 0
- _OutlineEnabled: 1
- _OutlineScale: 1
- _OutlineWidth: 1
- _OverrideLightmapDir: 0

View File

@ -13,6 +13,7 @@ Material:
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- DR_GRADIENT_ON
- DR_OUTLINE_ON
- DR_RIM_ON
- _CELPRIMARYMODE_SINGLE
- _DETAILMAPBLENDINGMODE_MULTIPLY
@ -25,8 +26,7 @@ Material:
m_CustomRenderQueue: 2000
stringTagMap:
RenderType: Opaque
disabledShaderPasses:
- SRPDEFAULTUNLIT
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
@ -213,7 +213,7 @@ Material:
- _NumLayersCount: 1
- _OcclusionStrength: 1
- _OutlineDepthOffset: 0
- _OutlineEnabled: 0
- _OutlineEnabled: 1
- _OutlineScale: 1
- _OutlineWidth: 1
- _OverrideLightmapDir: 0