WIP Entities

This commit is contained in:
Stedd 2022-09-17 18:38:21 +02:00
parent 27397c2409
commit 29d86194ca
52 changed files with 493 additions and 2689 deletions

View File

@ -3,7 +3,11 @@
"rootNamespace": "AsteroidGame", "rootNamespace": "AsteroidGame",
"references": [ "references": [
"GUID:bc7863ca0989b494d84426bfd28432fa", "GUID:bc7863ca0989b494d84426bfd28432fa",
"GUID:6055be8ebefd69e48b49212b09b47b2f" "GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:5041af1ee0cf75e4a9a52f5f23a0bfae",
"GUID:857695c8a9ee988459c9b50e4e75e660",
"GUID:17a5862fcd6383b4b97bad4dcb1e2e5d",
"GUID:f26d68a0bdefa1043b120b820f55e190"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View File

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

View File

@ -0,0 +1,50 @@
using UnityEngine;
using AsteroidGame.Interfaces;
namespace AsteroidGame.Entities.Enemies
{
public class EnemyBase : MonoBehaviour, IDamageable
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void ModifyHealth(int healthChange)
{
throw new System.NotImplementedException();
}
public void SetHealth(int newHealth)
{
throw new System.NotImplementedException();
}
public void SetMaxHealth(int newHealth)
{
throw new System.NotImplementedException();
}
public int GetHealth()
{
throw new System.NotImplementedException();
}
public int GetMaxHealth()
{
throw new System.NotImplementedException();
}
public float GetHealthFactor()
{
throw new System.NotImplementedException();
}
}
}

View File

@ -0,0 +1,64 @@
using AsteroidGame.Entities.Structures.Tower;
using UnityEngine;
namespace AsteroidGame.Entities.Enemies.Scripts
{
public class EnemyHealth : MonoBehaviour
{
[Header("Assigned on start")]
[SerializeField] EnemyHandler enemyHandler;
// [SerializeField] ScoreHandler scoreHandler;
[Header("Parameters")]
[SerializeField] int maxHealth = 5;
[SerializeField] int difficultyRamp = 1;
[SerializeField] int wealthValue = 5;
[Header("Stats")]
[SerializeField] int currentHealth;
#region Public
public int Health { get=> currentHealth;}
#endregion
void OnEnable()
{
enemyHandler = FindObjectOfType<EnemyHandler>();
// scoreHandler = FindObjectOfType<ScoreHandler>();
currentHealth = maxHealth;
}
private void OnParticleCollision(GameObject damager)
{
ProcessHitFrom(damager);
}
private void ProcessHitFrom(GameObject damager)
{
// SpawnFX(damageVFX);
// Debug.Log(damager.GetComponentInParent<Tower>().GetDamage());
currentHealth -= damager.GetComponentInParent<Turret>().Damage;
//UpdateHealthText(health);
if(currentHealth <= 0)
{
ProcessDeathFrom(damager);
}
}
private void ProcessDeathFrom(GameObject damager)
{
//damager.GetComponentInParent<Turret>().UpdateScore(1f);
// SpawnFX(deathFX);
// scoreHandler.ModifyWealth(wealthValue);
enemyHandler.RemoveEnemy(gameObject);
// Destroy(gameObject);
gameObject.SetActive(false);
maxHealth += difficultyRamp;
}
}
}

View File

@ -0,0 +1,62 @@
using System.Collections;
using AsteroidGame.Handlers;
using UnityEngine;
namespace AsteroidGame.Entities.Enemies
{
public class EnemyMovement : MonoBehaviour
{
[Header("Parameters")]
[SerializeField] [Range(0f, 5f)] float speed = 1f;
[SerializeField] int damage = 1;
[SerializeField] EnemyHandler enemyHandler;
[SerializeField] ScoreHandler scoreHandler;
Vector3 startPosition;
Vector3 endPosition;
float travelPercent = 0f;
private IEnumerator followPath;
void Awake()
{
enemyHandler = FindObjectOfType<EnemyHandler>();
scoreHandler = FindObjectOfType<ScoreHandler>();
}
void OnEnable()
{
enemyHandler.AddEnemyToAllEnemies(gameObject);
}
void RecalculatePath()
{
if (followPath != null)
{
//Debug.Log("Stopping Coroutine");
StopCoroutine(followPath);
}
}
void HandleReachedEndOfPath()
{
scoreHandler.ModifyHealth(-damage);
scoreHandler.ModifyWealth(-100);
enemyHandler.RemoveEnemy(gameObject);
//Destroy(gameObject);
gameObject.SetActive(false);
}
private Vector3 GetVector3(Vector2Int _coord)
{
return new Vector3((float)_coord.x, 0f, (float)_coord.y) * 10f;
}
}
}

View File

@ -0,0 +1,18 @@
{
"name": "Entities.Enemy",
"rootNamespace": "AsteroidGame",
"references": [
"GUID:bc7863ca0989b494d84426bfd28432fa",
"GUID:857695c8a9ee988459c9b50e4e75e660",
"GUID:17a5862fcd6383b4b97bad4dcb1e2e5d"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: d00403ece6c81e3409adb225c74eb396 guid: 5041af1ee0cf75e4a9a52f5f23a0bfae
PrefabImporter: AssemblyDefinitionImporter:
externalObjects: {} externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:

View File

@ -1,18 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -1,87 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &3276725320138281655
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4722945444804288858, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalScale.x
value: 6
objectReference: {fileID: 0}
- target: {fileID: 4722945444804288858, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalScale.y
value: 6
objectReference: {fileID: 0}
- target: {fileID: 4722945444804288858, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalScale.z
value: 6
objectReference: {fileID: 0}
- target: {fileID: 5599539567497807159, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_Name
value: EnemyFast
objectReference: {fileID: 0}
- target: {fileID: 6251302194646931819, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: maxHealth
value: 5
objectReference: {fileID: 0}
- target: {fileID: 6251302194646931819, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: wealthValue
value: 10
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: speed
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: damage
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}

View File

@ -1,63 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using AsteroidGame.Entities.Structures.Tower;
using UnityEngine;
public class EnemyHealth : MonoBehaviour
{
[Header("Assigned on start")]
[SerializeField] EnemyHandler enemyHandler;
[SerializeField] ScoreHandler scoreHandler;
[Header("Parameters")]
[SerializeField] int maxHealth = 5;
[SerializeField] int difficultyRamp = 1;
[SerializeField] int wealthValue = 5;
[Header("Stats")]
[SerializeField] int currentHealth;
#region Public
public int Health { get=> currentHealth;}
#endregion
void OnEnable()
{
enemyHandler = FindObjectOfType<EnemyHandler>();
scoreHandler = FindObjectOfType<ScoreHandler>();
currentHealth = maxHealth;
}
private void OnParticleCollision(GameObject damager)
{
ProcessHitFrom(damager);
}
private void ProcessHitFrom(GameObject damager)
{
// SpawnFX(damageVFX);
// Debug.Log(damager.GetComponentInParent<Tower>().GetDamage());
currentHealth -= damager.GetComponentInParent<Turret>().Damage;
//UpdateHealthText(health);
if(currentHealth <= 0)
{
ProcessDeathFrom(damager);
}
}
private void ProcessDeathFrom(GameObject damager)
{
damager.GetComponentInParent<Turret>().UpdateScore(1f);
// SpawnFX(deathFX);
scoreHandler.ModifyWealth(wealthValue);
enemyHandler.RemoveEnemy(gameObject);
// Destroy(gameObject);
gameObject.SetActive(false);
maxHealth += difficultyRamp;
}
}

View File

@ -1,59 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyMovement : MonoBehaviour
{
[Header("Parameters")]
[SerializeField] [Range(0f, 5f)] float speed = 1f;
[SerializeField] int damage = 1;
[SerializeField] EnemyHandler enemyHandler;
[SerializeField] ScoreHandler scoreHandler;
Vector3 startPosition;
Vector3 endPosition;
float travelPercent = 0f;
private IEnumerator followPath;
void Awake()
{
enemyHandler = FindObjectOfType<EnemyHandler>();
scoreHandler = FindObjectOfType<ScoreHandler>();
}
void OnEnable()
{
enemyHandler.AddEnemyToAllEnemies(gameObject);
}
void RecalculatePath()
{
if (followPath != null)
{
//Debug.Log("Stopping Coroutine");
StopCoroutine(followPath);
}
}
void HandleReachedEndOfPath()
{
scoreHandler.ModifyHealth(-damage);
scoreHandler.ModifyWealth(-100);
enemyHandler.RemoveEnemy(gameObject);
//Destroy(gameObject);
gameObject.SetActive(false);
}
private Vector3 GetVector3(Vector2Int _coord)
{
return new Vector3((float)_coord.x, 0f, (float)_coord.y) * 10f;
}
}

View File

@ -1,239 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &803458978269333711
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 248754501706230461}
- component: {fileID: 3028083790515686286}
m_Layer: 0
m_Name: Halo
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &248754501706230461
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 803458978269333711}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 2.15, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 8984628398547219187}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!122 &3028083790515686286
Halo:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 803458978269333711}
m_Enabled: 1
m_Color:
serializedVersion: 2
rgba: 3573448
m_Size: 3.63
--- !u!1001 &6481170536800402948
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4722945444804288858, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalScale.x
value: 6.7
objectReference: {fileID: 0}
- target: {fileID: 4722945444804288858, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalScale.y
value: 6.7
objectReference: {fileID: 0}
- target: {fileID: 4722945444804288858, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_LocalScale.z
value: 6.7
objectReference: {fileID: 0}
- target: {fileID: 5599539567497807159, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: m_Name
value: EnemyStrong
objectReference: {fileID: 0}
- target: {fileID: 6251302194646931819, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: maxHealth
value: 15
objectReference: {fileID: 0}
- target: {fileID: 6251302194646931819, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: wealthValue
value: 15
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: speed
value: 0.2
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: damage
value: 3
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[0]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[1]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[2]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[3]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[4]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[5]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[6]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[7]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[8]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[9]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[10]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[11]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[12]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[13]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[14]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[15]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[16]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[17]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[18]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[19]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[20]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[21]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[22]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[23]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[24]
value:
objectReference: {fileID: 0}
- target: {fileID: 6819292882879353878, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
propertyPath: path.Array.data[25]
value:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
--- !u!4 &8984628398547219187 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2692714622321691895, guid: 4af571b983b23f94f8d5ca4dbda27de5, type: 3}
m_PrefabInstance: {fileID: 6481170536800402948}
m_PrefabAsset: {fileID: 0}

File diff suppressed because it is too large Load Diff

View File

@ -1,101 +0,0 @@
fileFormatVersion: 2
guid: 0eaf0955d0035664c87a3d4177a41887
ModelImporter:
serializedVersion: 20101
internalIDToNameTable: []
externalObjects: {}
materials:
materialImportMode: 1
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
{
"name": "Entities",
"rootNamespace": "AsteroidGame",
"references": [
"GUID:17a5862fcd6383b4b97bad4dcb1e2e5d"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 0918a47a96be6ad4e853d83c60acda6d guid: f26d68a0bdefa1043b120b820f55e190
PrefabImporter: AssemblyDefinitionImporter:
externalObjects: {} externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:

View File

@ -0,0 +1,43 @@
using AsteroidGame.Interfaces;
using UnityEngine;
namespace AsteroidGame.Entities
{
public class EntityBase : MonoBehaviour, IDamageable
{
[SerializeField] protected int health;
[SerializeField] protected int maxHealth;
public void ModifyHealth(int healthChange)
{
health += healthChange;
}
public void SetHealth(int newHealth)
{
health = newHealth;
}
public void SetMaxHealth(int newHealth)
{
maxHealth = newHealth;
}
public int GetHealth()
{
return health;
}
public int GetMaxHealth()
{
return maxHealth;
}
public float GetHealthFactor()
{
// ReSharper disable once PossibleLossOfFraction
return health / maxHealth;
}
}
}

View File

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

View File

@ -1,47 +0,0 @@
using System.Collections.Generic;
using AsteroidGame.Entities.Structures.Scripts;
using UnityEngine;
public class BuildingHandler : MonoBehaviour
{
[Header("Assigned on start")] [SerializeField]
ScoreHandler scoreHandler;
[Header("Assigned on start")] [SerializeField]
int buildingSelector = 0;
[Header("Prefabs")] [SerializeField] List<StructureBase> buildings = new List<StructureBase>();
// Start is called before the first frame update
void Start()
{
scoreHandler = FindObjectOfType<ScoreHandler>();
}
public void BuildTower(GameObject _tileGO)
{
//Tile _tile = _tileGO.GetComponentInChildren<Tile>();
//Debug.Log($"Placing tower on Tile: {_tileGO.transform.position}");
//Debug.Log($"Placing tower on Node: {_node.coordinates}");
if (scoreHandler.CurrentBalance - buildings[buildingSelector].Cost < 0)
{
print("Insufficient Funds!");
return;
}
else
{
scoreHandler.ModifyWealth(-buildings[buildingSelector].Cost);
Instantiate(buildings[buildingSelector], _tileGO.transform.position, Quaternion.identity, transform);
}
}
public Vector2Int GetVector2(GameObject _o)
{
return new Vector2Int((Mathf.RoundToInt(_o.transform.position.x) / 10),
(Mathf.RoundToInt(_o.transform.position.z / 10)));
}
}

View File

@ -1,63 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using TMPro;
public class ScoreHandler : MonoBehaviour
{
[Header("UI")]
[SerializeField] TextMeshProUGUI dispayBalance;
[Header("Parameters")]
[SerializeField] int startHealth = 5;
[SerializeField] int startBalance = 100;
[Header("Stats")]
[SerializeField] int currentHealth;
[SerializeField] int currentBalance;
public int CurrentBalance {get {return currentBalance;}}
void Start()
{
currentHealth = startHealth;
currentBalance = startBalance;
UpdateGUI();
}
public void ModifyHealth(GameObject enemy)
{
currentHealth -= 1;
CheckIfYouLost();
}
public void ModifyHealth(int _amount)
{
currentHealth += _amount;
CheckIfYouLost();
}
void CheckIfYouLost(){
if(currentHealth <= 0)
{
Debug.Log("You lost");
Reload();
}
}
public void ModifyWealth(int _amount){
currentBalance += _amount;
UpdateGUI();
// Debug.Log($"Wealth modification. Change:{_amount}. Current: {wealthAmount}");
}
void Reload()
{
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(currentSceneIndex);
}
void UpdateGUI(){
dispayBalance.text = $"Gold: {currentBalance.ToString()}";
}
}

View File

@ -1,7 +1,7 @@
{ {
"name": "Entities.Structures", "name": "Entities.Structures",
"rootNamespace": "AsteroidGame", "rootNamespace": "AsteroidGame",
"references": [], "references": ["GUID:17a5862fcd6383b4b97bad4dcb1e2e5d","GUID:f26d68a0bdefa1043b120b820f55e190"],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],
"allowUnsafeCode": false, "allowUnsafeCode": false,

View File

@ -1,15 +1,18 @@
using System;
using AsteroidGame.Entities;
using UnityEngine; using UnityEngine;
namespace AsteroidGame.Entities.Structures.Scripts namespace AsteroidGame.Entities.Structures.Scripts
{ {
public class StructureBase : MonoBehaviour public class StructureBase : EntityBase
{ {
[Header("StructureInformation")] [Header("StructureInformation")] [SerializeField]
[SerializeField] protected string name; protected string name;
[SerializeField] protected int health;
[Header("BuildParameters")] [SerializeField]
protected int cost;
[Header("BuildParameters")]
[SerializeField] protected int cost;
[SerializeField] protected float buildTimer; [SerializeField] protected float buildTimer;
#region Publics #region Publics
@ -18,5 +21,6 @@ namespace AsteroidGame.Entities.Structures.Scripts
public int Cost { get; set; } public int Cost { get; set; }
#endregion #endregion
} }
} }

View File

@ -0,0 +1,50 @@
using System.Collections.Generic;
using AsteroidGame.Entities.Structures.Scripts;
using UnityEngine;
namespace AsteroidGame.Handlers
{
public class BuildingHandler : MonoBehaviour
{
[Header("Assigned on start")] [SerializeField]
ScoreHandler scoreHandler;
[Header("Assigned on start")] [SerializeField]
int buildingSelector = 0;
//[Header("Prefabs")] [SerializeField] List<StructureBase> buildings = new List<StructureBase>();
// Start is called before the first frame update
void Start()
{
scoreHandler = FindObjectOfType<ScoreHandler>();
}
public void BuildTower(GameObject _tileGO)
{
//Tile _tile = _tileGO.GetComponentInChildren<Tile>();
//Debug.Log($"Placing tower on Tile: {_tileGO.transform.position}");
//Debug.Log($"Placing tower on Node: {_node.coordinates}");
// if (scoreHandler.CurrentBalance - buildings[buildingSelector].Cost < 0)
// {
// print("Insufficient Funds!");
// return;
// }
// else
// {
// scoreHandler.ModifyWealth(-buildings[buildingSelector].Cost);
// Instantiate(buildings[buildingSelector], _tileGO.transform.position, Quaternion.identity, transform);
// }
}
public Vector2Int GetVector2(GameObject _o)
{
return new Vector2Int((Mathf.RoundToInt(_o.transform.position.x) / 10),
(Mathf.RoundToInt(_o.transform.position.z / 10)));
}
}
}

View File

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

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 857695c8a9ee988459c9b50e4e75e660
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,64 @@
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace AsteroidGame.Handlers
{
public class ScoreHandler : MonoBehaviour
{
[Header("UI")]
[SerializeField] TextMeshProUGUI dispayBalance;
[Header("Parameters")]
[SerializeField] int startHealth = 5;
[SerializeField] int startBalance = 100;
[Header("Stats")]
[SerializeField] int currentHealth;
[SerializeField] int currentBalance;
public int CurrentBalance {get {return currentBalance;}}
void Start()
{
currentHealth = startHealth;
currentBalance = startBalance;
UpdateGUI();
}
public void ModifyHealth(GameObject enemy)
{
currentHealth -= 1;
CheckIfYouLost();
}
public void ModifyHealth(int _amount)
{
currentHealth += _amount;
CheckIfYouLost();
}
void CheckIfYouLost(){
if(currentHealth <= 0)
{
Debug.Log("You lost");
Reload();
}
}
public void ModifyWealth(int _amount){
currentBalance += _amount;
UpdateGUI();
// Debug.Log($"Wealth modification. Change:{_amount}. Current: {wealthAmount}");
}
void Reload()
{
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(currentSceneIndex);
}
void UpdateGUI(){
dispayBalance.text = $"Gold: {currentBalance.ToString()}";
}
}
}

8
Assets/Interfaces.meta Normal file
View File

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

View File

@ -0,0 +1,17 @@
namespace AsteroidGame.Interfaces
{
public interface IDamageable
{
public void ModifyHealth(int healthChange);
public void SetHealth(int newHealth);
public void SetMaxHealth(int newHealth);
public int GetHealth();
public int GetMaxHealth();
public float GetHealthFactor();
}
}

View File

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

View File

@ -0,0 +1,20 @@
{
"name": "Damageable",
"rootNamespace": "AsteroidGame",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [
{
"name": "Select...",
"expression": "",
"define": ""
}
],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 17a5862fcd6383b4b97bad4dcb1e2e5d
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: