-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
80 changed files
with
636 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Console Game/Game/Runtime/GameObject/Model/SelfCleaningGameObjects.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Console_Game | ||
{ | ||
public sealed class SelfCleaningGameObjects : IGameObjects | ||
{ | ||
private readonly IGameObjects _gameObjects; | ||
|
||
public SelfCleaningGameObjects(IGameObjects gameObjects) | ||
{ | ||
_gameObjects = gameObjects ?? throw new ArgumentNullException(nameof(gameObjects)); | ||
} | ||
|
||
public bool IsActive => _gameObjects.IsActive; | ||
|
||
public IReadOnlyList<IGameObject> All => _gameObjects.All; | ||
|
||
public void Add(IGameObject instance) | ||
{ | ||
_gameObjects.Add(instance); | ||
} | ||
|
||
public void Remove(IGameObject instance) | ||
{ | ||
_gameObjects.Remove(instance); | ||
} | ||
|
||
public void Update(float deltaTime) | ||
{ | ||
_gameObjects.Update(deltaTime); | ||
CleanNotActiveObjects(); | ||
} | ||
|
||
private void CleanNotActiveObjects() | ||
{ | ||
foreach (var gameObject in All) | ||
{ | ||
if (gameObject.IsActive == false) | ||
_gameObjects.Remove(gameObject); | ||
} | ||
} | ||
|
||
public void Destroy() | ||
{ | ||
_gameObjects.Destroy(); | ||
} | ||
} | ||
} |
14 changes: 13 additions & 1 deletion
14
Console Game/Game/Runtime/Level/Factory/List/CharacterLevelsFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
using System; | ||
using Console_Game.UI; | ||
|
||
namespace Console_Game.Stats | ||
{ | ||
[Serializable] | ||
public sealed class LevelView : ILevelView | ||
{ | ||
private readonly string _levelOwnerName; | ||
|
||
public LevelView(string levelOwnerName) | ||
private readonly IText _text; | ||
|
||
public LevelView(string levelOwnerName, IText text) | ||
{ | ||
_levelOwnerName = levelOwnerName ?? throw new ArgumentNullException(nameof(levelOwnerName)); | ||
_text = text ?? throw new ArgumentNullException(nameof(text)); | ||
} | ||
|
||
public void Visualize(int xp, int maxXp) | ||
{ | ||
Console.WriteLine($"{_levelOwnerName} Xp: {xp}, MaxXp: {maxXp}"); | ||
_text.Visualize($"{_levelOwnerName} Xp: {xp}, MaxXp: {maxXp}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Numerics; | ||
|
||
namespace Console_Game.Physics | ||
{ | ||
public struct Box | ||
{ | ||
public Box(Vector3 size) | ||
{ | ||
Size = size; | ||
} | ||
|
||
public Vector3 Size { get; } | ||
|
||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Console Game/Game/Runtime/Physics/Colliders/BoxCollider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Numerics; | ||
|
||
namespace Console_Game.Physics | ||
{ | ||
public sealed class BoxCollider : ICollider | ||
{ | ||
private readonly Box _box; | ||
|
||
public BoxCollider(Box box, Vector3 center) | ||
{ | ||
_box = box; | ||
Center = center; | ||
} | ||
|
||
public Vector3 Center { get; } | ||
|
||
public bool Contains(Vector3 point) | ||
{ | ||
return Vector3.Distance(Center, point) <= Vector3.Distance(Center, _box.Size); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Numerics; | ||
|
||
namespace Console_Game.Physics | ||
{ | ||
public interface ICollider | ||
{ | ||
Vector3 Center { get; } | ||
|
||
bool Contains(Vector3 point); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Console Game/Game/Runtime/Physics/Colliders/World/CollidersWorld.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Console_Game.Physics | ||
{ | ||
public sealed class CollidersWorld<TModel> : ICollidersWorld<TModel> | ||
{ | ||
private readonly Dictionary<ICollider, TModel> _models; | ||
|
||
public CollidersWorld() | ||
{ | ||
_models = new Dictionary<ICollider, TModel>(); | ||
} | ||
|
||
public IReadOnlyDictionary<ICollider, TModel> Models => _models; | ||
|
||
public void Add(ICollider collider, TModel model) | ||
{ | ||
_models.Add(collider, model); | ||
} | ||
|
||
public void Remove(ICollider collider) | ||
{ | ||
_models.Remove(collider); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Console Game/Game/Runtime/Physics/Colliders/World/GameObjectsCollidersWorld.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Console_Game.Physics | ||
{ | ||
public sealed class GameObjectsCollidersWorld<TModel> : IGameLoopObject, ICollidersWorld<TModel> where TModel : IGameObject | ||
{ | ||
private readonly ICollidersWorld<TModel> _world; | ||
|
||
public GameObjectsCollidersWorld(ICollidersWorld<TModel> world) | ||
{ | ||
_world = world ?? throw new ArgumentNullException(nameof(world)); | ||
} | ||
|
||
public IReadOnlyDictionary<ICollider, TModel> Models => _world.Models; | ||
|
||
public void Add(ICollider collider, TModel model) => _world.Add(collider, model); | ||
|
||
public void Remove(ICollider collider) => _world.Remove(collider); | ||
|
||
public void Update(float deltaTime) | ||
{ | ||
foreach (var keyPair in _world.Models) | ||
{ | ||
ICollider collider = keyPair.Key; | ||
IGameObject gameObject = keyPair.Value; | ||
|
||
if (gameObject.IsActive == false) | ||
Remove(collider); | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Console Game/Game/Runtime/Physics/Colliders/World/ICollidersWorld.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Console_Game.Physics | ||
{ | ||
public interface ICollidersWorld<TModel> : IReadOnlyCollidersWorld<TModel> | ||
{ | ||
void Add(ICollider collider, TModel model); | ||
|
||
void Remove(ICollider collider); | ||
} | ||
} |
Oops, something went wrong.