Compare commits

..

No commits in common. "f89ab59fdf49898d35ae92967fc450b1b8769f9c" and "0cf7f6401b1829cbb473b8a0ca387f4f99d11e80" have entirely different histories.

79 changed files with 665 additions and 1349 deletions

1
.gitignore vendored
View File

@ -73,4 +73,3 @@ 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,12 +2,13 @@
"name": "AsteroidGame", "name": "AsteroidGame",
"rootNamespace": "AsteroidGame", "rootNamespace": "AsteroidGame",
"references": [ "references": [
"GUID:bc7863ca0989b494d84426bfd28432fa",
"GUID:6055be8ebefd69e48b49212b09b47b2f", "GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:75469ad4d38634e559750d17036d5f7c", "GUID:5041af1ee0cf75e4a9a52f5f23a0bfae",
"GUID:f008ecc6829887e478aeb5eb004eb01b", "GUID:857695c8a9ee988459c9b50e4e75e660",
"GUID:17a5862fcd6383b4b97bad4dcb1e2e5d", "GUID:17a5862fcd6383b4b97bad4dcb1e2e5d",
"GUID:f26d68a0bdefa1043b120b820f55e190", "GUID:f26d68a0bdefa1043b120b820f55e190",
"GUID:eb3099ff524d60545a136315a154d67b" "GUID:75469ad4d38634e559750d17036d5f7c"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View File

@ -1,15 +0,0 @@
%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

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

View File

@ -406,14 +406,11 @@ 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,21 +1,10 @@
using System;
using UnityEngine; using UnityEngine;
namespace AsteroidGame.Entities namespace AsteroidGame.Entities.Enemies.Scripts
{ {
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,3 +1,4 @@
using AsteroidGame.Entities.Structures.Tower;
using UnityEngine; using UnityEngine;
namespace AsteroidGame.Entities.Enemies.Scripts namespace AsteroidGame.Entities.Enemies.Scripts
@ -9,23 +10,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)
@ -38,11 +39,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);
} }
@ -57,7 +58,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,8 +2,7 @@
"name": "Entities", "name": "Entities",
"rootNamespace": "AsteroidGame", "rootNamespace": "AsteroidGame",
"references": [ "references": [
"GUID:17a5862fcd6383b4b97bad4dcb1e2e5d", "GUID:17a5862fcd6383b4b97bad4dcb1e2e5d"
"GUID:eb3099ff524d60545a136315a154d67b"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View File

@ -6,71 +6,79 @@ 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 SetHealth(int newHealth) => _health = newHealth; public void SetMaxHealth(int newHealth)
{
maxHealth = newHealth;
}
public void SetMaxHealth(int newHealth) => _maxHealth = newHealth; public void SetInvulnerable(bool newState)
{
public void SetInvulnerable(bool newState) => _isInvulnerable = newState; isInvulnerable = newState;
}
#endregion #endregion
#region Getters #region Getters
public Vector3 GetCenterPosition() => _centerPosition.transform.position; public Vector3 GetCenterPosition()
{
return centerPosition.transform.position;
}
public Vector3 GetBasePosition() => _basePosition.transform.position; public Vector3 GetBasePosition()
{
return basePosition.transform.position;
}
public int GetHealth()
{
return health;
}
public int GetHealth() => _health; public int GetMaxHealth()
{
return maxHealth;
}
public int GetMaxHealth() => _maxHealth; public float GetHealthFactor()
{
public float GetHealthFactor() => (float)_health / (float)_maxHealth; // ReSharper disable once PossibleLossOfFraction
return health / maxHealth;
}
#endregion #endregion
} }
} }

View File

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

View File

@ -1,15 +0,0 @@
%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

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

View File

@ -1,15 +0,0 @@
%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

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

View File

@ -1,15 +0,0 @@
%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

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

View File

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

View File

@ -1,12 +0,0 @@
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

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

View File

@ -1,11 +0,0 @@
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

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

View File

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

View File

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

View File

@ -1,11 +0,0 @@
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

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

View File

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

View File

@ -1,23 +0,0 @@
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

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

View File

@ -1,17 +0,0 @@
%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

@ -1,8 +0,0 @@
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,6 +1,11 @@
namespace AsteroidGame.Entities using AsteroidGame.Entities.Structures.Scripts;
using AsteroidGame.Interfaces;
using UnityEngine;
namespace AsteroidGame.Entities.Structures.PowerPlant
{ {
public class PowerPlant : StructureBase public class PowerPlant : StructureBase
{ {
} }
} }

