-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
* Move obstacle state to separate file * Create obstacle destroyer * Move obstacle configuring to separate file * Create bullet destroyer * Create bullet exploder
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using BlockBreaker.Data.Static.Configuration.Obstacle; | ||
using BlockBreaker.Features.Obstacle; | ||
using UnityEngine; | ||
|
||
namespace BlockBreaker.Data.Dynamic.Obstacle | ||
{ | ||
public class ObstacleData | ||
{ | ||
public ObstacleConfig Config { get; set; } | ||
public Transform Transform { get; set; } | ||
|
||
public ObstacleDestroyer Destroyer { get; set; } | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using BlockBreaker.Data.Dynamic.Obstacle; | ||
using BlockBreaker.Data.Static.Configuration.Obstacle; | ||
using BlockBreaker.Infrastructure.Services; | ||
|
||
namespace BlockBreaker.Features.Obstacle | ||
{ | ||
public class ObstacleConfigurator : IComponentConfigurator<ObstacleDataProvider> | ||
{ | ||
private readonly ObstacleConfig _config; | ||
|
||
public ObstacleConfigurator(ObstacleConfig config) => _config = config; | ||
|
||
public void Configure(ObstacleDataProvider component) | ||
{ | ||
ObstacleData data = component.Data; | ||
data.Config = _config; | ||
data.Transform = component.transform; | ||
data.Destroyer = new ObstacleDestroyer(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
using BlockBreaker.Data.Static.Configuration.Obstacle; | ||
using BlockBreaker.Data.Dynamic.Obstacle; | ||
using UnityEngine; | ||
using Zenject; | ||
|
||
namespace BlockBreaker.Features.Obstacle | ||
{ | ||
public class ObstacleDataProvider : MonoBehaviour | ||
{ | ||
public ObstacleConfig Config { get; private set; } | ||
public ObstacleData Data { get; private set; } | ||
|
||
[Inject] | ||
public void Construct(ObstacleConfig obstacle) => Config = obstacle; | ||
public void Construct(ObstacleData data) => Data = data; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using UnityEngine; | ||
|
||
namespace BlockBreaker.Features.Obstacle | ||
{ | ||
public class ObstacleDestroyer | ||
{ | ||
public void Destroy(GameObject gameObject) => gameObject.SetActive(false); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using BlockBreaker.Data.Dynamic.Obstacle; | ||
|
||
namespace BlockBreaker.Features.Obstacle | ||
{ | ||
public class ObstaclesProvider | ||
{ | ||
public IEnumerable<ObstacleDataProvider> ObstacleDataProviders { get; } | ||
public ObstacleData[] Obstacles { get; private set; } | ||
|
||
public ObstaclesProvider(IEnumerable<ObstacleDataProvider> obstacleDataProviders) => | ||
ObstacleDataProviders = obstacleDataProviders; | ||
|
||
public ObstacleData[] InitializeObstacleData() => | ||
Obstacles = ObstacleDataProviders.Select(obstacle => obstacle.Data).ToArray(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using BlockBreaker.Features.Obstacle; | ||
using UnityEngine; | ||
|
||
namespace BlockBreaker.Features.Player.Bullet | ||
{ | ||
[RequireComponent(typeof(PlayerBulletDataProvider))] | ||
public class PlayerBulletCollisionHandler : MonoBehaviour | ||
{ | ||
private PlayerBulletDataProvider _bulletProvider; | ||
|
||
private void Awake() => _bulletProvider = GetComponent<PlayerBulletDataProvider>(); | ||
|
||
private void OnCollisionEnter(Collision other) | ||
{ | ||
if (other.gameObject.TryGetComponent(out ObstacleDataProvider obstacleProvider)) | ||
_bulletProvider.Data.Exploder.Explode(_bulletProvider); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using UnityEngine.Pool; | ||
|
||
namespace BlockBreaker.Features.Player.Bullet | ||
{ | ||
public class PlayerBulletDestroyer | ||
{ | ||
public IObjectPool<PlayerBulletDataProvider> BulletsPool { get; set; } | ||
|
||
public void Destroy(PlayerBulletDataProvider bullet) => BulletsPool?.Release(bullet); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.