Added door animation and fixed thugs movement

This commit is contained in:
Jakub Sztuba 2022-12-10 02:24:32 +01:00
parent c991563aa4
commit b408f0fbe4
15 changed files with 174845 additions and 6522 deletions

View File

@ -154,6 +154,7 @@
<Compile Include="Assets\Scripts\MenuGUI.cs" /> <Compile Include="Assets\Scripts\MenuGUI.cs" />
<Compile Include="Assets\Scripts\REFACTORING\Application\Dialogue\Panel\IPanel.cs" /> <Compile Include="Assets\Scripts\REFACTORING\Application\Dialogue\Panel\IPanel.cs" />
<Compile Include="Assets\Scripts\SaveSystem.cs" /> <Compile Include="Assets\Scripts\SaveSystem.cs" />
<Compile Include="Assets\Scripts\AnimatedDoorBehaviour.cs" />
<Compile Include="Assets\Scripts\ProceduralGeneration\GraphNode.cs" /> <Compile Include="Assets\Scripts\ProceduralGeneration\GraphNode.cs" />
<Compile Include="Assets\Scripts\SceneManager\OnMapAppearanceMethod.cs" /> <Compile Include="Assets\Scripts\SceneManager\OnMapAppearanceMethod.cs" />
<Compile Include="Assets\Scripts\NPCs&apos; Scripts\NPCQuest.cs" /> <Compile Include="Assets\Scripts\NPCs&apos; Scripts\NPCQuest.cs" />
@ -223,6 +224,8 @@
<Compile Include="Assets\Scripts\NPCs&apos; Scripts\NPCDialogue.cs" /> <Compile Include="Assets\Scripts\NPCs&apos; Scripts\NPCDialogue.cs" />
<Compile Include="Assets\Scripts\REFACTORING\Application\UI\Panel\TaskPanelController.cs" /> <Compile Include="Assets\Scripts\REFACTORING\Application\UI\Panel\TaskPanelController.cs" />
<Compile Include="Assets\Scripts\Player.cs" /> <Compile Include="Assets\Scripts\Player.cs" />
<Compile Include="Assets\Scripts\Door\DetectionZone.cs" />
<Compile Include="Assets\Scripts\Door\TriggerDoor.cs" />
<None Include="Assets\TextMesh Pro\Shaders\TMPro.cginc" /> <None Include="Assets\TextMesh Pro\Shaders\TMPro.cginc" />
<None Include="Assets\TextMesh Pro\Shaders\TMP_SDF-Mobile Overlay.shader" /> <None Include="Assets\TextMesh Pro\Shaders\TMP_SDF-Mobile Overlay.shader" />
<None Include="Assets\TextMesh Pro\Shaders\TMP_Bitmap.shader" /> <None Include="Assets\TextMesh Pro\Shaders\TMP_Bitmap.shader" />

View File

