Project cleanup

This commit is contained in:
Stedd 2022-10-01 13:14:33 +02:00
parent 0cf7f6401b
commit 4151ba0050
46 changed files with 959 additions and 564 deletions

1
.gitignore vendored
View File

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

View File

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

View File

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

View File

@ -6,19 +6,19 @@ namespace AsteroidGame.Entities.Enemies
public class EnemyMovement : MonoBehaviour
{
[Header("Parameters")]
[SerializeField] [Range(0f, 5f)] float speed = 1f;
[SerializeField] int damage = 1;
[SerializeField] [Range(0f, 5f)] float _speed = 1f;
[SerializeField] int _damage = 1;
// [SerializeField] EnemyHandler enemyHandler;
// [SerializeField] ScoreHandler scoreHandler;
Vector3 startPosition;
Vector3 endPosition;
float travelPercent = 0f;
Vector3 _startPosition;
Vector3 _endPosition;
float _travelPercent = 0f;
private IEnumerator followPath;
private IEnumerator _followPath;
void Awake()
{
@ -35,10 +35,10 @@ namespace AsteroidGame.Entities.Enemies
void RecalculatePath()
{
if (followPath != null)
if (_followPath != null)
{
//Debug.Log("Stopping Coroutine");
StopCoroutine(followPath);
StopCoroutine(_followPath);
}
}
@ -52,9 +52,9 @@ namespace AsteroidGame.Entities.Enemies
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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,12 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace AsteroidGame.Entities.Structures.Scripts
namespace AsteroidGame.Entities
{
[CreateAssetMenu(fileName = "newStructureList", menuName = "Structures/StructureList")]
public class StructureBaseScriptableObject : ScriptableObject
{
public List<StructureBase> structureList;
public List<StructureBase> _structureList;
}
// public static class MakeScriptableObject

View File

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

View File

@ -1,42 +1,36 @@
using AsteroidGame.Entities.Enemies.Scripts;
using AsteroidGame.Entities.Structures.Scripts;
using AsteroidGame.Interfaces;
using UnityEngine;
namespace AsteroidGame.Entities.Structures.Tower
namespace AsteroidGame.Entities
{
public class Turret : StructureBase
{
[Header("WeaponParameters")] [SerializeField]
private float weaponRange = 40f;
private float _weaponRange = 40f;
[SerializeField] private int damage = 1;
[SerializeField] private float fireRate = 1;
[SerializeField] private float projectileSpeed = 5;
[SerializeField] private TargetStrategy targetStrategy = TargetStrategy.LowestHealth;
[SerializeField] private int _damage = 1;
[SerializeField] private float _fireRate = 1;
[SerializeField] private float _projectileSpeed = 5;
[SerializeField] private TargetStrategy _targetStrategy = TargetStrategy.LowestHealth;
[Header("Stats")]
[SerializeField]
private float score = 0f;
private float _score = 0f;
[Header("RigConnections")]
[SerializeField] private Transform turretHead;
[SerializeField] private Transform barrel;
[SerializeField] private Transform _turretHead;
[SerializeField] private Transform _barrel;
#region Privates
[SerializeField]
enum TargetStrategy
[SerializeField] private enum TargetStrategy
{
ClosestEnemy,
LowestHealth
};
[SerializeField] private EnemyBase targetEnemy;
[SerializeField] private Transform[] buildingParts;
[SerializeField] private EnemyBase _targetEnemy;
[SerializeField] private Transform[] _buildingParts;
#endregion
@ -46,8 +40,8 @@ namespace AsteroidGame.Entities.Structures.Tower
public int Damage
{
get => damage;
set => damage = value;
get => _damage;
set => _damage = value;
}
public int FireRate { get; set; }
@ -56,22 +50,22 @@ namespace AsteroidGame.Entities.Structures.Tower
private void Awake()
{
targetEnemy = FindObjectOfType<EnemyBase>();
_targetEnemy = FindObjectOfType<EnemyBase>();
}
private void Start()
{
// enemyHandler = FindObjectOfType<EnemyHandler>();
// scoreHandler = FindObjectOfType<ScoreHandler>();
UpdateWeaponParameters(fireRate, projectileSpeed);
UpdateWeaponParameters(_fireRate, _projectileSpeed);
}
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;
// main.startSpeed = _projectileSpeed;
@ -126,22 +120,5 @@ namespace AsteroidGame.Entities.Structures.Tower
// 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_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Size: {x: 1, y: 1.0236204, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &8704396752535238434
GameObject:
@ -742,26 +742,26 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d3a16cf44e28f02409c23498ed14acf5, type: 3}
m_Name:
m_EditorClassIdentifier:
health: 50
maxHealth: 50
isInvulnerable: 0
centerPosition: {fileID: 5103935544759496321}
basePosition: {fileID: 8324879816836607384}
uiFriendlyName: Turret
cost: 20
buildPlacementBlocked: 0
buildTimer: 1
isPowerGenerator: 0
isPowerConsumer: 1
maxPower: 10
currentPower: 0
weaponRange: 40
damage: 1
fireRate: 1
projectileSpeed: 5
targetStrategy: 1
score: 0
turretHead: {fileID: 5103935544653627402}
barrel: {fileID: 5103935545559248087}
targetEnemy: {fileID: 0}
buildingParts: []
_health: 10
_maxHealth: 0
_isInvulnerable: 0
_centerPosition: {fileID: 5103935544759496321}
_basePosition: {fileID: 8324879816836607384}
_uiFriendlyName: Turret
_cost: 10
_buildPlacementBlocked: 0
_buildTimer: 0
_isGenerator: 0
_isConsumer: 1
_maxPower: 10
_currentPower: 0
_weaponRange: 40
_damage: 1
_fireRate: 1
_projectileSpeed: 5
_targetStrategy: 1
_score: 0
_turretHead: {fileID: 5103935544653627402}
_barrel: {fileID: 5103935545559248087}
_targetEnemy: {fileID: 0}
_buildingParts: []

View File

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

View File

@ -0,0 +1,53 @@
%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
_availableStructuresObject: {fileID: 11400000, guid: f789f54c47873664284d6e8544724693, type: 2}
_activeStructures: []

View File

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

View File

@ -7,35 +7,35 @@ namespace AsteroidGame.Handlers
public class EnemyHandler : HandlerBase
{
[Header("Parameters")]
[SerializeField] [Range(0.1f, 60f)] float spawnRate = 60f;
[SerializeField] int objectPoolSize = 15;
[SerializeField] [Range(0.1f, 60f)] float _spawnRate = 60f;
[SerializeField] int _objectPoolSize = 15;
[Header("Prefabs")]
[SerializeField] GameObject objectPool;
[SerializeField] List<GameObject> enemyPrefabs = new List<GameObject>();
[SerializeField] GameObject _objectPool;
[SerializeField] List<GameObject> _enemyPrefabs = new List<GameObject>();
[Header("Lists")]
[SerializeField] List<GameObject> enemyPools = new List<GameObject>();
[SerializeField] List<GameObject> allEnemies = new List<GameObject>();
[SerializeField] List<GameObject> _enemyPools = new List<GameObject>();
[SerializeField] List<GameObject> _allEnemies = new List<GameObject>();
private void Start()
{
}
public void AddEnemyToAllEnemies(GameObject _enemy)
public void AddEnemyToAllEnemies(GameObject enemy)
{
allEnemies.Add(_enemy);
_allEnemies.Add(enemy);
}
public void RemoveEnemy(GameObject _enemy)
public void RemoveEnemy(GameObject enemy)
{
allEnemies.Remove(_enemy);
_allEnemies.Remove(enemy);
}
public List<GameObject> ReturnAllEnemies()
{
return allEnemies;
return _allEnemies;
}
public void NotifyEnemiesOfNewPath()

View File

@ -0,0 +1,52 @@
%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
_objectPool: {fileID: 0}
_enemyPrefabs: []
_enemyPools: []
_allEnemies: []

View File

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

View File

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

View File

@ -0,0 +1,51 @@
%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
_buildingHandler: {fileID: 0}
_activeStructures: []

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -153,8 +153,9 @@ Transform:
m_Children:
- {fileID: 1047643964}
- {fileID: 1158682046}
- {fileID: 624469242}
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &95533810
GameObject:
@ -203,6 +204,7 @@ MonoBehaviour:
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_DeselectOnBackgroundClick: 1
m_PointerBehavior: 0
m_CursorLockBehavior: 0
--- !u!114 &95533812
MonoBehaviour:
m_ObjectHideFlags: 0
@ -231,9 +233,9 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1047643963
--- !u!1 &157782260
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -241,101 +243,52 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1047643964}
- component: {fileID: 1047643965}
- component: {fileID: 157782261}
m_Layer: 0
m_Name: EnemyHandler
m_Name: TestObjects
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1047643964
--- !u!4 &157782261
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1047643963}
m_GameObject: {fileID: 157782260}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: -4.6326556, y: 0.98203504, z: 6.9309382}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2079460687}
- {fileID: 1715656626}
m_Father: {fileID: 38176946}
m_RootOrder: 0
- {fileID: 991542217}
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1047643965
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1047643963}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 62a3dc5f11a44cb4d9faccb4fda8599f, type: 3}
m_Name:
m_EditorClassIdentifier:
spawnRate: 60
objectPoolSize: 15
objectPool: {fileID: 0}
enemyPrefabs: []
enemyPools: []
allEnemies: []
--- !u!1 &1158682045
GameObject:
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
--- !u!4 &624469242 stripped
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 5263199550015624126, guid: 2e352ad6389b4234083764d15d4e6a5f, type: 3}
m_PrefabInstance: {fileID: 5263199549561108292}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1158682045}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 38176946}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1158682047
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
--- !u!4 &991542217 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
m_PrefabInstance: {fileID: 8451896670512076735}
m_PrefabAsset: {fileID: 0}
--- !u!4 &1047643964 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 5200388201450229074, guid: 07826307af1971948b98dd42d1e9457a, type: 3}
m_PrefabInstance: {fileID: 5200388200885062254}
m_PrefabAsset: {fileID: 0}
--- !u!4 &1158682046 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
m_PrefabInstance: {fileID: 664620741625697858}
m_PrefabAsset: {fileID: 0}
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
PrefabInstance:
m_ObjectHideFlags: 0
@ -349,7 +302,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8083988910661828847, guid: c2b4fe01faa847f4b976b5539477e1ec, type: 3}
propertyPath: m_RootOrder
value: 3
value: 2
objectReference: {fileID: 0}
- target: {fileID: 8083988910661828847, guid: c2b4fe01faa847f4b976b5539477e1ec, type: 3}
propertyPath: m_LocalPosition.x
@ -393,90 +346,28 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
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
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1047643964}
m_TransformParent: {fileID: 157782261}
m_Modifications:
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_RootOrder
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.x
value: -4.95
value: -0.3173442
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.y
value: 0
value: -0.98203504
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.z
value: 6.97
value: 0.039061546
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalRotation.w
@ -734,12 +625,17 @@ MonoBehaviour:
m_PointlightHDType: 0
m_SpotLightShape: 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
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_TransformParent: {fileID: 157782261}
m_Modifications:
- target: {fileID: 3252872069634226352, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_Enabled
@ -751,19 +647,19 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_RootOrder
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalPosition.x
value: 0
value: 4.6326556
objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalPosition.y
value: 0
value: -0.98203504
objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalPosition.z
value: 4.04
value: -2.8909383
objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalRotation.w
@ -771,15 +667,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalRotation.x
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalRotation.y
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalRotation.z
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8324879816836607384, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
@ -804,28 +700,256 @@ PrefabInstance:
m_RemovedComponents:
- {fileID: 1344974744014620977, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 534f8d15e0c83c646887bebfda2bdfd6, type: 3}
--- !u!1001 &8451896670512076735
--- !u!1001 &664620741625697858
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 38176946}
m_Modifications:
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 664620742648054780, guid: 3a89f87af6ee84a459d98a4c296dd1be, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 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:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
- target: {fileID: 3627079578080913704, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_Name
value: UserInterface
objectReference: {fileID: 0}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_RootOrder
value: 4
value: 3
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
- target: {fileID: 3627079578080913706, guid: 1170a91b91039d6429d389468bd72c6f, type: 3}
propertyPath: m_LocalPosition.x
value: -4.71
value: 0
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
- 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}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalPosition.x
value: -0.07734442
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalPosition.y
value: -0.98203504
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalPosition.z
value: 1.66
value: -5.2709384
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalRotation.w
@ -833,15 +957,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalRotation.x
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalRotation.y
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalRotation.z
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 493861824998956378, guid: 57a75520298c47140a928041b05d7f3c, type: 3}
propertyPath: m_LocalEulerAnglesHint.x

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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