From 1b36194f318c2148e944b3b6a2f59c5abc16c804 Mon Sep 17 00:00:00 2001 From: kabix09 Date: Thu, 5 Jan 2023 16:52:57 +0100 Subject: [PATCH] Lumberjack - getting reward after quest --- Assets/Resources/ThePlayer.prefab | 24 +++++++++++++++++-- Assets/Scripts/NPCs' Scripts/NPCDialogue.cs | 3 +++ Assets/Scripts/NPCs' Scripts/NPCQuest.cs | 2 ++ .../Application/Mission/MissionReward.cs | 3 +++ .../Application/Player/PlayerActions.cs | 7 +++++- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Assets/Resources/ThePlayer.prefab b/Assets/Resources/ThePlayer.prefab index 6ce61304..864e72ad 100644 --- a/Assets/Resources/ThePlayer.prefab +++ b/Assets/Resources/ThePlayer.prefab @@ -19,6 +19,7 @@ GameObject: - component: {fileID: 4869648843286970676} - component: {fileID: 4869648843286970678} - component: {fileID: 4869648843286970673} + - component: {fileID: -4072721723537361924} m_Layer: 0 m_Name: ThePlayer m_TagString: Player @@ -118,11 +119,18 @@ MonoBehaviour: walkSpeed: 10 Panel: {fileID: 0} dmgParticleSystem: {fileID: 4869648843387222763} - maxHealth: {fileID: 11400000, guid: 2cac7af95874b184aae736e0ed4994d7, type: 2} - currentHealth: 10 healthBar: {fileID: 0} lvlUp: 0 test: 0 + healthPoints: 0 + defensePoints: 0 + strengthPoints: 0 + intelligencePoints: 0 + attackValue: 0 + defenseValue: 0 + currentSpeed: 0 + currentHealth: 10 + maxHealth: 0 exp: 0 lvl: 0 maxExp: 0 @@ -270,6 +278,18 @@ MonoBehaviour: - E-InteractivePanelAbove - Spacebar-InteractivePanel - Spacebar-InteractivePanelAbove +--- !u!114 &-4072721723537361924 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4869648843286970700} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b706d33712b371949b5623cdf98fc4a4, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &4869648843387222766 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/NPCs' Scripts/NPCDialogue.cs b/Assets/Scripts/NPCs' Scripts/NPCDialogue.cs index f96255ed..075eb25f 100644 --- a/Assets/Scripts/NPCs' Scripts/NPCDialogue.cs +++ b/Assets/Scripts/NPCs' Scripts/NPCDialogue.cs @@ -332,6 +332,9 @@ public class NPCDialogue : MonoBehaviour else TaskUIManager.Instance.RemoveByName(gameObject.GetComponent().quest.Title); + // 4. Get reward + GameObject.FindGameObjectWithTag("Player").GetComponent().GetReward(gameObject.GetComponent().reward); + // 3. Set as finished isQuest = 3; EndDialogue(); diff --git a/Assets/Scripts/NPCs' Scripts/NPCQuest.cs b/Assets/Scripts/NPCs' Scripts/NPCQuest.cs index 145c9f01..60859906 100644 --- a/Assets/Scripts/NPCs' Scripts/NPCQuest.cs +++ b/Assets/Scripts/NPCs' Scripts/NPCQuest.cs @@ -14,6 +14,8 @@ public class NPCQuest : MonoBehaviour [SerializeField] private bool isTaskAccepted = false; + [SerializeField] public MissionReward reward; + // Start is called before the first frame update void Start() { diff --git a/Assets/Scripts/REFACTORING/Application/Mission/MissionReward.cs b/Assets/Scripts/REFACTORING/Application/Mission/MissionReward.cs index 322a7fd0..473e9965 100644 --- a/Assets/Scripts/REFACTORING/Application/Mission/MissionReward.cs +++ b/Assets/Scripts/REFACTORING/Application/Mission/MissionReward.cs @@ -11,6 +11,9 @@ public class MissionReward [SerializeField] public int Cash = 0; + [SerializeField] + public int Experience = 0; + public MissionReward() { } public MissionReward(List _items, int _cash) diff --git a/Assets/Scripts/REFACTORING/Application/Player/PlayerActions.cs b/Assets/Scripts/REFACTORING/Application/Player/PlayerActions.cs index 7ea5f799..0af60bd5 100644 --- a/Assets/Scripts/REFACTORING/Application/Player/PlayerActions.cs +++ b/Assets/Scripts/REFACTORING/Application/Player/PlayerActions.cs @@ -28,7 +28,10 @@ public class PlayerActions : MonoBehaviour // 2. Add cash AccountBalanceManager.Instance.IncreaseAccountBalanceValue(reward.Cash); - Debug.Log($"Give reward - {reward.Cash}"); + //Debug.Log($"Give reward - {reward.Cash}"); + + // 3. Add experience points + gameObject.GetComponent().GetExp(reward.Experience); // 3. Save changes // TODO - sync saving process reward / mission proggress @@ -36,5 +39,7 @@ public class PlayerActions : MonoBehaviour //GameObject.FindObjectOfType().SavePlayerEquipmentItems(); //GameObject.FindObjectOfType().SavePlayerInventory(); //GameObject.FindObjectOfType().SaveAccountBalance(); + + // save exp } }