Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVAC-34_ImplementScoreTrackingAndManagement #29

Draft
wants to merge 7 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 103 additions & 6 deletions Assets/Scenes/Development/MVP_01/01-Test-Level.unity
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 715037901}
- {fileID: 1422283200}
- {fileID: 1659243847}
- {fileID: 1209207043}
Expand Down Expand Up @@ -396,7 +397,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 2179118524695121354, guid: c8334bd58b752704aba342e7d8b8d531, type: 3}
propertyPath: m_RootOrder
value: 3
value: 4
objectReference: {fileID: 0}
- target: {fileID: 2179118524695121354, guid: c8334bd58b752704aba342e7d8b8d531, type: 3}
propertyPath: m_AnchorMax.x
Expand Down Expand Up @@ -740,7 +741,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1817721913033860250, guid: 7c7c015be8b7ec84eb885d744bc86193, type: 3}
propertyPath: m_RootOrder
value: 4
value: 5
objectReference: {fileID: 0}
- target: {fileID: 1817721913033860250, guid: 7c7c015be8b7ec84eb885d744bc86193, type: 3}
propertyPath: m_AnchorMax.x
Expand Down Expand Up @@ -838,6 +839,41 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 802304610390773987, guid: 7c7c015be8b7ec84eb885d744bc86193, type: 3}
m_PrefabInstance: {fileID: 512559899}
m_PrefabAsset: {fileID: 0}
--- !u!1 &715037900
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 715037901}
m_Layer: 5
m_Name: Global-Group
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &715037901
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 715037900}
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_Children: []
m_Father: {fileID: 354324118}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &757052400
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1093,7 +1129,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 354324118}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
Expand Down Expand Up @@ -1195,7 +1231,7 @@ RectTransform:
- {fileID: 158474445}
- {fileID: 149129738}
m_Father: {fileID: 354324118}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
Expand All @@ -1207,6 +1243,63 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 802304610312558818, guid: 7c7c015be8b7ec84eb885d744bc86193, type: 3}
m_PrefabInstance: {fileID: 512559899}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1625906523
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 346364099449539113, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_Name
value: Test-Score-Increment-Circle
objectReference: {fileID: 0}
- target: {fileID: 346364099449539116, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_RootOrder
value: 7
objectReference: {fileID: 0}
- target: {fileID: 346364099449539116, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_LocalPosition.x
value: 4.08
objectReference: {fileID: 0}
- target: {fileID: 346364099449539116, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 346364099449539116, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 346364099449539116, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 346364099449539116, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 346364099449539116, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 346364099449539116, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 346364099449539116, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 346364099449539116, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 346364099449539116, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4fa0217bd8f81684cbf94e5c0b6e8834, type: 3}
--- !u!1 &1644446227 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 802304609120141462, guid: 7c7c015be8b7ec84eb885d744bc86193, type: 3}
Expand Down Expand Up @@ -1240,7 +1333,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 354324118}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
Expand Down Expand Up @@ -1374,7 +1467,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1725739490127982125, guid: 8a6cf01c52815924f8db478f05623697, type: 3}
propertyPath: m_RootOrder
value: 5
value: 6
objectReference: {fileID: 0}
- target: {fileID: 1725739490127982125, guid: 8a6cf01c52815924f8db478f05623697, type: 3}
propertyPath: m_AnchorMax.x
Expand Down Expand Up @@ -1724,6 +1817,10 @@ PrefabInstance:
propertyPath: inputSystemManager
value:
objectReference: {fileID: 1147862328}
- target: {fileID: 1840124048, guid: e9ee3ac8edfbd2b4b90a46c9ff07c9cc, type: 3}
propertyPath: scorePointsPresenter
value:
objectReference: {fileID: 1911689718}
- target: {fileID: 1840124048, guid: e9ee3ac8edfbd2b4b90a46c9ff07c9cc, type: 3}
propertyPath: playerHealthBarGameObject
value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SceneLevelManager : MonoBehaviour, ISceneDeathEventHandler, ISceneP
public PlayerShipSpawner playerSpawner;
public GameObject playerHealthBarGameObject;
public SceneOperations sceneOperations;
public ScorePresenter scorePresenter;
public ScorePointsPresenter scorePointsPresenter;
public SceneScoreSystem sceneScoreSystem;
public InputSystemManager inputSystemManager;

Expand All @@ -40,14 +40,14 @@ private void Awake()
playerSpawner = FindObjectOfType<PlayerShipSpawner>();
sceneOperations = this.GetComponent<SceneOperations>();
sceneScoreSystem = this.GetComponent<SceneScoreSystem>();
scorePresenter = FindObjectOfType<ScorePresenter>();
scorePointsPresenter = FindObjectOfType<ScorePointsPresenter>();
}

