Merge remote-tracking branch 'origin/Syntriax' into Over
This commit is contained in:
@@ -20,6 +20,8 @@ namespace AI
|
||||
protected Transform target = null;
|
||||
protected bool isShooting = false;
|
||||
protected IMovement movement = null;
|
||||
protected Animator animator = null;
|
||||
protected int layerMask = ~(1 << 9);
|
||||
|
||||
protected bool canShoot => target != null && (target.transform.position - transform.position).sqrMagnitude < attackRangeSquared;
|
||||
|
||||
@@ -41,6 +43,7 @@ namespace AI
|
||||
protected virtual void Start()
|
||||
{
|
||||
movement = transform.GetComponentInParent<IMovement>();
|
||||
animator = transform.GetComponentInParent<Animator>();
|
||||
UpdateTarget(FindObjectOfType<Player.PlayerController>()?.transform);
|
||||
}
|
||||
|
||||
@@ -57,8 +60,11 @@ namespace AI
|
||||
isShooting = true;
|
||||
float movementBaseSpeed = movement.BaseSpeed;
|
||||
movement.BaseSpeed = 0f;
|
||||
animator.SetBool("isAttacking", true);
|
||||
|
||||
animator.speed = 0f;
|
||||
yield return new WaitForSeconds(focusingTime);
|
||||
animator.speed = 1f;
|
||||
|
||||
while (canShoot)
|
||||
{
|
||||
@@ -67,6 +73,7 @@ namespace AI
|
||||
yield return null;
|
||||
}
|
||||
movement.BaseSpeed = movementBaseSpeed;
|
||||
animator.SetBool("isAttacking", false);
|
||||
isShooting = false;
|
||||
}
|
||||
|
||||
@@ -77,7 +84,7 @@ namespace AI
|
||||
|
||||
Vector3 velocity = GetVelocityForProjectile(timeForProjectileToHit);
|
||||
|
||||
RaycastHit2D raycastHit2D = Physics2D.Raycast(transform.position, target.position - transform.position, attackRange);
|
||||
RaycastHit2D raycastHit2D = Physics2D.Raycast(transform.position, target.position - transform.position, attackRange, layerMask);
|
||||
if (raycastHit2D.transform != target)
|
||||
velocity = GetVelocityForProjectile(timeForProjectileToHit * 2);
|
||||
|
||||
|
@@ -41,6 +41,8 @@ namespace Level
|
||||
needsRestart = false;
|
||||
}
|
||||
|
||||
public void EndLevel() => PlayerPrefs.SetInt(LevelName, 1);
|
||||
|
||||
[ContextMenu("Restart")]
|
||||
public void Restart() => LevelManager.Instance.SwitchToLevel(LevelName);
|
||||
}
|
||||
|
12
Assets/Scripts/Level/LevelEnd.cs
Normal file
12
Assets/Scripts/Level/LevelEnd.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Level
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public class LevelEnd : MonoBehaviour
|
||||
{
|
||||
private Level level = null;
|
||||
private void Awake() => level = GetComponentInParent<Level>();
|
||||
|
||||
public void EndLevel() => level.EndLevel();
|
||||
}
|
||||
}
|
11
Assets/Scripts/Level/LevelEnd.cs.meta
Normal file
11
Assets/Scripts/Level/LevelEnd.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 696558d6c83d74a498934105513921b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user