Esempio n. 1
0
    public void Attack()
    {
        //check if posideon or an enemy are in range
        currentTimer += Time.deltaTime * attackSpeed;


        var hitColliders = Physics2D.OverlapCircleAll(transform.position, range, 1 << LayerMask.NameToLayer("Enemy"));

        if (currentTimer >= 1.0f)
        {
            for (int i = 0; i < hitColliders.Length; i++)
            {
                PosedionScript posedion = hitColliders[i].GetComponent <PosedionScript>();
                iEnemy         enemy    = hitColliders[i].GetComponent <iEnemy>();

                if (posedion != null)
                {
                    posedion.TakeDamage(damage);
                    AttackVisualization(posedion.gameObject.transform);
                }
                else if (enemy != null)
                {
                    enemy.TakeDamage(damage);
                    AttackVisualization(hitColliders[i].transform);
                }
            }

            currentTimer = 0f;
        }
    }
Esempio n. 2
0
    public static IEnumerator Move(Transform entity, Direction givenDirection, int givenTravel, float givenSpeed)
    {
        Vector3 startPosition = entity.position;
        Vector3 endPosition   = PathMovement.GetMovementOverDistance(entity, givenDirection, givenTravel);
        float   waitTime      = givenSpeed / 0.5f;

        float elapsedTime = 0;

        PosedionScript posideon = entity.gameObject.GetComponent <PosedionScript>();

        if (posideon != null)
        {
            posideon.SetMidMove(true);
        }

        while (elapsedTime < waitTime)
        {
            entity.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / waitTime));
            elapsedTime    += Time.deltaTime;
            yield return(null);
        }

        if (posideon != null)
        {
            posideon.SetMidMove(false);
        }



        // Make sure we got there
        entity.position = endPosition;
    }
Esempio n. 3
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     posedion      = GameObject.FindObjectOfType <PosedionScript>();
     waveText.text = "Wave: " + wave;
 }