View File

@ -46,21 +46,19 @@ 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: 10 health: 0
_maxHealth: 0 maxHealth: 0
_isInvulnerable: 0 isInvulnerable: 0
_centerPosition: {fileID: 1841478903898566568} centerPosition: {fileID: 0}
_basePosition: {fileID: 493861824998956378} basePosition: {fileID: 493861824998956378}
_uiFriendlyName: Power\nPlant uiFriendlyName: Power\nPlant
_entityBaseSet: {fileID: 11400000, guid: c5542e77624472441a67b1f34e19a116, type: 2} cost: 0
_cost: 100 buildPlacementBlocked: 0
_buildPlacementBlocked: 0 buildTimer: 0
_buildTimer: 0 isPowerGenerator: 1
_isGenerator: 1 isPowerConsumer: 0
_isConsumer: 0 maxPower: 100
_maxPower: 100 currentPower: 0
_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

@ -1,28 +0,0 @@
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

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

View File

@ -1,86 +1,90 @@
using System;
using AsteroidGame.Interfaces; using AsteroidGame.Interfaces;
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
namespace AsteroidGame.Entities namespace AsteroidGame.Entities.Structures.Scripts
{ {
public class StructureBase : EntityBase, IBuildable, IPowerSystem public class StructureBase : EntityBase, IBuildable, IPowerSystem
{ {
[Header("BuildParameters")] [Header("BuildParameters")]
[SerializeField] protected int _cost; [SerializeField]
[SerializeField] private bool _buildPlacementBlocked; protected int cost;
[SerializeField] protected float _buildTimer;
[SerializeField] private bool buildPlacementBlocked;
[SerializeField] protected float buildTimer;
[Header("Power")] [Header("Power")]
[SerializeField] protected bool _isGenerator; [SerializeField] protected bool isPowerGenerator;
[SerializeField] protected bool _isConsumer; [SerializeField] protected bool isPowerConsumer;
[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 IsGenerator => _isGenerator; public bool IsPowerConsumer => isPowerConsumer;
public bool IsConsumer => _isConsumer; public bool BuildPlacementBlocked => buildPlacementBlocked;
public bool BuildPlacementBlocked => _buildPlacementBlocked; public int Cost => cost;
#endregion #endregion
protected override void OnEnable() private void OnEnable()
{ {
base.OnEnable(); if (!isPowerConsumer && !isPowerGenerator)
if (!_isConsumer && !_isGenerator)
{ {
Debug.LogWarning("Power consumer/generator not set!"); Debug.Log("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) => _maxPower = newValue; public void SetMaxPower(int newValue)
public int SetCost(int newCost) => _cost = newCost; {
maxPower = newValue;
}
#endregion #endregion
#region Getters #region Getters
public int GetMaxPower()
{
return maxPower;
}
public int GetMaxPower() => _maxPower; public int GetCurrentPower()
{
public int GetCurrentPower() => _currentPower; return currentPower;
}
public float GetPowerFactor() => (float)_currentPower / _maxPower;
public int GetCost() => _cost;
public float GetPowerFactor()
{
// ReSharper disable once PossibleLossOfFraction
return currentPower / maxPower;
}
#endregion #endregion
} }
} }

View File

@ -0,0 +1,27 @@
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

@ -1,38 +1,42 @@
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 namespace AsteroidGame.Entities.Structures.Tower
{ {
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")]
[SerializeField] private Transform _turretHead; [Header("RigConnections")]
[SerializeField] private Transform _barrel; [SerializeField] private Transform turretHead;
[SerializeField] private Transform barrel;
#region Privates #region Privates
[Header("Target")]
[SerializeField] private SEnemyBaseRuntimeSet _activeEnemies;
[SerializeField] private EnemyBase _targetEnemy; [SerializeField]
enum TargetStrategy
[SerializeField] private enum TargetStrategy
{ {
ClosestEnemy, ClosestEnemy,
LowestHealth LowestHealth
}; };
[SerializeField] private Transform[] _buildingParts; [SerializeField] private EnemyBase targetEnemy;
[SerializeField] private Transform[] buildingParts;
#endregion #endregion
@ -42,32 +46,32 @@ namespace AsteroidGame.Entities
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; }
#endregion #endregion
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;
@ -122,5 +126,22 @@ namespace AsteroidGame.Entities
// 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.0236204, z: 1} m_Size: {x: 1, y: 1, 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,29 +742,26 @@ 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: 10 health: 50
_maxHealth: 0 maxHealth: 50
_isInvulnerable: 0 isInvulnerable: 0
_centerPosition: {fileID: 5103935544759496321} centerPosition: {fileID: 5103935544759496321}
_basePosition: {fileID: 8324879816836607384} basePosition: {fileID: 8324879816836607384}
_uiFriendlyName: Turret uiFriendlyName: Turret
_entityBaseSet: {fileID: 11400000, guid: c5542e77624472441a67b1f34e19a116, type: 2} cost: 20
_cost: 10 buildPlacementBlocked: 0
_buildPlacementBlocked: 0 buildTimer: 1
_buildTimer: 0 isPowerGenerator: 0
_isGenerator: 0 isPowerConsumer: 1
_isConsumer: 1 maxPower: 10
_maxPower: 10 currentPower: 0
_currentPower: 0 weaponRange: 40
_structureBaseSet: {fileID: 11400000, guid: bccdf438a1004a444bc24492728d6fbd, type: 2} damage: 1
_weaponRange: 40 fireRate: 1
_damage: 1 projectileSpeed: 5
_fireRate: 1 targetStrategy: 1
_projectileSpeed: 5 score: 0
_targetStrategy: 1 turretHead: {fileID: 5103935544653627402}
_score: 0 barrel: {fileID: 5103935545559248087}
_turretHead: {fileID: 5103935544653627402} targetEnemy: {fileID: 0}
_barrel: {fileID: 5103935545559248087} buildingParts: []
_activeEnemies: {fileID: 11400000, guid: 5f6dc84d75dbd9a459e519de42279066, type: 2}
_targetEnemy: {fileID: 0}
_buildingParts: []

View File

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

View File

@ -1,28 +1,30 @@
using AsteroidGame.Entities; using System.Collections.Generic;
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;
@ -30,36 +32,35 @@ namespace AsteroidGame.Handlers
private MeshRenderer[] _ghostStructureMeshRenderers; private MeshRenderer[] _ghostStructureMeshRenderers;
#endregion #endregion
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)
@ -74,41 +75,41 @@ namespace AsteroidGame.Handlers
protected override void OnBuild(InputAction.CallbackContext context) protected override void OnBuild(InputAction.CallbackContext context)
{ {
EnterBuildMode(_buildingSelector); EnterBuildMode(buildingSelector);
} }
private void PlaceStructure() public 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();
} }
private void AbortPlaceStructure() public 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(_availableSStructures._structureList[_buildingSelector], GetPlanePoint(), Quaternion.identity, _ghostStructure = Instantiate(_availableStructures[buildingSelector], GetPlanePoint(), Quaternion.identity, transform);
transform);
_ghostStructure.name = "GhostStructure"; _ghostStructure.name = "GhostStructure";
var rb = _ghostStructure.gameObject.AddComponent<Rigidbody>(); var rb = _ghostStructure.gameObject.AddComponent<Rigidbody>();
@ -118,7 +119,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;
@ -131,14 +132,12 @@ namespace AsteroidGame.Handlers
private void SpawnStructure() private void SpawnStructure()
{ {
_tempStructure = Instantiate(_availableSStructures._structureList[_buildingSelector], GetPlanePoint(), Quaternion.identity, _tempStructure = Instantiate(_availableStructures[buildingSelector], GetPlanePoint(), Quaternion.identity, transform);
transform); activeStructures.Add(_tempStructure);
// _activeStructures.Add(_tempStructure);
// _buildingLists[0].Add(_tempStructure);
} }
#region Getters #region Getters
private Vector3 GetPlanePoint() private Vector3 GetPlanePoint()
{ {
Ray ray = _camera.ScreenPointToRay(Mouse.current.position.ReadValue()); Ray ray = _camera.ScreenPointToRay(Mouse.current.position.ReadValue());
@ -146,20 +145,20 @@ namespace AsteroidGame.Handlers
{ {
return ray.GetPoint(distance); return ray.GetPoint(distance);
} }
print("BuildPlaneNotHit"); print("BuildPlaneNotHit");
return Vector3.zero; return Vector3.zero;
} }
// public List<StructureBase> GetAvailableStructures() public Dictionary<int, StructureBase> GetAvailableStructures()
// { {
// return _availableStructures._structureList; return _availableStructures;
// } }
// public List<StructureBase> GetActiveStructures() public List<StructureBase> GetActiveStructures()
// { {
// return _activeStructures; return activeStructures;
// } }
#endregion #endregion
@ -167,9 +166,10 @@ namespace AsteroidGame.Handlers
public void SetBuildingIndex(int index) public void SetBuildingIndex(int index)
{ {
_buildingSelector = index; buildingSelector = index;
} }
#endregion #endregion
} }
} }

View File

@ -1,52 +0,0 @@
%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,7 +0,0 @@
fileFormatVersion: 2
guid: 3a89f87af6ee84a459d98a4c296dd1be
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,18 +1,46 @@
using AsteroidGame.Entities; using System.Collections.Generic;
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)] private float _spawnRate = 60f; [SerializeField] [Range(0.1f, 60f)] float spawnRate = 60f;
[SerializeField] private int _objectPoolSize = 15; [SerializeField] int objectPoolSize = 15;
[Header("Configuration")] [Header("Prefabs")]
[SerializeField] private SEnemyBaseList _availableEnemies; [SerializeField] GameObject objectPool;
[SerializeField] List<GameObject> enemyPrefabs = new List<GameObject>();
[Header("Lists")] [Header("Lists")]
[SerializeField] private SEnemyBaseRuntimeSet _activeEnemies; [SerializeField] List<GameObject> enemyPools = new List<GameObject>();
[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

@ -1,50 +0,0 @@
%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,22 @@
{
"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,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: eb3099ff524d60545a136315a154d67b guid: 857695c8a9ee988459c9b50e4e75e660
AssemblyDefinitionImporter: AssemblyDefinitionImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -1,59 +1,75 @@
using System; using System;
using AsteroidGame.Entities; using System.Collections.Generic;
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")] [Header("State")] [SerializeField] private int powerConsumption;
[SerializeField] private int _powerConsumption; [SerializeField] private int powerCapacity;
[SerializeField] private int _powerCapacity; [SerializeField] private float powerFactor;
[SerializeField] private float _powerFactor;
[Header("Connections")] [SerializeField]
private BuildingHandler buildingHandler;
// [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();
}
[Header("Connections")]
[SerializeField] private SStructureBaseRuntimeSet _activeStructures;
private void Update() private void Update()
{ {
_powerConsumption = 0; powerConsumption = 0;
_powerCapacity = 0; powerCapacity = 0;
foreach (var structure in _activeStructures._list) foreach (var structure in activeStructures)
{ {
if (structure.IsConsumer) if (structure.IsPowerConsumer)
{ {
_powerConsumption += structure.GetMaxPower(); powerConsumption += structure.GetMaxPower();
} }
if (structure.IsGenerator) if (structure.IsPowerGenerator)
{ {
_powerCapacity += structure.GetMaxPower(); powerCapacity += structure.GetMaxPower();
} }
} }
if (_powerCapacity > 0) if (powerCapacity > 0)
{ {
_powerFactor = (float)_powerConsumption / _powerCapacity; powerFactor = (float)powerConsumption / (float)powerCapacity;
} }
else else
{ {
_powerFactor = 0; powerFactor = 0;
} }
} }
public int GetMaxPower() public int GetMaxPower()
{ {
throw new NotImplementedException(); throw new System.NotImplementedException();
} }
public int GetCurrentPower() public int GetCurrentPower()
{ {
throw new NotImplementedException(); throw new System.NotImplementedException();
} }
public float GetPowerFactor() public float GetPowerFactor()
{ {
throw new NotImplementedException(); throw new System.NotImplementedException();
} }
} }
} }

