commit
14c7fd7607
8 changed files with 20 additions and 25 deletions
|
@ -25,7 +25,7 @@ Transform:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1820949686450855695}
|
m_GameObject: {fileID: 1820949686450855695}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0.5, y: 0.5, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 5103883358052461890}
|
m_Father: {fileID: 5103883358052461890}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace src.Managers
|
||||||
public float explosionDuration = 0.55f;
|
public float explosionDuration = 0.55f;
|
||||||
|
|
||||||
|
|
||||||
private readonly HashSet<Vector3> _usedPosition = new HashSet<Vector3>();
|
private static readonly HashSet<Vector3> UsedPosition = new HashSet<Vector3>();
|
||||||
private const int MaxPower = 7;
|
private const int MaxPower = 7;
|
||||||
private const int MaxAllowedBombs = 10;
|
private const int MaxAllowedBombs = 10;
|
||||||
|
|
||||||
|
@ -51,19 +51,19 @@ namespace src.Managers
|
||||||
{
|
{
|
||||||
if (!CanPlaceBomb(position)) return;
|
if (!CanPlaceBomb(position)) return;
|
||||||
placedBombs++;
|
placedBombs++;
|
||||||
_usedPosition.Add(position);
|
UsedPosition.Add(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnregisterBomb(Vector3 position)
|
public void UnregisterBomb(Vector3 position)
|
||||||
{
|
{
|
||||||
if (!_usedPosition.Contains(position)) return;
|
if (!UsedPosition.Contains(position)) return;
|
||||||
placedBombs--;
|
placedBombs--;
|
||||||
_usedPosition.Remove(position);
|
UsedPosition.Remove(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanPlaceBomb(Vector3 position)
|
public bool CanPlaceBomb(Vector3 position)
|
||||||
{
|
{
|
||||||
return !_usedPosition.Contains(position) && placedBombs < allowedBombs;
|
return !UsedPosition.Contains(position) && placedBombs < allowedBombs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,7 +16,6 @@ namespace src.Managers
|
||||||
private GameStateManager _gameStateManager;
|
private GameStateManager _gameStateManager;
|
||||||
private LevelManager _levelManager;
|
private LevelManager _levelManager;
|
||||||
private UpgradeManager _upgradeManager;
|
private UpgradeManager _upgradeManager;
|
||||||
private BombsUtilManager _bombsUtilManager;
|
|
||||||
|
|
||||||
public void Awake()
|
public void Awake()
|
||||||
{
|
{
|
||||||
|
@ -33,7 +32,6 @@ namespace src.Managers
|
||||||
DontDestroyOnLoad(gameObject);
|
DontDestroyOnLoad(gameObject);
|
||||||
|
|
||||||
// Load singletons
|
// Load singletons
|
||||||
_bombsUtilManager = gameObject.AddComponent<BombsUtilManager>();
|
|
||||||
_gameStateManager = gameObject.AddComponent<GameStateManager>();
|
_gameStateManager = gameObject.AddComponent<GameStateManager>();
|
||||||
_levelManager = gameObject.AddComponent<LevelManager>();
|
_levelManager = gameObject.AddComponent<LevelManager>();
|
||||||
_upgradeManager = gameObject.AddComponent<UpgradeManager>();
|
_upgradeManager = gameObject.AddComponent<UpgradeManager>();
|
||||||
|
@ -64,11 +62,6 @@ namespace src.Managers
|
||||||
return _upgradeManager;
|
return _upgradeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BombsUtilManager GetBombsUtilManager()
|
|
||||||
{
|
|
||||||
return _bombsUtilManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerator PreInitGame()
|
private IEnumerator PreInitGame()
|
||||||
{
|
{
|
||||||
var preStageUi = Instantiate(PrefabAtlas.PreStageUi); // Will destroy itself.
|
var preStageUi = Instantiate(PrefabAtlas.PreStageUi); // Will destroy itself.
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace src.Player
|
||||||
private Rigidbody2D _rigidbody2d;
|
private Rigidbody2D _rigidbody2d;
|
||||||
private Collider2D _collider2D;
|
private Collider2D _collider2D;
|
||||||
private Transform _respawnPosition;
|
private Transform _respawnPosition;
|
||||||
private BombsUtilManager _bombsUtil;
|
private BombsUtilManager _bombsUtilManager;
|
||||||
private Animator _animator;
|
private Animator _animator;
|
||||||
private PlayerUpgrade _playerUpgrade;
|
private PlayerUpgrade _playerUpgrade;
|
||||||
|
|
||||||
|
@ -34,12 +34,12 @@ namespace src.Player
|
||||||
protected void Awake()
|
protected void Awake()
|
||||||
{
|
{
|
||||||
_playerUpgrade = gameObject.AddComponent<PlayerUpgrade>();
|
_playerUpgrade = gameObject.AddComponent<PlayerUpgrade>();
|
||||||
|
_bombsUtilManager = gameObject.AddComponent<BombsUtilManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Start()
|
protected void Start()
|
||||||
{
|
{
|
||||||
_gameStateManager = GameStateManager.instance;
|
_gameStateManager = GameStateManager.instance;
|
||||||
_bombsUtil = BombsUtilManager.instance;
|
|
||||||
|
|
||||||
_rigidbody2d = GetComponent<Rigidbody2D>();
|
_rigidbody2d = GetComponent<Rigidbody2D>();
|
||||||
_collider2D = GetComponent<Collider2D>();
|
_collider2D = GetComponent<Collider2D>();
|
||||||
|
@ -152,10 +152,10 @@ namespace src.Player
|
||||||
var absX = Mathf.RoundToInt(position.x);
|
var absX = Mathf.RoundToInt(position.x);
|
||||||
var absY = Mathf.RoundToInt(position.y);
|
var absY = Mathf.RoundToInt(position.y);
|
||||||
var newPosition = new Vector2(absX, absY);
|
var newPosition = new Vector2(absX, absY);
|
||||||
if (!_bombsUtil.CanPlaceBomb(newPosition)) return;
|
if (!_bombsUtilManager.CanPlaceBomb(newPosition)) return;
|
||||||
|
|
||||||
Instantiate(PrefabAtlas.Bomb, newPosition, Quaternion.identity);
|
Instantiate(PrefabAtlas.Bomb, newPosition, Quaternion.identity);
|
||||||
_bombsUtil.RegisterBomb(newPosition);
|
_bombsUtilManager.RegisterBomb(newPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Respawn()
|
public void Respawn()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using src.Base;
|
using src.Base;
|
||||||
|
using src.Managers;
|
||||||
|
|
||||||
namespace src.Upgrade
|
namespace src.Upgrade
|
||||||
{
|
{
|
||||||
|
@ -6,7 +7,7 @@ namespace src.Upgrade
|
||||||
{
|
{
|
||||||
public override void PerformUpgrade()
|
public override void PerformUpgrade()
|
||||||
{
|
{
|
||||||
var bombManager = gameManager.GetBombsUtilManager();
|
var bombManager = _playerToUpgrade.GetComponent<BombsUtilManager>();
|
||||||
bombManager.IncreasePower();
|
bombManager.IncreasePower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using src.Base;
|
using src.Base;
|
||||||
|
using src.Managers;
|
||||||
|
|
||||||
namespace src.Upgrade
|
namespace src.Upgrade
|
||||||
{
|
{
|
||||||
|
@ -6,7 +7,7 @@ namespace src.Upgrade
|
||||||
{
|
{
|
||||||
public override void PerformUpgrade()
|
public override void PerformUpgrade()
|
||||||
{
|
{
|
||||||
var bombManager = gameManager.GetBombsUtilManager();
|
var bombManager = _playerToUpgrade.GetComponent<BombsUtilManager>();
|
||||||
bombManager.IncreaseAllowedBombs();
|
bombManager.IncreaseAllowedBombs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using src.Base;
|
using src.Base;
|
||||||
|
using src.Managers;
|
||||||
|
|
||||||
namespace src.Upgrade
|
namespace src.Upgrade
|
||||||
{
|
{
|
||||||
|
@ -7,7 +8,7 @@ namespace src.Upgrade
|
||||||
{
|
{
|
||||||
public override void PerformUpgrade()
|
public override void PerformUpgrade()
|
||||||
{
|
{
|
||||||
var bombManager = gameManager.GetBombsUtilManager();
|
var bombManager = _playerToUpgrade.GetComponent<BombsUtilManager>();
|
||||||
bombManager.IncreaseAllowedBombs();
|
bombManager.IncreaseAllowedBombs();
|
||||||
bombManager.IncreasePower();
|
bombManager.IncreasePower();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using src.Base;
|
using src.Base;
|
||||||
|
using src.Helpers;
|
||||||
using src.Managers;
|
using src.Managers;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
@ -8,12 +9,10 @@ namespace src.Wall
|
||||||
public class ExitDoor : GameplayComponent
|
public class ExitDoor : GameplayComponent
|
||||||
{
|
{
|
||||||
private GameManager _gameManager;
|
private GameManager _gameManager;
|
||||||
private Collider2D _collider2D;
|
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
_gameManager = GameManager.instance;
|
_gameManager = GameManager.instance;
|
||||||
_collider2D = GetComponent<Collider2D>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Trigger the next level and destroy itself. */
|
/* Trigger the next level and destroy itself. */
|
||||||
|
|
Loading…
Reference in a new issue