@ -389,10 +389,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 18149eba0830c174c9dcc882c0e77eba, type: 3} m_Script: {fileID: 11500000, guid: 18149eba0830c174c9dcc882c0e77eba, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
ground: {fileID: 178967048}
walls: {fileID: 1177818049}
ground1: {fileID: 11400000, guid: 5b70fbf89fe74ba4899b6d05830a8340, type: 2}
wall1: {fileID: 11400000, guid: 120f4295c33110c42ada777e171036d1, type: 2}
--- !u!156049354 &1796128696 --- !u!156049354 &1796128696
Grid: Grid:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -466,14 +462,9 @@ MonoBehaviour:
m_GameObject: {fileID: 1856799950} m_GameObject: {fileID: 1856799950}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ef71482e4d2df8440a1117e181018706, type: 3} m_Script: {fileID: 11500000, guid: e069f5d1e3084101831c42a88d412f64, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
isNewGame: 1
isContinued: 0
MapName:
ElementFolderName: InventoryItem
ItemsListName: InventoryItemList
--- !u!114 &1856799953 --- !u!114 &1856799953
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -483,15 +474,13 @@ MonoBehaviour:
m_GameObject: {fileID: 1856799950} m_GameObject: {fileID: 1856799950}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b8a65f0b147a2e44e8f244301ff0de57, type: 3} m_Script: {fileID: 11500000, guid: 16a738463a5a474dac5fa29bccecbf43, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
TaskElements: [] ground: {fileID: 178967048}
isNewGame: 1 walls: {fileID: 1177818049}
isContinued: 0 ground1: {fileID: 11400000, guid: daff8503ea910584aa0c0bcaea47c1f3, type: 2}
MapName: wall1: {fileID: 11400000, guid: 3856c657f18141d448e0f4386818d808, type: 2}
ElementFolderName: Quest
ItemsListName: QuestsList
--- !u!114 &1856799954 --- !u!114 &1856799954
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -506,8 +495,6 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
StaticElements: [] StaticElements: []
DynamicElements: [] DynamicElements: []
isNewGame: 1
isContinued: 0
MapName: MapName:
ElementFolderName: EquippableItem ElementFolderName: EquippableItem
ItemsListName: EquippableItemList ItemsListName: EquippableItemList

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,68 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class AnimatedDoorBehaviour : TriggerDoor
{
public GameObject SaveController;
[SerializeField]
public Gateway gateway;
public string DoorOpenAnimatorParamName = "DoorOpen";
Animator animator;
// Start is called before the first frame update
void Start()
{
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
}
private IEnumerator coroutine;
private IEnumerator Wait(float waitTime)
{
while (true)
{
yield return new WaitForSeconds(waitTime);
}
}
public void ScenetToMoveTo()
{
//coroutine = Wait(2.0f);
//StartCoroutine(coroutine);
animator.SetBool(DoorOpenAnimatorParamName, true);
//saving info about used gate/door/teleport
OnMapAppearanceMethod.SetTeleportedStatus();
PlayerPrefs.SetString("gateway.sourceMapName", gateway.currentMapName);
PlayerPrefs.SetString("gateway.nextMapName", gateway.nextMapName);
PlayerPrefs.SetFloat("gateway.respawnCoords.x", gateway.respawnCoords.x);
PlayerPrefs.SetFloat("gateway.respawnCoords.y", gateway.respawnCoords.y);
PlayerPrefs.SetFloat("gateway.respawnCoords.z", gateway.respawnCoords.z);
// 1. Save all before change scene
SaveController.GetComponent<SaveController>().SavePlayerEquipmentItems();
SaveController.GetComponent<SaveController>().SavePlayerQuests();
SaveController.GetComponent<SaveController>().SavePlayerInventory();
SaveController.GetComponent<SaveController>().SaveHealth();
SaveController.GetComponent<SaveController>().SaveChests();
// 2. Change scene
SceneManager.LoadScene(gateway.nextMapName);
}
}

View File

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

View File

@ -13,6 +13,20 @@ public class ChangeScene : MonoBehaviour
SceneManager.LoadScene(sceneID); SceneManager.LoadScene(sceneID);
} }
void Start(){
}
private IEnumerator WaitForAnimationAndMoveToScene(float waitTime, Collision2D collision)
{
while (true)
{
yield return new WaitForSeconds(waitTime);
collision.gameObject.GetComponent<DoorBehaviour>().ScenetToMoveTo();
}
}
// method is invoked only when script is assign to the player prefab object // method is invoked only when script is assign to the player prefab object
public void OnCollisionEnter2D(Collision2D collision) public void OnCollisionEnter2D(Collision2D collision)
@ -21,5 +35,10 @@ public class ChangeScene : MonoBehaviour
{ {
collision.gameObject.GetComponent<DoorBehaviour>().ScenetToMoveTo(); collision.gameObject.GetComponent<DoorBehaviour>().ScenetToMoveTo();
} }
if(collision.gameObject.tag == "AnimatedDoorSceneTransition")
{
Debug.Log("Starting coroutine");
StartCoroutine(WaitForAnimationAndMoveToScene(0.3f, collision));
}
} }
} }

3
Assets/Scripts/Door.meta Normal file
View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7790e17a38c94ead9e481fc94ee73eb3
timeCreated: 1670611468

View File

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DetectionZone : MonoBehaviour
{
public string tagTarget = "Player";
// When object is detected, it is added to the list of actively detected objects
public List<Collider2D> detectedObjs = new List<Collider2D>();
// Detect when object enters range
void OnTriggerEnter2D(Collider2D collider) {
if(collider.gameObject.tag == tagTarget) {
detectedObjs.Add(collider);
}
}
// Detect when object leaves range
void OnTriggerExit2D(Collider2D collider) {
if(collider.gameObject.tag == tagTarget) {
detectedObjs.Remove(collider);
}
}
}

