game: paper interaction pt4
debugs for paper in socket
This commit is contained in:
parent
9f5a882727
commit
9229cdae8a
5 changed files with 107 additions and 3 deletions
|
@ -474,6 +474,7 @@ GameObject:
|
|||
- component: {fileID: 370788366}
|
||||
- component: {fileID: 370788365}
|
||||
- component: {fileID: 370788364}
|
||||
- component: {fileID: 370788367}
|
||||
m_Layer: 0
|
||||
m_Name: Paper Socket_NPC
|
||||
m_TagString: Untagged
|
||||
|
@ -590,6 +591,19 @@ BoxCollider:
|
|||
serializedVersion: 3
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &370788367
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 370788362}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 120dec3a4fef31d4c8b88a1e19de3d80, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
socketName: Paper Socket_NPC
|
||||
--- !u!1 &397894337
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -2688,6 +2702,7 @@ GameObject:
|
|||
- component: {fileID: 1938714096}
|
||||
- component: {fileID: 1938714095}
|
||||
- component: {fileID: 1938714098}
|
||||
- component: {fileID: 1938714099}
|
||||
m_Layer: 0
|
||||
m_Name: Paper Socket
|
||||
m_TagString: Untagged
|
||||
|
@ -2751,8 +2766,8 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1938714094}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: 0.9904229, z: -0, w: 0.13806713}
|
||||
m_LocalPosition: {x: -0.072, y: 0.893, z: 1.389}
|
||||
m_LocalRotation: {x: 0, y: 0.9904229, z: 0, w: 0.13806683}
|
||||
m_LocalPosition: {x: -0.645, y: 0.893, z: 1.389}
|
||||
m_LocalScale: {x: 0.45395544, y: 0.014691553, z: 0.57689166}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
|
@ -2804,6 +2819,19 @@ MonoBehaviour:
|
|||
m_SocketScaleMode: 0
|
||||
m_FixedScale: {x: 1, y: 1, z: 1}
|
||||
m_TargetBoundsSize: {x: 1, y: 1, z: 1}
|
||||
--- !u!114 &1938714099
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1938714094}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 120dec3a4fef31d4c8b88a1e19de3d80, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
socketName: Paper Socket
|
||||
--- !u!1 &2027209538
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -18,6 +18,8 @@ public class NPCBehaviour : MonoBehaviour
|
|||
[SerializeField] private GameObject navigationTxtBubble;
|
||||
[SerializeField] public TextMeshProUGUI navigationTxt;
|
||||
|
||||
public static bool paperProduced;
|
||||
|
||||
private string[] possibleSentences =
|
||||
{
|
||||
"I want to go left!",
|
||||
|
@ -31,6 +33,8 @@ public class NPCBehaviour : MonoBehaviour
|
|||
paperObject.SetActive(false);
|
||||
navigationTxtBubble.SetActive(false);
|
||||
|
||||
paperProduced = false;
|
||||
|
||||
if (navigationTxt != null)
|
||||
{
|
||||
navigationTxt.text = GetRandomSentence();
|
||||
|
@ -43,6 +47,8 @@ public class NPCBehaviour : MonoBehaviour
|
|||
{
|
||||
paperObject.SetActive(true);
|
||||
navigationTxtBubble.SetActive(true);
|
||||
|
||||
paperProduced = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
59
SSLR/Assets/Scripts/PaperSocket.cs
Normal file
59
SSLR/Assets/Scripts/PaperSocket.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Author: Livinia Poo
|
||||
* Date: 1/2/25
|
||||
* Description:
|
||||
* Paper Handling
|
||||
Interaction*/
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Interactors;
|
||||
|
||||
public class PaperSocket : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private string socketName;
|
||||
XRSocketInteractor interactor;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
interactor = GetComponent<XRSocketInteractor>();
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
interactor.selectEntered.AddListener(OnPaperAttached);
|
||||
interactor.selectExited.AddListener(OnPaperDetached);
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
interactor.selectEntered.RemoveListener(OnPaperAttached);
|
||||
interactor.selectExited.RemoveListener(OnPaperDetached);
|
||||
}
|
||||
|
||||
private void OnPaperAttached(SelectEnterEventArgs args)
|
||||
{
|
||||
if (socketName == "Paper Socket_NPC")
|
||||
{
|
||||
Debug.Log("Paper returned to NPC");
|
||||
}
|
||||
else if (socketName == "Paper Socket")
|
||||
{
|
||||
Debug.Log("Paper placed on table");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPaperDetached(SelectExitEventArgs args)
|
||||
{
|
||||
if (socketName == "Paper Socket_NPC")
|
||||
{
|
||||
Debug.Log("Paper taken from NPC");
|
||||
}
|
||||
else if (socketName == "Paper Socket")
|
||||
{
|
||||
Debug.Log("Paper removed from table");
|
||||
}
|
||||
}
|
||||
}
|
11
SSLR/Assets/Scripts/PaperSocket.cs.meta
Normal file
11
SSLR/Assets/Scripts/PaperSocket.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 120dec3a4fef31d4c8b88a1e19de3d80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -27,7 +27,7 @@ public class Player : MonoBehaviour
|
|||
|
||||
void CheckDayEnd()
|
||||
{
|
||||
if (score <= 0)
|
||||
if (score < 0)
|
||||
{
|
||||
Debug.Log("Game Over, Day has ended");
|
||||
gm.dayEnded = true;
|
||||
|
|
Loading…
Add table
Reference in a new issue