Reset player after finishing introduction
This commit is contained in:
parent
b61f7bd694
commit
d90ca46069
@ -147412,7 +147412,7 @@ MonoBehaviour:
|
|||||||
SaveController: {fileID: 1995903830}
|
SaveController: {fileID: 1995903830}
|
||||||
gateway:
|
gateway:
|
||||||
id: 0
|
id: 0
|
||||||
currentMapName:
|
currentMapName: SampleScene
|
||||||
coords: {x: 0, y: 0, z: 0}
|
coords: {x: 0, y: 0, z: 0}
|
||||||
nextMapName: WizardHouse
|
nextMapName: WizardHouse
|
||||||
respawnCoords: {x: -5, y: 1.5, z: 10}
|
respawnCoords: {x: -5, y: 1.5, z: 10}
|
||||||
@ -147525,7 +147525,7 @@ MonoBehaviour:
|
|||||||
SaveController: {fileID: 2020454682}
|
SaveController: {fileID: 2020454682}
|
||||||
gateway:
|
gateway:
|
||||||
id: 0
|
id: 0
|
||||||
currentMapName:
|
currentMapName: SampleScene
|
||||||
coords: {x: 0, y: 0, z: 0}
|
coords: {x: 0, y: 0, z: 0}
|
||||||
nextMapName: CaveEntrance
|
nextMapName: CaveEntrance
|
||||||
respawnCoords: {x: 0.55, y: -11.5, z: 10}
|
respawnCoords: {x: 0.55, y: -11.5, z: 10}
|
||||||
|
@ -24446,6 +24446,50 @@ SpriteRenderer:
|
|||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
|
--- !u!1 &543241738
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 543241739}
|
||||||
|
- component: {fileID: 543241740}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: StoryManager
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &543241739
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 543241738}
|
||||||
|
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: 1144548810}
|
||||||
|
m_RootOrder: 3
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &543241740
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 543241738}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: a200e4962f3c3e04d8d1eaec90f407cc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &549018180
|
--- !u!1 &549018180
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -28497,6 +28541,7 @@ Transform:
|
|||||||
- {fileID: 1701466737}
|
- {fileID: 1701466737}
|
||||||
- {fileID: 1539180721}
|
- {fileID: 1539180721}
|
||||||
- {fileID: 2042768023}
|
- {fileID: 2042768023}
|
||||||
|
- {fileID: 543241739}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
@ -22,6 +22,7 @@ public class AnimatedDoorBehaviour : TriggerDoor
|
|||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
animator = GetComponent<Animator>();
|
animator = GetComponent<Animator>();
|
||||||
|
gateway.currentMapName = SceneManager.GetActiveScene().name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
@ -13,7 +13,7 @@ public class DoorBehaviour : MonoBehaviour
|
|||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
gateway.currentMapName = SceneManager.GetActiveScene().name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
@ -27,6 +27,11 @@ public abstract class DataListManager<T> : SceneDataListManagerInterface<T>
|
|||||||
Elements = _elements;
|
Elements = _elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ClearList()
|
||||||
|
{
|
||||||
|
Elements.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void AddElementToList(T newElement);
|
public abstract void AddElementToList(T newElement);
|
||||||
|
|
||||||
public abstract void RemoveElementFromList(T element);
|
public abstract void RemoveElementFromList(T element);
|
||||||
|
@ -157,4 +157,9 @@ public abstract class SceneBaseDataManager<T> : MonoBehaviour
|
|||||||
return SaveData(DynamicDataList.GetList(), SceneElementTypeEnum.Dynamic);
|
return SaveData(DynamicDataList.GetList(), SceneElementTypeEnum.Dynamic);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public void ClearListOfElements()
|
||||||
|
{
|
||||||
|
DynamicDataList.ClearList();
|
||||||
|
}
|
||||||
}
|
}
|
62
Assets/Scripts/REFACTORING/Story/WizardHouse/ResetPlayer.cs
Normal file
62
Assets/Scripts/REFACTORING/Story/WizardHouse/ResetPlayer.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Script to reset player stuf like
|
||||||
|
/// - missions list
|
||||||
|
/// - items
|
||||||
|
/// - equipment
|
||||||
|
/// - health
|
||||||
|
/// - exp
|
||||||
|
/// </summary>
|
||||||
|
public class ResetPlayer : MonoBehaviour
|
||||||
|
{
|
||||||
|
public bool isAfterReset = false;
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (!isAfterReset)
|
||||||
|
ResetPlayerData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetPlayerData()
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
EquipmentDataManager.Instance == null ||
|
||||||
|
SceneInventoryDataManager.Instance == null ||
|
||||||
|
SceneTaskDataManager.Instance == null
|
||||||
|
) return;
|
||||||
|
|
||||||
|
if (PlayerPrefs.GetString("gateway.sourceMapName") == "SampleScene")
|
||||||
|
{
|
||||||
|
isAfterReset = true;
|
||||||
|
|
||||||
|
// Clear panels data
|
||||||
|
EquipmentDataManager.Instance.ClearListOfElements();
|
||||||
|
SceneInventoryDataManager.Instance.ClearListOfElements();
|
||||||
|
SceneTaskDataManager.Instance.ClearListOfElements();
|
||||||
|
|
||||||
|
var saveController = GameObject.FindObjectOfType<SaveController>();
|
||||||
|
|
||||||
|
saveController.SavePlayerEquipmentItems();
|
||||||
|
saveController.SavePlayerInventory();
|
||||||
|
saveController.SavePlayerQuests();
|
||||||
|
|
||||||
|
// Player reset lvl, exp & health
|
||||||
|
var playerAgent = GameObject.FindGameObjectWithTag("Player");
|
||||||
|
|
||||||
|
playerAgent.GetComponent<Player>().currentHealth = PlayerPrefs.GetFloat("maxHealth");
|
||||||
|
PlayerPrefs.SetFloat("health-S", PlayerPrefs.GetFloat("maxHealth"));
|
||||||
|
PlayerPrefs.SetFloat("health", PlayerPrefs.GetFloat("maxHealth"));
|
||||||
|
|
||||||
|
playerAgent.GetComponent<Player>().exp = 0;
|
||||||
|
PlayerPrefs.SetFloat("exp-S", 0);
|
||||||
|
|
||||||
|
playerAgent.GetComponent<Player>().lvl = 1;
|
||||||
|
PlayerPrefs.SetInt("lvl-S", 1);
|
||||||
|
|
||||||
|
playerAgent.GetComponent<Player>().SaveCheckpoint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,8 @@ TagManager:
|
|||||||
- UIPanel
|
- UIPanel
|
||||||
- AnimatedDoorSceneTransition
|
- AnimatedDoorSceneTransition
|
||||||
- Test
|
- Test
|
||||||
|
- ChestCollection
|
||||||
|
- Manager
|
||||||
layers:
|
layers:
|
||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
|
Loading…
Reference in New Issue
Block a user