Esempio n. 1
0
 private void AimTarget()
 {
     if (m_targetTransform == null && m_setTargetFromTag)
     {
         m_targetTransform = Utils2D.GetTransformFromTagName(m_targetTagName, m_randomSelectTagTarget);
     }
     if (m_targetTransform != null)
     {
         m_centerAngle = Utils2D.GetAngleFromTwoPosition(transform, m_targetTransform, Utils2D.AXIS.X_AND_Y);
     }
 }
Esempio n. 2
0
    public override void Shot()
    {
        if (m_targetTransform == null && m_setTargetFromTag)
        {
            m_targetTransform = Utils2D.GetTransformFromTagName(m_targetTagName, m_randomSelectTagTarget);
        }
        if (m_targetTransform == null)
        {
            Debug.LogWarning("Cannot shot because TargetTransform is not set.");
            return;
        }

        m_holeCenterAngle = Utils2D.GetAngleFromTwoPosition(transform, m_targetTransform, Utils2D.AXIS.X_AND_Y);

        base.Shot();
    }
Esempio n. 3
0
    private IEnumerator ShotCoroutine()
    {
        if (m_bulletNum <= 0 || m_bulletSpeed <= 0f)
        {
            Debug.LogWarning("Cannot shot because BulletNum or BulletSpeed is not set.");
            yield break;
        }
        if (m_shooting)
        {
            yield break;
        }
        m_shooting = true;

        for (int i = 0; i < m_bulletNum; i++)
        {
            if (0 < i && 0f < m_betweenDelay)
            {
                FiredShot();
                yield return(new WaitForSeconds(m_betweenDelay));
            }

            var bullet = GetBullet(transform.position);
            if (bullet == null)
            {
                break;
            }

            if (m_targetTransform == null && m_setTargetFromTag)
            {
                m_targetTransform = Utils2D.GetTransformFromTagName(m_targetTagName, m_randomSelectTagTarget);
            }

            float angle = Utils2D.GetAngleFromTwoPosition(transform, m_targetTransform, Utils2D.AXIS.X_AND_Y);

            ShotBullet(bullet, m_bulletSpeed, angle, true, m_targetTransform, m_homingAngleSpeed);
        }

        FiredShot();

        FinishedShot();

        yield break;
    }