Merge branch 'main' of https://gitea.deprived.dev/Sveskejuice/ColorDefense
This commit is contained in:
commit
facd72e73d
File diff suppressed because one or more lines are too long
|
@ -34,7 +34,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 1}
|
||||
m_AnchorMax: {x: 0.5, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -6.8}
|
||||
m_AnchoredPosition: {x: 0, y: -6.800003}
|
||||
m_SizeDelta: {x: 115.1155, y: 25.5046}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!222 &7689507736539613673
|
||||
|
@ -636,7 +636,7 @@ Canvas:
|
|||
m_GameObject: {fileID: 715023913428069073}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 0
|
||||
m_RenderMode: 1
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
|
@ -647,7 +647,7 @@ Canvas:
|
|||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayerID: -767687967
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!114 &4835633829532637798
|
||||
|
@ -1304,6 +1304,7 @@ GameObject:
|
|||
- component: {fileID: 8910208410353961356}
|
||||
- component: {fileID: 5247536788810898341}
|
||||
- component: {fileID: 7089564642283241555}
|
||||
- component: {fileID: 5392333961791742706}
|
||||
m_Layer: 5
|
||||
m_Name: Scrap Text
|
||||
m_TagString: Untagged
|
||||
|
@ -1428,6 +1429,19 @@ MonoBehaviour:
|
|||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!114 &5392333961791742706
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2234419455049360093}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7baabee564ffd2775907492ea319584e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
text: {fileID: 7089564642283241555}
|
||||
--- !u!1 &2480620014458753815
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -2855,7 +2869,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 0.5}
|
||||
m_AnchorMax: {x: 1, y: 0.5}
|
||||
m_AnchoredPosition: {x: 359.99994, y: 0}
|
||||
m_AnchoredPosition: {x: 360, y: 0}
|
||||
m_SizeDelta: {x: 720, y: 1100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8199987074529867173
|
||||
|
@ -3304,7 +3318,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 46.2, y: 47.9}
|
||||
m_AnchoredPosition: {x: 46.19995, y: 47.900024}
|
||||
m_SizeDelta: {x: 100, y: 150}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!222 &63844667557183575
|
||||
|
@ -4651,6 +4665,11 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8630885327163994142, guid: fff998a9abaaf2f43a388f7a721aa1c2,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: -20.599998
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
|
@ -4786,6 +4805,11 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8630885327163994142, guid: fff998a9abaaf2f43a388f7a721aa1c2,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: -20.599998
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
|
@ -4921,6 +4945,11 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8630885327163994142, guid: fff998a9abaaf2f43a388f7a721aa1c2,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: -20.599998
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
|
@ -5056,6 +5085,11 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8630885327163994142, guid: fff998a9abaaf2f43a388f7a721aa1c2,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: -20.599998
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
|
@ -5191,6 +5225,11 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8630885327163994142, guid: fff998a9abaaf2f43a388f7a721aa1c2,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: -20.599998
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
|
|
|
@ -2,9 +2,13 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EnemySpawnManager : MonoBehaviour
|
||||
{
|
||||
public bool HasStarted = false;
|
||||
public bool IsAutoPlaying = false;
|
||||
|
||||
private float time = 0f;
|
||||
[SerializeField] private LevelDefinition levelDefinition;
|
||||
[SerializeField] private EnemyCollection enemyCollection;
|
||||
|
@ -12,11 +16,33 @@ public class EnemySpawnManager : MonoBehaviour
|
|||
[SerializeField] private WaypointPath groundPath;
|
||||
[SerializeField] private WaypointPath skyPath;
|
||||
|
||||
[Header("Buttons")]
|
||||
|
||||
[SerializeField] private Button PlayButton;
|
||||
[SerializeField] private Button AutoPlayButton;
|
||||
|
||||
private Queue<Wave> waveQueue;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
waveQueue = new Queue<Wave>(levelDefinition.Waves);
|
||||
|
||||
if (PlayButton != null)
|
||||
PlayButton.onClick.AddListener(OnPlayButtonClicked);
|
||||
if (AutoPlayButton != null)
|
||||
AutoPlayButton.onClick.AddListener(ToggleAutoPlayClicked);
|
||||
}
|
||||
|
||||
public void OnPlayButtonClicked()
|
||||
{
|
||||
HasStarted = true;
|
||||
time = waveQueue.Peek().spawnTime;
|
||||
PopWave();
|
||||
}
|
||||
|
||||
public void ToggleAutoPlayClicked()
|
||||
{
|
||||
IsAutoPlaying = !IsAutoPlaying;
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
@ -26,7 +52,8 @@ public class EnemySpawnManager : MonoBehaviour
|
|||
return;
|
||||
}
|
||||
|
||||
time += Time.deltaTime;
|
||||
if (HasStarted && IsAutoPlaying)
|
||||
time += Time.deltaTime;
|
||||
|
||||
if (waveQueue.Peek().spawnTime < time)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@ using UnityEngine;
|
|||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public float Balance = 0;
|
||||
public Observer<float> Balance = new(500f);
|
||||
public static GameManager Instance;
|
||||
|
||||
public bool IsBuildMode = false;
|
||||
|
|
|
@ -28,6 +28,16 @@ public class MoneyManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// TODO: move to observer patter idgaf rn
|
||||
for (int i = 0; i < MoneyTexts.Length; i++)
|
||||
{
|
||||
float price = towerCollection.Towers[i].price;
|
||||
MoneyTexts[i].color = GameManager.Instance.Balance.Value >= price ? Color.green : Color.red;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Show prices
|
||||
|
@ -40,7 +50,11 @@ public class MoneyManager : MonoBehaviour
|
|||
private void OnShopButtonClicked(int index)
|
||||
{
|
||||
Assert.AreNotEqual(index, -1, "Shop button not init-ed with index");
|
||||
TowerInfo info = towerCollection.Towers[index];
|
||||
|
||||
OnShopSelected?.Invoke(towerCollection.Towers[index]);
|
||||
if (GameManager.Instance.Balance >= info.price)
|
||||
{
|
||||
OnShopSelected?.Invoke(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,10 +88,14 @@ public class TowerPlacementManager : MonoBehaviour
|
|||
|
||||
public void OnSlotClicked(SlotManager slot, GridManager grid, int x, int y)
|
||||
{
|
||||
slot.gameObject.GetComponentInChildren<Renderer>().material.color = Color.blue;
|
||||
if (GameManager.Instance.Balance.Value < SelectedTowerInfo.price) return; // cant afford
|
||||
|
||||
// slot.gameObject.GetComponentInChildren<Renderer>().material.color = Color.blue;
|
||||
OnSelectSlot(slot);
|
||||
|
||||
SpawnTowerAtSelected(SelectedTowerPrefab);
|
||||
Debug.Log("TAX");
|
||||
GameManager.Instance.Balance.Value -= SelectedTowerInfo.price;
|
||||
}
|
||||
|
||||
// Called when a slot is selected
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class BalanceDisplay : MonoBehaviour
|
||||
{
|
||||
public TMP_Text text;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// idgaf
|
||||
UpdateText(GameManager.Instance.Balance.Value);
|
||||
}
|
||||
|
||||
private void UpdateText(float balance)
|
||||
{
|
||||
text.text = $"$ {balance}";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7baabee564ffd2775907492ea319584e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue