Compare commits

...

2 Commits

Author SHA1 Message Date
Stedd f89ab59fdf Changed to using Runtime sets
Handlers are now using runtime sets instead of owning lists.
Entities that are instantiated assign themselves to their respective Runtime sets.

Heavily inspired by:
https://www.youtube.com/watch?v=raQ3iHhE_Kk
https://github.com/roboryantron/Unite2017
2022-10-01 17:59:06 +02:00
Stedd 4151ba0050 Project cleanup 2022-10-01 13:31:32 +02:00
79 changed files with 1348 additions and 664 deletions

1
.gitignore vendored
View File

@ -73,3 +73,4 @@ crashlytics-build.properties
/[Aa]ssets/[Ss]treamingAssets/aa/* /[Aa]ssets/[Ss]treamingAssets/aa/*
game_notes/.obsidian game_notes/.obsidian
.idea/.idea.AsteroidGame/.idea/dictionaries

View File

@ -2,13 +2,12 @@
"name": "AsteroidGame", "name": "AsteroidGame",
"rootNamespace": "AsteroidGame", "rootNamespace": "AsteroidGame",
"references": [ "references": [
"GUID:bc7863ca0989b494d84426bfd28432fa",
"GUID:6055be8ebefd69e48b49212b09b47b2f", "GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:5041af1ee0cf75e4a9a52f5f23a0bfae", "GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:857695c8a9ee988459c9b50e4e75e660", "GUID:f008ecc6829887e478aeb5eb004eb01b",
"GUID:17a5862fcd6383b4b97bad4dcb1e2e5d", "GUID:17a5862fcd6383b4b97bad4dcb1e2e5d",
"GUID:f26d68a0bdefa1043b120b820f55e190", "GUID:f26d68a0bdefa1043b120b820f55e190",
"GUID:75469ad4d38634e559750d17036d5f7c" "GUID:eb3099ff524d60545a136315a154d67b"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View File

@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1260fd8b7346bdf41a685d24b968a231, type: 3}
m_Name: AvailableEnemies
m_EditorClassIdentifier:
_list: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 00c435d92e1df55499826c91b4f1e62f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -406,11 +406,14 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a8e2a3a5a069cea4cbe59c093201d8dc, type: 3} m_Script: {fileID: 11500000, guid: a8e2a3a5a069cea4cbe59c093201d8dc, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
health: 0 _health: 0
maxHealth: 0 _maxHealth: 0
isInvulnerable: 0 _isInvulnerable: 0
centerPosition: {fileID: 3291032053430181389} _centerPosition: {fileID: 3291032053430181389}
basePosition: {fileID: 2692714622321691895} _basePosition: {fileID: 2692714622321691895}
_uiFriendlyName: Enemy
_entityBaseSet: {fileID: 11400000, guid: c5542e77624472441a67b1f34e19a116, type: 2}
_enemyBaseSet: {fileID: 11400000, guid: 5f6dc84d75dbd9a459e519de42279066, type: 2}
--- !u!1 &6940800288144322101 --- !u!1 &6940800288144322101
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -1,10 +1,21 @@
using System;
using UnityEngine; using UnityEngine;
namespace AsteroidGame.Entities.Enemies.Scripts namespace AsteroidGame.Entities
{ {
public class EnemyBase : EntityBase public class EnemyBase : EntityBase
{ {
[SerializeField] private SEnemyBaseRuntimeSet _enemyBaseSet;
protected override void OnEnable()
{
base.OnEnable();
_enemyBaseSet.Add(this);
}
protected override void OnDisable()
{
base.OnDisable();
_enemyBaseSet.Remove(this);
}
} }
} }

View File

@ -1,4 +1,3 @@
using AsteroidGame.Entities.Structures.Tower;
using UnityEngine; using UnityEngine;
namespace AsteroidGame.Entities.Enemies.Scripts namespace AsteroidGame.Entities.Enemies.Scripts
@ -10,23 +9,23 @@ namespace AsteroidGame.Entities.Enemies.Scripts
// [SerializeField] ScoreHandler scoreHandler; // [SerializeField] ScoreHandler scoreHandler;
[Header("Parameters")] [Header("Parameters")]
[SerializeField] int maxHealth = 5; [SerializeField] int _maxHealth = 5;
[SerializeField] int difficultyRamp = 1; [SerializeField] int _difficultyRamp = 1;
[SerializeField] int wealthValue = 5; [SerializeField] int _wealthValue = 5;
[Header("Stats")] [Header("Stats")]
[SerializeField] int currentHealth; [SerializeField] int _currentHealth;
#region Public #region Public
public int Health { get=> currentHealth;} public int Health { get=> _currentHealth;}
#endregion #endregion
void OnEnable() void OnEnable()
{ {
// enemyHandler = FindObjectOfType<EnemyHandler>(); // enemyHandler = FindObjectOfType<EnemyHandler>();
// scoreHandler = FindObjectOfType<ScoreHandler>(); // scoreHandler = FindObjectOfType<ScoreHandler>();
currentHealth = maxHealth; _currentHealth = _maxHealth;
} }
private void OnParticleCollision(GameObject damager) private void OnParticleCollision(GameObject damager)
@ -39,11 +38,11 @@ namespace AsteroidGame.Entities.Enemies.Scripts
// SpawnFX(damageVFX); // SpawnFX(damageVFX);
// Debug.Log(damager.GetComponentInParent<Tower>().GetDamage()); // Debug.Log(damager.GetComponentInParent<Tower>().GetDamage());
currentHealth -= damager.GetComponentInParent<Turret>().Damage; _currentHealth -= damager.GetComponentInParent<Turret>().Damage;
//UpdateHealthText(health); //UpdateHealthText(health);
if(currentHealth <= 0) if(_currentHealth <= 0)
{ {
ProcessDeathFrom(damager); ProcessDeathFrom(damager);
} }
@ -58,7 +57,7 @@ namespace AsteroidGame.Entities.Enemies.Scripts
// enemyHandler.RemoveEnemy(gameObject); // enemyHandler.RemoveEnemy(gameObject);
// Destroy(gameObject); // Destroy(gameObject);
gameObject.SetActive(false); gameObject.SetActive(false);
maxHealth += difficultyRamp; _maxHealth += _difficultyRamp;
} }
} }
} }

View File

@ -6,19 +6,19 @@ namespace AsteroidGame.Entities.Enemies
public class EnemyMovement : MonoBehaviour public class EnemyMovement : MonoBehaviour
{ {
[Header("Parameters")] [Header("Parameters")]
[SerializeField] [Range(0f, 5f)] float speed = 1f; [SerializeField] [Range(0f, 5f)] float _speed = 1f;
[SerializeField] int damage = 1; [SerializeField] int _damage = 1;
// [SerializeField] EnemyHandler enemyHandler; // [SerializeField] EnemyHandler enemyHandler;
// [SerializeField] ScoreHandler scoreHandler; // [SerializeField] ScoreHandler scoreHandler;
Vector3 startPosition; Vector3 _startPosition;
Vector3 endPosition; Vector3 _endPosition;
float travelPercent = 0f; float _travelPercent = 0f;
private IEnumerator followPath; private IEnumerator _followPath;
void Awake() void Awake()
{ {
@ -35,10 +35,10 @@ namespace AsteroidGame.Entities.Enemies
void RecalculatePath() void RecalculatePath()
{ {
if (followPath != null) if (_followPath != null)
{ {
//Debug.Log("Stopping Coroutine"); //Debug.Log("Stopping Coroutine");
StopCoroutine(followPath); StopCoroutine(_followPath);
} }
} }
@ -52,9 +52,9 @@ namespace AsteroidGame.Entities.Enemies
gameObject.SetActive(false); gameObject.SetActive(false);
} }
private Vector3 GetVector3(Vector2Int _coord) private Vector3 GetVector3(Vector2Int coord)
{ {
return new Vector3((float)_coord.x, 0f, (float)_coord.y) * 10f; return new Vector3((float)coord.x, 0f, (float)coord.y) * 10f;
} }
} }

View File

@ -2,7 +2,8 @@
"name": "Entities", "name": "Entities",
"rootNamespace": "AsteroidGame", "rootNamespace": "AsteroidGame",
"references": [ "references": [
"GUID:17a5862fcd6383b4b97bad4dcb1e2e5d" "GUID:17a5862fcd6383b4b97bad4dcb1e2e5d",
"GUID:eb3099ff524d60545a136315a154d67b"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View File

@ -6,78 +6,70 @@ namespace AsteroidGame.Entities
public class EntityBase : MonoBehaviour, IDamageable, ITargetable public class EntityBase : MonoBehaviour, IDamageable, ITargetable
{ {
[Header("Health")] [Header("Health")]
[SerializeField] protected int health; [SerializeField] protected int _health;
[SerializeField] protected int maxHealth; [SerializeField] protected int _maxHealth;
[SerializeField] protected bool isInvulnerable; [SerializeField] protected bool _isInvulnerable;
[Header("TargetPositions")] [Header("TargetPositions")]
[SerializeField] private Transform centerPosition; [SerializeField] private Transform _centerPosition;
[SerializeField] private Transform basePosition; [SerializeField] private Transform _basePosition;
[Header("UI")] [Header("UI")]
[SerializeField]protected string uiFriendlyName; [SerializeField] protected string _uiFriendlyName;
[Space]
[SerializeField] private SEntityBaseRuntimeSet _entityBaseSet;
#region Props #region Props
public bool IsInvulnerable => isInvulnerable; public bool IsInvulnerable => _isInvulnerable;
public string UiFriendlyName => uiFriendlyName; public string UiFriendlyName => _uiFriendlyName;
#endregion #endregion
protected virtual void OnEnable()
{
_entityBaseSet.Add(this);
}
protected virtual void OnDisable()
{
_entityBaseSet.Remove(this);
}
#region Methods #region Methods
public void ModifyHealth(int healthChange) public void ModifyHealth(int healthChange)
{ {
if (!isInvulnerable) if (!_isInvulnerable)
{ {
health += healthChange; _health += healthChange;
} }
} }
#endregion #endregion
#region Setters #region Setters
public void SetHealth(int newHealth)
{
health = newHealth;
}
public void SetMaxHealth(int newHealth) public void SetHealth(int newHealth) => _health = newHealth;
{
maxHealth = newHealth;
}
public void SetInvulnerable(bool newState) public void SetMaxHealth(int newHealth) => _maxHealth = newHealth;
{
isInvulnerable = newState; public void SetInvulnerable(bool newState) => _isInvulnerable = newState;
}
#endregion #endregion
#region Getters #region Getters
public Vector3 GetCenterPosition() public Vector3 GetCenterPosition() => _centerPosition.transform.position;
{
return centerPosition.transform.position;
}
public Vector3 GetBasePosition() public Vector3 GetBasePosition() => _basePosition.transform.position;
{
return basePosition.transform.position;
}
public int GetHealth()
{
return health;
}
public int GetMaxHealth() public int GetHealth() => _health;
{
return maxHealth;
}
public float GetHealthFactor() public int GetMaxHealth() => _maxHealth;
{
// ReSharper disable once PossibleLossOfFraction public float GetHealthFactor() => (float)_health / (float)_maxHealth;
return health / maxHealth;
}
#endregion #endregion
} }

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3b846d413af4ba14ab89d5f44be1a3b7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33f48df2d03212c4986fe2c47c5de796, type: 3}
m_Name: ActiveEnemies
m_EditorClassIdentifier:
_list: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5f6dc84d75dbd9a459e519de42279066
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9da2d6a0206101c47a22881a0ba2ece2, type: 3}
m_Name: ActiveEntities
m_EditorClassIdentifier:
_list: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c5542e77624472441a67b1f34e19a116
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fbc6f67c9903cc8448f793da64d840cf, type: 3}
m_Name: ActiveStructures
m_EditorClassIdentifier:
_list: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bccdf438a1004a444bc24492728d6fbd
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f690b649bafc7be4595cacba515c2c11
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,12 @@
using System.Collections.Generic;
using AsteroidGame.Entities.Enemies.Scripts;
using UnityEngine;
namespace AsteroidGame.Entities
{
[CreateAssetMenu(fileName = "newEnemyList", menuName = "Enemies/EnemyList")]
public class SEnemyBaseList : ScriptableObject
{
public List<EnemyBase> _list;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1260fd8b7346bdf41a685d24b968a231
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,11 @@
using AsteroidGame.Entities.Enemies.Scripts;
using AsteroidGame.ScriptableObjects;
using UnityEngine;
namespace AsteroidGame.Entities
{
[CreateAssetMenu(fileName = "newEnemyBaseRuntimeSet", menuName = "RuntimeSet/EnemyBase")]
public class SEnemyBaseRuntimeSet : SRuntimeSet<EnemyBase>
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 33f48df2d03212c4986fe2c47c5de796
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
using AsteroidGame.ScriptableObjects;
using UnityEngine;
namespace AsteroidGame.Entities
{
[CreateAssetMenu(fileName = "newEntityBaseRuntimeSet", menuName = "RuntimeSet/EntityBase")]
public class SEntityBaseRuntimeSet : SRuntimeSet<EntityBase>
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9da2d6a0206101c47a22881a0ba2ece2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,11 @@
using System.Collections.Generic;
using UnityEngine;
namespace AsteroidGame.Entities
{
[CreateAssetMenu(fileName = "newStructureList", menuName = "Structures/StructureList")]
public class SStructureBaseList : ScriptableObject
{
public List<StructureBase> _structureList;
}
}

View File

@ -0,0 +1,10 @@
using AsteroidGame.ScriptableObjects;
using UnityEngine;
namespace AsteroidGame.Entities
{
[CreateAssetMenu(fileName = "newStructureBaseRuntimeSet", menuName = "RuntimeSet/StructureBase")]
public class SStructureBaseRuntimeSet : SRuntimeSet<StructureBase>
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fbc6f67c9903cc8448f793da64d840cf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
using AsteroidGame.Interfaces;
using UnityEngine;
namespace AsteroidGame.Entities
{
public class SWeaponConfig : ScriptableObject, IWeapon
{
[SerializeField] private float _fireRate;
[SerializeField] private float _damage;
public float FireRate
{
get => _fireRate;
set => _fireRate = value;
}
public float Damage
{
get => _damage;
set => _damage = value;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 19bf3f6dd184a48499aff1db728edfcd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 652265e583504f4479d63342d0afb59d, type: 3}
m_Name: AllStructures
m_EditorClassIdentifier:
_structureList:
- {fileID: 8787361557661825162, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
- {fileID: 5166195223278443568, guid: 57a75520298c47140a928041b05d7f3c, type: 3}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a6bec5a151656ac428c38df1675ee2e4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -12,6 +12,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 652265e583504f4479d63342d0afb59d, type: 3} m_Script: {fileID: 11500000, guid: 652265e583504f4479d63342d0afb59d, type: 3}
m_Name: AvailableStructures m_Name: AvailableStructures
m_EditorClassIdentifier: m_EditorClassIdentifier:
structureList: _structureList:
- {fileID: 8787361557661825162, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - {fileID: 8787361557661825162, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
- {fileID: 5166195223278443568, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - {fileID: 5166195223278443568, guid: 57a75520298c47140a928041b05d7f3c, type: 3}

View File

@ -1,11 +1,6 @@
using AsteroidGame.Entities.Structures.Scripts; namespace AsteroidGame.Entities
using AsteroidGame.Interfaces;
using UnityEngine;
namespace AsteroidGame.Entities.Structures.PowerPlant
{ {
public class PowerPlant : StructureBase public class PowerPlant : StructureBase
{ {
} }
} }

View File

@ -46,19 +46,21 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b5b8b24a2cbe7294c90fb34afeca78e7, type: 3} m_Script: {fileID: 11500000, guid: b5b8b24a2cbe7294c90fb34afeca78e7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
health: 0 _health: 10
maxHealth: 0 _maxHealth: 0
isInvulnerable: 0 _isInvulnerable: 0
centerPosition: {fileID: 0} _centerPosition: {fileID: 1841478903898566568}
basePosition: {fileID: 493861824998956378} _basePosition: {fileID: 493861824998956378}
uiFriendlyName: Power\nPlant _uiFriendlyName: Power\nPlant
cost: 0 _entityBaseSet: {fileID: 11400000, guid: c5542e77624472441a67b1f34e19a116, type: 2}
buildPlacementBlocked: 0 _cost: 100
buildTimer: 0 _buildPlacementBlocked: 0
isPowerGenerator: 1 _buildTimer: 0
isPowerConsumer: 0 _isGenerator: 1
maxPower: 100 _isConsumer: 0
currentPower: 0 _maxPower: 100
_currentPower: 0
_structureBaseSet: {fileID: 11400000, guid: bccdf438a1004a444bc24492728d6fbd, type: 2}
--- !u!1 &1863277996181035512 --- !u!1 &1863277996181035512
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -0,0 +1,28 @@
using UnityEngine;
using UnityEngine.Serialization;
namespace AsteroidGame.Entities
{
public class Disabler : MonoBehaviour
{
[FormerlySerializedAs("Set")]
[SerializeField] private SStructureBaseRuntimeSet _set;
[ContextMenu("Disable All")]
public void DisableAll()
{
// Loop backwards since the list may change when disabling
for (int i = _set._list.Count - 1; i >= 0; i--)
{
_set._list[i].gameObject.SetActive(false);
}
}
[ContextMenu("Disable Random")]
public void DisableRandom()
{
int index = Random.Range(0, _set._list.Count);
_set._list[index].gameObject.SetActive(false);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f60f8a4b6b214b04083229f46bf1170b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,89 +1,85 @@
using System;
using AsteroidGame.Interfaces; using AsteroidGame.Interfaces;
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
namespace AsteroidGame.Entities.Structures.Scripts namespace AsteroidGame.Entities
{ {
public class StructureBase : EntityBase, IBuildable, IPowerSystem public class StructureBase : EntityBase, IBuildable, IPowerSystem
{ {
[Header("BuildParameters")] [Header("BuildParameters")]
[SerializeField] [SerializeField] protected int _cost;
protected int cost; [SerializeField] private bool _buildPlacementBlocked;
[SerializeField] protected float _buildTimer;
[SerializeField] private bool buildPlacementBlocked;
[SerializeField] protected float buildTimer;
[Header("Power")] [Header("Power")]
[SerializeField] protected bool isPowerGenerator; [SerializeField] protected bool _isGenerator;
[SerializeField] protected bool isPowerConsumer; [SerializeField] protected bool _isConsumer;
[SerializeField] protected int maxPower; [SerializeField] protected int _maxPower;
[SerializeField] protected int currentPower; [SerializeField] protected int _currentPower;
[Header("Configuration")]
[SerializeField] private SStructureBaseRuntimeSet _structureBaseSet;
#region Private #region Private
#endregion #endregion
#region Publics #region Publics
public bool IsPowerGenerator => isPowerGenerator;
public bool IsPowerConsumer => isPowerConsumer; public bool IsGenerator => _isGenerator;
public bool BuildPlacementBlocked => buildPlacementBlocked; public bool IsConsumer => _isConsumer;
public int Cost => cost; public bool BuildPlacementBlocked => _buildPlacementBlocked;
#endregion #endregion
private void OnEnable() protected override void OnEnable()
{ {
if (!isPowerConsumer && !isPowerGenerator) base.OnEnable();
if (!_isConsumer && !_isGenerator)
{ {
Debug.Log("Power consumer/generator not set!"); Debug.LogWarning("Power consumer/generator not set!");
} }
_structureBaseSet.Add(this);
}
protected override void OnDisable()
{
base.OnDisable();
_structureBaseSet.Remove(this);
} }
private void OnTriggerStay(Collider other) private void OnTriggerStay(Collider other)
{ {
if(other.name == "BuildCollider") if (other.name == "BuildCollider")
{ {
buildPlacementBlocked = true; _buildPlacementBlocked = true;
} }
} }
private void OnTriggerExit(Collider other) private void OnTriggerExit(Collider other)
{ {
if(other.name == "BuildCollider") if (other.name == "BuildCollider")
{ {
buildPlacementBlocked = false; _buildPlacementBlocked = false;
} }
} }
#region Setters #region Setters
public void SetMaxPower(int newValue) public void SetMaxPower(int newValue) => _maxPower = newValue;
{ public int SetCost(int newCost) => _cost = newCost;
maxPower = newValue;
}
#endregion #endregion
#region Getters #region Getters
public int GetMaxPower() public int GetMaxPower() => _maxPower;
{
return maxPower;
}
public int GetCurrentPower() public int GetCurrentPower() => _currentPower;
{
return currentPower;
}
public float GetPowerFactor() public float GetPowerFactor() => (float)_currentPower / _maxPower;
{
// ReSharper disable once PossibleLossOfFraction public int GetCost() => _cost;
return currentPower / maxPower;
}
#endregion #endregion
} }

View File

@ -1,27 +0,0 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace AsteroidGame.Entities.Structures.Scripts
{
public class StructureBaseScriptableObject : ScriptableObject
{
public List<StructureBase> structureList;
}
// public static class MakeScriptableObject
// {
// [MenuItem("Assets/Create/ScriptableObject:AvailableStructures")]
// public static void CreateMyAsset()
// {
// StructureBaseScriptableObject asset = ScriptableObject.CreateInstance<StructureBaseScriptableObject>();
//
// AssetDatabase.CreateAsset(asset, "Assets/Entities/Structures/AvailableStructures.asset");
// AssetDatabase.SaveAssets();
//
// EditorUtility.FocusProjectWindow();
//
// Selection.activeObject = asset;
// }
// }
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e9db218efcae6ef47ac0d9eb96240cb0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,42 +1,38 @@
using AsteroidGame.Entities.Enemies.Scripts; using AsteroidGame.Entities.Enemies.Scripts;
using AsteroidGame.Entities.Structures.Scripts;
using AsteroidGame.Interfaces;
using UnityEngine; using UnityEngine;
namespace AsteroidGame.Entities.Structures.Tower namespace AsteroidGame.Entities
{ {
public class Turret : StructureBase public class Turret : StructureBase
{ {
[Header("WeaponParameters")] [SerializeField] [Header("WeaponParameters")] [SerializeField]
private float weaponRange = 40f; private float _weaponRange = 40f;
[SerializeField] private int damage = 1; [SerializeField] private int _damage = 1;
[SerializeField] private float fireRate = 1; [SerializeField] private float _fireRate = 1;
[SerializeField] private float projectileSpeed = 5; [SerializeField] private float _projectileSpeed = 5;
[SerializeField] private TargetStrategy targetStrategy = TargetStrategy.LowestHealth; [SerializeField] private TargetStrategy _targetStrategy = TargetStrategy.LowestHealth;
[Header("Stats")] [Header("Stats")]
[SerializeField] [SerializeField]
private float score = 0f; private float _score = 0f;
[Header("RigConnections")] [Header("RigConnections")]
[SerializeField] private Transform turretHead; [SerializeField] private Transform _turretHead;
[SerializeField] private Transform barrel; [SerializeField] private Transform _barrel;
#region Privates #region Privates
[Header("Target")]
[SerializeField] private SEnemyBaseRuntimeSet _activeEnemies;
[SerializeField] private EnemyBase _targetEnemy;
[SerializeField] private enum TargetStrategy
[SerializeField]
enum TargetStrategy
{ {
ClosestEnemy, ClosestEnemy,
LowestHealth LowestHealth
}; };
[SerializeField] private EnemyBase targetEnemy; [SerializeField] private Transform[] _buildingParts;
[SerializeField] private Transform[] buildingParts;
#endregion #endregion
@ -46,8 +42,8 @@ namespace AsteroidGame.Entities.Structures.Tower
public int Damage public int Damage
{ {
get => damage; get => _damage;
set => damage = value; set => _damage = value;
} }
public int FireRate { get; set; } public int FireRate { get; set; }
@ -56,22 +52,22 @@ namespace AsteroidGame.Entities.Structures.Tower
private void Awake() private void Awake()
{ {
targetEnemy = FindObjectOfType<EnemyBase>(); _targetEnemy = FindObjectOfType<EnemyBase>();
} }
private void Start() private void Start()
{ {
// enemyHandler = FindObjectOfType<EnemyHandler>(); // enemyHandler = FindObjectOfType<EnemyHandler>();
// scoreHandler = FindObjectOfType<ScoreHandler>(); // scoreHandler = FindObjectOfType<ScoreHandler>();
UpdateWeaponParameters(fireRate, projectileSpeed); UpdateWeaponParameters(_fireRate, _projectileSpeed);
} }
private void Update() private void Update()
{ {
turretHead.transform.LookAt(targetEnemy.GetCenterPosition()); _turretHead.transform.LookAt(_targetEnemy.GetCenterPosition());
} }
private void UpdateWeaponParameters(float _fireRate, float _projectileSpeed) private void UpdateWeaponParameters(float fireRate, float projectileSpeed)
{ {
// var main = _projectile.main; // var main = _projectile.main;
// main.startSpeed = _projectileSpeed; // main.startSpeed = _projectileSpeed;
@ -126,22 +122,5 @@ namespace AsteroidGame.Entities.Structures.Tower
// ShootProjectile(true); // ShootProjectile(true);
// } // }
// } // }
// private void OnTriggerEnter(Collider other)
// {
// print($"TriggerEnter: {other.name}");
// // if(other.name == "BuildCollider")
// // {
// // _buildPlacementBlocked = true;
// // }
// }
//
// private void OnTriggerExit(Collider other)
// {
// print($"TriggerExit: {other.name}");
// // if(other.name == "BuildCollider")
// // {
// // _buildPlacementBlocked = false;
// // }
// }
} }
} }

View File

@ -692,7 +692,7 @@ BoxCollider:
m_IsTrigger: 1 m_IsTrigger: 1
m_Enabled: 1 m_Enabled: 1
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1} m_Size: {x: 1, y: 1.0236204, z: 1}
m_Center: {x: 0, y: 0, z: 0} m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &8704396752535238434 --- !u!1 &8704396752535238434
GameObject: GameObject:
@ -742,26 +742,29 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d3a16cf44e28f02409c23498ed14acf5, type: 3} m_Script: {fileID: 11500000, guid: d3a16cf44e28f02409c23498ed14acf5, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
health: 50 _health: 10
maxHealth: 50 _maxHealth: 0
isInvulnerable: 0 _isInvulnerable: 0
centerPosition: {fileID: 5103935544759496321} _centerPosition: {fileID: 5103935544759496321}
basePosition: {fileID: 8324879816836607384} _basePosition: {fileID: 8324879816836607384}
uiFriendlyName: Turret _uiFriendlyName: Turret
cost: 20 _entityBaseSet: {fileID: 11400000, guid: c5542e77624472441a67b1f34e19a116, type: 2}
buildPlacementBlocked: 0 _cost: 10
buildTimer: 1 _buildPlacementBlocked: 0
isPowerGenerator: 0 _buildTimer: 0
isPowerConsumer: 1 _isGenerator: 0
maxPower: 10 _isConsumer: 1
currentPower: 0 _maxPower: 10
weaponRange: 40 _currentPower: 0
damage: 1 _structureBaseSet: {fileID: 11400000, guid: bccdf438a1004a444bc24492728d6fbd, type: 2}
fireRate: 1 _weaponRange: 40
projectileSpeed: 5 _damage: 1
targetStrategy: 1 _fireRate: 1
score: 0 _projectileSpeed: 5
turretHead: {fileID: 5103935544653627402} _targetStrategy: 1
barrel: {fileID: 5103935545559248087} _score: 0
targetEnemy: {fileID: 0} _turretHead: {fileID: 5103935544653627402}
buildingParts: [] _barrel: {fileID: 5103935545559248087}
_activeEnemies: {fileID: 11400000, guid: 5f6dc84d75dbd9a459e519de42279066, type: 2}
_targetEnemy: {fileID: 0}
_buildingParts: []

View File

@ -1,30 +1,28 @@
using System.Collections.Generic; using AsteroidGame.Entities;
using AsteroidGame.Entities.Structures.Scripts;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
using UnityEngine.Serialization;
namespace AsteroidGame.Handlers namespace AsteroidGame.Handlers
{ {
public class BuildingHandler : HandlerBase public class BuildingHandler : HandlerBase
{ {
[Header("Config")] [Header("Config")]
[SerializeField] private Color colorGhost = new Color(1f, 1f, 1f, 0.12f); [SerializeField] private Color _colorGhost = new Color(1f, 1f, 1f, 0.12f);
[SerializeField] private Color colorBuildingBlocked = new Color(1f, 0f, 0f, 0.12f); [SerializeField] private Color _colorBuildingBlocked = new Color(1f, 0f, 0f, 0.12f);
[SerializeField] private Material ghostStructureMaterial; [SerializeField] private Material _ghostStructureMaterial;
[Header("State")] [Header("State")]
[SerializeField] private bool isBuilding; [SerializeField] private bool _isBuilding;
[SerializeField] private int buildingSelector; [SerializeField] private int _buildingSelector;
[FormerlySerializedAs("_availableStructures")]
[Header("Structures")] [Header("Structures")]
[SerializeField] private StructureBaseScriptableObject availableStructuresObject; [SerializeField] private SStructureBaseList _availableSStructures;
#region Private #region Private
private Color _colorCurrent;
private Dictionary<int, StructureBase> _availableStructures = new();
[SerializeField] private Color colorCurrent;
private Camera _camera; private Camera _camera;
[SerializeField] private List<StructureBase> activeStructures;
private Vector3 _tempVec; private Vector3 _tempVec;
private Plane _buildPlane; private Plane _buildPlane;
private StructureBase _tempStructure; private StructureBase _tempStructure;
@ -36,31 +34,32 @@ namespace AsteroidGame.Handlers
protected override void OnEnable() protected override void OnEnable()
{ {
base.OnEnable(); base.OnEnable();
for (int i = 0; i < availableStructuresObject.structureList.Count; i++) // for (int i = 0; i < _availableStructuresObject._structureList.Count; i++)
{ // {
_availableStructures.Add(i, availableStructuresObject.structureList[i]); // _availableStructures.Add(i, _availableStructuresObject._structureList[i]);
} // }
_camera = Camera.main; _camera = Camera.main;
_buildPlane = new Plane(Vector3.up, Vector3.zero); _buildPlane = new Plane(Vector3.up, Vector3.zero);
activeStructures.Clear(); //_activeStructures.Clear();
} }
private void Update() private void Update()
{ {
if (!isBuilding) return; if (!_isBuilding) return;
_ghostStructure.transform.position = GetPlanePoint(); _ghostStructure.transform.position = GetPlanePoint();
SetGhostColor(_ghostStructure.BuildPlacementBlocked ? colorBuildingBlocked : colorGhost); SetGhostColor(_ghostStructure.BuildPlacementBlocked ? _colorBuildingBlocked : _colorGhost);
} }
private void SetGhostColor(Color newColor) private void SetGhostColor(Color newColor)
{ {
if (newColor == colorCurrent) return; if (newColor == _colorCurrent) return;
foreach (var meshRenderer in _ghostStructureMeshRenderers) foreach (var meshRenderer in _ghostStructureMeshRenderers)
{ {
meshRenderer.material.color = newColor; meshRenderer.material.color = newColor;
} }
colorCurrent = newColor; _colorCurrent = newColor;
} }
protected override void OnLeftClick(InputAction.CallbackContext context) protected override void OnLeftClick(InputAction.CallbackContext context)
@ -75,41 +74,41 @@ namespace AsteroidGame.Handlers
protected override void OnBuild(InputAction.CallbackContext context) protected override void OnBuild(InputAction.CallbackContext context)
{ {
EnterBuildMode(buildingSelector); EnterBuildMode(_buildingSelector);
} }
public void PlaceStructure() private void PlaceStructure()
{ {
if (!isBuilding) return; if (!_isBuilding) return;
if (_ghostStructure.BuildPlacementBlocked) return; if (_ghostStructure.BuildPlacementBlocked) return;
if (!Keyboard.current.shiftKey.isPressed) if (!Keyboard.current.shiftKey.isPressed)
{ {
DestroyGhostStructure(); DestroyGhostStructure();
isBuilding = false; _isBuilding = false;
} }
SpawnStructure(); SpawnStructure();
} }
public void AbortPlaceStructure() private void AbortPlaceStructure()
{ {
if (!isBuilding) return; if (!_isBuilding) return;
DestroyGhostStructure(); DestroyGhostStructure();
isBuilding = false; _isBuilding = false;
} }
public void EnterBuildMode(int index) public void EnterBuildMode(int index)
{ {
if (isBuilding) return; if (_isBuilding) return;
isBuilding = true; _isBuilding = true;
SetBuildingIndex(index); SetBuildingIndex(index);
SpawnGhostStructure(); SpawnGhostStructure();
} }
private void SpawnGhostStructure() private void SpawnGhostStructure()
{ {
_ghostStructure = Instantiate(_availableStructures[buildingSelector], GetPlanePoint(), Quaternion.identity, transform); _ghostStructure = Instantiate(_availableSStructures._structureList[_buildingSelector], GetPlanePoint(), Quaternion.identity,
transform);
_ghostStructure.name = "GhostStructure"; _ghostStructure.name = "GhostStructure";
var rb = _ghostStructure.gameObject.AddComponent<Rigidbody>(); var rb = _ghostStructure.gameObject.AddComponent<Rigidbody>();
@ -119,7 +118,7 @@ namespace AsteroidGame.Handlers
foreach (var meshRenderer in _ghostStructureMeshRenderers) foreach (var meshRenderer in _ghostStructureMeshRenderers)
{ {
meshRenderer.material = ghostStructureMaterial; meshRenderer.material = _ghostStructureMaterial;
} }
_ghostStructure.GetComponent<StructureBase>().enabled = false; _ghostStructure.GetComponent<StructureBase>().enabled = false;
@ -132,8 +131,10 @@ namespace AsteroidGame.Handlers
private void SpawnStructure() private void SpawnStructure()
{ {
_tempStructure = Instantiate(_availableStructures[buildingSelector], GetPlanePoint(), Quaternion.identity, transform); _tempStructure = Instantiate(_availableSStructures._structureList[_buildingSelector], GetPlanePoint(), Quaternion.identity,
activeStructures.Add(_tempStructure); transform);
// _activeStructures.Add(_tempStructure);
// _buildingLists[0].Add(_tempStructure);
} }
#region Getters #region Getters
@ -150,15 +151,15 @@ namespace AsteroidGame.Handlers
return Vector3.zero; return Vector3.zero;
} }
public Dictionary<int, StructureBase> GetAvailableStructures() // public List<StructureBase> GetAvailableStructures()
{ // {
return _availableStructures; // return _availableStructures._structureList;
} // }
public List<StructureBase> GetActiveStructures() // public List<StructureBase> GetActiveStructures()
{ // {
return activeStructures; // return _activeStructures;
} // }
#endregion #endregion
@ -166,10 +167,9 @@ namespace AsteroidGame.Handlers
public void SetBuildingIndex(int index) public void SetBuildingIndex(int index)
{ {
buildingSelector = index; _buildingSelector = index;
} }
#endregion #endregion
} }
} }

View File

@ -0,0 +1,52 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &664620742648054783
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 664620742648054780}
- component: {fileID: 664620742648054781}
m_Layer: 0
m_Name: BuildingHandler
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &664620742648054780
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 664620742648054783}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &664620742648054781
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 664620742648054783}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 51bf353b43f7b2448bbb3088d78ee8a6, type: 3}
m_Name:
m_EditorClassIdentifier:
_colorGhost: {r: 1, g: 1, b: 1, a: 0.12}
_colorBuildingBlocked: {r: 1, g: 0, b: 0, a: 0.12}
_ghostStructureMaterial: {fileID: 2100000, guid: dc919a35edbf85647939132e73b39642, type: 2}
_isBuilding: 0
_buildingSelector: 0
_availableSStructures: {fileID: 11400000, guid: f789f54c47873664284d6e8544724693, type: 2}

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 857695c8a9ee988459c9b50e4e75e660 guid: 3a89f87af6ee84a459d98a4c296dd1be
AssemblyDefinitionImporter: PrefabImporter:
externalObjects: {} externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:

View File

@ -1,46 +1,18 @@
using System.Collections.Generic; using AsteroidGame.Entities;
using UnityEngine; using UnityEngine;
using UnityEngine.Pool;
namespace AsteroidGame.Handlers namespace AsteroidGame.Handlers
{ {
public class EnemyHandler : HandlerBase public class EnemyHandler : HandlerBase
{ {
[Header("Parameters")] [Header("Parameters")]
[SerializeField] [Range(0.1f, 60f)] float spawnRate = 60f; [SerializeField] [Range(0.1f, 60f)] private float _spawnRate = 60f;
[SerializeField] int objectPoolSize = 15; [SerializeField] private int _objectPoolSize = 15;
[Header("Prefabs")] [Header("Configuration")]
[SerializeField] GameObject objectPool; [SerializeField] private SEnemyBaseList _availableEnemies;
[SerializeField] List<GameObject> enemyPrefabs = new List<GameObject>();
[Header("Lists")] [Header("Lists")]
[SerializeField] List<GameObject> enemyPools = new List<GameObject>(); [SerializeField] private SEnemyBaseRuntimeSet _activeEnemies;
[SerializeField] List<GameObject> allEnemies = new List<GameObject>();
private void Start()
{
}
public void AddEnemyToAllEnemies(GameObject _enemy)
{
allEnemies.Add(_enemy);
}
public void RemoveEnemy(GameObject _enemy)
{
allEnemies.Remove(_enemy);
}
public List<GameObject> ReturnAllEnemies()
{
return allEnemies;
}
public void NotifyEnemiesOfNewPath()
{
BroadcastMessage("RecalculatePath", SendMessageOptions.DontRequireReceiver);
}
} }
} }

View File

@ -0,0 +1,50 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5200388201450229077
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5200388201450229074}
- component: {fileID: 5200388201450229075}
m_Layer: 0
m_Name: EnemyHandler
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5200388201450229074
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5200388201450229077}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5200388201450229075
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5200388201450229077}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 62a3dc5f11a44cb4d9faccb4fda8599f, type: 3}
m_Name:
m_EditorClassIdentifier:
_spawnRate: 60
_objectPoolSize: 15
_availableEnemies: {fileID: 11400000, guid: 00c435d92e1df55499826c91b4f1e62f, type: 2}
_activeEnemies: {fileID: 11400000, guid: 5f6dc84d75dbd9a459e519de42279066, type: 2}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 07826307af1971948b98dd42d1e9457a
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,22 +0,0 @@
{
"name": "Handlers",
"rootNamespace": "AsteroidGame",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:f008ecc6829887e478aeb5eb004eb01b",
"GUID:f26d68a0bdefa1043b120b820f55e190",
"GUID:5041af1ee0cf75e4a9a52f5f23a0bfae",
"GUID:bc7863ca0989b494d84426bfd28432fa",
"GUID:17a5862fcd6383b4b97bad4dcb1e2e5d"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,75 +1,59 @@
using System; using System;
using System.Collections.Generic; using AsteroidGame.Entities;
using AsteroidGame.Entities.Structures.Scripts;
using AsteroidGame.Interfaces;
using UnityEngine; using UnityEngine;
using UnityEngine.Pool;
namespace AsteroidGame.Handlers namespace AsteroidGame.Handlers
{ {
public class PowerHandler : HandlerBase public class PowerHandler : HandlerBase
{ {
[Header("State")] [SerializeField] private int powerConsumption; [Header("State")]
[SerializeField] private int powerCapacity; [SerializeField] private int _powerConsumption;
[SerializeField] private float powerFactor; [SerializeField] private int _powerCapacity;
[SerializeField] private float _powerFactor;
[Header("Connections")] [SerializeField] [Header("Connections")]
private BuildingHandler buildingHandler; [SerializeField] private SStructureBaseRuntimeSet _activeStructures;
// [SerializeField] private BuildingHandler buildingHandler;
#region Private
[SerializeField] private List<StructureBase> activeStructures = new();
#endregion
protected override void OnEnable()
{
base.OnEnable();
buildingHandler = FindObjectOfType<BuildingHandler>();
activeStructures = buildingHandler.GetActiveStructures();
}
private void Update() private void Update()
{ {
powerConsumption = 0; _powerConsumption = 0;
powerCapacity = 0; _powerCapacity = 0;
foreach (var structure in activeStructures) foreach (var structure in _activeStructures._list)
{ {
if (structure.IsPowerConsumer) if (structure.IsConsumer)
{ {
powerConsumption += structure.GetMaxPower(); _powerConsumption += structure.GetMaxPower();
} }
if (structure.IsPowerGenerator) if (structure.IsGenerator)
{ {
powerCapacity += structure.GetMaxPower(); _powerCapacity += structure.GetMaxPower();
} }
} }
if (powerCapacity > 0) if (_powerCapacity > 0)
{ {
powerFactor = (float)powerConsumption / (float)powerCapacity; _powerFactor = (float)_powerConsumption / _powerCapacity;
} }
else else
{ {
powerFactor = 0; _powerFactor = 0;
} }
} }
public int GetMaxPower() public int GetMaxPower()
{ {
throw new System.NotImplementedException(); throw new NotImplementedException();
} }
public int GetCurrentPower() public int GetCurrentPower()
{ {
throw new System.NotImplementedException(); throw new NotImplementedException();
} }
public float GetPowerFactor() public float GetPowerFactor()
{ {
throw new System.NotImplementedException(); throw new NotImplementedException();
} }
} }
} }

View File

@ -0,0 +1,50 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5263199550015624125
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5263199550015624126}
- component: {fileID: 5263199550015624127}
m_Layer: 0
m_Name: PowerHandler
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5263199550015624126
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5263199550015624125}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5263199550015624127
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5263199550015624125}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bf720c524a2a9624099d0e4ba3d78108, type: 3}
m_Name:
m_EditorClassIdentifier:
_powerConsumption: 0
_powerCapacity: 0
_powerFactor: 0
_activeStructures: {fileID: 11400000, guid: bccdf438a1004a444bc24492728d6fbd, type: 2}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2e352ad6389b4234083764d15d4e6a5f
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +1,6 @@
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.Serialization;
namespace AsteroidGame.Handlers namespace AsteroidGame.Handlers
{ {
@ -9,41 +8,41 @@ namespace AsteroidGame.Handlers
{ {
[Header("UI")] [Header("UI")]
[SerializeField] [SerializeField]
private TextMeshProUGUI displayBalance; private TextMeshProUGUI _displayBalance;
[Header("Parameters")] [Header("Parameters")]
[SerializeField] [SerializeField]
private int startHealth = 5; private int _startHealth = 5;
[SerializeField] [SerializeField]
private int startBalance = 100; private int _startBalance = 100;
[Header("Stats")] [Header("Stats")]
[SerializeField] [SerializeField]
private int currentHealth; private int _currentHealth;
[SerializeField] [SerializeField]
private int currentBalance; private int _currentBalance;
public int CurrentBalance => currentBalance; public int CurrentBalance => _currentBalance;
private void Start() private void Start()
{ {
currentHealth = startHealth; _currentHealth = _startHealth;
currentBalance = startBalance; _currentBalance = _startBalance;
UpdateGUI(); UpdateGUI();
} }
public void ModifyHealth(GameObject enemy) public void ModifyHealth(GameObject enemy)
{ {
currentHealth -= 1; _currentHealth -= 1;
CheckIfYouLost(); CheckIfYouLost();
} }
public void ModifyHealth(int amount) public void ModifyHealth(int amount)
{ {
currentHealth += amount; _currentHealth += amount;
CheckIfYouLost(); CheckIfYouLost();
} }
private void CheckIfYouLost(){ private void CheckIfYouLost(){
if(currentHealth <= 0) if(_currentHealth <= 0)
{ {
Debug.Log("You lost"); Debug.Log("You lost");
Reload(); Reload();
@ -51,7 +50,7 @@ namespace AsteroidGame.Handlers
} }
public void ModifyWealth(int amount){ public void ModifyWealth(int amount){
currentBalance += amount; _currentBalance += amount;
UpdateGUI(); UpdateGUI();
// Debug.Log($"Wealth modification. Change:{_amount}. Current: {wealthAmount}"); // Debug.Log($"Wealth modification. Change:{_amount}. Current: {wealthAmount}");
} }
@ -63,7 +62,7 @@ namespace AsteroidGame.Handlers
} }
private void UpdateGUI(){ private void UpdateGUI(){
displayBalance.text = $"Gold: {currentBalance.ToString()}"; _displayBalance.text = $"Gold: {_currentBalance.ToString()}";
} }
} }

View File

@ -2,6 +2,7 @@ namespace AsteroidGame.Interfaces
{ {
public interface IBuildable public interface IBuildable
{ {
public int GetCost();
public int SetCost(int newCost);
} }
} }

View File

@ -2,9 +2,9 @@ namespace AsteroidGame.Interfaces
{ {
public interface IPowerSystem public interface IPowerSystem
{ {
public bool IsPowerGenerator { get; } public bool IsGenerator { get; }
public bool IsPowerConsumer { get; } public bool IsConsumer { get; }
public void SetMaxPower(int newValue); public void SetMaxPower(int newValue);

View File

@ -0,0 +1,8 @@
namespace AsteroidGame.Interfaces
{
public interface IWeapon
{
public float FireRate { get; set; }
public float Damage { get; set; }
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a4d06a75a5a64c83aa191a8610f5080f
timeCreated: 1664621279

View File

@ -153,8 +153,9 @@ Transform:
m_Children: m_Children:
- {fileID: 1047643964} - {fileID: 1047643964}
- {fileID: 1158682046} - {fileID: 1158682046}
- {fileID: 624469242}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &95533810 --- !u!1 &95533810
GameObject: GameObject:
@ -203,6 +204,7 @@ MonoBehaviour:
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_DeselectOnBackgroundClick: 1 m_DeselectOnBackgroundClick: 1
m_PointerBehavior: 0 m_PointerBehavior: 0
m_CursorLockBehavior: 0
--- !u!114 &95533812 --- !u!114 &95533812
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -231,9 +233,9 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1047643963 --- !u!1 &157782260
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -241,50 +243,38 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 1047643964} - component: {fileID: 157782261}
- component: {fileID: 1047643965}
m_Layer: 0 m_Layer: 0
m_Name: EnemyHandler m_Name: TestObjects
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!4 &1047643964 --- !u!4 &157782261
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1047643963} m_GameObject: {fileID: 157782260}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: -4.6326556, y: 0.98203504, z: 6.9309382}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 2079460687}
- {fileID: 1715656626} - {fileID: 1715656626}
m_Father: {fileID: 38176946} - {fileID: 991542217}
m_RootOrder: 0 m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1047643965 --- !u!4 &624469242 stripped
MonoBehaviour: Transform:
m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 5263199549561108292}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1047643963} --- !u!1 &732841883
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 62a3dc5f11a44cb4d9faccb4fda8599f, type: 3}
m_Name:
m_EditorClassIdentifier:
spawnRate: 60
objectPoolSize: 15
objectPool: {fileID: 0}
enemyPrefabs: []
enemyPools: []
allEnemies: []
--- !u!1 &1158682045
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -292,50 +282,58 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 1158682046} - component: {fileID: 732841885}
- component: {fileID: 1158682047} - component: {fileID: 732841884}
m_Layer: 0 m_Layer: 0
m_Name: BuildingHandler m_Name: Disabler
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!4 &1158682046 --- !u!114 &732841884
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1158682045}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 38176946}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1158682047
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1158682045} m_GameObject: {fileID: 732841883}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 51bf353b43f7b2448bbb3088d78ee8a6, type: 3} m_Script: {fileID: 11500000, guid: f60f8a4b6b214b04083229f46bf1170b, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
colorGhost: {r: 1, g: 1, b: 1, a: 0.12} _set: {fileID: 11400000, guid: bccdf438a1004a444bc24492728d6fbd, type: 2}
colorBuildingBlocked: {r: 1, g: 0, b: 0, a: 0.12} --- !u!4 &732841885
ghostStructureMaterial: {fileID: 2100000, guid: dc919a35edbf85647939132e73b39642, type: 2} Transform:
isBuilding: 0 m_ObjectHideFlags: 0
buildingSelector: 0 m_CorrespondingSourceObject: {fileID: 0}
availableStructuresObject: {fileID: 11400000, guid: f789f54c47873664284d6e8544724693, type: 2} m_PrefabInstance: {fileID: 0}
colorCurrent: {r: 0, g: 0, b: 0, a: 0} m_PrefabAsset: {fileID: 0}
activeStructures: [] m_GameObject: {fileID: 732841883}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.8230318, y: 5.3787107, z: -4.0428505}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &991542217 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
m_PrefabInstance: {fileID: 8451896670512076735}
m_PrefabAsset: {fileID: 0}
--- !u!4 &1047643964 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
m_PrefabInstance: {fileID: 5200388200885062254}
m_PrefabAsset: {fileID: 0}
--- !u!4 &1158682046 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
m_PrefabInstance: {fileID: 664620741625697858}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1191794244 --- !u!1001 &1191794244
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -349,7 +347,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8083988910661828847, guid: c2b4fe01faa847f4b976b5539477e1ec, type: 3} - target: {fileID: 8083988910661828847, guid: c2b4fe01faa847f4b976b5539477e1ec, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 3 value: 2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8083988910661828847, guid: c2b4fe01faa847f4b976b5539477e1ec, type: 3} - target: {fileID: 8083988910661828847, guid: c2b4fe01faa847f4b976b5539477e1ec, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -393,90 +391,28 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c2b4fe01faa847f4b976b5539477e1ec, type: 3} m_SourcePrefab: {fileID: 100100000, guid: c2b4fe01faa847f4b976b5539477e1ec, type: 3}
--- !u!1 &1223464901
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1223464903}
- component: {fileID: 1223464902}
- component: {fileID: 1223464904}
m_Layer: 5
m_Name: UserInterface
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1223464902
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1223464901}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier:
m_PanelSettings: {fileID: 11400000, guid: e6db20d33c1e6754e961e09ddc91ad73, type: 2}
m_ParentUI: {fileID: 0}
sourceAsset: {fileID: 9197481963319205126, guid: 80724155ca8b2ef4bbd2cbb3b6049114, type: 3}
m_SortingOrder: 0
--- !u!4 &1223464903
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1223464901}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1223464904
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1223464901}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e0455460303dea141b831f0bfdd0e47f, type: 3}
m_Name:
m_EditorClassIdentifier:
availableStructuresObject: {fileID: 11400000, guid: f789f54c47873664284d6e8544724693, type: 2}
--- !u!1001 &1715656625 --- !u!1001 &1715656625
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
m_TransformParent: {fileID: 1047643964} m_TransformParent: {fileID: 157782261}
m_Modifications: m_Modifications:
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3} - target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3} - target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: -4.95 value: -0.3173442
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3} - target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: 0 value: -0.98203504
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3} - target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 6.97 value: 0.039061546
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3} - target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalRotation.w propertyPath: m_LocalRotation.w
@ -734,12 +670,17 @@ MonoBehaviour:
m_PointlightHDType: 0 m_PointlightHDType: 0
m_SpotLightShape: 0 m_SpotLightShape: 0
m_AreaLightShape: 0 m_AreaLightShape: 0
--- !u!4 &2079460687 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
m_PrefabInstance: {fileID: 2134547390}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &2134547390 --- !u!1001 &2134547390
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 157782261}
m_Modifications: m_Modifications:
- target: {fileID: 3252872069634226352, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - target: {fileID: 3252872069634226352, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_Enabled propertyPath: m_Enabled
@ -751,19 +692,19 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 1 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: 0 value: 4.6326556
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: 0 value: -0.98203504
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 4.04 value: -2.8909383
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalRotation.w propertyPath: m_LocalRotation.w
@ -771,15 +712,15 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalEulerAnglesHint.x propertyPath: m_LocalEulerAnglesHint.x
@ -804,28 +745,268 @@ PrefabInstance:
m_RemovedComponents: m_RemovedComponents:
- {fileID: 1344974744014620977, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - {fileID: 1344974744014620977, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
--- !u!1001 &8451896670512076735 --- !u!1001 &664620741625697858
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 38176946}
m_Modifications:
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054781, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: _availableStructures
value:
objectReference: {fileID: 11400000, guid: f789f54c47873664284d6e8544724693, type: 2}
- target: {fileID: 664620742648054781, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: _buildingLists.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 664620742648054781, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: _buildingLists.Array.data[0]
value:
objectReference: {fileID: 11400000, guid: bccdf438a1004a444bc24492728d6fbd, type: 2}
- target: {fileID: 664620742648054783, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_Name
value: BuildingHandler
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
--- !u!1001 &3627079579018641133
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - target: {fileID: 3627079578080913704, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_Name
value: UserInterface
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 4 value: 3
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: -4.71 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
--- !u!1001 &5200388200885062254
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 38176946}
m_Modifications:
- target: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5200388201450229077, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
propertyPath: m_Name
value: EnemyHandler
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
--- !u!1001 &5263199549561108292
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 38176946}
m_Modifications:
- target: {fileID: 5263199550015624125, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_Name
value: PowerHandler
objectReference: {fileID: 0}
- target: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
--- !u!1001 &8451896670512076735
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 157782261}
m_Modifications:
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalPosition.x
value: -0.07734442
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalPosition.y
value: -0.98203504
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 1.66 value: -5.2709384
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalRotation.w propertyPath: m_LocalRotation.w
@ -833,15 +1014,15 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalEulerAnglesHint.x propertyPath: m_LocalEulerAnglesHint.x

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4b8bc87700fc5a44b88c1b13c4bdb3cf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,20 @@
using System.Collections.Generic;
using UnityEngine;
namespace AsteroidGame.ScriptableObjects
{
public abstract class SRuntimeSet<T> : ScriptableObject
{
public List<T> _list;
public void Add(T component)
{
_list.Add(component);
}
public void Remove(T component)
{
_list.Remove(component);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1e81b384c7f010b4fa3c1b8f293a4c42
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,10 +1,7 @@
{ {
"name": "Scripts", "name": "ScriptableObjects",
"rootNamespace": "AsteroidGame", "rootNamespace": "AsteroidGame",
"references": [ "references": [],
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:f008ecc6829887e478aeb5eb004eb01b"
],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],
"allowUnsafeCode": false, "allowUnsafeCode": false,

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 896bd127e4aae4c4d86d99385f967c0c guid: eb3099ff524d60545a136315a154d67b
AssemblyDefinitionImporter: AssemblyDefinitionImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -6,77 +6,77 @@ namespace AsteroidGame
{ {
public class CameraController : MonoBehaviour public class CameraController : MonoBehaviour
{ {
private CameraControllActions cameraActions; private CameraControllActions _cameraActions;
private InputAction movement; private InputAction _movement;
private Transform cameraTransform; private Transform _cameraTransform;
private Camera cameraReference; private Camera _cameraReference;
// Horizontal Movement // Horizontal Movement
[SerializeField] [SerializeField]
private float maxSpeed = 5f; private float _maxSpeed = 5f;
private float speed; private float _speed;
[SerializeField] [SerializeField]
private float acceleration = 10f; private float _acceleration = 10f;
[SerializeField] [SerializeField]
private float damping = 15f; private float _damping = 15f;
//Vertial Motion - Zooming //Vertial Motion - Zooming
[SerializeField] [SerializeField]
private float stepSize = 2f; private float _stepSize = 2f;
[SerializeField] [SerializeField]
private float zoomDampening = 7.5f; private float _zoomDampening = 7.5f;
[SerializeField] [SerializeField]
private float minHeight = 5f; private float _minHeight = 5f;
[SerializeField] [SerializeField]
private float maxHeight = 50f; private float _maxHeight = 50f;
[SerializeField] [SerializeField]
private float zoomSpeed = 2f; private float _zoomSpeed = 2f;
//Rotation //Rotation
[SerializeField] [SerializeField]
private float maxRotationSpeed = 1f; private float _maxRotationSpeed = 1f;
//Screen Edge Motion //Screen Edge Motion
[SerializeField] [SerializeField]
[Range(0f, 0.1f)] [Range(0f, 0.1f)]
private float edgeTolerance = 0.05f; private float _edgeTolerance = 0.05f;
[SerializeField] [SerializeField]
private bool useScreenEdge = false; private bool _useScreenEdge = false;
private Vector3 targetPosition; private Vector3 _targetPosition;
private float zoomHeight; private float _zoomHeight;
private Vector3 horizontalVelocity; private Vector3 _horizontalVelocity;
private Vector3 lastPosition; private Vector3 _lastPosition;
private Plane cameraPlane; private Plane _cameraPlane;
Vector3 startDrag; Vector3 _startDrag;
private void Awake() private void Awake()
{ {
cameraActions = new CameraControllActions(); _cameraActions = new CameraControllActions();
cameraReference = this.GetComponentInChildren<Camera>(); _cameraReference = this.GetComponentInChildren<Camera>();
cameraTransform = cameraReference.transform; _cameraTransform = _cameraReference.transform;
} }
private void OnEnable() private void OnEnable()
{ {
cameraPlane = new Plane(Vector3.up, Vector3.zero); _cameraPlane = new Plane(Vector3.up, Vector3.zero);
zoomHeight = cameraTransform.localPosition.y; _zoomHeight = _cameraTransform.localPosition.y;
cameraTransform.LookAt(this.transform); _cameraTransform.LookAt(this.transform);
lastPosition = this.transform.position; _lastPosition = this.transform.position;
movement = cameraActions.Camera.Movement; _movement = _cameraActions.Camera.Movement;
cameraActions.Camera.RotateCamera.performed += RotateCamera; _cameraActions.Camera.RotateCamera.performed += RotateCamera;
cameraActions.Camera.ZoomCamera.performed += ZoomCamera; _cameraActions.Camera.ZoomCamera.performed += ZoomCamera;
cameraActions.Camera.Enable(); _cameraActions.Camera.Enable();
} }
private void OnDisable() private void OnDisable()
{ {
cameraActions.Camera.RotateCamera.performed -= RotateCamera; _cameraActions.Camera.RotateCamera.performed -= RotateCamera;
cameraActions.Camera.ZoomCamera.performed -= ZoomCamera; _cameraActions.Camera.ZoomCamera.performed -= ZoomCamera;
cameraActions.Disable(); _cameraActions.Disable();
} }
@ -84,7 +84,7 @@ namespace AsteroidGame
private void Update() private void Update()
{ {
GetKeyboardMovement(); GetKeyboardMovement();
if (useScreenEdge) if (_useScreenEdge)
{ {
CheckMouseAtScreenEdge(); CheckMouseAtScreenEdge();
} }
@ -97,51 +97,51 @@ namespace AsteroidGame
private void UpdateVelocity() private void UpdateVelocity()
{ {
horizontalVelocity = (this.transform.position - lastPosition) / Time.deltaTime; _horizontalVelocity = (this.transform.position - _lastPosition) / Time.deltaTime;
horizontalVelocity.y = 0; _horizontalVelocity.y = 0;
lastPosition = this.transform.position; _lastPosition = this.transform.position;
} }
private void GetKeyboardMovement() private void GetKeyboardMovement()
{ {
Vector3 inputValue = movement.ReadValue<Vector2>().x * GetCameraRight() Vector3 inputValue = _movement.ReadValue<Vector2>().x * GetCameraRight()
+ movement.ReadValue<Vector2>().y * GetCameraForward(); + _movement.ReadValue<Vector2>().y * GetCameraForward();
inputValue = inputValue.normalized; inputValue = inputValue.normalized;
if (inputValue.sqrMagnitude > 0.1f) if (inputValue.sqrMagnitude > 0.1f)
{ {
targetPosition += inputValue; _targetPosition += inputValue;
} }
} }
private Vector3 GetCameraRight() private Vector3 GetCameraRight()
{ {
Vector3 right = cameraTransform.right; Vector3 right = _cameraTransform.right;
right.y = 0; right.y = 0;
return right; return right;
} }
private Vector3 GetCameraForward() private Vector3 GetCameraForward()
{ {
Vector3 forward = cameraTransform.forward; Vector3 forward = _cameraTransform.forward;
forward.y = 0; forward.y = 0;
return forward; return forward;
} }
private void UpdateBasePosition() private void UpdateBasePosition()
{ {
if (targetPosition.sqrMagnitude > 0.1f) if (_targetPosition.sqrMagnitude > 0.1f)
{ {
speed = Mathf.Lerp(speed, maxSpeed, Time.deltaTime * acceleration); _speed = Mathf.Lerp(_speed, _maxSpeed, Time.deltaTime * _acceleration);
transform.position += speed * Time.deltaTime * targetPosition; transform.position += _speed * Time.deltaTime * _targetPosition;
} }
else else
{ {
horizontalVelocity = Vector3.Lerp(horizontalVelocity, Vector3.zero, Time.deltaTime * damping); _horizontalVelocity = Vector3.Lerp(_horizontalVelocity, Vector3.zero, Time.deltaTime * _damping);
transform.position += horizontalVelocity * Time.deltaTime; transform.position += _horizontalVelocity * Time.deltaTime;
} }
targetPosition = Vector3.zero; _targetPosition = Vector3.zero;
} }
private void RotateCamera(InputAction.CallbackContext inputValue) private void RotateCamera(InputAction.CallbackContext inputValue)
@ -149,7 +149,7 @@ namespace AsteroidGame
if (!Mouse.current.middleButton.isPressed) { return; } if (!Mouse.current.middleButton.isPressed) { return; }
float value = inputValue.ReadValue<Vector2>().x; float value = inputValue.ReadValue<Vector2>().x;
transform.rotation = Quaternion.Euler(0f, value * maxRotationSpeed + transform.rotation.eulerAngles.y, 0f); transform.rotation = Quaternion.Euler(0f, value * _maxRotationSpeed + transform.rotation.eulerAngles.y, 0f);
} }
private void ZoomCamera(InputAction.CallbackContext inputValue) private void ZoomCamera(InputAction.CallbackContext inputValue)
@ -158,21 +158,21 @@ namespace AsteroidGame
if (Mathf.Abs(value) > 0.1f) if (Mathf.Abs(value) > 0.1f)
{ {
zoomHeight = cameraTransform.localPosition.y + value * stepSize; _zoomHeight = _cameraTransform.localPosition.y + value * _stepSize;
if (zoomHeight < minHeight) if (_zoomHeight < _minHeight)
zoomHeight = minHeight; _zoomHeight = _minHeight;
else if (zoomHeight > maxHeight) else if (_zoomHeight > _maxHeight)
zoomHeight = maxHeight; _zoomHeight = _maxHeight;
} }
} }
private void UpdateCameraPosition() private void UpdateCameraPosition()
{ {
Vector3 zoomTarget = new Vector3(cameraTransform.localPosition.x, zoomHeight, cameraTransform.localPosition.z); Vector3 zoomTarget = new Vector3(_cameraTransform.localPosition.x, _zoomHeight, _cameraTransform.localPosition.z);
zoomTarget -= zoomSpeed * (zoomHeight - cameraTransform.localPosition.y) * Vector3.forward; zoomTarget -= _zoomSpeed * (_zoomHeight - _cameraTransform.localPosition.y) * Vector3.forward;
cameraTransform.localPosition = Vector3.Lerp(cameraTransform.localPosition, zoomTarget, Time.deltaTime * zoomDampening); _cameraTransform.localPosition = Vector3.Lerp(_cameraTransform.localPosition, zoomTarget, Time.deltaTime * _zoomDampening);
cameraTransform.LookAt(this.transform); _cameraTransform.LookAt(this.transform);
} }
private void CheckMouseAtScreenEdge() private void CheckMouseAtScreenEdge()
@ -180,17 +180,17 @@ namespace AsteroidGame
Vector2 mousePosition = Mouse.current.position.ReadValue(); Vector2 mousePosition = Mouse.current.position.ReadValue();
Vector3 moveDirection = Vector3.zero; Vector3 moveDirection = Vector3.zero;
if (mousePosition.x < edgeTolerance * Screen.width) if (mousePosition.x < _edgeTolerance * Screen.width)
moveDirection += -GetCameraRight(); moveDirection += -GetCameraRight();
else if (mousePosition.x > (1f - edgeTolerance) * Screen.width) else if (mousePosition.x > (1f - _edgeTolerance) * Screen.width)
moveDirection += GetCameraRight(); moveDirection += GetCameraRight();
if (mousePosition.y < edgeTolerance * Screen.height) if (mousePosition.y < _edgeTolerance * Screen.height)
moveDirection += -GetCameraForward(); moveDirection += -GetCameraForward();
else if (mousePosition.y > (1f - edgeTolerance) * Screen.height) else if (mousePosition.y > (1f - _edgeTolerance) * Screen.height)
moveDirection += GetCameraForward(); moveDirection += GetCameraForward();
targetPosition += moveDirection; _targetPosition += moveDirection;
} }
private void DragCamera() private void DragCamera()
@ -198,13 +198,13 @@ namespace AsteroidGame
if (!Mouse.current.rightButton.isPressed) { return; } if (!Mouse.current.rightButton.isPressed) { return; }
Ray ray = cameraReference.ScreenPointToRay(Mouse.current.position.ReadValue()); Ray ray = _cameraReference.ScreenPointToRay(Mouse.current.position.ReadValue());
if (cameraPlane.Raycast(ray,out float distance)) if (_cameraPlane.Raycast(ray,out float distance))
{ {
if (Mouse.current.rightButton.wasPressedThisFrame) if (Mouse.current.rightButton.wasPressedThisFrame)
startDrag = ray.GetPoint(distance); _startDrag = ray.GetPoint(distance);
else else
targetPosition += startDrag - ray.GetPoint(distance); _targetPosition += _startDrag - ray.GetPoint(distance);
} }
} }

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 624b0cf4f0dd38a459121c046c909786
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,43 +1,43 @@
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using AsteroidGame.Entities;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; using UnityEngine.UIElements;
using AsteroidGame.Entities.Structures.Scripts;
using AsteroidGame.Handlers; using AsteroidGame.Handlers;
using UnityEditor; using UnityEngine.Serialization;
namespace AsteroidGame namespace AsteroidGame.UI
{ {
public class BuildMenuUiController : MonoBehaviour public class BuildMenuUiController : MonoBehaviour
{ {
[FormerlySerializedAs("_availableStructuresObject")]
[Header("Structures")] [Header("Structures")]
[SerializeField] private StructureBaseScriptableObject availableStructuresObject; [SerializeField] private SStructureBaseList _availableSStructuresObject;
private VisualElement m_Root; private VisualElement _mRoot;
private VisualElement m_SlotContainer; private VisualElement _mSlotContainer;
private List<StructureBase> buildings = new(); private List<StructureBase> _buildings = new();
private BuildingHandler buildingHandler; private BuildingHandler _buildingHandler;
void OnEnable()
private void OnEnable()
{ {
buildings = availableStructuresObject.structureList; _buildings = _availableSStructuresObject._structureList;
buildingHandler = FindObjectOfType<BuildingHandler>(); _buildingHandler = FindObjectOfType<BuildingHandler>();
//Store the root from the UI Document component //Store the root from the UI Document component
m_Root = GetComponent<UIDocument>().rootVisualElement; _mRoot = GetComponent<UIDocument>().rootVisualElement;
m_SlotContainer = m_Root.Q<VisualElement>("Menu"); _mSlotContainer = _mRoot.Q<VisualElement>("Menu");
for (int i = 0; i < buildings.Count; i++) for (int i = 0; i < _buildings.Count; i++)
{ {
StructureBase building = buildings[i]; StructureBase building = _buildings[i];
BuildingButton button = new(); BuildingButton button = new()
button.name = building.name;
button.text = building.UiFriendlyName;
button.RegisterCallback<ClickEvent, int>((evt, index) =>
{ {
buildingHandler.EnterBuildMode(index); name = building.name,
},i); text = building.UiFriendlyName
m_SlotContainer.Add(button); };
button.RegisterCallback<ClickEvent, int>((evt, index) => { _buildingHandler.EnterBuildMode(index); },
i);
_mSlotContainer.Add(button);
} }
} }
} }

View File

@ -1,9 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements; using UnityEngine.UIElements;
namespace AsteroidGame namespace AsteroidGame.UI
{ {
public class BuildingButton : Button public class BuildingButton : Button
{ {
@ -14,7 +11,6 @@ namespace AsteroidGame
icon.AddToClassList("slotIcon"); icon.AddToClassList("slotIcon");
AddToClassList("button"); AddToClassList("button");
} }
} }
} }

View File

@ -0,0 +1,64 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3627079578080913704
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3627079578080913706}
- component: {fileID: 3627079578080913707}
- component: {fileID: 3627079578080913701}
m_Layer: 5
m_Name: UserInterface
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3627079578080913706
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3627079578080913704}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3627079578080913707
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3627079578080913704}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier:
m_PanelSettings: {fileID: 11400000, guid: e6db20d33c1e6754e961e09ddc91ad73, type: 2}
m_ParentUI: {fileID: 0}
sourceAsset: {fileID: 9197481963319205126, guid: 80724155ca8b2ef4bbd2cbb3b6049114, type: 3}
m_SortingOrder: 0
--- !u!114 &3627079578080913701
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3627079578080913704}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e0455460303dea141b831f0bfdd0e47f, type: 3}
m_Name:
m_EditorClassIdentifier:
_availableStructuresObject: {fileID: 11400000, guid: f789f54c47873664284d6e8544724693, type: 2}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1170a91b91039d6429d389468bd72c6f
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Cscripts_005Cscriptableobjects/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -0,0 +1,9 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Centities_005Cenemies/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Centities_005Cenemies_005Cscripts/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Centities_005Cscriptableobjects/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Centities_005Cstructures/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Centities_005Cstructures_005Cpowerplant/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Centities_005Cstructures_005Cscriptableobjects/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Centities_005Cstructures_005Cscripts/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Centities_005Cstructures_005Cturret/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Cscripts/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Cscripts_005Cscriptableobjects/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>