private void Start()
{
GameManager.Instance.sceneLevelManager = this;

sceneOperations.ConfigureSceneLevel(playerSpawner, sceneScoreSystem, scorePresenter);
sceneOperations.ConfigureSceneLevel(playerSpawner, sceneScoreSystem, scorePointsPresenter);
OnGameStart?.Invoke();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SceneOperations : MonoBehaviour
public void ConfigureSceneLevel(
PlayerShipSpawner playerSpawner,
SceneScoreSystem sceneScoreSystem,
ScorePresenter scorePresenter)
ScorePointsPresenter scorePresenter)
{
sceneScoreSystem.InitialiseSceneScoreSystem(scorePresenter);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using System;
using TheEvacuation.Infrastructure.Score.CreateScoreRecord;
using TheEvacuation.Infrastructure.Score.LoadScoreBoard;
using TheEvacuation.Infrastructure.Score.UpdateScoreRecord;
using TheEvacuation.Interfaces.GameInterfaces.Score;
using TheEvacuation.Model.Entities;
using UnityEngine;

namespace TheEvacuation.Infrastructure.GameSystems.SceneSystems
Expand All @@ -9,21 +14,16 @@ public class SceneScoreSystem : MonoBehaviour

#region - - - - - - Fields - - - - - -

public IScorePresenter scorePresenter;
public IScorePointsPresenter scorePresenter;
public ICreateScoreRecord createScoreRecord;
public IUpdateScoreRecord updateScoreRecord;
public ILoadScoreBoard loadScoreBoard;

public int totalScore;
private ScoreRecord scoreRecord;
private ScoreBoard scoreBoard;

#endregion Fields

#region - - - - - - MonoBehaviour - - - - - -

private void Start()
{

}

#endregion MonoBehaviour

#region - - - - - - Methods - - - - - -

/*
Expand All @@ -37,19 +37,84 @@ private void Start()
*
*/

public void InitialiseSceneScoreSystem(IScorePresenter scorePresenter)
public void InitialiseSceneScoreSystem(IScorePointsPresenter scorePresenter)
{
this.scorePresenter = scorePresenter;
}

public void UpdateTotalScore(int scoreValue)
{
totalScore += scoreValue;
scorePresenter.PresentScore(totalScore);
this.createScoreRecord = new CreateScoreRecordController();
this.updateScoreRecord = new UpdateScoreRecordController(scorePresenter);
this.loadScoreBoard = new LoadScoreBoardController();

this.scoreRecord = this.createScoreRecord.CreateScoreRecord();
}

/// <summary>
/// Loads existing scoreboard, else create scoreboard
/// </summary>
public void LoadScoreBoard(Guid scoreBoardID)
=> scoreBoard = this.loadScoreBoard.LoadScoreBoard(scoreBoardID);

public void SaveScoreRecord() { }

public void UpdateTotalScore(ScoreEvent scoreEvent)
=> this.updateScoreRecord.UpdateScoreRecord(scoreRecord, scoreEvent);

public ScoreRecord GetScoreRecord()
=> this.scoreRecord;

#endregion Methods

}

/// <summary>
/// Tracks the score game data during scene gameplay.
/// </summary>
public class ScoreRecord
{

#region - - - - - - Properties - - - - - -

public int KillCount { get; set; }

public int SkillPoints { get; set; }

public int TotalScore { get; set; }

#endregion Properties

}

/// <summary>
/// Represents an event containing the score sent by a subscribing game entity.
/// </summary>
public class ScoreEvent
{

#region - - - - - - Properties - - - - - -

public int ScoreValue { get; set; }

public ScoreEventType EventType { get; set; }

public ScoreSubscriber ScoreSubscriber { get; set; }

#endregion Properties

}

public class ScoreSubscriber
{

#region - - - - - - Properties - - - - - -

public string Name { get; set; }

public Transform Transform { get; set; }

#endregion Properties

}



}
1 change: 0 additions & 1 deletion Assets/Scripts/Infrastructure/GameSystems/SessionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class SessionData : UnitOfWork

public Player CurrentPlayer { get; set; }
public SpaceShip SelectedSpaceShip { get; set; }
public ScoreBoard PlayerScoreBoard { get; set; }

#endregion Properties

Expand Down
10 changes: 8 additions & 2 deletions Assets/Scripts/Infrastructure/Persistence/DataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public void CreateNewGameData()
{
data = new GameData()
{
m_Players = new List<Player>()
m_Levels = new List<Level>(),
m_Players = new List<Player>(),
m_ScoreBoards = new List<ScoreBoard>()
};
}

Expand All @@ -35,8 +37,12 @@ public void CreateNewGameData()

public List<TBase> Set<TBase>()
{
if (typeof(TBase) == typeof(Player))
if (typeof(TBase) == typeof(Level))
return data.m_Levels as List<TBase>;
else if (typeof(TBase) == typeof(Player))
return data.m_Players as List<TBase>;
else if (typeof(TBase) == typeof(ScoreBoard))
return data.m_ScoreBoards as List<TBase>;

return null;
}
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Infrastructure/Persistence/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public class GameData

#region - - - - - - Fields - - - - - -

public List<Level> m_Levels;
public List<Player> m_Players;
public List<ScoreBoard> m_ScoreBoards;

#endregion Fields

Expand Down
Loading