Ejemplo n.º 1
0
    public FCBullet GetFromPool(string bulletName)
    {
        if (!_allBulletArray.ContainsKey(bulletName))
        {
            _allBulletArray.Add(bulletName, new List <FCBullet>());
        }
        List <FCBullet> leb = _allBulletArray[bulletName];
        FCBullet        eb  = null;

        if (leb.Count > 0)
        {
            foreach (FCBullet ebf in leb)
            {
                if (!ebf.enabled && ebf.DeadTime < 0)
                {
                    ebf.enabled = true;
                    eb          = ebf;
                    break;
                }
            }
        }
        if (eb == null || leb.Count <= 0)
        {
            eb = AddBulletToPool(bulletName);
        }
        return(eb);
    }
Ejemplo n.º 2
0
 public void ReturnToPool(FCBullet eb)
 {
     eb.enabled = false;
     if (eb.DeadTime >= 0)
     {
         _deadArray.Add(eb);
     }
 }
Ejemplo n.º 3
0
    public void Active(ActionController target, FCBullet owner)
    {
        _target = target;

        _myTransform.localPosition = _pool._core.position;
        _targetTransform           = target.ACGetTransformByName(_targetPart);
        gameObject.SetActive(true);

        _timer = -1.0f;         // delay 1st hurt to update.
        // init hurt parameter.
        _fastCommand._param1 = _pool;
        _fastCommand._cmd    = FCCommand.CMD.HURT;
        _fastCommand._param2 = _target;
        _fastCommand._param3 = 0;
        _owner = owner;
    }
Ejemplo n.º 4
0
    protected FCBullet AddBulletToPool(string bulletName)
    {
        GameObject go = BulletAssembler.Singleton.AssembleBullet(bulletName);

        if (go != null)
        {
            List <FCBullet> leb = _allBulletArray[bulletName];
            go.transform.parent = LevelManager.Singleton.BulletRoot;
            FCBullet eb = go.GetComponent <FCBullet>();
            eb._name   = bulletName;
            eb.enabled = true;
            leb.Add(eb);
            return(eb);
        }
        else
        {
            return(null);
        }
    }
Ejemplo n.º 5
0
 public void RefreshPorts(FCBullet eb)
 {
     if (_firePointNames != null && _firePointNames.Length != 0)
     {
         _firePoints = new Transform[_firePointNames.Length];
         for (int i = 0; i < _firePointNames.Length; i++)
         {
             _firePoints[i] = eb.ACGetTransformByName(_firePointNames[i]);
         }
         _fireAngleTotal = _fireAngleRight - _fireAngleLeft;
         if (_angleStep > 0)
         {
             _angleOffest = _fireAngleTotal / _angleStep;
         }
         else
         {
             _angleOffest = 0;
         }
     }
 }
Ejemplo n.º 6
0
 public override void AttackQuit()
 {
     if (_attackEffect != FC_CHARACTER_EFFECT.INVALID)
     {
         //stop effect
         CharacterEffectManager.Instance.StopEffect(_attackEffect,
                                                    _owner.ACOwner._avatarController, 1);
     }
     if (_bhBullet != null)
     {
         _bhBullet.Dead();
     }
     if (_owner.ACOwner.IsClientPlayer)
     {
         if (_owner._updateAttackPos)
         {
             _owner.ACOwner.ACStop();
         }
         //_owner._attackMoveSpeed = _owner.ACOwner.Data.TotalMoveSpeed * _speedScale;
     }
     _bhBullet = null;
     base.AttackQuit();
 }
Ejemplo n.º 7
0
 public void ReturnToPool(FCBullet eb)
 {
     _bulletListSource.ReturnToPool(eb);
 }
Ejemplo n.º 8
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);
            }
        }
    }