Пример #1
0
    /*
     * Fire at closest enemy to this character, assuming it sees more than one
     */
    private void fireClosest()
    {
        GameObject target = null;
        float      cDist  = Mathf.Infinity;

        foreach (GameObject g in visible)
        {
            float dist = Vector3.Distance(prefabObject.transform.position, g.transform.position);
            if (dist < cDist)
            {
                cDist  = dist;
                target = g;
            }
        }
        if (target != null && reloadTimer == 0)
        {
            CharacterScript targetScript = target.GetComponent <CharacterScript>();
            IShot.Invoke(targetScript, damage);
            anim.SetTrigger("Shoot");
            part.Play();
            //StartCoroutine(shootLine(target.transform.position));
            targetScript.attackedFromLocations.Add(prefabObject.transform.position);
            targetScript.refreshEnemyLocationTimer();
            this.refreshReloadTimer();
        }
    }
 /**
  * raises ShotEvent
  */
 private void OnShotEvent()
 {
     _isShot = true;
     ShotEvent?.Invoke(this, EventArgs.Empty);
 }
Пример #3
0
 public void Shot()
 {
     ShotEvent?.Invoke();
 }