Merge branch 'main' of https://github.com/Crizomb/ProjetAMJV_CR
This commit is contained in:
commit
e51417a4e5
11 changed files with 135 additions and 53 deletions
|
@ -9262,16 +9262,39 @@ PrefabInstance:
|
|||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedComponents:
|
||||
- {fileID: 3872651080186061807, guid: 47d419944f796b5c895d7a27016647a1, type: 3}
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 3519332865738438487, guid: 47d419944f796b5c895d7a27016647a1, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 719165817}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 47d419944f796b5c895d7a27016647a1, type: 3}
|
||||
--- !u!4 &719165806 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 498920847641565454, guid: 47d419944f796b5c895d7a27016647a1, type: 3}
|
||||
m_PrefabInstance: {fileID: 719165805}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &719165807 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 3519332865738438487, guid: 47d419944f796b5c895d7a27016647a1, type: 3}
|
||||
m_PrefabInstance: {fileID: 719165805}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &719165817
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 719165807}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 794f919ac24609c05b9c690aaab19146, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
pathFps: 1
|
||||
distanceGoal: 0
|
||||
--- !u!1001 &730637819
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -17086,16 +17109,39 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedComponents:
|
||||
- {fileID: 5068148679420978154, guid: 87b84199a88b2822fb7a2a230db2f0ba, type: 3}
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 4845006117378930514, guid: 87b84199a88b2822fb7a2a230db2f0ba, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1339550862}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 87b84199a88b2822fb7a2a230db2f0ba, type: 3}
|
||||
--- !u!4 &1339550851 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 8432779344647231755, guid: 87b84199a88b2822fb7a2a230db2f0ba, type: 3}
|
||||
m_PrefabInstance: {fileID: 1339550850}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &1339550852 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 4845006117378930514, guid: 87b84199a88b2822fb7a2a230db2f0ba, type: 3}
|
||||
m_PrefabInstance: {fileID: 1339550850}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1339550862
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1339550852}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 794f919ac24609c05b9c690aaab19146, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
pathFps: 1
|
||||
distanceGoal: 0
|
||||
--- !u!1001 &1346902245
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -27717,16 +27763,39 @@ PrefabInstance:
|
|||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedComponents:
|
||||
- {fileID: 3872651080186061807, guid: 47d419944f796b5c895d7a27016647a1, type: 3}
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 3519332865738438487, guid: 47d419944f796b5c895d7a27016647a1, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 2105221389}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 47d419944f796b5c895d7a27016647a1, type: 3}
|
||||
--- !u!4 &2105221378 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 498920847641565454, guid: 47d419944f796b5c895d7a27016647a1, type: 3}
|
||||
m_PrefabInstance: {fileID: 2105221377}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &2105221379 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 3519332865738438487, guid: 47d419944f796b5c895d7a27016647a1, type: 3}
|
||||
m_PrefabInstance: {fileID: 2105221377}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &2105221389
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2105221379}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 794f919ac24609c05b9c690aaab19146, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
pathFps: 1
|
||||
distanceGoal: 0
|
||||
--- !u!1001 &2109955598
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -12,7 +12,6 @@ public class CameraMouvement : MonoBehaviour
|
|||
if (context.phase == InputActionPhase.Performed)
|
||||
{
|
||||
_moveInput = context.ReadValue<Vector2>();
|
||||
print(_moveInput);
|
||||
}
|
||||
}
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
|
|
|
@ -21,7 +21,6 @@ public class GameManager : MonoBehaviourSingletonPersistent<GameManager>
|
|||
// Delete, use only for Debug
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
print("OOKOKOKOKOKOK");
|
||||
StartFightForAll();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ public class AttackProjectile : AttackHandler
|
|||
{
|
||||
if (GlobalsVariable.AliveUnitsTeamA.Count == 0) return false;
|
||||
}
|
||||
_minecraftUnit.MovementHandler.UpdateNearest();
|
||||
}
|
||||
float launchAngle = findLaunchAngle();
|
||||
//print(launchAngle);
|
||||
|
@ -47,6 +46,7 @@ public class AttackProjectile : AttackHandler
|
|||
// Source : https://en.wikipedia.org/wiki/Projectile_motion#Angle_%CE%B8_required_to_hit_coordinate_(x,_y)
|
||||
|
||||
AbstractUnit targetUnit = _minecraftUnit.MovementHandler.TargetUnit;
|
||||
if (targetUnit == null) return -1f;
|
||||
Vector3 diffVector = targetUnit.transform.position - spawnPos.position;
|
||||
Vector3 projectOnPlane = Vector3.ProjectOnPlane(diffVector, Vector3.up);
|
||||
|
||||
|
|
|
@ -8,10 +8,9 @@ using System.Collections.Generic;
|
|||
public abstract class AbstractBehaviour : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float pathFps = 1.0f;
|
||||
[SerializeField] private float attackFps = 5.0f;
|
||||
[SerializeField] protected float distanceGoal = 0.0f;
|
||||
|
||||
protected abstract void MoveAction();
|
||||
protected abstract void AttackAction();
|
||||
|
||||
protected MinecraftUnit CurrentMinecraftUnit;
|
||||
|
||||
|
@ -19,23 +18,9 @@ public abstract class AbstractBehaviour : MonoBehaviour
|
|||
void Start()
|
||||
{
|
||||
CurrentMinecraftUnit = GetComponent<MinecraftUnit>();
|
||||
StartCoroutine(attackUpdate());
|
||||
StartCoroutine(pathUpdate());
|
||||
}
|
||||
|
||||
// Path update and attack update can be expansive, so we don't do that every frame. We create custom update
|
||||
// We create custom update at low fps to handle this without performance issues
|
||||
|
||||
private IEnumerator attackUpdate()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
AttackAction();
|
||||
yield return new WaitForSeconds(1.0f/attackFps);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator pathUpdate()
|
||||
{
|
||||
while (true)
|
||||
|
|
|
@ -4,11 +4,20 @@ public class DefensiveBehaviour : AbstractBehaviour
|
|||
{
|
||||
protected override void MoveAction()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
if (CurrentMinecraftUnit.IsTeamA)
|
||||
{
|
||||
if (GlobalsVariable.AliveUnitsTeamB.Count == 0) return;
|
||||
CurrentMinecraftUnit.MovementHandler.UpdateNearestFrom(GlobalsVariable.QueenA.transform);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GlobalsVariable.AliveUnitsTeamA.Count == 0) return;
|
||||
CurrentMinecraftUnit.MovementHandler.UpdateNearestFrom(GlobalsVariable.QueenB.transform);
|
||||
}
|
||||
|
||||
protected override void AttackAction()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
Vector3 targetPos = CurrentMinecraftUnit.MovementHandler.TargetUnit.transform.position;
|
||||
Vector3 goalPos = targetPos + (transform.position - targetPos).normalized * distanceGoal;
|
||||
CurrentMinecraftUnit.MovementHandler.MoveTowards(goalPos);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class NeutralBehaviour : AbstractBehaviour
|
||||
{
|
||||
[SerializeField] private float distanceGoal = 0.0f;
|
||||
protected override void MoveAction()
|
||||
{
|
||||
if (CurrentMinecraftUnit.IsTeamA)
|
||||
|
@ -13,15 +13,14 @@ public class NeutralBehaviour : AbstractBehaviour
|
|||
{
|
||||
if (GlobalsVariable.AliveUnitsTeamA.Count == 0) return;
|
||||
}
|
||||
|
||||
CurrentMinecraftUnit.MovementHandler.UpdateNearest();
|
||||
Vector3 targetPos = CurrentMinecraftUnit.MovementHandler.TargetUnit.transform.position;
|
||||
AbstractUnit targetUnit = CurrentMinecraftUnit.MovementHandler.TargetUnit;
|
||||
if (targetUnit == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Vector3 targetPos = targetUnit.transform.position;
|
||||
Vector3 goalPos = targetPos + (transform.position - targetPos).normalized * distanceGoal;
|
||||
CurrentMinecraftUnit.MovementHandler.MoveTowards(goalPos);
|
||||
}
|
||||
|
||||
protected override void AttackAction()
|
||||
{
|
||||
//CurrentMinecraftUnit.AttackHandler.Attack();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,19 @@ public class OffensiveBehaviour : AbstractBehaviour
|
|||
{
|
||||
protected override void MoveAction()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
if (CurrentMinecraftUnit.IsTeamA)
|
||||
{
|
||||
if (GlobalsVariable.QueenB == null) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GlobalsVariable.QueenA == null) return;
|
||||
}
|
||||
|
||||
protected override void AttackAction()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
CurrentMinecraftUnit.MovementHandler.TargetUnit = GlobalsVariable.QueenB;
|
||||
Vector3 targetPos = CurrentMinecraftUnit.MovementHandler.TargetUnit.transform.position;
|
||||
Vector3 goalPos = targetPos + (transform.position - targetPos).normalized * distanceGoal;
|
||||
CurrentMinecraftUnit.MovementHandler.MoveTowards(goalPos);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ public class WitchSummon : BaseCapacity
|
|||
|
||||
protected override bool CapacityCall()
|
||||
{
|
||||
print("SUMMON");
|
||||
print(Mana);
|
||||
Instantiate(summonUnit, transform.position, Quaternion.identity);
|
||||
GameObject unit = Instantiate(summonUnit, transform.position, Quaternion.identity);
|
||||
AbstractUnit unitScript = unit.GetComponent<AbstractUnit>();
|
||||
unitScript.StartFight();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public class HealthHandler : MonoBehaviour
|
|||
if (deathState == DeathSate.NotImportant)
|
||||
{
|
||||
Destroy(gameObject, delay);
|
||||
return;
|
||||
}
|
||||
|
||||
GlobalsVariable.AliveUnitsTeamB = new List<AbstractUnit>();
|
||||
|
|
|
@ -15,7 +15,7 @@ public class MovementHandler : MonoBehaviour
|
|||
[SerializeField] private float knockbackTime = 1.2f;
|
||||
private float _noNavMeshDeadTime = 6.0f;
|
||||
|
||||
[HideInInspector] public AbstractUnit TargetUnit {get; private set; }
|
||||
[HideInInspector] public AbstractUnit TargetUnit {get; set; }
|
||||
|
||||
private MinecraftUnit _minecraftUnit;
|
||||
private Rigidbody _rigidbody;
|
||||
|
@ -62,13 +62,14 @@ public class MovementHandler : MonoBehaviour
|
|||
TargetUnit = FindNearest(followEnemy);
|
||||
}
|
||||
|
||||
public void MoveTowardsNearest()
|
||||
public void UpdateNearestFrom(Transform transform)
|
||||
{
|
||||
MoveTowards(TargetUnit.transform.position);
|
||||
TargetUnit = FindNearestFromTransform(true, transform);
|
||||
}
|
||||
|
||||
|
||||
// If findEnemy, return closest ennemy else return closest ally
|
||||
public AbstractUnit FindNearest(bool findEnemy)
|
||||
private AbstractUnit FindNearestFromTransform(bool findEnemy, Transform from)
|
||||
{
|
||||
// Funny funny double ternary operator.
|
||||
List<AbstractUnit> targets = findEnemy ?
|
||||
|
@ -79,7 +80,7 @@ public class MovementHandler : MonoBehaviour
|
|||
float closestDistance = float.MaxValue;
|
||||
foreach (AbstractUnit target in targets)
|
||||
{
|
||||
float distanceToEnemy = (target.transform.position - transform.position).sqrMagnitude;
|
||||
float distanceToEnemy = (target.transform.position - from.position).sqrMagnitude;
|
||||
if (distanceToEnemy < closestDistance && target != _minecraftUnit)
|
||||
{
|
||||
closestUnit = target;
|
||||
|
@ -87,9 +88,21 @@ public class MovementHandler : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
if (closestUnit == null)
|
||||
{
|
||||
print("What");
|
||||
print(targets.Count);
|
||||
print(targets);
|
||||
}
|
||||
|
||||
return closestUnit;
|
||||
}
|
||||
|
||||
private AbstractUnit FindNearest(bool findEnemy)
|
||||
{
|
||||
return FindNearestFromTransform(findEnemy, transform);
|
||||
}
|
||||
|
||||
public IEnumerator TakeImpulse(Vector3 impulse)
|
||||
{
|
||||
// Unity navmesh, can't handle physics (it rewrite velocity). So we deactivate it when applying force.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue