Ejemplo n.º 1
0
    static void FireBullet(string bulletName, int angle, int angleY, Transform tf, FirePort fp, float lifeTime, ActionController owner)
    {
        FCBullet         eb = owner.GetBulletFromPool(bulletName);
        ActionController ac = null;

        if (owner.IsPlayer)
        {
            if (eb._seekLevel == FCBullet.SEEK_LEVEL.NORMAL)
            {
                ac = ActionControllerManager.Instance.GetEnemyTargetBySight
                         (owner.ThisTransform, eb._maxTargetingDistance, 0, owner.Faction, FCConst.SEEK_ANGLE_NORMAL, true);
            }
            else if (eb._seekLevel == FCBullet.SEEK_LEVEL.PRO)
            {
                ac = ActionControllerManager.Instance.GetEnemyTargetBySight
                         (owner.ThisTransform, eb._maxTargetingDistance, 0, owner.Faction, FCConst.SEEK_ANGLE_NORMAL, FCConst.SEEK_ANGLE_PRO, true);
            }
        }
        else
        {
            if (eb._seekLevel == FCBullet.SEEK_LEVEL.NORMAL)
            {
                //ac = ActionControllerManager.Instance.GetEnemyTargetBySight
                //	(owner.ThisTransform,eb._maxTargetingDistance ,0,owner.Faction,FC_CONST.SEEK_ANGLE_NORMAL,true);
            }
            else if (eb._seekLevel == FCBullet.SEEK_LEVEL.PRO)
            {
                if (owner.TargetAC != null)
                {
                    ac = owner.TargetAC;
                }
            }
        }
        if (eb != null)
        {
            /*_fastCommand._cmd = FCCommand.CMD.DIRECTION_FACE_TARGET;
             * _fastCommand._param1 = ac;
             * CommandManager.Instance.SendFast(ref _fastCommand,_owner);*/
            eb.Init(owner);
            if (eb.IsRangerBullet)
            {
                eb.FireRanger(null, tf, fp);
                //(eb as BulletRanger).Fire(5f,3f,FC_HIT_TYPE.DIZZY,tf,false);
            }
            else
            {
                eb.Fire(ac, tf, angle, angleY, lifeTime, fp);
                if (eb._controlByAttack &&
                    ac != null &&
                    owner.ACGetCurrentAttack() != null &&
                    owner.ACGetCurrentAttack()._needAttackCorrect)
                {
                    Vector3 v3 = ac.ThisTransform.localPosition - owner.ThisTransform.localPosition;
                    v3.y = 0;
                    v3.Normalize();
                    if (v3 != Vector3.zero)
                    {
                        owner.ACRotateTo(v3, -1, true, true);
                    }
                }
            }
            if (eb._controlByAttack)
            {
                owner.ACAddBulletToAttack(eb);
            }
        }
    }