mirror of
https://github.com/ryzij/Cube-Tower-Defense.git
synced 2026-07-14 01:56:57 +00:00
Добавил возможность удалять путь во время строительства
This commit is contained in:
@@ -14184,6 +14184,84 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 8d6715c95501a4f49bd34c8832850f32, type: 3}
|
m_Script: {fileID: 11500000, guid: 8d6715c95501a4f49bd34c8832850f32, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::BlockScript
|
m_EditorClassIdentifier: Assembly-CSharp::BlockScript
|
||||||
|
--- !u!1001 &1522202350
|
||||||
|
PrefabInstance:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TransformParent: {fileID: 1739395622}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalScale.x
|
||||||
|
value: 0.73
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalScale.y
|
||||||
|
value: 0.73
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalScale.z
|
||||||
|
value: 0.73
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: -1.774
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: -0.71799994
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: -0.506
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 0.7071068
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: -0.7071068
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.y
|
||||||
|
value: -90
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_ConstrainProportionsScale
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2282463062789957701, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
propertyPath: m_Name
|
||||||
|
value: door_1a (1)
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_RemovedGameObjects: []
|
||||||
|
m_AddedGameObjects: []
|
||||||
|
m_AddedComponents: []
|
||||||
|
m_SourcePrefab: {fileID: 100100000, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
--- !u!4 &1522202351 stripped
|
||||||
|
Transform:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 1522202350}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1001 &1543141569
|
--- !u!1001 &1543141569
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -15108,7 +15186,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
value: 1.961
|
value: 1.986
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
- target: {fileID: 1506208594825835263, guid: f43f402f15b1069488b837e6f472a868, type: 3}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
@@ -15919,6 +15997,7 @@ Transform:
|
|||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 692742697}
|
- {fileID: 692742697}
|
||||||
- {fileID: 1642372930}
|
- {fileID: 1642372930}
|
||||||
|
- {fileID: 1522202351}
|
||||||
m_Father: {fileID: 35686721}
|
m_Father: {fileID: 35686721}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!54 &1739395623
|
--- !u!54 &1739395623
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ public class BlockDestoyReward : MonoBehaviour
|
|||||||
_sandPathBuildService.OnBlockDestroy -= OnBlockDestroy;
|
_sandPathBuildService.OnBlockDestroy -= OnBlockDestroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBlockDestroy(BlockScript _)
|
private void OnBlockDestroy(BlockScript block)
|
||||||
{
|
{
|
||||||
_wallet.AddMoney(_reward);
|
if (block.Type == BlockScript.BlockType.Grass)
|
||||||
|
_wallet.AddMoney(_reward);
|
||||||
|
else if (block.Type == BlockScript.BlockType.Sand)
|
||||||
|
_wallet.TakeMoney(_reward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,17 +60,37 @@ public class SandPathBuildService : MonoBehaviour
|
|||||||
{
|
{
|
||||||
var block = _blocksInPath[i];
|
var block = _blocksInPath[i];
|
||||||
Instantiate(_grassBlockPrefab, block.transform.position, block.transform.localRotation, block.transform.parent);
|
Instantiate(_grassBlockPrefab, block.transform.position, block.transform.localRotation, block.transform.parent);
|
||||||
Destroy(block.gameObject);
|
DestroyBlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
_blocksInPath.Clear();
|
_blocksInPath.Clear();
|
||||||
InitBlocks();
|
InitBlocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetLastBlock()
|
||||||
|
{
|
||||||
|
if (_predefinedBlocks.Contains(_currentBlock))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_blocksInPath.Remove(_currentBlock);
|
||||||
|
Instantiate(_grassBlockPrefab,
|
||||||
|
_currentBlock.transform.position,
|
||||||
|
_currentBlock.transform.localRotation,
|
||||||
|
_currentBlock.transform.parent);
|
||||||
|
DestroyBlock(_currentBlock);
|
||||||
|
|
||||||
|
_currentBlock = _blocksInPath.LastOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnBlockDetected(BlockScript block)
|
private void OnBlockDetected(BlockScript block)
|
||||||
{
|
{
|
||||||
if (_gameManager.CurrentState != GameManager.GameState.BuildingPath)
|
if (_gameManager.CurrentState != GameManager.GameState.BuildingPath)
|
||||||
return;
|
return;
|
||||||
|
if (block == _currentBlock)
|
||||||
|
{
|
||||||
|
ResetLastBlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!block.CompareTag("GrassBlock") ||
|
if (!block.CompareTag("GrassBlock") ||
|
||||||
!_currentBlock.GetNeighbors().Contains(block) ||
|
!_currentBlock.GetNeighbors().Contains(block) ||
|
||||||
block.GetNeighbors().Count((o) => o.Type == BlockScript.BlockType.Sand) > 1)
|
block.GetNeighbors().Count((o) => o.Type == BlockScript.BlockType.Sand) > 1)
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ public class GameMenuButtons : MonoBehaviour
|
|||||||
{
|
{
|
||||||
[SerializeField] private GameManager _gameManager;
|
[SerializeField] private GameManager _gameManager;
|
||||||
[SerializeField] private SandPathBuildService _sandPathBuildService;
|
[SerializeField] private SandPathBuildService _sandPathBuildService;
|
||||||
[SerializeField] private Wallet _wallet;
|
|
||||||
[SerializeField] private Button _mainMenuButton;
|
[SerializeField] private Button _mainMenuButton;
|
||||||
[SerializeField] private Button _nextLevelButton;
|
[SerializeField] private Button _nextLevelButton;
|
||||||
[SerializeField] private Button _resetPathButton;
|
[SerializeField] private Button _resetPathButton;
|
||||||
@@ -49,7 +48,6 @@ public class GameMenuButtons : MonoBehaviour
|
|||||||
private void OnResetButtonClick()
|
private void OnResetButtonClick()
|
||||||
{
|
{
|
||||||
_sandPathBuildService.ResetPath();
|
_sandPathBuildService.ResetPath();
|
||||||
_wallet.TakeMoney(_wallet.Money);
|
|
||||||
_gameManager.CurrentState = GameManager.GameState.BuildingPath;
|
_gameManager.CurrentState = GameManager.GameState.BuildingPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user