temporary files rename

This commit is contained in:
Crizomb 2025-01-29 00:34:36 +01:00
parent 8e077e523c
commit a87f0ed109
823 changed files with 20 additions and 5 deletions

View file

@ -1,25 +0,0 @@
using UnityEngine;
public class Arrow : ProjectileHandler
{
[SerializeField] private float baseDamage;
[SerializeField] private float baseKnockback;
void OnCollisionEnter(Collision collision)
{
// Can be optimized with tags, but it add dependance beetween teams
if (collision.gameObject.TryGetComponent<AbstractUnit>(out AbstractUnit unit))
{
if (unit is MinecraftUnit && unit.IsTeamA != FromTeamA) // No friendly fire
{
MinecraftUnit minecraftUnit = unit as MinecraftUnit;
Vector3 knockback = RigidBody.linearVelocity * baseKnockback;
minecraftUnit.StartCoroutine(minecraftUnit.MovementHandler.TakeImpulse(knockback));
}
unit.TakeDamage(baseDamage);
_minecraftUnitOrigin.Capacity.AddMana(baseDamage);
}
Destroy(this.gameObject);
}
}

View file

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 36e1a3cc9e04b444cadcfe2b444d0abc

View file

@ -1,70 +0,0 @@
using UnityEngine;
public class AttackProjectile : AttackHandler
{
[SerializeField] private GameObject arrowPrefab;
[SerializeField] private float arrowBaseSpeed;
[SerializeField] private Transform spawnPos;
[SerializeField] private bool directShot;
public override bool Attack()
{
// If no target (target is dead an destroyed)
if (!_minecraftUnit.MovementHandler.TargetUnit)
{
if (_minecraftUnit.IsTeamA)
{
if (GlobalsVariable.AliveUnitsTeamB.Count == 0) return false;
}
else
{
if (GlobalsVariable.AliveUnitsTeamA.Count == 0) return false;
}
}
float launchAngle = findLaunchAngle();
//print(launchAngle);
// If target not reachable
if (launchAngle < 0) return false;
GameObject arrow = Instantiate(arrowPrefab, spawnPos.position, spawnPos.rotation);
ProjectileHandler projectileHandler = arrow.GetComponent<ProjectileHandler>();
// In target <-> launcher + transform.up basis
Vector2 localLaunchVector = arrowBaseSpeed * new Vector2(Mathf.Cos(launchAngle), Mathf.Sin(launchAngle));
// Transform it in global basis
AbstractUnit targetUnit = _minecraftUnit.MovementHandler.TargetUnit;
Vector3 diffVector = Vector3.ProjectOnPlane(targetUnit.transform.position - spawnPos.position, Vector3.up);
Vector3 launchVectorNormalized = (localLaunchVector.x * diffVector.normalized + localLaunchVector.y * Vector3.up).normalized;
projectileHandler.LaunchProjectile(launchVectorNormalized * arrowBaseSpeed, _minecraftUnit.IsTeamA, _minecraftUnit);
return true;
}
private float findLaunchAngle()
{
// 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);
float x = Vector3.ProjectOnPlane(projectOnPlane, Vector3.up).magnitude;
float y = diffVector.y;
float g = Physics.gravity.magnitude;
float v = arrowBaseSpeed;
float v_sqr = v * v;
//print("x : " + x);
float inside_sqrt_root = v_sqr*v_sqr - g*(g*x*x + 2*y*v_sqr);
if (inside_sqrt_root < 0.0f) return -1f; // Can't reach target
// directShot is the smallest angle, undirectShot shot is the biggest angle
float numerator = directShot ? v_sqr - Mathf.Sqrt(inside_sqrt_root) : v_sqr + Mathf.Sqrt(inside_sqrt_root);
float inside_arctan = numerator / (g * x);
return Mathf.Atan(inside_arctan);
}
}

View file

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 6fa6d262ce5ee0761b28bd18f6bcd247

View file

@ -1,38 +0,0 @@
using UnityEngine;
using System.Collections;
public class HealthPotion : ProjectileHandler
{
[SerializeField] private float healthAdd;
[SerializeField] private SphereCollider healthPotionEffectArea;
[SerializeField] private GameObject explodeMesh;
[SerializeField] private float exploseMeshTime = 0.5f;
void OnCollisionEnter(Collision collision)
{
Collider[] targets = Physics.OverlapSphere(transform.position, healthPotionEffectArea.radius, healthPotionEffectArea.includeLayers);
foreach (Collider target in targets)
{
if (!target.CompareTag("Unit")) continue;
// GetComponent is expensive in performance, optimize here if it's slow
AbstractUnit targetUnit = target.GetComponent<AbstractUnit>();
// No EnemyHealing
if (targetUnit.IsTeamA != FromTeamA) continue;
targetUnit.Heal(healthAdd);
_minecraftUnitOrigin.Capacity.AddMana(healthAdd*0.1f);
}
CoroutineManager.Instance.StartCoroutine(ExplodeVisual());
Destroy(gameObject);
}
private IEnumerator ExplodeVisual()
{
GameObject explosion = Instantiate(explodeMesh, transform.position, Quaternion.identity);
explosion.transform.parent = null;
yield return new WaitForSeconds(exploseMeshTime);
Destroy(explosion);
}
}

View file

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: fd66c851299240c02a3082ade5b6295d

View file

@ -1,40 +0,0 @@
using Unity.VisualScripting;
using UnityEngine;
/// <summary>
/// Should be attached to the Arrow, not the skeleton
/// </summary>
[RequireComponent(typeof(Rigidbody))]
public class ProjectileHandler : MonoBehaviour
{
[SerializeField] protected float _lifeSpan = 8.0f;
protected Rigidbody RigidBody;
protected bool FromTeamA;
protected MinecraftUnit _minecraftUnitOrigin;
void Awake()
{
RigidBody = GetComponent<Rigidbody>();
}
void Start()
{
// Destroy after _lifeSpan, in all case
Destroy(this.gameObject, _lifeSpan);
}
void Update()
{
// Align with speed
if (RigidBody.linearVelocity.magnitude >= 1f) transform.forward = RigidBody.linearVelocity.normalized;
}
public void LaunchProjectile(Vector3 baseSpeed, bool fromTeamA, MinecraftUnit minecraftUnit)
{
RigidBody.linearVelocity = baseSpeed;
FromTeamA = fromTeamA;
_minecraftUnitOrigin = minecraftUnit;
}
}

View file

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 9aa6ff4d0673f53389daff2a5ba3c45f