Пример #1
0
 public static IEnumerator TestAttack(WeaponController self, EnemyUnitController ec)
 {
     while (self.Target != null)
     {
         while (ec?.IsTargetable() ?? false)
         {
             Debug.DrawLine(self.ProjectileExitPoint, ec.transform.position);
             yield return(new WaitForFixedUpdate());
         }
         yield return(new WaitForFixedUpdate());
     }
 }
Пример #2
0
    public static IEnumerator RotateTowardsEnemyTargetUnit(Transform self, EnemyUnitController target, float rotationSpeed)
    {
        Transform targetTransform = target.transform;

        while (target?.IsTargetable() ?? false)
        {
            Vector2    vecToTarget   = targetTransform.position - self.position;
            float      angleToTarget = Mathf.Atan2(vecToTarget.y, vecToTarget.x) * Mathf.Rad2Deg;
            Quaternion q             = Quaternion.AngleAxis(angleToTarget, Vector3.forward);
            self.rotation = Quaternion.Slerp(self.rotation, q, StaticObjects.DeltaGameTime * rotationSpeed);
            yield return(new WaitForFixedUpdate());
        }
    }
Пример #3
0
    public void AddObjectToTargets(EnemyUnitController ec)
    {
        clearNullsFromList();
        if (ec.CompareTag("Enemy"))
        {
            if (ec.IsTargetable())
            {
                try {
                    targets.Add(ec.name, ec);
//                Debug.LogWarning(ec.name);
                    CurrentLowestProximityTarget = FindSingleTargetNearestToEndOfSpline();
                }
                catch (Exception e) {
                    Debug.LogWarning(e.Message);
                }
            }
        }
    }