override public void OnStateEnter(Animator fsm, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (laserManLogic == null)
     {
         laserManLogic = fsm.gameObject.GetComponent <LaserManLogic>();
     }
 }
    override public void OnStateEnter(Animator fsm, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (laserManLogic == null)
        {
            laserManLogic = fsm.gameObject.GetComponentInParent <LaserManLogic>();

            Debug.Assert(laserManLogic != null, "LaserManLogic must not be null!");
        }

        if (laserMan == null)
        {
            laserMan = laserManLogic.transform;
        }
    }
    override public void OnStateUpdate(Animator fsm, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (dragon.lifeOver)
        {
            fsm.SetTrigger("Leave");
            return;
        }


        List <GameObject> enemies = dragon.GetEnemyList();

        foreach (GameObject enemy in enemies)
        {
            if (enemy == null)
            {
                continue;
            }


            LaserManLogic laserMan = enemy.GetComponent <LaserManLogic>();

            if (laserMan != null)
            {
                if (laserMan.landed == false)
                {
                    continue;
                }

                if (laserMan.currentBlockBlocking == null || laserMan.currentBlockBlocking == laserMan.blockCol.gameObject)
                {
                    continue;
                }
                else
                {
                    laserMenBlocked.Add(laserMan);
                }
            }

            //Lasermen are given priority over turrets
            if (laserMenBlocked.Count > 0)
            {
                continue;
            }

            TurretLogic turret = enemy.GetComponent <TurretLogic>();

            if (turret != null)
            {
                if (turret.currentBlockBlocking != null)
                {
                    turretsBlocked.Add(turret);
                }
            }
        }

        float winningDistance = Mathf.Infinity;

        foreach (LaserManLogic laserMan in laserMenBlocked)
        {
            if (laserMan == null)
            {
                continue;
            }

            float distance = Vector3.Distance(spirit.position, laserMan.transform.position);

            if (distance < winningDistance)
            {
                dragon.destroyTarget = laserMan.currentBlockBlocking;
                winningDistance      = distance;
            }
        }


        if (laserMenBlocked.Count == 0)
        {
            foreach (TurretLogic turret in turretsBlocked)
            {
                if (turret == null)
                {
                    continue;
                }

                float distance = Vector3.Distance(spirit.position, turret.transform.position);

                if (distance < winningDistance)
                {
                    dragon.destroyTarget = turret.currentBlockBlocking;
                    winningDistance      = distance;
                }
            }
        }

        if (dragon.detectedSpiritBlock != null)
        {
            Block block = dragon.detectedSpiritBlock.GetComponent <Block>();

            if (block != null)
            {
                if (block.insidePlane == true && block.canMove == true)
                {
                    dragon.freezeTarget = dragon.detectedSpiritBlock;
                }
            }
        }


        if (dragon.destroyTarget != null || dragon.freezeTarget != null)
        {
            fsm.SetTrigger("Fire");
        }
    }