Merge branch 'main' of https://github.com/Crizomb/ProjetAMJV_CR
This commit is contained in:
commit
c2af70eeb4
102 changed files with 5483 additions and 44 deletions
|
@ -18,6 +18,7 @@ public abstract class AbstractUnit : MonoBehaviour
|
|||
public abstract void Heal(float heal);
|
||||
public abstract void AddArmor(float armor);
|
||||
public abstract void RemoveArmor(float armor);
|
||||
public abstract void StartFight();
|
||||
|
||||
protected void Awake()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,5 +51,23 @@ public class MinecraftUnit : AbstractUnit
|
|||
{
|
||||
HealthHandler.RemoveArmor(armor);
|
||||
}
|
||||
|
||||
public override void StartFight()
|
||||
{
|
||||
Component[] components = GetComponents<Component>();
|
||||
|
||||
foreach (Component component in components)
|
||||
{
|
||||
if (component is MonoBehaviour monoBehaviour)
|
||||
{
|
||||
monoBehaviour.enabled = true;
|
||||
}
|
||||
|
||||
if (component is NavMeshAgent agent)
|
||||
{
|
||||
agent.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue