Skip to content

Commit 1828d28

Browse files
refactored code
1 parent 4e7a866 commit 1828d28

23 files changed

+177
-192
lines changed

Audio/Footsteps.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using UnityEngine;
22

33
namespace RPG.Audio {
4-
//TODO
4+
// TODO
55
/// <summary>
66
/// The implementation for footsteps sounds is still TODO
77
/// </summary>

Combat/PickupBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace RPG.Combat {
88
public class PickupBase : MonoBehaviour, IRaycastable {
99
private Collider objectCollider;
1010

11-
[SerializeField] public OnPickupEvent onPickup;
11+
[SerializeField] private OnPickupEvent onPickup;
1212

1313
[System.Serializable]
1414
public class OnPickupEvent : UnityEvent<PickupBase> { }

Combat/WeaponConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public bool HasProjectile() {
5858
return projectile != null;
5959
}
6060

61-
//TODO finish this
61+
// TODO finish this
6262
/// <summary>
6363
///
6464
/// </summary>

Conversing/DialogueManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void ContinueDialogue() {
4848

4949
}
5050

51-
//TODO Implement close dialogue on moving away from NPC
51+
// TODO Implement close dialogue on moving away from NPC
5252
public void CloseDialogue() {
5353
Debug.Log("End of conversation with.");
5454
animator.SetBool(IS_OPEN_TRIGGER, false);

Movement/Mover.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ public class Mover : MonoBehaviour, IAction, ISaveable {
1111
[SerializeField] private float maxSpeed = 6f;
1212
[SerializeField] private float maxNavPathLength = 40f;
1313
[SerializeField] private float interactStoppingDistance = 3f;
14+
private float originalStoppingDistance = 0;
15+
private Action callbackOnReachingDestination = null;
1416
private NavMeshAgent navMeshAgent;
1517
private Animator animator;
1618
private ActionScheduler actionScheduler;
1719
private Health health;
18-
private Action callbackOnReachingDestination = null;
19-
private float originalStoppingDistance = 0;
2020

2121
private void Awake() {
2222
navMeshAgent = GetComponent<NavMeshAgent>();
@@ -90,6 +90,7 @@ public Mover StartMovement(Vector3 destination, float speedFraction) {
9090

9191
return this;
9292
}
93+
9394
public void Cancel() {
9495
navMeshAgent.isStopped = true;
9596
}

NPC/DialogueInitiator.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ public class DialogueInitiator : NPCBase {
88
[SerializeField] private Dialogue dialogue;
99
[SerializeField] private DialogueManager dialogueManager;
1010
[SerializeField] public OnDialogueInitiatedEvent onDialogeInitiated;
11+
private bool isInteracting = false;
1112

1213
[System.Serializable]
1314
public class OnDialogueInitiatedEvent : UnityEvent<DialogueInitiator> { }
1415

1516
public new CursorType Cursor => CursorType.Converse;
1617
public DialogueManager DialogueManager => dialogueManager;
1718

18-
private bool isInteracting = false;
19-
2019
private void OnEnable() {
2120
dialogueManager.onDialogueClose += EndInteraction;
2221
}
@@ -25,6 +24,10 @@ private void OnDisable() {
2524
dialogueManager.onDialogueClose -= EndInteraction;
2625
}
2726

27+
private void EndInteraction() {
28+
isInteracting = false;
29+
}
30+
2831
public override void Interact() {
2932
if (!isInteracting) {
3033
StartDialogue(dialogue);
@@ -36,10 +39,5 @@ public void StartDialogue(Dialogue dialogue) {
3639
onDialogeInitiated.Invoke(this);
3740
isInteracting = true;
3841
}
39-
40-
void EndInteraction() {
41-
isInteracting = false;
42-
}
43-
4442
}
4543
}

NPC/NPCBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public virtual void Interact() { }
1313
public bool HandleRaycast(GameObject callingObject) {
1414
if (Input.GetMouseButtonDown(0)) {
1515
if (IsTargetInRange(callingObject.transform, transform, 2.5f)) {
16-
//TODO make this work with CharacterBehaviour's smooth LookAt. Maybe use a Coroutine?
16+
// TODO make this work with CharacterBehaviour's smooth LookAt. Maybe use a Coroutine?
1717
transform.LookAt(callingObject.transform);
1818
callingObject.transform.LookAt(transform);
1919
Interact();

Questing/Goal/ConversationGoal.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ public ConversationGoal(Stage stage, string target, string description) {
1111
Description = description;
1212
}
1313

14-
public override void Init() {
15-
base.Init();
16-
EventSystem.OnTalkedToNPC += TalkedToNPC;
17-
}
18-
1914
private void TalkedToNPC(DialogueInitiator npc) {
2015
if (Stage.Active && npc.name.Contains(Target)) {
2116
Complete();
2217
EventSystem.OnTalkedToNPC -= TalkedToNPC;
2318
}
2419
}
20+
21+
public override void Init() {
22+
base.Init();
23+
EventSystem.OnTalkedToNPC += TalkedToNPC;
24+
}
2525
}
2626
}

Questing/Goal/Goal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ public class Goal {
66
public event Action<Stage, Goal> onComplete;
77
public bool Completed { get; set; } = false;
88
public string Description { get; set; } = "";
9-
protected Stage Stage { get; set; } = null;
109
public int CurrentAmount { get; set; } = 0;
10+
protected Stage Stage { get; set; } = null;
1111
protected int RequiredAmount { get; set; } = 1;
1212

1313
public virtual void Init() { }

Questing/Goal/PickupGoal.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using RPG.Events;
33

44
namespace RPG.Questing {
5-
public class PickuppGoal : Goal {
6-
private string Pickup;
7-
public PickuppGoal(Stage stage, string pickup, int currentAmount, int requiredAmount, string description = "", bool completed = false) {
5+
public class PickupGoal : Goal {
6+
public string Pickup;
7+
public PickupGoal(Stage stage, string pickup, int currentAmount, int requiredAmount, string description = "", bool completed = false) {
88
Stage = stage;
99
Pickup = pickup;
1010
CurrentAmount = currentAmount;
@@ -25,7 +25,6 @@ private void ItemPickedUp(PickupBase pickup) {
2525
EventSystem.OnItemPickedUp -= ItemPickedUp;
2626
}
2727
}
28-
2928
}
3029
}
3130
}

0 commit comments

Comments
 (0)