diff --git a/Assets/Prefabs/ManagersAndCam/GameManager.prefab b/Assets/Prefabs/ManagersAndCam/GameManager.prefab index 45a4632..8faecb5 100644 --- a/Assets/Prefabs/ManagersAndCam/GameManager.prefab +++ b/Assets/Prefabs/ManagersAndCam/GameManager.prefab @@ -11,6 +11,7 @@ GameObject: - component: {fileID: 2326023822257198758} - component: {fileID: 7444322309943002451} - component: {fileID: -4518928198845659541} + - component: {fileID: 4500885157334573855} m_Layer: 0 m_Name: GameManager m_TagString: Untagged @@ -167,6 +168,24 @@ MonoBehaviour: m_EditorClassIdentifier: EffectsSource: {fileID: 5412373041479583195} MusicSource: {fileID: 6398205375808577097} +--- !u!114 &4500885157334573855 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4421777460897078516} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3aa2eb264738746aab80b5768ad3206f, type: 3} + m_Name: + m_EditorClassIdentifier: + levelNames: + - 0_Steeve + - 1_Pumpkin + - 2_Plaza + - 3_Flat + - 4_NotVillage --- !u!1 &7552951648969690334 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/LevelsTest/0_Steeve.unity b/Assets/Scenes/LevelsTest/0_Steeve.unity index 6ab417f..19147a0 100644 --- a/Assets/Scenes/LevelsTest/0_Steeve.unity +++ b/Assets/Scenes/LevelsTest/0_Steeve.unity @@ -512,28 +512,8 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 4421777460897078516, guid: e0cd2add4bbdcf59a8c46048ba422a58, type: 3} - insertIndex: -1 - addedObject: {fileID: 441349220} + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: e0cd2add4bbdcf59a8c46048ba422a58, type: 3} ---- !u!1 &441349216 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 4421777460897078516, guid: e0cd2add4bbdcf59a8c46048ba422a58, type: 3} - m_PrefabInstance: {fileID: 300434390} - m_PrefabAsset: {fileID: 0} ---- !u!114 &441349220 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 441349216} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 3aa2eb264738746aab80b5768ad3206f, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1 &687112591 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/LevelsTest/1_Pumpkin.meta b/Assets/Scenes/LevelsTest/1_Pumpkin.meta new file mode 100644 index 0000000..97e752c --- /dev/null +++ b/Assets/Scenes/LevelsTest/1_Pumpkin.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a97bd697808077e90a69a5a853ead2b3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/LevelsTest/1_Pumpkin.unity b/Assets/Scenes/LevelsTest/1_Pumpkin.unity index 9c4afb8..34b83ad 100644 --- a/Assets/Scenes/LevelsTest/1_Pumpkin.unity +++ b/Assets/Scenes/LevelsTest/1_Pumpkin.unity @@ -523,7 +523,7 @@ PrefabInstance: - target: {fileID: 1969199041552567758, guid: 6ad55a398b7989c9cbd10b7804913360, type: 3} propertyPath: m_NavMeshData value: - objectReference: {fileID: 23800000, guid: c6990f57c4a41e3fc83259edf4b5788c, type: 2} + objectReference: {fileID: 23800000, guid: 966ab30231f8849209ccf80b87cf41ec, type: 2} - target: {fileID: 1969199041552567758, guid: 6ad55a398b7989c9cbd10b7804913360, type: 3} propertyPath: m_GenerateLinks value: 0 @@ -535,7 +535,7 @@ PrefabInstance: - target: {fileID: 6778669920814834500, guid: 6ad55a398b7989c9cbd10b7804913360, type: 3} propertyPath: m_NavMeshData value: - objectReference: {fileID: 23800000, guid: b131d22c420e393e096e910186a08091, type: 2} + objectReference: {fileID: 23800000, guid: a7dd1adfee813ce63b709cb7c05b4091, type: 2} - target: {fileID: 6778669920814834500, guid: 6ad55a398b7989c9cbd10b7804913360, type: 3} propertyPath: m_GenerateLinks value: 0 diff --git a/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface 1.asset b/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface 1.asset new file mode 100644 index 0000000..8606327 Binary files /dev/null and b/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface 1.asset differ diff --git a/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface 1.asset.meta b/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface 1.asset.meta new file mode 100644 index 0000000..10ce987 --- /dev/null +++ b/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface 1.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 966ab30231f8849209ccf80b87cf41ec +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 23800000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface.asset b/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface.asset new file mode 100644 index 0000000..ef6c12b Binary files /dev/null and b/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface.asset differ diff --git a/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface.asset.meta b/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface.asset.meta new file mode 100644 index 0000000..580df85 --- /dev/null +++ b/Assets/Scenes/LevelsTest/1_Pumpkin/NavMesh-NavMesh Surface.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a7dd1adfee813ce63b709cb7c05b4091 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 23800000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Singletons/GameManager.cs b/Assets/Scripts/Singletons/GameManager.cs index 0de55c9..90f9714 100644 --- a/Assets/Scripts/Singletons/GameManager.cs +++ b/Assets/Scripts/Singletons/GameManager.cs @@ -1,8 +1,14 @@ +using System; using System.Collections; +using System.Collections.Generic; using UnityEngine; +using UnityEngine.SceneManagement; public class GameManager : MonoBehaviourSingletonPersistent { + [SerializeField] private List levelNames; + + int current_level = 0; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { @@ -15,6 +21,7 @@ public class GameManager : MonoBehaviourSingletonPersistent // Delete, use only for Debug if (Input.GetKeyDown(KeyCode.Space)) { + print("OOKOKOKOKOKOK"); StartFightForAll(); } } @@ -27,5 +34,19 @@ public class GameManager : MonoBehaviourSingletonPersistent unit.StartFight(); } } + + + public void GoNextLevel() + { + if (current_level < levelNames.Count) + { + current_level++; + SceneManager.LoadScene(levelNames[current_level]); + return; + } + + throw new Exception("Bro there is no next level like stop pls"); + + } } diff --git a/Assets/Scripts/UnitScripts/Attacks/AttackHandler.cs b/Assets/Scripts/UnitScripts/Attacks/AttackHandler.cs index 4fa7706..fcc69ff 100644 --- a/Assets/Scripts/UnitScripts/Attacks/AttackHandler.cs +++ b/Assets/Scripts/UnitScripts/Attacks/AttackHandler.cs @@ -50,7 +50,7 @@ public class AttackHandler : MonoBehaviour Vector3 knockbackVector = knockbackHorizontalForce * (target.transform.position - transform.position).normalized + knockbackVerticalForce * Vector3.up; - // logic specific if targetUnit is MinecraftUnit + // logic specific if targetUnit is Unit if (targetUnit is MinecraftUnit) { MinecraftUnit minecraftTarget = (MinecraftUnit)targetUnit; diff --git a/Assets/Scripts/UnitScripts/Attacks/Projectiles/AttackProjectile.cs b/Assets/Scripts/UnitScripts/Attacks/Projectiles/AttackProjectile.cs index 8a1ce1e..43c37bd 100644 --- a/Assets/Scripts/UnitScripts/Attacks/Projectiles/AttackProjectile.cs +++ b/Assets/Scripts/UnitScripts/Attacks/Projectiles/AttackProjectile.cs @@ -11,7 +11,18 @@ public class AttackProjectile : AttackHandler public override bool Attack() { // If no target (target is dead an destroyed) - if (!_minecraftUnit.MovementHandler.TargetUnit) _minecraftUnit.MovementHandler.UpdateNearest(); + if (!_minecraftUnit.MovementHandler.TargetUnit) + { + if (_minecraftUnit.IsTeamA) + { + if (GlobalsVariable.AliveUnitsTeamB.Count == 0) return false; + } + else + { + if (GlobalsVariable.AliveUnitsTeamA.Count == 0) return false; + } + _minecraftUnit.MovementHandler.UpdateNearest(); + } float launchAngle = findLaunchAngle(); //print(launchAngle); // If target not reachable diff --git a/Assets/Scripts/UnitScripts/BehaviorState/AbstractBehaviour.cs b/Assets/Scripts/UnitScripts/BehaviorState/AbstractBehaviour.cs index 390d88f..136dba1 100644 --- a/Assets/Scripts/UnitScripts/BehaviorState/AbstractBehaviour.cs +++ b/Assets/Scripts/UnitScripts/BehaviorState/AbstractBehaviour.cs @@ -13,12 +13,12 @@ public abstract class AbstractBehaviour : MonoBehaviour protected abstract void MoveAction(); protected abstract void AttackAction(); - protected MinecraftUnit Unit; + protected MinecraftUnit CurrentMinecraftUnit; void Start() { - Unit = GetComponent(); + CurrentMinecraftUnit = GetComponent(); StartCoroutine(attackUpdate()); StartCoroutine(pathUpdate()); } diff --git a/Assets/Scripts/UnitScripts/BehaviorState/NeutralBehaviour.cs b/Assets/Scripts/UnitScripts/BehaviorState/NeutralBehaviour.cs index 4f3de39..52b5a36 100644 --- a/Assets/Scripts/UnitScripts/BehaviorState/NeutralBehaviour.cs +++ b/Assets/Scripts/UnitScripts/BehaviorState/NeutralBehaviour.cs @@ -5,14 +5,23 @@ public class NeutralBehaviour : AbstractBehaviour [SerializeField] private float distanceGoal = 0.0f; protected override void MoveAction() { - Unit.MovementHandler.UpdateNearest(); - Vector3 targetPos = Unit.MovementHandler.TargetUnit.transform.position; + if (CurrentMinecraftUnit.IsTeamA) + { + if (GlobalsVariable.AliveUnitsTeamB.Count == 0) return; + } + else + { + if (GlobalsVariable.AliveUnitsTeamA.Count == 0) return; + } + + CurrentMinecraftUnit.MovementHandler.UpdateNearest(); + Vector3 targetPos = CurrentMinecraftUnit.MovementHandler.TargetUnit.transform.position; Vector3 goalPos = targetPos + (transform.position - targetPos).normalized * distanceGoal; - Unit.MovementHandler.MoveTowards(goalPos); + CurrentMinecraftUnit.MovementHandler.MoveTowards(goalPos); } protected override void AttackAction() { - //Unit.AttackHandler.Attack(); + //CurrentMinecraftUnit.AttackHandler.Attack(); } } diff --git a/Assets/Scripts/UnitScripts/Capacities/GolemDefense.cs b/Assets/Scripts/UnitScripts/Capacities/GolemDefense.cs index c91f8c4..d5422cd 100644 --- a/Assets/Scripts/UnitScripts/Capacities/GolemDefense.cs +++ b/Assets/Scripts/UnitScripts/Capacities/GolemDefense.cs @@ -12,7 +12,7 @@ public class GolemDefense : BaseCapacity Collider[] hitColliders = Physics.OverlapSphere(transform.position, buffArea.radius, buffArea.includeLayers); foreach (Collider target in hitColliders) { - if (!target.CompareTag("Unit")) continue; + if (!target.CompareTag("CurrentMinecraftUnit")) continue; AbstractUnit targetUnit = target.GetComponent(); if (targetUnit.IsTeamA == _unit.IsTeamA) { diff --git a/Assets/Scripts/UnitScripts/HealthHandler.cs b/Assets/Scripts/UnitScripts/HealthHandler.cs index 1fb005d..353d09d 100644 --- a/Assets/Scripts/UnitScripts/HealthHandler.cs +++ b/Assets/Scripts/UnitScripts/HealthHandler.cs @@ -1,4 +1,6 @@ +using System.Collections.Generic; using UnityEngine; +using UnityEngine.SceneManagement; [RequireComponent(typeof(MinecraftUnit))] public class HealthHandler : MonoBehaviour @@ -43,9 +45,26 @@ public class HealthHandler : MonoBehaviour public void Death(float delay = 0) { DeathSate deathState = _minecraftUnit.AbstractDeath(); - if (deathState == DeathSate.QueenADead) print("TEAM B WIN GG"); - if (deathState == DeathSate.QueenBDead) print("TEAM A WIN GG"); - Destroy(gameObject, delay); + + if (deathState == DeathSate.NotImportant) + { + Destroy(gameObject, delay); + } + + GlobalsVariable.AliveUnitsTeamB = new List(); + GlobalsVariable.AliveUnitsTeamA = new List(); + + if (deathState == DeathSate.QueenADead) + { + print("get good, reload current scene"); + SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name); + } + + if (deathState == DeathSate.QueenBDead) + { + print("GG going to next scene"); + GameManager.Instance.GoNextLevel(); + } } } diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 23cce20..a69da9b 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -5,12 +5,21 @@ EditorBuildSettings: m_ObjectHideFlags: 0 serializedVersion: 2 m_Scenes: - - enabled: 0 - path: Assets/Scenes/Clement.unity - guid: 1a97891ce0a685849849868f0d4b9dfd + - enabled: 1 + path: Assets/Scenes/LevelsTest/0_Steeve.unity + guid: 2c3403c1fdb8d1dcf9b520e66841c95b + - enabled: 1 + path: Assets/Scenes/LevelsTest/1_Pumpkin.unity + guid: f19979b02b35fb34590aaabf38c7fb96 + - enabled: 1 + path: Assets/Scenes/LevelsTest/2_Plaza.unity + guid: 9f44655af04ade9ada0953441ebb0652 - enabled: 1 path: Assets/Scenes/LevelsTest/3_Flat.unity guid: e2d5ca4e4affa49adb640c2abb1bb2e6 + - enabled: 1 + path: Assets/Scenes/LevelsTest/4_NotVillageButFine.unity + guid: bcebc0c8b4fd6cafb970b4449a251d75 m_configObjects: com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 289c1b55c9541489481df5cc06664110, type: 3} m_UseUCBPForAssetBundles: 0