Implement exit strategy
This commit is contained in:
parent
97b09ec1e5
commit
d3243016f9
19 changed files with 228 additions and 202 deletions
|
@ -10,6 +10,8 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 3243993883904879596}
|
||||
- component: {fileID: 3212428174306319952}
|
||||
- component: {fileID: 3858379993772342456}
|
||||
- component: {fileID: 1949159407646367785}
|
||||
m_Layer: 0
|
||||
m_Name: exitDoorPrefab
|
||||
m_TagString: Untagged
|
||||
|
@ -79,3 +81,41 @@ SpriteRenderer:
|
|||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!114 &3858379993772342456
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1538214466168189615}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d5d5847c8fef4a91bafe88cc2ccf43ec, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!61 &1949159407646367785
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1538214466168189615}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0.5, y: 0.5}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0, y: 0}
|
||||
oldSize: {x: 1, y: 1}
|
||||
newSize: {x: 0.32, y: 0.32}
|
||||
adaptiveTilingThreshold: 0.5
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 0.1, y: 0.8}
|
||||
m_EdgeRadius: 0
|
||||
|
|
|
@ -45,6 +45,8 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 697f5ae5656c74dcd8d7f5d619adb0ac, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
preStageUiPrefab: {fileID: 4994633962466276707, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
--- !u!114 &158905820630581596
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -553,7 +553,7 @@ MonoBehaviour:
|
|||
m_FloatArgument: 1
|
||||
m_StringArgument: Jump
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
m_CallState: 1
|
||||
m_TypeName: UnityEngine.EventSystems.EventTrigger+TriggerEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
delegates:
|
||||
|
|
|
@ -78,7 +78,7 @@ MonoBehaviour:
|
|||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Stage 1
|
||||
m_Text:
|
||||
--- !u!1 &2251350585563921972
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -165,7 +165,7 @@ GameObject:
|
|||
- component: {fileID: 2152024136797500473}
|
||||
- component: {fileID: 936482196064115039}
|
||||
- component: {fileID: 826719949318333507}
|
||||
- component: {fileID: 2684488013186753063}
|
||||
- component: {fileID: 4764158450672019134}
|
||||
m_Layer: 5
|
||||
m_Name: PreStageUI
|
||||
m_TagString: Untagged
|
||||
|
@ -254,7 +254,7 @@ MonoBehaviour:
|
|||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &2684488013186753063
|
||||
--- !u!114 &4764158450672019134
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
|
|
|
@ -271,7 +271,7 @@ Transform:
|
|||
m_Children:
|
||||
- {fileID: 97386695}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &266944717
|
||||
MonoBehaviour:
|
||||
|
@ -404,7 +404,7 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 519420028}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 11.456655, y: -4.0430503, z: -10}
|
||||
m_LocalPosition: {x: 13.828903, y: -4.0430503, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
|
@ -478,137 +478,8 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &1152312890
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 4994633962466276707, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
value: PreStageUI
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 9
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMin.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_Pivot.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7935883257743492533, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_Pivot.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2152024136797500473, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4935993846136593301, guid: 1f5ebc13237e070449ea8bc9e8b07ac8,
|
||||
type: 3}
|
||||
propertyPath: m_Text
|
||||
value:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 1f5ebc13237e070449ea8bc9e8b07ac8, type: 3}
|
||||
--- !u!4 &1352658977 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
|
||||
|
@ -734,7 +605,7 @@ PrefabInstance:
|
|||
- target: {fileID: 158905820630581587, guid: fdaa7451ab31b477b930076bbc888bab,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 6
|
||||
value: 5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 158905820630581587, guid: fdaa7451ab31b477b930076bbc888bab,
|
||||
type: 3}
|
||||
|
@ -882,27 +753,27 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 311312839, guid: 4ca131020414f4b1597dac2e1d292d7f, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8007755715420797612, guid: 4ca131020414f4b1597dac2e1d292d7f,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2219516564249810540, guid: 4ca131020414f4b1597dac2e1d292d7f,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1533625511004221075, guid: 4ca131020414f4b1597dac2e1d292d7f,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7551096532728223647, guid: 4ca131020414f4b1597dac2e1d292d7f,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 4ca131020414f4b1597dac2e1d292d7f, type: 3}
|
||||
|
@ -1099,7 +970,7 @@ PrefabInstance:
|
|||
- target: {fileID: 9082059503774285365, guid: fd1ddd924c55b4f9694b98102c91a0a6,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 4
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9082059503774285365, guid: fd1ddd924c55b4f9694b98102c91a0a6,
|
||||
type: 3}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
using src.Base;
|
||||
using src.Interfaces;
|
||||
using src.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace src.Upgrade
|
||||
namespace src.Base
|
||||
{
|
||||
public class UpgradeBase : GameplayComponent, IUpgrade
|
||||
{
|
||||
protected GameManager gameManager;
|
||||
protected GameManager GameManager;
|
||||
private UpgradeManager _upgradeManager;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
gameManager = GameManager.Instance;
|
||||
GameManager = GameManager.Instance;
|
||||
_upgradeManager = UpgradeManager.Instance;
|
||||
}
|
||||
|
||||
public virtual void PerformUpgrade()
|
||||
|
@ -23,6 +24,7 @@ namespace src.Upgrade
|
|||
{
|
||||
if (!other.CompareTag("Player")) return;
|
||||
PerformUpgrade();
|
||||
_upgradeManager.ClaimUpgrade(gameObject);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections;
|
||||
using src.Helpers;
|
||||
using src.Player;
|
||||
using UnityEngine;
|
||||
|
||||
namespace src.Managers
|
||||
|
@ -10,7 +11,11 @@ namespace src.Managers
|
|||
private LevelManager _levelManager;
|
||||
private UpgradeManager _upgradeManager;
|
||||
private BombsUtilManager _bombsUtilManager;
|
||||
private GameObject _preStageUi;
|
||||
|
||||
// External Components
|
||||
public GameObject preStageUiPrefab;
|
||||
private PlayerController _playerController;
|
||||
private readonly GameStateManager _gameStateManager = GameStateManager.Instance;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
|
@ -26,16 +31,26 @@ namespace src.Managers
|
|||
/* Don't destroy when reloading the scene */
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
// Load inner components
|
||||
_levelManager = GetComponent<LevelManager>();
|
||||
_upgradeManager = GetComponent<UpgradeManager>();
|
||||
_bombsUtilManager = BombsUtilManager.Instance;
|
||||
_preStageUi = GameObject.Find("PreStageUI");
|
||||
|
||||
// Load external components
|
||||
_playerController = GameObject.Find("Player").GetComponent<PlayerController>();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_levelManager.InitBoard();
|
||||
StartLevel();
|
||||
}
|
||||
|
||||
private void StartLevel()
|
||||
{
|
||||
_playerController.Respawn();
|
||||
StartCoroutine(PreInitGame());
|
||||
InitGame();
|
||||
_levelManager.InitLevel();
|
||||
}
|
||||
|
||||
public UpgradeManager GetUpgradeManager()
|
||||
|
@ -47,16 +62,13 @@ namespace src.Managers
|
|||
{
|
||||
return _bombsUtilManager;
|
||||
}
|
||||
|
||||
private void InitGame()
|
||||
{
|
||||
_levelManager.InitLevel();
|
||||
}
|
||||
|
||||
private IEnumerator PreInitGame()
|
||||
{
|
||||
_preStageUi.SetActive(true);
|
||||
var preStageUi = Instantiate(preStageUiPrefab); // Will destroy itself.
|
||||
preStageUi.SetActive(true);
|
||||
yield return new WaitForSeconds(1f);
|
||||
_preStageUi.SetActive(false);
|
||||
Destroy(preStageUi);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
@ -75,5 +87,14 @@ namespace src.Managers
|
|||
ApplicationActions.HandlePauseKey();
|
||||
}
|
||||
}
|
||||
|
||||
public void StartNextLevel()
|
||||
{
|
||||
DebugHelper.LogInfo("Initializing next level!");
|
||||
_levelManager.DestroyLevel();
|
||||
_upgradeManager.DestroyUnclaimedUpgrades();
|
||||
_gameStateManager.IncreaseLevel();
|
||||
StartLevel();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using src.Base;
|
||||
using src.Helpers;
|
||||
using src.Wall;
|
||||
|
@ -63,47 +64,46 @@ namespace src.Managers
|
|||
private const int Rows = 20;
|
||||
|
||||
/* Holds the available positions */
|
||||
private readonly List<Vector3> _freeGridPositions = new List<Vector3>();
|
||||
private readonly List<GameObject> _destructibleWalls = new List<GameObject>();
|
||||
private readonly List<GameObject> _enemies = new List<GameObject>();
|
||||
private readonly List<Vector3> _freeGridPositionsBoard = new List<Vector3>();
|
||||
private List<Vector3> _freeGridPositions;
|
||||
private List<GameObject> _destructibleWalls;
|
||||
private List<GameObject> _enemies;
|
||||
|
||||
private void SetupUpgrades()
|
||||
/* Modifies walls from _destructibleWalls in order to setup upgrades*/
|
||||
private void SetupSpawnables()
|
||||
{
|
||||
var count = _upgradesCount.RandomIntRange();
|
||||
var wallsSize = _destructibleWalls.Count;
|
||||
_destructibleWalls.ShuffleList();
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
if (_destructibleWalls.Count == 0)
|
||||
if (i > wallsSize - 1)
|
||||
{
|
||||
DebugHelper.LogWarning("No destructible walls left, cannot spawn upgrade.");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Get the destructible wall script and make it to spawn the upgrade */
|
||||
var wall = _destructibleWalls.PopRandom().GetComponent<DestructibleWall>();
|
||||
var wall = _destructibleWalls[i].GetComponent<DestructibleWall>();
|
||||
DebugHelper.LogInfo($"Spawned upgrade at: x:{wall.XCoordinate} y:{wall.YCoordinate}");
|
||||
wall.SpawnsUpgrade();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupExit()
|
||||
{
|
||||
if (_destructibleWalls.Count == 0)
|
||||
|
||||
if (count > wallsSize - 2)
|
||||
{
|
||||
Debug.LogWarning("No destructible walls found, cannot spawn exit!");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the destructible wall script and make it to spawn the exit */
|
||||
var wall = _destructibleWalls.PopRandom().GetComponent<DestructibleWall>();
|
||||
DebugHelper.LogInfo($"Spawned exit at: x:{wall.XCoordinate} y:{wall.YCoordinate}");
|
||||
wall.SpawnsExit();
|
||||
|
||||
var exitWall = _destructibleWalls[count + 1].GetComponent<DestructibleWall>();
|
||||
DebugHelper.LogInfo($"Spawned exit at: x:{exitWall.XCoordinate} y:{exitWall.YCoordinate}");
|
||||
exitWall.SpawnsExit();
|
||||
}
|
||||
|
||||
/* Place the indestructible tiles on the board and saves the
|
||||
* unused positions in a list. */
|
||||
private void InitBoard()
|
||||
public void InitBoard()
|
||||
{
|
||||
_freeGridPositions.Clear();
|
||||
/* We want to iterate over the X axis taking into consideration the startPosition's offset */
|
||||
for (var x = startPosition.position.x; x < Columns; x++)
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ namespace src.Managers
|
|||
}
|
||||
|
||||
/* Add position to _gridPositions */
|
||||
_freeGridPositions.Add(new Vector3(x, y, 0f));
|
||||
_freeGridPositionsBoard.Add(new Vector3(x, y, 0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,18 +143,18 @@ namespace src.Managers
|
|||
/* Randomly places destructible tiles on the level. */
|
||||
private void SetupLevelDestructibleWalls()
|
||||
{
|
||||
var numberOfDestructilbeWallsToPlace = _destructibleWallCount.RandomIntRange();
|
||||
var numberOfWallsRemaining = _destructibleWallCount.RandomIntRange();
|
||||
List<Vector3> usedPositions = new List<Vector3>();
|
||||
_freeGridPositions.ShuffleList();
|
||||
foreach (var nextPosition in _freeGridPositions)
|
||||
{
|
||||
if (numberOfDestructilbeWallsToPlace == 0)
|
||||
if (numberOfWallsRemaining == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
usedPositions.Add(nextPosition);
|
||||
PlaceDestructibleTile(nextPosition);
|
||||
numberOfDestructilbeWallsToPlace -= 1;
|
||||
numberOfWallsRemaining -= 1;
|
||||
}
|
||||
foreach (var usedPosition in usedPositions)
|
||||
{
|
||||
|
@ -164,7 +164,8 @@ namespace src.Managers
|
|||
|
||||
private void PlaceDestructibleTile(Vector3 position)
|
||||
{
|
||||
DebugHelper.LogInfo($"PlaceDestructibleTile: x:{position.x} y:{position.y}");
|
||||
// TODO ADD ENUMS AND DEFINES TO THE LOGGING SYSTEM
|
||||
// DebugHelper.LogInfo($"PlaceDestructibleTile: x:{position.x} y:{position.y}");
|
||||
var randomWall = destructibleWallPrefabs.ChoseRandom();
|
||||
var instance = Instantiate(randomWall, position, Quaternion.identity);
|
||||
_destructibleWalls.Add(instance);
|
||||
|
@ -173,7 +174,7 @@ namespace src.Managers
|
|||
|
||||
private bool PlaceIndestructibleTile(float x, float y)
|
||||
{
|
||||
DebugHelper.LogInfo($"PlaceIndestructibleTile: x:{x} y:{y}");
|
||||
// DebugHelper.LogInfo($"PlaceIndestructibleTile: x:{x} y:{y}");
|
||||
var absX = Mathf.RoundToInt(x);
|
||||
var absY = Mathf.RoundToInt(y);
|
||||
|
||||
|
@ -207,7 +208,7 @@ namespace src.Managers
|
|||
|
||||
private bool PlaceEnemy(Vector3 position)
|
||||
{
|
||||
DebugHelper.LogInfo($"PlaceEnemy: x:{position.x} y:{position.y}");
|
||||
// DebugHelper.LogInfo($"PlaceEnemy: x:{position.x} y:{position.y}");
|
||||
var randomEnemy = enemiesPrefab.ChoseRandom();
|
||||
var instance = Instantiate(randomEnemy, position, Quaternion.identity);
|
||||
_enemies.Add(instance);
|
||||
|
@ -218,11 +219,26 @@ namespace src.Managers
|
|||
/* Initializes the level. */
|
||||
public void InitLevel()
|
||||
{
|
||||
InitBoard();
|
||||
_freeGridPositions = new List<Vector3>(_freeGridPositionsBoard);
|
||||
_destructibleWalls = new List<GameObject>();
|
||||
_enemies = new List<GameObject>();
|
||||
SetupLevelDestructibleWalls();
|
||||
SetupLevelEnemies();
|
||||
SetupExit();
|
||||
SetupUpgrades();
|
||||
SetupSpawnables();
|
||||
}
|
||||
|
||||
public void DestroyLevel()
|
||||
{
|
||||
foreach (var enemy in _enemies)
|
||||
{
|
||||
Destroy(enemy);
|
||||
}
|
||||
|
||||
foreach (var wall in _destructibleWalls)
|
||||
{
|
||||
Destroy(wall);
|
||||
}
|
||||
DebugHelper.LogInfo("LevelManager: Cleared level!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using src.Base;
|
||||
using src.Helpers;
|
||||
using UnityEngine;
|
||||
|
@ -6,11 +8,45 @@ namespace src.Managers
|
|||
{
|
||||
public class UpgradeManager : GameplayComponent
|
||||
{
|
||||
public static UpgradeManager Instance;
|
||||
private List<GameObject> _unclaimedUpgrades = new List<GameObject>();
|
||||
public GameObject[] upgradePrefabs;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
else if (Instance != null)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject GetUpgradePrefab()
|
||||
{
|
||||
return upgradePrefabs.ChoseRandom();
|
||||
}
|
||||
|
||||
/* Register unclaimed upgrades so then can be destroyed on level changed or other events. */
|
||||
public void RegisterUpgradeAsUnclaimed(GameObject instance)
|
||||
{
|
||||
_unclaimedUpgrades.Add(instance);
|
||||
}
|
||||
|
||||
public void ClaimUpgrade(GameObject instance)
|
||||
{
|
||||
_unclaimedUpgrades.Remove(instance);
|
||||
}
|
||||
|
||||
public void DestroyUnclaimedUpgrades()
|
||||
{
|
||||
foreach (var upgrade in _unclaimedUpgrades)
|
||||
{
|
||||
Destroy(upgrade);
|
||||
}
|
||||
_unclaimedUpgrades = new List<GameObject>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,10 +29,6 @@ namespace src.Player
|
|||
|
||||
movementSpeed = _playerUpgrade.GetMovementSpeed();
|
||||
_playerUpgrade.PlayerSpeed += IncreaseSpeed;
|
||||
|
||||
|
||||
/* Always start at the starting point. */
|
||||
Respawn();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
|
@ -106,9 +102,11 @@ namespace src.Player
|
|||
#endif
|
||||
}
|
||||
|
||||
private void Respawn()
|
||||
public void Respawn()
|
||||
{
|
||||
DebugHelper.LogInfo("Player is respawning!");
|
||||
transform.SetPositionAndRotation(_respawnPosition.position, Quaternion.identity);
|
||||
_animator.Play("IdleDown");
|
||||
}
|
||||
|
||||
public void OnTriggerExit2D(Collider2D other)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
using src.Base;
|
||||
using src.Managers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace src.UI
|
||||
{
|
||||
public class PreLevelLoad : MonoBehaviour
|
||||
public class PreStageUiScript : GameplayComponent
|
||||
{
|
||||
private readonly GameStateManager _gameStateManager = GameStateManager.Instance;
|
||||
private Text _stageText;
|
|
@ -1,10 +1,12 @@
|
|||
using src.Base;
|
||||
|
||||
namespace src.Upgrade
|
||||
{
|
||||
public class BombFlamesUpgrade : UpgradeBase
|
||||
{
|
||||
public override void PerformUpgrade()
|
||||
{
|
||||
var bombManager = gameManager.GetBombsUtilManager();
|
||||
var bombManager = GameManager.GetBombsUtilManager();
|
||||
bombManager.IncreasePower();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
using src.Base;
|
||||
|
||||
namespace src.Upgrade
|
||||
{
|
||||
public class BombPlacementUpgrade : UpgradeBase
|
||||
{
|
||||
public override void PerformUpgrade()
|
||||
{
|
||||
var bombManager = gameManager.GetBombsUtilManager();
|
||||
var bombManager = GameManager.GetBombsUtilManager();
|
||||
bombManager.IncreaseAllowedBombs();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using src.Base;
|
||||
using src.Player;
|
||||
|
||||
namespace src.Upgrade
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace src.Wall
|
|||
public float XCoordinate => transform.position.x;
|
||||
public float YCoordinate => transform.position.y;
|
||||
|
||||
private void BeforeDestroy()
|
||||
private void SpawnSomething()
|
||||
{
|
||||
var currentPosition = transform.position;
|
||||
Destroy(GetComponent<SpriteRenderer>());
|
||||
|
@ -50,12 +50,12 @@ namespace src.Wall
|
|||
{
|
||||
DebugHelper.LogInfo($"Destructible spawned upgrade {transform.position}");
|
||||
var upgrade = _upgradeManager.GetUpgradePrefab();
|
||||
Instantiate(upgrade, currentPosition, Quaternion.identity);
|
||||
var instance = Instantiate(upgrade, currentPosition, Quaternion.identity);
|
||||
_upgradeManager.RegisterUpgradeAsUnclaimed(instance);
|
||||
}
|
||||
SwapToPulverise();
|
||||
}
|
||||
|
||||
private void SwapToPulverise()
|
||||
private void PlayDestroyAnimation()
|
||||
{
|
||||
// _animator.speed = 10;
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ namespace src.Wall
|
|||
public void onExplosion()
|
||||
{
|
||||
DebugHelper.LogInfo($"Destructible wall hit by explosion {transform.position}");
|
||||
BeforeDestroy();
|
||||
PlayDestroyAnimation();
|
||||
SpawnSomething();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
|
30
Assets/Scripts/src/Wall/ExitDoor.cs
Normal file
30
Assets/Scripts/src/Wall/ExitDoor.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using src.Base;
|
||||
using src.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace src.Wall
|
||||
{
|
||||
public class ExitDoor : GameplayComponent
|
||||
{
|
||||
private GameManager _gameManager;
|
||||
private Collider2D _collider2D;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_gameManager = GameManager.Instance;
|
||||
_collider2D = GetComponent<Collider2D>();
|
||||
}
|
||||
|
||||
/* Trigger the next level and destroy itself. */
|
||||
private void OnTriggerStay2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag("Player"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Destroy(this);
|
||||
_gameManager.StartNextLevel();
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/src/Wall/ExitDoor.cs.meta
Normal file
3
Assets/Scripts/src/Wall/ExitDoor.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d5d5847c8fef4a91bafe88cc2ccf43ec
|
||||
timeCreated: 1563024607
|
|
@ -591,9 +591,9 @@ PlayerSettings:
|
|||
webGLThreadsSupport: 0
|
||||
scriptingDefineSymbols:
|
||||
1: CROSS_PLATFORM_INPUT
|
||||
4: CROSS_PLATFORM_INPUT;MOBILE_INPUT
|
||||
7: CROSS_PLATFORM_INPUT;MOBILE_INPUT
|
||||
14: MOBILE_INPUT
|
||||
4: CROSS_PLATFORM_INPUT
|
||||
7: CROSS_PLATFORM_INPUT
|
||||
14:
|
||||
platformArchitecture: {}
|
||||
scriptingBackend: {}
|
||||
il2cppCompilerConfiguration: {}
|
||||
|
|
Loading…
Reference in a new issue