Merge branch 'main' of 121.165.94.243:capers/bluewater into NTG

This commit is contained in:
NTG 2023-11-28 22:46:23 +09:00
commit 7e1d42fb76
20 changed files with 7743 additions and 107 deletions

File diff suppressed because it is too large Load Diff

View File

@ -232,6 +232,17 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
""isComposite"": false, ""isComposite"": false,
""isPartOfComposite"": false ""isPartOfComposite"": false
}, },
{
""name"": """",
""id"": ""857036ad-83d5-4d39-a34d-eb3f7d804912"",
""path"": ""<Mouse>/leftButton"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard&Mouse"",
""action"": ""Interaction"",
""isComposite"": false,
""isPartOfComposite"": false
},
{ {
""name"": """", ""name"": """",
""id"": ""df7a5259-c313-4b14-9cca-9e1acfc0a31a"", ""id"": ""df7a5259-c313-4b14-9cca-9e1acfc0a31a"",

View File

@ -210,6 +210,17 @@
"isComposite": false, "isComposite": false,
"isPartOfComposite": false "isPartOfComposite": false
}, },
{
"name": "",
"id": "857036ad-83d5-4d39-a34d-eb3f7d804912",
"path": "<Mouse>/leftButton",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Interaction",
"isComposite": false,
"isPartOfComposite": false
},
{ {
"name": "", "name": "",
"id": "df7a5259-c313-4b14-9cca-9e1acfc0a31a", "id": "df7a5259-c313-4b14-9cca-9e1acfc0a31a",

View File

@ -13,7 +13,7 @@ namespace BlueWaterProject.Type
private Transform visaualLook; private Transform visaualLook;
[Title("Nature")] [Title("Nature")]
public float MotionSickValue { get; set; } //멀미 public float MotionSickValue { get; set; } //멀미 //motionSickValue가 1초당 10씩 증가
private float motionSickMaxValue; private float motionSickMaxValue;
private float hungerValue; //배고픔 private float hungerValue; //배고픔
private float hungerMaxValue; private float hungerMaxValue;
@ -27,6 +27,30 @@ namespace BlueWaterProject.Type
public InShipMapInfo InShipMapInfo { get; set; } public InShipMapInfo InShipMapInfo { get; set; }
#region Init
private void Init()
{
agent = GetComponent<NavMeshAgent>();
visaualLook = transform.Find("UnitRoot");
InShipMapInfo = GameObject.Find("InShipMap").GetComponent<InShipMapInfo>();
}
private void InitNatureValue()
{
MotionSickValue = 0;
motionSickMaxValue = Random.Range(100, 1000);
hungerValue = 0;
hungerMaxValue = 100;
diseaseValue = 0;
diseaseMaxValue = 100;
tiredValue = 0;
tiredMaxValue = 100;
betrayalValue = 0;
}
#endregion
protected override void OnEnable() protected override void OnEnable()
{ {
base.OnEnable(); base.OnEnable();
@ -53,47 +77,30 @@ namespace BlueWaterProject.Type
{ {
base.Update(); base.Update();
stateMachine.Update(); stateMachine.Update();
//motionSickValue가 1초당 10씩 증가
} }
protected override void LateUpdate() protected override void LateUpdate()
{ {
base.LateUpdate(); base.LateUpdate();
if(stateMachine.CurrentState.GetType() != typeof(UsuallyPointState)) return; MotionSicking();
if(MotionSickValue < motionSickMaxValue) }
private void MotionSicking()
{
if (stateMachine.CurrentState.GetType() != typeof(UsuallyPointState)) return;
if (MotionSickValue < motionSickMaxValue)
{ {
MotionSickValue += 10 * Time.deltaTime; MotionSickValue += 10 * Time.deltaTime;
} }
else if (stateMachine.CurrentState.GetType() != typeof(MotionSickState)) else if (stateMachine.CurrentState.GetType() != typeof(MotionSickState))
{ {
var motionSickState = new MotionSickState(); var motionSickState = new MotionSickState(agent, InShipMapInfo);
motionSickState.OnEnterAction += OnEnterAction; motionSickState.OnEnterAction += OnEnterAction;
stateMachine.ChangeState(motionSickState); stateMachine.ChangeState(motionSickState);
} }
} }
private void Init() public void ReleaseFromJail()
{
agent = GetComponent<NavMeshAgent>();
visaualLook = transform.Find("UnitRoot");
InShipMapInfo = GameObject.Find("InShipMap").GetComponent<InShipMapInfo>();
}
private void InitNatureValue()
{
MotionSickValue = 0;
motionSickMaxValue = 100;
hungerValue = 0;
hungerMaxValue = 100;
diseaseValue = 0;
diseaseMaxValue = 100;
tiredValue = 0;
tiredMaxValue = 100;
betrayalValue = 0;
}
public void ReleaseFromPrison()
{ {
stateMachine.RestorePreviousState(); stateMachine.RestorePreviousState();
} }
@ -103,10 +110,10 @@ namespace BlueWaterProject.Type
MotionSickValue = 0; MotionSickValue = 0;
} }
public void ChangeStateToOrderToPrison() public void ChangeStateToOrderToJail()
{ {
var orderToPrisonState = new OrderToPrisonState(agent, InShipMapInfo); var orderToJailState = new OrderToJailState(agent, InShipMapInfo, transform);
stateMachine.ChangeState(orderToPrisonState); stateMachine.ChangeState(orderToJailState);
} }
public void ChangeStateToInteraction() public void ChangeStateToInteraction()

View File

@ -215,10 +215,10 @@ namespace BlueWaterProject
} }
public void OrderToPrison() public void OrderToJail()
{ {
EndInteraction(); EndInteraction();
interactionTarget.GetComponent<InShipNpc>().ChangeStateToOrderToPrison(); interactionTarget.GetComponent<InShipNpc>().ChangeStateToOrderToJail();
} }
} }
} }

View File

@ -1,34 +1,26 @@
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
using System; using System;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
namespace BlueWaterProject namespace BlueWaterProject
{ {
public class InShipMapInfo : MonoBehaviour public class InShipMapInfo : MonoBehaviour
{ {
private GameObject usablePrisonDoor; [field: SerializeField] public List<Toilet> Toilets { get; set; }
public Transform prisonPoint; [field: SerializeField] public List<Jail> Jails { get; set; }
private void Init() private void Init()
{ {
usablePrisonDoor = GameObject.Find("UsablePrisonDoor"); Toilets = new List<Toilet>();
prisonPoint = GameObject.Find("PrisonPoint").transform; Jails = new List<Jail>();
} }
private void Awake() private void Awake()
{ {
Init(); Init();
} }
public void OpenPrisonDoor()
{
usablePrisonDoor.SetActive(false);
}
public void ClosePrisonDoor()
{
usablePrisonDoor.SetActive(true);
}
} }
} }

View File

@ -1,22 +1,79 @@
using System; using System;
using System.Linq;
using BlueWaterProject.Type; using BlueWaterProject.Type;
using UnityEngine;
using UnityEngine.AI;
namespace BlueWaterProject namespace BlueWaterProject
{ {
public class MotionSickState : INpcState public class MotionSickState : INpcState
{ {
public event Action OnEnterAction; public event Action OnEnterAction;
private NavMeshAgent agent;
private InShipMapInfo inShipMapInfo;
private bool isMovingToToilet;
private Toilet targetToilet;
public MotionSickState(NavMeshAgent agent, InShipMapInfo inShipMapInfo)
{
this.agent = agent;
this.inShipMapInfo = inShipMapInfo;
}
public void OnEnter(NpcStateMachine npcStateMachine) public void OnEnter(NpcStateMachine npcStateMachine)
{ {
npcStateMachine.InstantiateObject(DataManager.Inst.vomit, npcStateMachine.transform.position); var toilets = inShipMapInfo.Toilets;
OnEnterAction?.Invoke();
npcStateMachine.RestorePreviousState(); // 화장실을 NPC와의 거리에 따라 정렬
var sortedToilets = toilets.OrderBy(toilet => Vector3.Distance(agent.transform.position, toilet.transform.position)).ToList();
Toilet availableToilet = null;
foreach (var toilet in sortedToilets)
{
// 사용 가능한 화장실을 찾음
if (!toilet.IsUsed)
{
availableToilet = toilet;
break;
}
}
// 사용 가능한 화장실이 있는 경우
if (availableToilet != null)
{
isMovingToToilet = true;
targetToilet = availableToilet;
agent.SetDestination(availableToilet.transform.position);
agent.stoppingDistance = 0;
}
else
{
npcStateMachine.InstantiateObject(DataManager.Inst.vomit, npcStateMachine.transform.position);
OnEnterAction?.Invoke();
npcStateMachine.RestorePreviousState();
}
} }
public void OnUpdate(NpcStateMachine npcStateMachine) public void OnUpdate(NpcStateMachine npcStateMachine)
{ {
// 화장실로 이동 중이라면
if (isMovingToToilet)
{
// 도착 여부 확인
if (agent.remainingDistance <= agent.stoppingDistance && !agent.pathPending)
{
// 이동 상태 업데이트
isMovingToToilet = false;
// 도착했다면 화장실 사용
targetToilet.UseToilet();
OnEnterAction?.Invoke();
npcStateMachine.RestorePreviousState();
}
}
} }
public void OnExit(NpcStateMachine npcStateMachine) public void OnExit(NpcStateMachine npcStateMachine)

View File

@ -39,7 +39,7 @@ namespace BlueWaterProject
} }
else else
{ {
// 목적지가 없는 경우, 다른 처리를 수행하거나 그대로 둡니다. // 목적지가 없는 경우, 다른 처리를 수행하거나 그대로
} }
} }
else else

View File

@ -0,0 +1,80 @@
using System;
using System.Linq;
using PixelCrushers.DialogueSystem;
using UnityEngine;
using UnityEngine.AI;
namespace BlueWaterProject
{
public class OrderToJailState : INpcState
{
private NavMeshAgent agent;
private InShipMapInfo inShipMapInfo;
private bool isMovingToJail;
private Jail targetJail;
private Transform npcTransform;
public OrderToJailState(NavMeshAgent agent, InShipMapInfo inShipMapInfo, Transform npcTransform)
{
this.agent = agent;
this.inShipMapInfo = inShipMapInfo;
this.npcTransform = npcTransform;
}
public void OnEnter(NpcStateMachine npcStateMachine)
{
var jails = inShipMapInfo.Jails;
var sortedJails = jails.OrderBy(jail => Vector3.Distance(agent.transform.position, jail.transform.position)).ToList();
Jail availableJail = null;
foreach (var jail in sortedJails)
{
if (!jail.IsUsed)
{
availableJail = jail;
break;
}
}
if (availableJail != null)
{
agent.isStopped = true;
isMovingToJail = true;
targetJail = availableJail;
agent.SetDestination(availableJail.transform.position + new Vector3(0,0,1));
agent.stoppingDistance = 0;
agent.speed = 10f;
targetJail.UseJail();
agent.isStopped = false;
}
else
{
//TODO 감옥이 없거나 꽉 찬 경우를 처리해야함
DialogueManager.Bark("NotJail", npcTransform);
npcStateMachine.RestorePreviousState();
}
}
public void OnUpdate(NpcStateMachine npcStateMachine)
{
if (isMovingToJail)
{
if (agent.remainingDistance <= agent.stoppingDistance)
{
isMovingToJail = false;
}
}
}
public void OnExit(NpcStateMachine npcStateMachine)
{
agent.speed = 3.5f;
}
public INpcState Clone()
{
return null;
}
}
}

View File

@ -1,46 +0,0 @@
using System;
using UnityEngine;
using UnityEngine.AI;
namespace BlueWaterProject
{
public class OrderToPrisonState : INpcState
{
private NavMeshAgent agent;
private InShipMapInfo inShipMapInfo;
public OrderToPrisonState(NavMeshAgent agent, InShipMapInfo inShipMapInfo)
{
this.agent = agent;
this.inShipMapInfo = inShipMapInfo;
}
public void OnEnter(NpcStateMachine npcStateMachine)
{
inShipMapInfo.OpenPrisonDoor();
agent.isStopped = true;
agent.destination = inShipMapInfo.prisonPoint.position;
agent.speed = 10f;
agent.isStopped = false;
}
public void OnUpdate(NpcStateMachine npcStateMachine)
{
if (!agent.pathPending && agent.remainingDistance < .5f)
{
inShipMapInfo.ClosePrisonDoor();
agent.speed = 3.5f;
}
}
public void OnExit(NpcStateMachine npcStateMachine)
{
}
public INpcState Clone()
{
return null;
}
}
}

View File

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

View File

@ -0,0 +1,32 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BlueWaterProject
{
public class Jail : MonoBehaviour
{
private InShipMapInfo inShipMapInfo;
[field: SerializeField] public bool IsUsed { get; set; }
private void Awake()
{
inShipMapInfo = GameObject.Find("InShipMap").GetComponent<InShipMapInfo>();
inShipMapInfo.Jails.Add(this);
}
public void UseJail()
{
if (IsUsed) return;
IsUsed = true;
}
public void ReleaseJail()
{
if (!IsUsed) return;
IsUsed = false;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a79440a6c863548eda7074095b374c91
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,53 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BlueWaterProject
{
public class Toilet : MonoBehaviour
{
private InShipMapInfo inShipMapInfo;
[field: SerializeField] public bool IsUsed { get; set; }
[SerializeField] private int toiletGauge = 0;
private int toiletMaxGauge = 100;
private void Awake()
{
inShipMapInfo = GameObject.Find("InShipMap").GetComponent<InShipMapInfo>();
inShipMapInfo.Toilets.Add(this);
}
public Transform UseToilet()
{
if (IsUsed) return null;
if (toiletGauge >= toiletMaxGauge)
{
ToiletFull();
return null;
}
IsUsed = true;
StartCoroutine(ToiletGaugeUp());
return transform;
}
private void ToiletFull()
{
// TODO 화장실게이지가 꽉 찼을 때 이벤트
}
IEnumerator ToiletGaugeUp()
{
while (true)
{
yield return new WaitForSeconds(1f);
toiletGauge += 5;
IsUsed = false;
break;
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a9e567bc086814a5c823025f50d68481
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -10,8 +10,10 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 4954690593422870212} - component: {fileID: 4954690593422870212}
- component: {fileID: 4075789757365797969} - component: {fileID: 4075789757365797969}
- component: {fileID: 2605975875765928815}
- component: {fileID: 9080384280691289475}
- component: {fileID: 5342100355408239326} - component: {fileID: 5342100355408239326}
m_Layer: 0 m_Layer: 21
m_Name: Vomit m_Name: Vomit
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
@ -85,6 +87,66 @@ SpriteRenderer:
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 1
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!136 &2605975875765928815
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8216347814332420713}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 1
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.7
m_Height: 1
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &9080384280691289475
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8216347814332420713}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 274b80ab5b659c646ba9338870d14625, type: 3}
m_Name:
m_EditorClassIdentifier:
overrideName: Clean Up
overrideUseMessage:
maxUseDistance: 5
events:
onSelect:
m_PersistentCalls:
m_Calls: []
onDeselect:
m_PersistentCalls:
m_Calls: []
onUse:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 8216347814332420713}
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
m_MethodName: SetActive
m_Mode: 6
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &5342100355408239326 --- !u!114 &5342100355408239326
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -1130,6 +1130,159 @@ MonoBehaviour:
entryGroups: [] entryGroups: []
canvasScrollPosition: {x: 0, y: 0} canvasScrollPosition: {x: 0, y: 0}
canvasZoom: 0.99149966 canvasZoom: 0.99149966
- id: 4
fields:
- title: Title
value: NotJail
type: 0
typeString: CustomFieldType_Text
- title: Description
value:
type: 0
typeString: CustomFieldType_Text
- title: Actor
value: -1
type: 5
typeString: CustomFieldType_Actor
- title: Conversant
value: -1
type: 5
typeString: CustomFieldType_Actor
overrideSettings:
useOverrides: 0
overrideSubtitleSettings: 0
showNPCSubtitlesDuringLine: 1
showNPCSubtitlesWithResponses: 1
showPCSubtitlesDuringLine: 0
skipPCSubtitleAfterResponseMenu: 0
subtitleCharsPerSecond: 30
minSubtitleSeconds: 2
continueButton: 0
overrideSequenceSettings: 0
defaultSequence:
defaultPlayerSequence:
defaultResponseMenuSequence:
overrideInputSettings: 0
alwaysForceResponseMenu: 1
includeInvalidEntries: 0
responseTimeout: 0
emTagForOldResponses: 0
emTagForInvalidResponses: 0
cancelSubtitle:
key: 27
buttonName:
cancelConversation:
key: 27
buttonName:
nodeColor:
dialogueEntries:
- id: 0
fields:
- title: Title
value: START
type: 0
typeString:
- title: Description
value:
type: 0
typeString:
- title: Actor
value: -1
type: 5
typeString: CustomFieldType_Actor
- title: Conversant
value: -1
type: 5
typeString: CustomFieldType_Actor
- title: Menu Text
value:
type: 0
typeString:
- title: Dialogue Text
value:
type: 0
typeString:
- title: Sequence
value: None()
type: 0
typeString:
conversationID: 4
isRoot: 0
isGroup: 0
nodeColor:
delaySimStatus: 0
falseConditionAction: Block
conditionPriority: 2
outgoingLinks:
- originConversationID: 4
originDialogueID: 0
destinationConversationID: 4
destinationDialogueID: 1
isConnector: 0
priority: 2
conditionsString:
userScript:
onExecute:
m_PersistentCalls:
m_Calls: []
canvasRect:
serializedVersion: 2
x: 164
y: 36
width: 160
height: 30
- id: 1
fields:
- title: Title
value:
type: 0
typeString: CustomFieldType_Text
- title: Description
value:
type: 0
typeString: CustomFieldType_Text
- title: Actor
value: -1
type: 5
typeString: CustomFieldType_Actor
- title: Conversant
value: 1
type: 5
typeString: CustomFieldType_Actor
- title: Menu Text
value:
type: 0
typeString: CustomFieldType_Text
- title: Dialogue Text
value: "\uB2C8\uAC00 \uAC00\uB77C... \uD558\uC640\uC774..."
type: 0
typeString: CustomFieldType_Text
- title: Sequence
value:
type: 0
typeString: CustomFieldType_Text
conversationID: 4
isRoot: 0
isGroup: 0
nodeColor:
delaySimStatus: 0
falseConditionAction: Block
conditionPriority: 2
outgoingLinks: []
conditionsString:
userScript:
onExecute:
m_PersistentCalls:
m_Calls: []
canvasRect:
serializedVersion: 2
x: 165
y: 108
width: 160
height: 30
entryGroups: []
canvasScrollPosition: {x: 0, y: 0}
canvasZoom: 1
syncInfo: syncInfo:
syncActors: 0 syncActors: 0
syncItems: 0 syncItems: 0

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using BlueWaterProject;
using SoulGames.Utilities; using SoulGames.Utilities;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@ -49,6 +50,8 @@ namespace SoulGames.EasyGridBuilderPro
private bool hasCollider = false; private bool hasCollider = false;
private static Transform inShipProp;
private void Start() private void Start()
{ {
if (MultiGridManager.Instance.activeGridSystem == null) return; if (MultiGridManager.Instance.activeGridSystem == null) return;
@ -77,6 +80,8 @@ namespace SoulGames.EasyGridBuilderPro
} }
HandleVisualCanvasGrid(activeGridSystem); HandleVisualCanvasGrid(activeGridSystem);
} }
inShipProp = GameObject.Find("InShipMap/Props").transform;
} }
private void OnDestroy() private void OnDestroy()
@ -256,6 +261,19 @@ namespace SoulGames.EasyGridBuilderPro
buildableGridObject.HandleVisualCanvasGrid(system); buildableGridObject.HandleVisualCanvasGrid(system);
buildableGridObject.Setup(); buildableGridObject.Setup();
placedObjectTransform.SetParent(inShipProp);
switch (placedObjectTransform.name)
{
case "Toilet":
placedObjectTransform.gameObject.AddComponent<Toilet>();
break;
case "Jail":
placedObjectTransform.gameObject.AddComponent<Jail>();
break;
}
return buildableGridObject; return buildableGridObject;
} }