update to unity 6.2, add save system and quest system
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 9
|
||||
version: 10
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
|
||||
@@ -456,14 +456,14 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e85641f45d2eb9b458bbba38374b1360, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
dialogue:
|
||||
charName: Samuel Ballman
|
||||
defaultDialogue:
|
||||
charName: Sam Ballman
|
||||
isActive: 0
|
||||
sentences:
|
||||
- 'Hi Doug. '
|
||||
- You helped me.
|
||||
- Thanks for doing that!
|
||||
- Hey, Doug.
|
||||
talkIndicator: {fileID: 1356554487}
|
||||
quests:
|
||||
- {fileID: 462221471}
|
||||
--- !u!23 &265036977
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -530,6 +530,7 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 462221472}
|
||||
- {fileID: 1356554488}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@@ -1131,6 +1132,60 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 434479291}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &462221470
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 462221472}
|
||||
- component: {fileID: 462221471}
|
||||
m_Layer: 0
|
||||
m_Name: Quest1
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &462221471
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 462221470}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2db38219bed101e44b995a3611e4cedd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
hasStarted: 0
|
||||
hasCompleted: 0
|
||||
askText:
|
||||
- Hey Doug, I need your help.
|
||||
- Could you grab 3 star shards and touch the cube over there?
|
||||
duringText:
|
||||
- 'Remember: 3 star shards and touch the cube over there.'
|
||||
completionText:
|
||||
- Thanks for your help, Doug!
|
||||
questID: 1
|
||||
--- !u!4 &462221472
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 462221470}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 265036979}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &580033626
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1715,6 +1770,72 @@ Animator:
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorStateOnDisable: 0
|
||||
m_WriteDefaultValuesOnDisable: 0
|
||||
--- !u!1 &1210745723
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1210745724}
|
||||
- component: {fileID: 1210745725}
|
||||
- component: {fileID: 1210745726}
|
||||
m_Layer: 0
|
||||
m_Name: TouchRange
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1210745724
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1210745723}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1892268943}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!65 &1210745725
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1210745723}
|
||||
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: 3
|
||||
m_Size: {x: 1.1, y: 1.1, z: 1.1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1210745726
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1210745723}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a9ab60ad80ee08f4eb031540a5744ab5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1230830888
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1726,6 +1847,7 @@ GameObject:
|
||||
- component: {fileID: 1230830891}
|
||||
- component: {fileID: 1230830890}
|
||||
- component: {fileID: 1230830889}
|
||||
- component: {fileID: 1230830892}
|
||||
m_Layer: 0
|
||||
m_Name: GameManager
|
||||
m_TagString: Untagged
|
||||
@@ -1762,6 +1884,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 65dc1a5d5b17b874087eb45227f838f2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
StarShards: 0
|
||||
--- !u!4 &1230830891
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1777,6 +1900,20 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1230830892
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1230830888}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cf9658f7202522245b3ac80235b98b50, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
CompletedQuests:
|
||||
ActiveQuests:
|
||||
--- !u!1 &1316688875
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2449,6 +2586,143 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!1 &1892268938
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1892268943}
|
||||
- component: {fileID: 1892268942}
|
||||
- component: {fileID: 1892268941}
|
||||
- component: {fileID: 1892268940}
|
||||
- component: {fileID: 1892268939}
|
||||
m_Layer: 0
|
||||
m_Name: TouchCube
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!54 &1892268939
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1892268938}
|
||||
serializedVersion: 5
|
||||
m_Mass: 1
|
||||
m_LinearDamping: 0
|
||||
m_AngularDamping: 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: 1
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!65 &1892268940
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1892268938}
|
||||
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: 3
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &1892268941
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1892268938}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!33 &1892268942
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1892268938}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &1892268943
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1892268938}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 2.66292, y: 0.94, z: 13.0053}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1210745724}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &2063514701
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2828,3 +3102,4 @@ SceneRoots:
|
||||
- {fileID: 1023236592}
|
||||
- {fileID: 23024842}
|
||||
- {fileID: 2146681817}
|
||||
- {fileID: 1892268943}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public static GameManager Instance { get; private set; }
|
||||
public DialogueManager DialogueManager { get; private set; }
|
||||
public Storybools Storybools { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -19,6 +21,34 @@ private void Awake()
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
DialogueManager = GetComponent<DialogueManager>();
|
||||
SaveSystem.Load();
|
||||
}
|
||||
}
|
||||
|
||||
#region Storybool Save/Load
|
||||
public void SaveStoryBools(ref StoryboolSaveData data)
|
||||
{
|
||||
data.Storybools = Instance.Storybools;
|
||||
}
|
||||
|
||||
public void LoadStoryBools(StoryboolSaveData data)
|
||||
{
|
||||
if (data.Storybools != null)
|
||||
{
|
||||
Instance.Storybools = data.Storybools;
|
||||
}
|
||||
else
|
||||
{
|
||||
Instance.Storybools = new Storybools();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public int StarShards = 0; // will replace with inventory system
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct StoryboolSaveData
|
||||
{
|
||||
public Storybools Storybools;
|
||||
}
|
||||
|
||||
@@ -1,2 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65dc1a5d5b17b874087eb45227f838f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -1
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -7,6 +7,8 @@ public class PickupableItem : Interactable
|
||||
|
||||
public override void Interact()
|
||||
{
|
||||
GameManager.Instance.StarShards++; // REMOVE, JUST HERE FOR TESTING BEFORE ADDING INVENTORY SYSTEM
|
||||
|
||||
Debug.Log("Picked up " + item.itemName + "!");
|
||||
MoveOutsideRange(); // I don't love this but if we destroy the object we probably need to do this first
|
||||
Destroy(gameObject);
|
||||
|
||||
@@ -6,6 +6,10 @@ public class PlayerController : MonoBehaviour
|
||||
public Shovel Shovel;
|
||||
public float walkSpeed;
|
||||
|
||||
float digTime = 0.9f;
|
||||
float digTimestamp = 0;
|
||||
bool isDigging = false;
|
||||
|
||||
Interactable nearestInteractable;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
@@ -16,10 +20,14 @@ void Start()
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (!isDigging)
|
||||
{
|
||||
RotatePlayerTowardMouse();
|
||||
Walk();
|
||||
TryInteract();
|
||||
}
|
||||
|
||||
DigDetector();
|
||||
}
|
||||
|
||||
@@ -30,10 +38,22 @@ void Walk()
|
||||
}
|
||||
|
||||
void DigDetector()
|
||||
{
|
||||
if (!isDigging)
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Shovel.Dig();
|
||||
isDigging = true;
|
||||
digTimestamp = Time.time + digTime; // fuck coroutines fr fr
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Time.time > digTimestamp)
|
||||
{
|
||||
isDigging = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Quest : MonoBehaviour
|
||||
{
|
||||
public bool hasStarted = false;
|
||||
public bool hasCompleted = false;
|
||||
|
||||
public string[] askText; // ask the player to complete the task
|
||||
public string[] duringText; // what to say to the player when the task is complete
|
||||
public string[] completionText; // what to say to the player upon completion
|
||||
|
||||
public int questID = 0; // connects the quest to the registry, which gives us conditions
|
||||
|
||||
public void Start()
|
||||
{
|
||||
// check if we've completed the quest
|
||||
hasCompleted = QuestRegistry.Instance.CompletedQuests.Contains(questID);
|
||||
hasStarted = QuestRegistry.Instance.ActiveQuests.Contains(questID);
|
||||
|
||||
// this shouldn't be possible, but if the save is changed manually it could happen
|
||||
if (hasStarted && hasCompleted)
|
||||
{
|
||||
hasStarted = false;
|
||||
|
||||
// make sure only one reference exists
|
||||
QuestRegistry.Instance.CompletedQuests.RemoveAll(id => id == questID);
|
||||
QuestRegistry.Instance.CompletedQuests.Add(questID);
|
||||
|
||||
QuestRegistry.Instance.ActiveQuests.RemoveAll(id => id == questID);
|
||||
SaveSystem.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public void StartQuest()
|
||||
{
|
||||
hasStarted = true;
|
||||
QuestRegistry.Instance.ActiveQuests.Add(questID);
|
||||
SaveSystem.Save();
|
||||
}
|
||||
|
||||
public bool CheckComplete()
|
||||
{
|
||||
QuestBool[] conditionList = QuestRegistry.Instance.QuestBoolMap[questID];
|
||||
|
||||
if (conditionList != null)
|
||||
{
|
||||
foreach (QuestBool condition in conditionList)
|
||||
{
|
||||
// try each condition until we hit a false
|
||||
if (!condition.getValue())
|
||||
return false;
|
||||
}
|
||||
|
||||
// otherwise return true and mark quest complete
|
||||
QuestRegistry.Instance.ActiveQuests.Remove(questID);
|
||||
QuestRegistry.Instance.CompletedQuests.Add(questID);
|
||||
|
||||
SaveSystem.Save();
|
||||
hasCompleted = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2db38219bed101e44b995a3611e4cedd
|
||||
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class QuestRegistry : MonoBehaviour
|
||||
{
|
||||
// This will keep a register of all quest data and status
|
||||
public static QuestRegistry Instance { get; private set; }
|
||||
public Dictionary<int, QuestBool[]> QuestBoolMap;
|
||||
public List<int> CompletedQuests;
|
||||
public List<int> ActiveQuests;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// If there is an instance, and it's not me, delete myself.
|
||||
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
Instance = this;
|
||||
Instance.QuestBoolMap = PopulateQuestData();
|
||||
|
||||
PopulateQuestData();
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<int, QuestBool[]> PopulateQuestData()
|
||||
{
|
||||
Dictionary<int, QuestBool[]> questBoolMap = new Dictionary<int, QuestBool[]>();
|
||||
|
||||
// Quest Bool Structure: QID<QuestID>_<Bool Number>_<descriptiveName>
|
||||
// Example: QID11_4_landBurgerGreaseCleared
|
||||
#region 1 - Sam's Plea
|
||||
QuestBool[] QID1_List = new QuestBool[2];
|
||||
|
||||
// QID1_1_hasEnoughStarshards
|
||||
QID1_List[0] = new QuestBool(() =>
|
||||
{
|
||||
return GameManager.Instance.StarShards > 2;
|
||||
});
|
||||
|
||||
// QID1_2_hasHelpedSam
|
||||
QID1_List[1] = new QuestBool(() =>
|
||||
{
|
||||
return GameManager.Instance.Storybools.hasHelpedSam;
|
||||
});
|
||||
|
||||
questBoolMap.Add(1, QID1_List);
|
||||
#endregion
|
||||
|
||||
return questBoolMap;
|
||||
}
|
||||
|
||||
// Save completed quests to disk
|
||||
public void SaveQuestData(ref QuestSaveData data)
|
||||
{
|
||||
data.ActiveQuests = Instance.ActiveQuests;
|
||||
data.CompletedQuests = Instance.CompletedQuests;
|
||||
}
|
||||
|
||||
public void LoadQuestData(QuestSaveData data)
|
||||
{
|
||||
if (data.ActiveQuests != null)
|
||||
{
|
||||
Instance.ActiveQuests = data.ActiveQuests;
|
||||
}
|
||||
else
|
||||
{
|
||||
Instance.ActiveQuests = new List<int>();
|
||||
}
|
||||
|
||||
if (data.CompletedQuests != null)
|
||||
{
|
||||
Instance.CompletedQuests = data.CompletedQuests;
|
||||
}
|
||||
else
|
||||
{
|
||||
Instance.CompletedQuests = new List<int>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class QuestBool
|
||||
{
|
||||
// This let's us define complex behavior for quests. We can also store
|
||||
// raw booleans for this if we have story beats we want to keep track of.
|
||||
public Func<bool> getValue;
|
||||
|
||||
public QuestBool(Func<bool> getValue)
|
||||
{
|
||||
this.getValue = getValue;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct QuestSaveData
|
||||
{
|
||||
public List<int> CompletedQuests;
|
||||
public List<int> ActiveQuests;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf9658f7202522245b3ac80235b98b50
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -2
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
public class SaveSystem
|
||||
{
|
||||
private static SaveData _saveData = new SaveData();
|
||||
|
||||
[System.Serializable]
|
||||
public struct SaveData
|
||||
{
|
||||
public QuestSaveData QuestData;
|
||||
public StoryboolSaveData StoryboolData;
|
||||
}
|
||||
|
||||
public static string SaveFileName()
|
||||
{
|
||||
return Application.persistentDataPath + "/save.data";
|
||||
}
|
||||
|
||||
public static void GenerateCorruptedSaveReadme()
|
||||
{
|
||||
string path = Application.persistentDataPath + "/README.txt";
|
||||
string errorText = "Your save was corrupted.\n\n" +
|
||||
"This can happen when you edit the save manually, or if the game closed while saving. Your\n" +
|
||||
"corrupted save file has been saved in this directory as 'save.data.backup' if you'd like to\n" +
|
||||
"try manually fixing it. It should follow standard JSON formatting.\n\n" +
|
||||
"Once you fix it, just delete the current save.data file, and remove the '.backup' from your \n" +
|
||||
"old save file. Good luck, and sorry for the inconvenience!";
|
||||
|
||||
File.WriteAllText(path, errorText);
|
||||
}
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
HandleSaveData();
|
||||
|
||||
File.WriteAllText(SaveFileName(), JsonUtility.ToJson(_saveData, true));
|
||||
}
|
||||
|
||||
private static void HandleSaveData()
|
||||
{
|
||||
GameManager.Instance.SaveStoryBools(ref _saveData.StoryboolData);
|
||||
QuestRegistry.Instance.SaveQuestData(ref _saveData.QuestData);
|
||||
}
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
string saveContent;
|
||||
|
||||
try
|
||||
{
|
||||
saveContent = File.ReadAllText(SaveFileName());
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
Save(); // create new save file if one does not exist
|
||||
saveContent = File.ReadAllText(SaveFileName());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_saveData = JsonUtility.FromJson<SaveData>(saveContent);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
// Likely a JSON parse error. Let's back up the old version of the save and
|
||||
// make a new one for now
|
||||
|
||||
File.WriteAllText(SaveFileName() + ".backup", saveContent);
|
||||
GenerateCorruptedSaveReadme();
|
||||
Save();
|
||||
}
|
||||
|
||||
HandleLoadData();
|
||||
}
|
||||
|
||||
public static void HandleLoadData()
|
||||
{
|
||||
GameManager.Instance.LoadStoryBools(_saveData.StoryboolData);
|
||||
QuestRegistry.Instance.LoadQuestData(_saveData.QuestData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2f06729fcc0a08408d90d49c2336d22
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class Storybools
|
||||
{
|
||||
// not sure how we'll organize this yet, but right now lets do it by quest
|
||||
#region QID1
|
||||
public bool hasHelpedSam = false;
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70e96df6062507943b1f7ae7df89dee5
|
||||
@@ -3,18 +3,85 @@
|
||||
public class Talkable : Interactable
|
||||
{
|
||||
// this is a character or object that will talk upon interaction
|
||||
public Dialogue dialogue;
|
||||
public Dialogue defaultDialogue;
|
||||
public GameObject talkIndicator;
|
||||
|
||||
public Quest[] quests;
|
||||
Dialogue currentDialogue;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
talkIndicator.SetActive(false);
|
||||
}
|
||||
|
||||
void DetermineDialogue()
|
||||
{
|
||||
// based on if we have any open quests and where we're at in the quest,
|
||||
// determine what dialogue to show
|
||||
Quest currentQuest = null;
|
||||
|
||||
// Grab the first ACTIVE quest
|
||||
// If none active, grab the first AVAILABLE quest
|
||||
// If none available, revert to default dialogue
|
||||
if (quests.Length > 0)
|
||||
{
|
||||
// check for ACTIVE quests
|
||||
foreach (Quest q in quests)
|
||||
{
|
||||
if (q.hasStarted && !q.hasCompleted)
|
||||
{
|
||||
currentQuest = q;
|
||||
}
|
||||
}
|
||||
// check for AVAILABLE quests
|
||||
if (currentQuest == null)
|
||||
{
|
||||
foreach (Quest q in quests)
|
||||
{
|
||||
if (!q.hasStarted && !q.hasCompleted)
|
||||
{
|
||||
currentQuest = q;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// revert to default if no suitable quest found
|
||||
if (currentQuest == null)
|
||||
{
|
||||
currentDialogue = defaultDialogue;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentQuest.CheckComplete();
|
||||
|
||||
currentDialogue = new Dialogue();
|
||||
currentDialogue.charName = defaultDialogue.charName;
|
||||
|
||||
// set up dialogue based on quest
|
||||
if (currentQuest.hasStarted && !currentQuest.hasCompleted)
|
||||
{
|
||||
currentDialogue.sentences = currentQuest.duringText;
|
||||
}
|
||||
else if (!currentQuest.hasStarted && !currentQuest.hasCompleted)
|
||||
{
|
||||
currentDialogue.sentences = currentQuest.askText;
|
||||
currentQuest.StartQuest();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentDialogue.sentences = currentQuest.completionText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Interact()
|
||||
{
|
||||
if (!dialogue.isActive)
|
||||
GameManager.Instance.DialogueManager.StartDialogue(dialogue);
|
||||
if (currentDialogue == null || !currentDialogue.isActive)
|
||||
{
|
||||
DetermineDialogue();
|
||||
GameManager.Instance.DialogueManager.StartDialogue(currentDialogue);
|
||||
}
|
||||
else
|
||||
GameManager.Instance.DialogueManager.DisplayNextSentence();
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ MonoBehaviour:
|
||||
- rid: 3760263086078427141
|
||||
- rid: 3760263086078427142
|
||||
- rid: 3760263086078427143
|
||||
- rid: 4669856846790000640
|
||||
m_RuntimeSettings:
|
||||
m_List: []
|
||||
m_AssetVersion: 8
|
||||
@@ -222,6 +223,10 @@ MonoBehaviour:
|
||||
- {r: 0.5, g: 0, b: 0.5, a: 1}
|
||||
- {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
- {r: 0, g: 0, b: 1, a: 1}
|
||||
- rid: 4669856846790000640
|
||||
type: {class: RenderingDebuggerRuntimeResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||
data:
|
||||
m_version: 0
|
||||
- rid: 6852985685364965376
|
||||
type: {class: URPShaderStrippingSetting, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||
data:
|
||||
@@ -235,9 +240,6 @@ MonoBehaviour:
|
||||
m_AutodeskInteractive: {fileID: 4800000, guid: 0e9d5a909a1f7e84882a534d0d11e49f, type: 3}
|
||||
m_AutodeskInteractiveTransparent: {fileID: 4800000, guid: 5c81372d981403744adbdda4433c9c11, type: 3}
|
||||
m_AutodeskInteractiveMasked: {fileID: 4800000, guid: 80aa867ac363ac043847b06ad71604cd, type: 3}
|
||||
m_TerrainDetailLit: {fileID: 4800000, guid: f6783ab646d374f94b199774402a5144, type: 3}
|
||||
m_TerrainDetailGrassBillboard: {fileID: 4800000, guid: 29868e73b638e48ca99a19ea58c48d90, type: 3}
|
||||
m_TerrainDetailGrass: {fileID: 4800000, guid: e507fdfead5ca47e8b9a768b51c291a1, type: 3}
|
||||
m_DefaultSpeedTree7Shader: {fileID: 4800000, guid: 0f4122b9a743b744abe2fb6a0a88868b, type: 3}
|
||||
m_DefaultSpeedTree8Shader: {fileID: -6465566751694194690, guid: 9920c1f1781549a46ba081a2a15a16ec, type: 3}
|
||||
m_DefaultSpeedTree9Shader: {fileID: -6465566751694194690, guid: cbd3e1cc4ae141c42a30e33b4d666a61, type: 3}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class TouchCubeTest : Interactable
|
||||
{
|
||||
public override void Interact()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public override void MoveInsideRange()
|
||||
{
|
||||
if (GameManager.Instance.Storybools.hasHelpedSam)
|
||||
{
|
||||
Debug.Log("You've already touched the cube!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Touched the cube!");
|
||||
GameManager.Instance.Storybools.hasHelpedSam = true;
|
||||
SaveSystem.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public override void MoveOutsideRange()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9ab60ad80ee08f4eb031540a5744ab5
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"com.unity.ai.navigation": "2.0.8",
|
||||
"com.unity.collab-proxy": "2.8.2",
|
||||
"com.unity.ide.visualstudio": "2.0.23",
|
||||
"com.unity.render-pipelines.universal": "17.1.0",
|
||||
"com.unity.timeline": "1.8.7",
|
||||
"com.unity.ai.navigation": "2.0.9",
|
||||
"com.unity.collab-proxy": "2.10.2",
|
||||
"com.unity.ide.visualstudio": "2.0.25",
|
||||
"com.unity.render-pipelines.universal": "17.2.0",
|
||||
"com.unity.timeline": "1.8.9",
|
||||
"com.unity.ugui": "2.0.0",
|
||||
"com.unity.visualscripting": "1.9.7",
|
||||
"com.unity.visualscripting": "1.9.8",
|
||||
"com.unity.modules.accessibility": "1.0.0",
|
||||
"com.unity.modules.ai": "1.0.0",
|
||||
"com.unity.modules.androidjni": "1.0.0",
|
||||
|
||||
+23
-21
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"com.unity.ai.navigation": {
|
||||
"version": "2.0.8",
|
||||
"version": "2.0.9",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
@@ -10,7 +10,7 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.burst": {
|
||||
"version": "1.8.21",
|
||||
"version": "1.8.25",
|
||||
"depth": 2,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
@@ -20,20 +20,21 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.collab-proxy": {
|
||||
"version": "2.8.2",
|
||||
"version": "2.10.2",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.collections": {
|
||||
"version": "2.5.1",
|
||||
"version": "2.6.2",
|
||||
"depth": 2,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.burst": "1.8.17",
|
||||
"com.unity.test-framework": "1.4.5",
|
||||
"com.unity.nuget.mono-cecil": "1.11.4",
|
||||
"com.unity.burst": "1.8.23",
|
||||
"com.unity.mathematics": "1.3.2",
|
||||
"com.unity.test-framework": "1.4.6",
|
||||
"com.unity.nuget.mono-cecil": "1.11.5",
|
||||
"com.unity.test-framework.performance": "3.0.3"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
@@ -45,11 +46,11 @@
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.ide.visualstudio": {
|
||||
"version": "2.0.23",
|
||||
"version": "2.0.25",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.1.9"
|
||||
"com.unity.test-framework": "1.1.31"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
@@ -61,14 +62,14 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.nuget.mono-cecil": {
|
||||
"version": "1.11.4",
|
||||
"version": "1.11.5",
|
||||
"depth": 3,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.render-pipelines.core": {
|
||||
"version": "17.1.0",
|
||||
"version": "17.2.0",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
@@ -83,12 +84,12 @@
|
||||
}
|
||||
},
|
||||
"com.unity.render-pipelines.universal": {
|
||||
"version": "17.1.0",
|
||||
"version": "17.2.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.render-pipelines.core": "17.1.0",
|
||||
"com.unity.shadergraph": "17.1.0",
|
||||
"com.unity.render-pipelines.core": "17.2.0",
|
||||
"com.unity.shadergraph": "17.2.0",
|
||||
"com.unity.render-pipelines.universal-config": "17.0.3"
|
||||
}
|
||||
},
|
||||
@@ -118,16 +119,16 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.shadergraph": {
|
||||
"version": "17.1.0",
|
||||
"version": "17.2.0",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.render-pipelines.core": "17.1.0",
|
||||
"com.unity.render-pipelines.core": "17.2.0",
|
||||
"com.unity.searcher": "4.9.3"
|
||||
}
|
||||
},
|
||||
"com.unity.test-framework": {
|
||||
"version": "1.5.1",
|
||||
"version": "1.6.0",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
@@ -137,7 +138,7 @@
|
||||
}
|
||||
},
|
||||
"com.unity.test-framework.performance": {
|
||||
"version": "3.1.0",
|
||||
"version": "3.2.0",
|
||||
"depth": 3,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
@@ -147,7 +148,7 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.timeline": {
|
||||
"version": "1.8.7",
|
||||
"version": "1.8.9",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
@@ -168,7 +169,7 @@
|
||||
}
|
||||
},
|
||||
"com.unity.visualscripting": {
|
||||
"version": "1.9.7",
|
||||
"version": "1.9.8",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
@@ -325,7 +326,8 @@
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.hierarchycore": "1.0.0"
|
||||
"com.unity.modules.hierarchycore": "1.0.0",
|
||||
"com.unity.modules.physics": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.umbra": {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
m_EditorVersion: 6000.1.7f1
|
||||
m_EditorVersionWithRevision: 6000.1.7f1 (13a8ffad9172)
|
||||
m_EditorVersion: 6000.2.14f1
|
||||
m_EditorVersionWithRevision: 6000.2.14f1 (589824c1fc31)
|
||||
|
||||
@@ -13,6 +13,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
shaderVariantLimit: 128
|
||||
overrideShaderVariantLimit: 0
|
||||
customInterpolatorErrorThreshold: 32
|
||||
customInterpolatorWarningThreshold: 16
|
||||
customHeatmapValues: {fileID: 0}
|
||||
|
||||
@@ -12,4 +12,4 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 247994e1f5a72c2419c26a37e9334c01, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_LastMaterialVersion: 9
|
||||
m_LastMaterialVersion: 10
|
||||
|
||||
Reference in New Issue
Block a user