next level logic

This commit is contained in:
Crizomb 2025-01-28 04:11:53 +01:00
parent ee2a5fdf08
commit 37bed1fd33
16 changed files with 130 additions and 38 deletions

View file

@ -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

View file

@ -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

View file

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

View file

@ -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

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 966ab30231f8849209ccf80b87cf41ec
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 23800000
userData:
assetBundleName:
assetBundleVariant:

View file

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

View file

@ -1,8 +1,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviourSingletonPersistent<GameManager>
{
[SerializeField] private List<string> 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<GameManager>
// Delete, use only for Debug
if (Input.GetKeyDown(KeyCode.Space))
{
print("OOKOKOKOKOKOK");
StartFightForAll();
}
}
@ -27,5 +34,19 @@ public class GameManager : MonoBehaviourSingletonPersistent<GameManager>
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");
}
}

View file

@ -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;

View file

@ -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

View file

@ -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<MinecraftUnit>();
CurrentMinecraftUnit = GetComponent<MinecraftUnit>();
StartCoroutine(attackUpdate());
StartCoroutine(pathUpdate());
}

View file

@ -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();
}
}

View file

@ -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<AbstractUnit>();
if (targetUnit.IsTeamA == _unit.IsTeamA)
{

View file

@ -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<AbstractUnit>();
GlobalsVariable.AliveUnitsTeamA = new List<AbstractUnit>();
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();
}
}
}

View file

@ -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