View File

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

View File

@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerDoor : DetectionZone
{
public string DoorOpenAnimatorParamName = "DoorOpen";
Animator animator;
void Start(){
animator = GetComponent<Animator>();
}
void Update() {
if(detectedObjs.Count > 0) {
animator.SetBool(DoorOpenAnimatorParamName, true);
} else {
animator.SetBool(DoorOpenAnimatorParamName, false);
}
}
public void triggerDoor()
{
animator = GetComponent<Animator>();
animator.SetBool(DoorOpenAnimatorParamName, true);
}
}

View File

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

View File

@ -22,6 +22,12 @@ public class DoorBehaviour : MonoBehaviour
} }
public static IEnumerator Wait()
{
yield return new WaitForSeconds(2);
}
public void ScenetToMoveTo() public void ScenetToMoveTo()
{ {
//saving info about used gate/door/teleport //saving info about used gate/door/teleport
@ -41,7 +47,6 @@ public class DoorBehaviour : MonoBehaviour
SaveController.GetComponent<SaveController>().SaveHealth(); SaveController.GetComponent<SaveController>().SaveHealth();
SaveController.GetComponent<SaveController>().SaveChests(); SaveController.GetComponent<SaveController>().SaveChests();
// 2. Change scene // 2. Change scene
SceneManager.LoadScene(gateway.nextMapName); SceneManager.LoadScene(gateway.nextMapName);
} }

View File

@ -18,9 +18,9 @@ public class TileMapGenerator : MonoBehaviour
Map map = new Map(new Vector2Int(100, 100)); Map map = new Map(new Vector2Int(100, 100));
List<FloodFill> fillers = new List<FloodFill>(); List<FloodFill> fillers = new List<FloodFill>();
for (int i = 0; i < 50; i++) for (int i = 0; i < 70; i++)
{ {
FloodFill filler = new FloodFill(map, 1, new Vector2Int(Random.Range(0, 50), Random.Range(0, 50))); FloodFill filler = new FloodFill(map, 1, new Vector2Int(Random.Range(0, 70), Random.Range(0, 70)));
fillers.Add(filler); fillers.Add(filler);
} }
map.Fill(fillers); map.Fill(fillers);

View File

@ -15,6 +15,8 @@ TagManager:
- EnemyCollection - EnemyCollection
- NPCCollection - NPCCollection
- UIPanel - UIPanel
- AnimatedDoorSceneTransition
- Test
layers: layers:
- Default - Default
- TransparentFX - TransparentFX

View File

@ -12,25 +12,25 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c68190c160a2e042733232867083debf42d value: 22424703114646680e0b0227036c68190c160a2e042733232867083debf42d
flags: 0 flags: 0
RecentlyUsedScenePath-2: RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c70050204112e291f2f2a2c3b1920caef212be7a923e7ee2e26
flags: 0
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c72111f19352f223d667d6d0a1532f0e1372ce7f518e8ea3f7129370bfb25 value: 22424703114646680e0b0227036c72111f19352f223d667d6d0a1532f0e1372ce7f518e8ea3f7129370bfb25
flags: 0 flags: 0
RecentlyUsedScenePath-4: RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c72111f19352f223d667d6d1a1226ece42776f7e93ffdfe value: 22424703114646680e0b0227036c72111f19352f223d667d6d1a1226ece42776f7e93ffdfe
flags: 0 flags: 0
RecentlyUsedScenePath-5: RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c71150130192729686b700e261335ebf23939f6ee39e7a92f31352d1b value: 22424703114646680e0b0227036c71150130192729686b700e261335ebf23939f6ee39e7a92f31352d1b
flags: 0 flags: 0
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
flags: 0
RecentlyUsedScenePath-6: RecentlyUsedScenePath-6:
value: 22424703114646680e0b0227036c7b0518101d252266333e243d04 value: 22424703114646680e0b0227036c7b0518101d252266333e243d04
flags: 0 flags: 0
RecentlyUsedScenePath-7: RecentlyUsedScenePath-7:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d value: 22424703114646680e0b0227036c70050204112e291f2f2a2c3b1920caef212be7a923e7ee2e26
flags: 0 flags: 0
RecentlyUsedScenePath-8: RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0 flags: 0
vcSharedLogLevel: vcSharedLogLevel:
value: 0d5e400f0650 value: 0d5e400f0650