poprawki materialy unity 6, pajaki, podmiana katalogu FSM w AIControlerze, zmiana w Spider 2.0 Behaviours , skopane zycie bylo, ladowalo pajaka z zyciem 2.
This commit is contained in:
@@ -7,6 +7,7 @@ namespace Invector.vCharacterController.AI
|
||||
|
||||
public partial interface vIControlAI : vIHealthController
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Used just to Create AI Editor
|
||||
/// </summary>
|
||||
@@ -49,13 +50,14 @@ namespace Invector.vCharacterController.AI
|
||||
bool isRolling { get; }
|
||||
bool isCrouching { get; set; }
|
||||
bool targetInLineOfSight { get; }
|
||||
vAISightMethod SightMethod { get ; set ; }
|
||||
vAISightMethod SightMethod { get; set; }
|
||||
vAIUpdateQuality UpdatePathQuality { get; set; }
|
||||
vAIUpdateQuality FindTargetUpdateQuality { get; set ; }
|
||||
vAIUpdateQuality CanseeTargetUpdateQuality { get; set ; }
|
||||
vAIUpdateQuality FindTargetUpdateQuality { get; set; }
|
||||
vAIUpdateQuality CanseeTargetUpdateQuality { get; set; }
|
||||
vAIMovementSpeed movementSpeed { get; }
|
||||
float targetDistance { get; }
|
||||
float changeWaypointDistance { get; }
|
||||
Vector3 desiredVelocity { get; }
|
||||
float remainingDistance { get; }
|
||||
float stopingDistance { get; set; }
|
||||
float minDistanceToDetect { get; set; }
|
||||
@@ -70,12 +72,12 @@ namespace Invector.vCharacterController.AI
|
||||
void SetObstaclesLayer(LayerMask mask);
|
||||
void SetLineOfSight(float fov = -1, float minDistToDetect = -1, float maxDistToDetect = -1, float lostTargetDistance = -1);
|
||||
void NextWayPoint();
|
||||
|
||||
/// <summary>
|
||||
/// Move AI to a position in World Space
|
||||
/// </summary>
|
||||
/// <param name="destination">world space position</param>
|
||||
/// <param name="speed">movement speed</param>
|
||||
|
||||
/// <summary>
|
||||
/// Move AI to a position in World Space
|
||||
/// </summary>
|
||||
/// <param name="destination">world space position</param>
|
||||
/// <param name="speed">movement speed</param>
|
||||
void MoveTo(Vector3 destination, vAIMovementSpeed speed = vAIMovementSpeed.Walking);
|
||||
/// <summary>
|
||||
/// Move AI to a position in World Space and rotate to a custom direction
|
||||
@@ -85,24 +87,109 @@ namespace Invector.vCharacterController.AI
|
||||
/// <param name="speed">>movement speed</param>
|
||||
void StrafeMoveTo(Vector3 destination, Vector3 forwardDirection, vAIMovementSpeed speed = vAIMovementSpeed.Walking);
|
||||
|
||||
/// <summary>
|
||||
/// Move AI to a position in World Space with out update the target rotation direction of the AI
|
||||
/// </summary>
|
||||
/// <param name="destination">world space position</param>
|
||||
/// <param name="speed">>movement speed</param>
|
||||
void StrafeMoveTo(Vector3 destination, vAIMovementSpeed speed = vAIMovementSpeed.Walking);
|
||||
|
||||
void RotateTo(Vector3 direction);
|
||||
void RollTo(Vector3 direction);
|
||||
void SetCurrentTarget(Transform target);
|
||||
void SetCurrentTarget(Transform target, bool overrideCanseeTarget);
|
||||
void SetCurrentTarget(vAITarget target);
|
||||
void SetCurrentTarget(vAITarget target, bool overrideCanseeTarget);
|
||||
void RemoveCurrentTarget();
|
||||
/// <summary>
|
||||
/// Current target
|
||||
/// </summary>
|
||||
vAITarget currentTarget { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Secundary targets storage
|
||||
/// </summary>
|
||||
List<vAITarget> secundaryTargets { get; set; }
|
||||
/// <summary>
|
||||
/// Return a list of targets resulted of <seealso cref="FindTarget"/> method
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<vAITarget> GetTargetsInRange();
|
||||
/// <summary>
|
||||
/// Find target using Detection settings
|
||||
/// </summary>
|
||||
void FindTarget();
|
||||
/// <summary>
|
||||
/// Find target with ignoring obstacles option and set to <see cref="currentTarget"/>
|
||||
/// </summary>
|
||||
/// <param name="checkForObstacles"></param>
|
||||
void FindTarget(bool checkForObstacles);
|
||||
/// <summary>
|
||||
/// Try get a target
|
||||
/// <remarks>Needs to call <see cref="FindTarget"/> method to detect all target in range.The result is the most closest target</remarks>
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <returns></returns>
|
||||
bool TryGetTarget(out vAITarget target);
|
||||
/// <summary>
|
||||
/// Try get a target with specific tag
|
||||
/// <remarks>Needs to call <see cref="FindTarget"/> method to detect all target in range.The result is the most closest target</remarks>
|
||||
/// </summary>
|
||||
/// <param name="tag">possible target tag</param>
|
||||
/// <param name="target"></param>
|
||||
/// <returns></returns>
|
||||
bool TryGetTarget(string tag, out vAITarget target);
|
||||
/// <summary>
|
||||
/// Try get a target with specific tags
|
||||
/// </summary>
|
||||
/// <remarks>Needs to call <see cref="FindTarget"/> method to detect all target in range.The result is the most closest target</remarks>
|
||||
/// <param name="m_detectTags">list of possible target tags</param>
|
||||
/// <param name="target"></param>
|
||||
/// <returns></returns>
|
||||
bool TryGetTarget(List<string> m_detectTags, out vAITarget target);
|
||||
|
||||
/// <summary>
|
||||
/// Find target with specific detection settings
|
||||
/// </summary>
|
||||
/// <remarks>Needs to call <see cref="FindTarget"/> method to detect all target in range.The result is the most closest target</remarks>
|
||||
/// <param name="m_detectTags">list of possible target tags</param>
|
||||
/// <param name="m_detectLayer">layer of possible target</param>
|
||||
/// <param name="checkForObstables"></param>
|
||||
void FindSpecificTarget(List<string> m_detectTags, LayerMask m_detectLayer, bool checkForObstables = true);
|
||||
|
||||
void LookAround();
|
||||
void LookTo(Vector3 point, float stayLookTime = 1f, float offsetLookHeight = -1);
|
||||
void LookToTarget(Transform target, float stayLookTime = 1f, float offsetLookHeight = -1);
|
||||
void Stop();
|
||||
void ForceUpdatePath(float timeInUpdate = 1f);
|
||||
|
||||
/// <summary>
|
||||
/// Check if AI is Trigger With some collider with specific tag
|
||||
/// </summary>
|
||||
/// <param name="targ"></param>
|
||||
/// <returns></returns>
|
||||
bool IsInTriggerWithTag(string tag);
|
||||
/// <summary>
|
||||
/// Check if AI is Trigger With some collider with specific name
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
bool IsInTriggerWithName(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Check if AI is Trigger With some collider with specific name
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool IsInTriggerWithTag(string tag, out Collider result);
|
||||
/// <summary>
|
||||
/// Check if AI is Trigger With some collider with specific tag
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool IsInTriggerWithName(string name, out Collider result);
|
||||
}
|
||||
|
||||
public partial interface vIControlAICombat : vIControlAI
|
||||
@@ -143,186 +230,9 @@ namespace Invector.vCharacterController.AI
|
||||
{
|
||||
vAIShooterManager shooterManager { get; set; }
|
||||
void SetShooterHitLayer(LayerMask mask);
|
||||
}
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class vAITarget
|
||||
{
|
||||
[SerializeField] protected Transform _transform;
|
||||
[SerializeField, HideInInspector] protected Collider _collider;
|
||||
public Transform transform { get { return _transform; } protected set { _transform = value; } }
|
||||
public Collider collider { get { return _collider; } protected set { _collider = value; } }
|
||||
|
||||
public vIHealthController healthController;
|
||||
public vIControlAICombat combateController;
|
||||
public vIMeleeFighter meleeFighter;
|
||||
public vICharacter character;
|
||||
|
||||
public bool isFixedTarget = true;
|
||||
[HideInInspector]
|
||||
public bool isLost;
|
||||
[HideInInspector]
|
||||
public bool _hadHealthController;
|
||||
|
||||
public bool hasCollider
|
||||
{
|
||||
get
|
||||
{
|
||||
return collider != null;
|
||||
}
|
||||
}
|
||||
public static implicit operator Transform(vAITarget m)
|
||||
{
|
||||
try
|
||||
{
|
||||
return m.transform;
|
||||
}
|
||||
catch { return null; }
|
||||
}
|
||||
public bool hasHealthController
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_hadHealthController && healthController == null)
|
||||
transform = null;
|
||||
return healthController != null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isDead
|
||||
{
|
||||
get
|
||||
{
|
||||
var value = true;
|
||||
if (hasHealthController) value = healthController.isDead;
|
||||
else if (_hadHealthController) value = true;
|
||||
else if (!transform.gameObject.activeInHierarchy) value = true;
|
||||
else if (_collider) value = !_collider.enabled;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isArmed
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!isFighter) return false;
|
||||
return meleeFighter != null ? meleeFighter.isArmed : combateController != null ? combateController.isArmed : false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isBlocking
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!isFighter) return false;
|
||||
return meleeFighter != null ? meleeFighter.isBlocking : combateController != null ? combateController.isBlocking : false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isAttacking
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!isFighter) return false;
|
||||
return meleeFighter != null ? meleeFighter.isAttacking : combateController != null ? combateController.isAttacking : false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isFighter
|
||||
{
|
||||
get
|
||||
{
|
||||
return meleeFighter != null || combateController != null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isCharacter
|
||||
{
|
||||
get
|
||||
{
|
||||
return character != null;
|
||||
}
|
||||
}
|
||||
|
||||
public float currentHealth
|
||||
{
|
||||
get
|
||||
{
|
||||
if (hasHealthController) return healthController.currentHealth;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitTarget(Transform target)
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
transform = target;
|
||||
collider = transform.GetComponent<Collider>();
|
||||
healthController = transform.GetComponent<vIHealthController>();
|
||||
_hadHealthController = this.healthController != null;
|
||||
meleeFighter = transform.GetComponent<vIMeleeFighter>();
|
||||
character = transform.GetComponent<vICharacter>();
|
||||
combateController = transform.GetComponent<vIControlAICombat>();
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearTarget()
|
||||
{
|
||||
transform = null;
|
||||
collider = null;
|
||||
healthController = null;
|
||||
meleeFighter = null;
|
||||
character = null;
|
||||
combateController = null;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class vAIReceivedDamegeInfo
|
||||
{
|
||||
public vAIReceivedDamegeInfo()
|
||||
{
|
||||
lasType = "unnamed";
|
||||
}
|
||||
[vReadOnly(false)] public bool isValid;
|
||||
[vReadOnly(false)] public int lastValue;
|
||||
[vReadOnly(false)] public string lasType = "unnamed";
|
||||
[vReadOnly(false)] public Transform lastSender;
|
||||
[vReadOnly(false)] public int massiveCount;
|
||||
[vReadOnly(false)] public int massiveValue;
|
||||
|
||||
protected float lastValidDamage;
|
||||
float _massiveTime;
|
||||
public void Update()
|
||||
{
|
||||
_massiveTime -= Time.deltaTime;
|
||||
if (_massiveTime <= 0)
|
||||
{
|
||||
_massiveTime = 0;
|
||||
if (massiveValue > 0) massiveValue -= 1;
|
||||
if (massiveCount > 0) massiveCount -= 1;
|
||||
}
|
||||
isValid = lastValidDamage > Time.time;
|
||||
}
|
||||
|
||||
public void UpdateDamage(vDamage damage, float validDamageTime = 2f)
|
||||
{
|
||||
if (damage == null) return;
|
||||
lastValidDamage = Time.time + validDamageTime;
|
||||
_massiveTime += Time.deltaTime;
|
||||
massiveCount++;
|
||||
lastValue = damage.damageValue;
|
||||
massiveValue += lastValue;
|
||||
lastSender = damage.sender;
|
||||
lasType = string.IsNullOrEmpty(damage.damageType) ? "unnamed" : damage.damageType;
|
||||
}
|
||||
}
|
||||
|
||||
public interface vIStateAttackListener
|
||||
{
|
||||
void OnReceiveAttack(vIControlAICombat combatController, ref vDamage damage, vIMeleeFighter attacker, ref bool canBlock);
|
||||
/// <summary>
|
||||
/// Check if Aim is aligned to the target position setted from method <see cref="vIControlAICombat.AimTo(Vector3, float, object)"/>
|
||||
/// </summary>
|
||||
bool IsInShotAngle { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user