Closes #53 Prison -> Jail, Now Player Can Order Go To Jail NPC, And Bark
This commit is contained in:
parent
1a972a3018
commit
207156cef9
@ -268,7 +268,7 @@ MonoBehaviour:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 474660164}
|
||||
m_TargetAssemblyTypeName: BlueWaterProject.InShipPlayer, Assembly-CSharp
|
||||
m_MethodName: OrderToPrison
|
||||
m_MethodName: OrderToJail
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
@ -40035,7 +40035,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
<Toilets>k__BackingField: []
|
||||
prisonPoint: {fileID: 0}
|
||||
<Jails>k__BackingField: []
|
||||
--- !u!1001 &1254663816
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -54256,7 +54256,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1625123128}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.6753435, y: 0.030742656, z: -0.028196681, w: 0.73632264}
|
||||
m_LocalRotation: {x: 0.6753435, y: 0.030742353, z: -0.028196404, w: 0.73632264}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0.00000047683716}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
|
@ -27,6 +27,30 @@ namespace BlueWaterProject.Type
|
||||
|
||||
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()
|
||||
{
|
||||
base.OnEnable();
|
||||
@ -58,8 +82,13 @@ namespace BlueWaterProject.Type
|
||||
protected override void LateUpdate()
|
||||
{
|
||||
base.LateUpdate();
|
||||
if(stateMachine.CurrentState.GetType() != typeof(UsuallyPointState)) return;
|
||||
if(MotionSickValue < motionSickMaxValue)
|
||||
MotionSicking();
|
||||
}
|
||||
|
||||
private void MotionSicking()
|
||||
{
|
||||
if (stateMachine.CurrentState.GetType() != typeof(UsuallyPointState)) return;
|
||||
if (MotionSickValue < motionSickMaxValue)
|
||||
{
|
||||
MotionSickValue += 10 * Time.deltaTime;
|
||||
}
|
||||
@ -71,27 +100,7 @@ namespace BlueWaterProject.Type
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void ReleaseFromPrison()
|
||||
public void ReleaseFromJail()
|
||||
{
|
||||
stateMachine.RestorePreviousState();
|
||||
}
|
||||
@ -101,10 +110,10 @@ namespace BlueWaterProject.Type
|
||||
MotionSickValue = 0;
|
||||
}
|
||||
|
||||
public void ChangeStateToOrderToPrison()
|
||||
public void ChangeStateToOrderToJail()
|
||||
{
|
||||
var orderToPrisonState = new OrderToPrisonState(agent, InShipMapInfo);
|
||||
stateMachine.ChangeState(orderToPrisonState);
|
||||
var orderToJailState = new OrderToJailState(agent, InShipMapInfo, transform);
|
||||
stateMachine.ChangeState(orderToJailState);
|
||||
}
|
||||
|
||||
public void ChangeStateToInteraction()
|
||||
|
@ -215,10 +215,10 @@ namespace BlueWaterProject
|
||||
|
||||
}
|
||||
|
||||
public void OrderToPrison()
|
||||
public void OrderToJail()
|
||||
{
|
||||
EndInteraction();
|
||||
interactionTarget.GetComponent<InShipNpc>().ChangeStateToOrderToPrison();
|
||||
interactionTarget.GetComponent<InShipNpc>().ChangeStateToOrderToJail();
|
||||
}
|
||||
}
|
||||
}
|
@ -10,34 +10,17 @@ namespace BlueWaterProject
|
||||
public class InShipMapInfo : MonoBehaviour
|
||||
{
|
||||
[field: SerializeField] public List<Toilet> Toilets { get; set; }
|
||||
private GameObject usablePrisonDoor;
|
||||
public Transform prisonPoint;
|
||||
[field: SerializeField] public List<Jail> Jails { get; set; }
|
||||
|
||||
private void Init()
|
||||
{
|
||||
Toilets = new List<Toilet>();
|
||||
usablePrisonDoor = GameObject.Find("UsablePrisonDoor");
|
||||
prisonPoint = GameObject.Find("PrisonPoint").transform;
|
||||
Jails = new List<Jail>();
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void OpenPrisonDoor()
|
||||
{
|
||||
usablePrisonDoor.SetActive(false);
|
||||
}
|
||||
|
||||
public void ClosePrisonDoor()
|
||||
{
|
||||
usablePrisonDoor.SetActive(true);
|
||||
}
|
||||
|
||||
public void AddToilet(Toilet toilet)
|
||||
{
|
||||
Toilets.Add(toilet);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,14 +24,14 @@ namespace BlueWaterProject
|
||||
{
|
||||
var toilets = inShipMapInfo.Toilets;
|
||||
|
||||
// 화장실을 NPC와의 거리에 따라 정렬합니다.
|
||||
// 화장실을 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;
|
||||
@ -42,9 +42,6 @@ namespace BlueWaterProject
|
||||
// 사용 가능한 화장실이 있는 경우
|
||||
if (availableToilet != null)
|
||||
{
|
||||
agent.SetDestination(availableToilet.transform.position);
|
||||
agent.stoppingDistance = 0;
|
||||
|
||||
isMovingToToilet = true;
|
||||
targetToilet = availableToilet;
|
||||
agent.SetDestination(availableToilet.transform.position);
|
||||
@ -66,13 +63,15 @@ namespace BlueWaterProject
|
||||
// 도착 여부 확인
|
||||
if (agent.remainingDistance <= agent.stoppingDistance && !agent.pathPending)
|
||||
{
|
||||
// 이동 상태 업데이트
|
||||
isMovingToToilet = false;
|
||||
|
||||
// 도착했다면 화장실 사용
|
||||
targetToilet.UseToilet();
|
||||
OnEnterAction?.Invoke();
|
||||
npcStateMachine.RestorePreviousState();
|
||||
|
||||
// 이동 상태 업데이트
|
||||
isMovingToToilet = false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace BlueWaterProject
|
||||
}
|
||||
else
|
||||
{
|
||||
// 목적지가 없는 경우, 다른 처리를 수행하거나 그대로 둡니다.
|
||||
// 목적지가 없는 경우, 다른 처리를 수행하거나 그대로 둠
|
||||
}
|
||||
}
|
||||
else
|
||||
|
80
BlueWater/Assets/02.Scripts/Npc/OrderToJailState.cs
Normal file
80
BlueWater/Assets/02.Scripts/Npc/OrderToJailState.cs
Normal 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;
|
||||
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;
|
||||
targetJail.UseJail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnExit(NpcStateMachine npcStateMachine)
|
||||
{
|
||||
agent.speed = 3.5f;
|
||||
}
|
||||
|
||||
public INpcState Clone()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
32
BlueWater/Assets/02.Scripts/Props/Jail.cs
Normal file
32
BlueWater/Assets/02.Scripts/Props/Jail.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
11
BlueWater/Assets/02.Scripts/Props/Jail.cs.meta
Normal file
11
BlueWater/Assets/02.Scripts/Props/Jail.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a79440a6c863548eda7074095b374c91
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -7,16 +7,16 @@ 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 InShipMapInfo inShipMapInfo;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
inShipMapInfo = GameObject.Find("InShipMap").GetComponent<InShipMapInfo>();
|
||||
inShipMapInfo.AddToilet(this);
|
||||
inShipMapInfo.Toilets.Add(this);
|
||||
}
|
||||
|
||||
public Transform UseToilet()
|
||||
@ -34,7 +34,7 @@ namespace BlueWaterProject
|
||||
|
||||
private void ToiletFull()
|
||||
{
|
||||
// 화장실이 꽉 찼을 때 이벤트
|
||||
// TODO 화장실게이지가 꽉 찼을 때 이벤트
|
||||
}
|
||||
|
||||
IEnumerator ToiletGaugeUp()
|
||||
|
@ -1130,6 +1130,159 @@ MonoBehaviour:
|
||||
entryGroups: []
|
||||
canvasScrollPosition: {x: 0, y: 0}
|
||||
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:
|
||||
syncActors: 0
|
||||
syncItems: 0
|
||||
|
@ -263,10 +263,17 @@ namespace SoulGames.EasyGridBuilderPro
|
||||
buildableGridObject.Setup();
|
||||
|
||||
placedObjectTransform.SetParent(inShipProp);
|
||||
if (placedObjectTransform.name == "Toilet")
|
||||
|
||||
switch (placedObjectTransform.name)
|
||||
{
|
||||
placedObjectTransform.gameObject.AddComponent<Toilet>();
|
||||
case "Toilet":
|
||||
placedObjectTransform.gameObject.AddComponent<Toilet>();
|
||||
break;
|
||||
case "Jail":
|
||||
placedObjectTransform.gameObject.AddComponent<Jail>();
|
||||
break;
|
||||
}
|
||||
|
||||
return buildableGridObject;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user