View File

@ -1,50 +0,0 @@
%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

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

View File

@ -1,6 +1,7 @@
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.Serialization;
namespace AsteroidGame.Handlers namespace AsteroidGame.Handlers
{ {
@ -8,41 +9,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();
@ -50,7 +51,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}");
} }
@ -62,7 +63,7 @@ namespace AsteroidGame.Handlers
} }
private void UpdateGUI(){ private void UpdateGUI(){
_displayBalance.text = $"Gold: {_currentBalance.ToString()}"; displayBalance.text = $"Gold: {currentBalance.ToString()}";
} }
} }

View File

@ -2,7 +2,6 @@ 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 IsGenerator { get; } public bool IsPowerGenerator { get; }
public bool IsConsumer { get; } public bool IsPowerConsumer { get; }
public void SetMaxPower(int newValue); public void SetMaxPower(int newValue);

View File

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

View File

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

View File

@ -153,9 +153,8 @@ 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: 1 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &95533810 --- !u!1 &95533810
GameObject: GameObject:
@ -204,7 +203,6 @@ 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
@ -233,9 +231,9 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &157782260 --- !u!1 &1047643963
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -243,97 +241,101 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 157782261} - component: {fileID: 1047643964}
- component: {fileID: 1047643965}
m_Layer: 0 m_Layer: 0
m_Name: TestObjects m_Name: EnemyHandler
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 &157782261 --- !u!4 &1047643964
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: 157782260} m_GameObject: {fileID: 1047643963}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -4.6326556, y: 0.98203504, z: 6.9309382} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 2079460687}
- {fileID: 1715656626} - {fileID: 1715656626}
- {fileID: 991542217} m_Father: {fileID: 38176946}
m_Father: {fileID: 0} m_RootOrder: 0
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &624469242 stripped --- !u!114 &1047643965
Transform:
m_CorrespondingSourceObject: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
m_PrefabInstance: {fileID: 5263199549561108292}
m_PrefabAsset: {fileID: 0}
--- !u!1 &732841883
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 732841885}
- component: {fileID: 732841884}
m_Layer: 0
m_Name: Disabler
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &732841884
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: 732841883} m_GameObject: {fileID: 1047643963}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f60f8a4b6b214b04083229f46bf1170b, type: 3} m_Script: {fileID: 11500000, guid: 62a3dc5f11a44cb4d9faccb4fda8599f, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_set: {fileID: 11400000, guid: bccdf438a1004a444bc24492728d6fbd, type: 2} spawnRate: 60
--- !u!4 &732841885 objectPoolSize: 15
objectPool: {fileID: 0}
enemyPrefabs: []
enemyPools: []
allEnemies: []
--- !u!1 &1158682045
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1158682046}
- component: {fileID: 1158682047}
m_Layer: 0
m_Name: BuildingHandler
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1158682046
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: 732841883} m_GameObject: {fileID: 1158682045}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.8230318, y: 5.3787107, z: -4.0428505} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 38176946}
m_RootOrder: 6 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &991542217 stripped --- !u!114 &1158682047
Transform: MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} m_ObjectHideFlags: 0
m_PrefabInstance: {fileID: 8451896670512076735} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabInstance: {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} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1158682045}
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
availableStructuresObject: {fileID: 11400000, guid: f789f54c47873664284d6e8544724693, type: 2}
colorCurrent: {r: 0, g: 0, b: 0, a: 0}
activeStructures: []
--- !u!1001 &1191794244 --- !u!1001 &1191794244
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -347,7 +349,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: 2 value: 3
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
@ -391,28 +393,90 @@ 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: 157782261} m_TransformParent: {fileID: 1047643964}
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: 1 value: 0
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: -0.3173442 value: -4.95
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.98203504 value: 0
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: 0.039061546 value: 6.97
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
@ -670,17 +734,12 @@ 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: 157782261} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 3252872069634226352, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3} - target: {fileID: 3252872069634226352, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_Enabled propertyPath: m_Enabled
@ -692,19 +751,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: 0 value: 1
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: 4.6326556 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.y propertyPath: m_LocalPosition.y
value: -0.98203504 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.z propertyPath: m_LocalPosition.z
value: -2.8909383 value: 4.04
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
@ -712,15 +771,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
@ -745,268 +804,28 @@ 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 &664620741625697858 --- !u!1001 &8451896670512076735
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: 3627079578080913704, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_Name
value: UserInterface
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalPosition.y
value: 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} - target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 2 value: 4
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: -0.07734442 value: -4.71
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3} - target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: -0.98203504 value: 0
objectReference: {fileID: 0} 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: -5.2709384 value: 1.66
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
@ -1014,15 +833,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

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

View File

@ -1,20 +0,0 @@
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

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

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

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

View File

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

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 07826307af1971948b98dd42d1e9457a guid: 896bd127e4aae4c4d86d99385f967c0c
PrefabImporter: AssemblyDefinitionImporter:
externalObjects: {} externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:

View File

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

View File

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

View File

@ -1,64 +0,0 @@
%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

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

View File

@ -1,3 +0,0 @@
<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

@ -1,9 +0,0 @@
<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

@ -1,3 +0,0 @@
<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>