void StartSpawnNpcAmmo()
    {
        if (AudioNpcFire != null)
        {
            if (AudioNpcFire.isPlaying)
            {
                AudioNpcFire.Stop();
            }
            AudioNpcFire.Play();
        }

        GameObject obj  = null;
        Transform  tran = null;

        if (AmmoLiZiPrefab != null)
        {
            obj = SpawnParticleCom.SpawnParticleObject(AmmoLiZiPrefab, AmmoSpawnTran.position, AmmoSpawnTran.rotation);
            if (obj.transform.parent != XkGameCtrl.NpcAmmoArray)
            {
                obj.transform.parent = XkGameCtrl.NpcAmmoArray;
            }
        }

        PlayerAmmoCtrl ammoPlayerScript = AmmoPrefab.GetComponent <PlayerAmmoCtrl>();

        if (ammoPlayerScript != null && !XkGameCtrl.GetInstance().IsCartoonShootTest)
        {
            return;
        }

        obj = GetNpcAmmoFromList(AmmoSpawnTran);
        if (obj == null)
        {
            return;
        }

        tran        = obj.transform;
        tran.parent = XkGameCtrl.NpcAmmoArray;
        NpcAmmoCtrl AmmoScript = obj.GetComponent <NpcAmmoCtrl>();

        if (AmmoScript != null)
        {
            AmmoScript.SetNpcScriptInfo(NpcScript);
            AmmoScript.SetIsAimFeiJiPlayer(IsAimFeiJiPlayer);
        }
        else
        {
            PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();
            if (ammoScript != null)
            {
                Vector3 startPos    = tran.position;
                Vector3 firePos     = tran.position;
                Vector3 ammoForward = tran.forward;
                firePos = Random.Range(300f, 400f) * ammoForward + startPos;
                float      fireDisVal = Vector3.Distance(firePos, startPos);
                RaycastHit hit;
                LayerMask  FireLayer = XkGameCtrl.GetInstance().PlayerAmmoHitLayer;
                if (Physics.Raycast(startPos, ammoForward, out hit, fireDisVal, FireLayer.value))
                {
                    //Debug.Log("npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
                    firePos = hit.point;
                    XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                    if (healthScript != null)
                    {
                        healthScript.OnDamageNpc(ammoScript.AmmoType, PlayerEnum.Null);
                    }

                    BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                    if (buJiBaoScript != null)
                    {
                        buJiBaoScript.RemoveBuJiBao(PlayerEnum.Null);                         //buJiBaoScript
                    }
                }
                ammoScript.StartMoveAmmo(firePos, PlayerEnum.Null);
            }
        }
    }
Exemplo n.º 2
0
    void SpawnAmmoParticleObj()
    {
        GameObject objParticle = null;
        GameObject obj         = null;
        Transform  tran        = null;
        Vector3    hitPos      = transform.position;

        RaycastHit hit;

        if (!IsHandleRpc)
        {
            AmmoEndPos   = transform.position;
            AmmoStartPos = transform.position - transform.forward * 3f;
            Physics.Raycast(AmmoStartPos, transform.forward, out hit, 1000f, PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
                AmmoEndPos = hit.point;
            }
        }

        Vector3 forwardVal = Vector3.Normalize(AmmoEndPos - AmmoStartPos);

        if (AmmoType == PlayerAmmoType.PuTongAmmo)
        {
//			float disVal = Vector3.Distance(AmmoEndPos, AmmoStartPos) + 10f;
//			Physics.Raycast(AmmoStartPos, forwardVal, out hit, disVal, PlayerAmmoHitLayer);

            Vector3 startPos = Vector3.zero;
            Vector3 backVal  = -10f * transform.forward;
            if (GameTypeCtrl.IsTankVRStatic)
            {
                startPos = transform.position + backVal;
            }
            else
            {
                float   disAmmoOffset = AmmoSanSheDis;
                float   randKay       = Random.Range(0, 100) % 2 == 0 ? -1 : 1;
                Vector3 upVal         = randKay * Random.Range(0f, disAmmoOffset) * transform.up;
                randKay = Random.Range(0, 100) % 2 == 0 ? -1 : 1;
                Vector3 rightVal = randKay * Random.Range(0f, disAmmoOffset) * transform.right;
                startPos = transform.position + upVal + rightVal + backVal;
            }

            Physics.Raycast(startPos, transform.forward, out hit, 20f, PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
                hitPos = hit.point;
                XKAmmoParticleCtrl ammoParticleScript = hit.collider.GetComponent <XKAmmoParticleCtrl>();
                if (ammoParticleScript != null && ammoParticleScript.PuTongAmmoLZ != null)
                {
                    objParticle = ammoParticleScript.PuTongAmmoLZ;
                }
                else
                {
                    string tagHitObj = hit.collider.tag;
                    switch (tagHitObj)
                    {
                    case "metal":
                        if (MetalParticle != null)
                        {
                            objParticle = MetalParticle;
                        }
                        break;

                    case "concrete":
                        if (ConcreteParticle != null)
                        {
                            objParticle = ConcreteParticle;
                        }
                        break;

                    case "dirt":
                        if (DirtParticle != null)
                        {
                            objParticle = DirtParticle;
                        }
                        break;

                    case "wood":
                        if (WoodParticle != null)
                        {
                            objParticle = WoodParticle;
                        }
                        break;

                    case "water":
                        if (WaterParticle != null)
                        {
                            objParticle = WaterParticle;
                        }
                        break;

                    case "sand":
                        if (SandParticle != null)
                        {
                            objParticle = SandParticle;
                        }
                        break;

                    case "glass":
                        if (GlassParticle != null)
                        {
                            objParticle = GlassParticle;
                        }
                        break;
                    }

                    if (objParticle == null)
                    {
                        objParticle = AmmoExplode;
                    }
                }

                if (IsHandleRpc &&
                    !IsDonotHurtNpc &&
                    Network.peerType != NetworkPeerType.Server &&
                    AmmoType == PlayerAmmoType.PuTongAmmo)
                {
                    XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                    if (healthScript != null)
                    {
                        if (HitNpcObj == null || HitNpcObj != hit.collider.gameObject)
                        {
                            //Debug.Log("playerAmmo hit npc, npc is "+hit.collider.name);
                            healthScript.OnDamageNpc(AmmoType, PlayerState);
                        }
                    }
                }
            }
            else
            {
                objParticle = AmmoExplode;
            }
        }
        else
        {
            float disVal = Vector3.Distance(AmmoEndPos, AmmoStartPos) + 10f;
            Physics.Raycast(AmmoStartPos, forwardVal, out hit, disVal, PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
//				if (AmmoType == PlayerAmmoType.GaoBaoAmmo) {
//					Debug.Log("hit.collider "+hit.collider.name);
//				}
                hitPos = hit.point;
                string tagHitObj = hit.collider.tag;
                switch (tagHitObj)
                {
                case "dirt":
                    if (DirtParticle != null)
                    {
                        objParticle = DirtParticle;
                    }
                    break;

                case "water":
                    if (WaterParticle != null)
                    {
                        objParticle = WaterParticle;
                    }
                    break;
                }

                if (objParticle == null)
                {
                    objParticle = AmmoExplode;
                }
            }
            else
            {
                objParticle = AmmoExplode;
            }
        }

        if (objParticle == null)
        {
            return;
        }

        if (AmmoType == PlayerAmmoType.DaoDanAmmo)
        {
            Vector3 AmmoPos = transform.position - (transform.forward * 3f);
            Physics.Raycast(AmmoPos, forwardVal, out hit, 13f, XkGameCtrl.GetInstance().LandLayer);
            if (hit.collider != null)
            {
                hitPos = hit.point;
                Vector3    normalVal = hit.normal;
                Quaternion rotVal    = Quaternion.LookRotation(normalVal);
                obj = SpawnParticleCom.SpawnParticleObject(objParticle, hitPos, rotVal);
                obj.transform.up = normalVal;
            }
            else
            {
                obj = SpawnParticleCom.SpawnParticleObject(objParticle, hitPos, transform.rotation);
            }
        }
        else
        {
            obj = SpawnParticleCom.SpawnParticleObject(objParticle, hitPos, transform.rotation);
        }
        tran        = obj.transform;
        tran.parent = XkGameCtrl.PlayerAmmoArray;
        XkGameCtrl.CheckObjDestroyThisTimed(obj);

        XkAmmoTieHuaCtrl tieHuaScript = obj.GetComponent <XkAmmoTieHuaCtrl>();

        if (tieHuaScript != null && tieHuaScript.TieHuaTran != null)
        {
            Transform tieHuaTran = tieHuaScript.TieHuaTran;
            Vector3   AmmoPos    = transform.position - (transform.forward * 3f);
            Physics.Raycast(AmmoPos, forwardVal, out hit, 13f, XkGameCtrl.GetInstance().PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
                tieHuaTran.up = hit.normal;
            }
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Removes the bu ji bao. key == 0 -> hit TerrainLayer, key == 1 -> PlayerOne, key == 2 -> PlayerTwo.
    /// </summary>
    /// <param name="key">Key.</param>
    public void RemoveBuJiBao(PlayerEnum key, int keyHit = 0)
    {
        if (IsDeath)
        {
            return;
        }
        IsDeath = true;
        CancelInvoke("DelayDestroyBuJiBao");
        if (key != PlayerEnum.Null || keyHit == 1)
        {
            XKGlobalData.GetInstance().PlayAudioHitBuJiBao();
            if (ExplodeObj != null)
            {
                GameObject obj = SpawnParticleCom.SpawnParticleObject(ExplodeObj, transform.position, transform.rotation, true);
                obj.transform.parent = XkGameCtrl.NpcAmmoArray;
            }

            if (Network.peerType != NetworkPeerType.Server || XkGameCtrl.GetInstance().IsOpenVR)
            {
                //Add BuJiBao
                switch (BuJiBao)
                {
                case BuJiBaoType.DaoDan:
                    if (keyHit == 1)
                    {
                        XkGameCtrl.GetInstance().AddDaoDanNum(PlayerEnum.PlayerOne);
                        XkGameCtrl.GetInstance().AddDaoDanNum(PlayerEnum.PlayerTwo);
                    }
                    else
                    {
                        XkGameCtrl.GetInstance().AddDaoDanNum(key);
                    }
                    break;

                case BuJiBaoType.GaoBaoDan:
                    if (keyHit == 1)
                    {
                        XkGameCtrl.GetInstance().AddGaoBaoDanNum(PlayerEnum.PlayerOne);
                        XkGameCtrl.GetInstance().AddGaoBaoDanNum(PlayerEnum.PlayerTwo);
                    }
                    else
                    {
                        XkGameCtrl.GetInstance().AddGaoBaoDanNum(key);
                    }
                    break;

                case BuJiBaoType.YouLiang:
                    XkGameCtrl.GetInstance().AddPlayerYouLiang(XkGameCtrl.YouLiangBuJiNum);
                    break;
                }
            }
        }

        if (Network.peerType != NetworkPeerType.Disconnected)
        {
            if (Network.peerType == NetworkPeerType.Client)
            {
                NetworkViewCom.RPC("BuJiBaoSendRemoveObj", RPCMode.OthersBuffered);
                return;
            }
        }
        DestroyNetObj(gameObject);
    }
    IEnumerator PlayPaoGuanAnimation()
    {
        int   count         = 0;
        int   maxCount      = 1;
        float speed         = PaoGuanZhenFu / maxCount;
        bool  isBackPaoGuan = false;
        bool  isFireAmmo    = false;

        IsPlayPaoGuanAnimation = true;
        do
        {
//			if (JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask()
//			    || IsDeathNpc
//			    || GameOverCtrl.IsShowGameOver) {
//				yield break;
//			}

            if (IsStopAnimation)
            {
                yield return(new WaitForSeconds(0.3f));

                continue;
            }

            if (!isBackPaoGuan)
            {
                PaoGuan.position -= PaoGuan.forward * speed;
                count++;
                if (count >= maxCount)
                {
                    isBackPaoGuan = true;
                }

                if (count == 1 && !isFireAmmo)
                {
                    isFireAmmo = true;
                    PlayAudioCannonFire();

                    PlayerAmmoCtrl ammoPlayerScript = DaPaoAmmo.GetComponent <PlayerAmmoCtrl>();
                    if (ammoPlayerScript != null && !XkGameCtrl.GetInstance().IsCartoonShootTest)
                    {
                        yield break;
                    }

                    GameObject obj = GetNpcAmmoFromList(SpawnAmmoPoint[0]);
                    if (obj == null)
                    {
                        yield break;
                    }

                    NpcAmmoCtrl AmmoScript = obj.GetComponent <NpcAmmoCtrl>();
                    Transform   tran       = obj.transform;
                    tran.parent = XkGameCtrl.NpcAmmoArray;
                    if (AmmoScript != null)
                    {
                        AmmoScript.SetIsAimPlayer(false);
                        AmmoScript.SetIsAimFeiJiPlayer(false);
                    }
                    else
                    {
                        PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();
                        if (ammoScript != null)
                        {
                            Vector3 startPos    = tran.position;
                            Vector3 firePos     = tran.position;
                            Vector3 ammoForward = tran.forward;
                            firePos = Random.Range(300f, 400f) * ammoForward + startPos;
                            float      fireDisVal = Vector3.Distance(firePos, startPos);
                            RaycastHit hit;
                            LayerMask  FireLayer = XkGameCtrl.GetInstance().PlayerAmmoHitLayer;
                            if (Physics.Raycast(startPos, ammoForward, out hit, fireDisVal, FireLayer.value))
                            {
                                //Debug.Log("npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
                                firePos = hit.point;
                                XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                                if (healthScript != null)
                                {
                                    healthScript.OnDamageNpc(ammoScript.AmmoType, PlayerEnum.Null);
                                }

                                BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                                if (buJiBaoScript != null)
                                {
                                    buJiBaoScript.RemoveBuJiBao(PlayerEnum.Null);                                     //buJiBaoScript
                                }
                            }
                            ammoScript.StartMoveAmmo(firePos, PlayerEnum.Null, AmmoMovePath);
                        }
                    }

                    if (DaPaoAmmoLiZi != null)
                    {
                        obj  = SpawnParticleCom.SpawnParticleObject(DaPaoAmmoLiZi, SpawnAmmoPoint[0].position, SpawnAmmoPoint[0].rotation);
                        tran = obj.transform;
                    }

                    if (!SpawnAmmoPoint[0].gameObject.activeSelf)
                    {
                        SpawnAmmoPoint[0].gameObject.SetActive(true);
                    }
                    tran.parent = SpawnAmmoPoint[0];
                }
            }
            else
            {
                PaoGuan.position += PaoGuan.forward * speed;
                count--;
                if (count <= 0)
                {
                    //break;
                    IsPlayPaoGuanAnimation = false;
                    isBackPaoGuan          = false;
                    isFireAmmo             = false;
                    count = 0;
                    if (IsDoFireAnimation)
                    {
                        yield return(new WaitForSeconds(TimeDanGuanFire));

                        IsPlayPaoGuanAnimation = true;
                        continue;
                    }
                }
            }
            yield return(new WaitForSeconds(PaoGuanShenSuoSD));
//			Debug.Log("dp****************"+Time.deltaTime);
        } while (IsDoFireAnimation);
    }
Exemplo n.º 5
0
    void CheckPlayerOneFireBt()
    {
        if (XKPlayerCamera.IndexPlayerNum != 0)
        {
            return;
        }

        if (!ScreenDanHeiCtrl.IsStartGame)
        {
            SetQianGuanTwRot(PlayerEnum.PlayerOne, false);
            return;
        }

        if (!XkGameCtrl.IsActivePlayerOne)
        {
            SetQianGuanTwRot(PlayerEnum.PlayerOne, false);
            return;
        }

        if (!IsActiveFireBtOne)
        {
            SetQianGuanTwRot(PlayerEnum.PlayerOne, false);
            return;
        }
        SetQianGuanTwRot(PlayerEnum.PlayerOne, true);

//		if (DaoJiShiCtrl.GetInstance().GetIsPlayDaoJishi()) {
//			return;
//		}

        if (!XkGameCtrl.IsTiaoGuoStartCartoon)
        {
            if (!ZhunXingCtrl.GetInstanceOne().GetActiveZhunXing() || !ZhunXingTeXiaoCtrl.IsOverTeXiaoZhunXing)
            {
                return;
            }
        }

        if (Camera.main == null)
        {
            return;
        }
//		if (GameOverCtrl.IsShowGameOver || JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask()) {
//			IsActiveFireBtOne = false;
//			return;
//		}

//		if (PlayerStEnum == PlayerTypeEnum.FeiJi && XkGameCtrl.GameJiTaiSt != GameJiTaiType.FeiJiJiTai) {
//			IsActiveFireBtOne = false;
//			return;
//		}

//		if (PlayerStEnum == PlayerTypeEnum.TanKe && XkGameCtrl.GameJiTaiSt != GameJiTaiType.TanKeJiTai) {
//			IsActiveFireBtOne = false;
//			return;
//		}

        if (XkGameCtrl.GaoBaoDanNumPOne <= 0 &&
            Time.time < LastFireTimeOne + 1f / Frequency)
        {
            return;
        }

        if (XkGameCtrl.GaoBaoDanNumPOne > 0 &&
            Time.time < LastFireTimeOne + 1f / FrequencyGaoBao)
        {
            return;
        }
        LastFireTimeOne = Time.time;
        Vector3    ammoSpawnPos = AmmoStartPosOne[0].position;
        GameObject obj          = null;

        CheckFireAudioPlayerOne();

        bool isSpawnGaoBaoDan = false;

        if (XkGameCtrl.GaoBaoDanNumPOne <= 0)
        {
            if (AmmoParticle[0] != null)
            {
                obj = SpawnParticleCom.SpawnParticleObject(AmmoParticle[0], ammoSpawnPos, AmmoStartPosOne[0].rotation);
                obj.transform.parent = AmmoStartPosOne[0];
            }
            obj = GetPlayerAmmo(PlayerAmmoType.PuTongAmmo, ammoSpawnPos, AmmoStartPosOne[0].rotation);
        }
        else
        {
            isSpawnGaoBaoDan = true;
            if (GaoBaoAmmoParticle[0] != null)
            {
                obj = SpawnParticleCom.SpawnParticleObject(GaoBaoAmmoParticle[0], ammoSpawnPos, AmmoStartPosOne[0].rotation);
                obj.transform.parent = AmmoStartPosOne[0];
            }
            XkGameCtrl.GetInstance().SubGaoBaoDanNumPOne();
            obj = GetPlayerAmmo(PlayerAmmoType.GaoBaoAmmo, ammoSpawnPos, AmmoStartPosOne[0].rotation);
        }
        obj.transform.parent = XkGameCtrl.PlayerAmmoArray;
        PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();

        ammoScript.SetIsDonotHurtNpc(false);

        Vector3    mousePosInput = pcvr.GetPlayerMousePos(PlayerEnum.PlayerOne);
        Vector3    firePos       = Vector3.zero;
        Vector3    mousePos      = mousePosInput + Vector3.forward * OffsetForward;
        Vector3    posTmp        = Camera.main.ScreenToWorldPoint(mousePos);
        Vector3    ammoForward   = Vector3.Normalize(posTmp - ammoSpawnPos);
        Ray        ray           = Camera.main.ScreenPointToRay(mousePosInput);
        RaycastHit hit;

        if (!IsPSAutoFire)
        {
            firePos = FirePosValTmp * ammoForward + ammoSpawnPos;
            if (Physics.Raycast(ray, out hit, FireRayDirLen, FireLayer.value))
            {
                //Debug.Log("Player fire obj -> "+hit.collider.name);
                firePos = hit.point;
                if (ammoScript.AmmoType == PlayerAmmoType.PuTongAmmo)
                {
                    XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                    if (healthScript != null && !healthScript.GetIsDeathNpc())
                    {
                        healthScript.OnDamageNpc(ammoScript.AmmoType, PlayerEnum.PlayerOne);
                    }
                }

                BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                if (buJiBaoScript != null)
                {
                    buJiBaoScript.RemoveBuJiBao(PlayerEnum.PlayerOne);                     //buJiBaoScript
                }
            }
        }
        else
        {
            ammoForward = obj.transform.forward;
            firePos     = FirePosValTmp * ammoForward + ammoSpawnPos;
            if (Physics.Raycast(ammoSpawnPos, ammoForward, out hit, FireRayDirLen, FireLayer.value))
            {
                //Debug.Log("Player fire obj -> "+hit.collider.name);
                firePos = hit.point;
                if (ammoScript.AmmoType == PlayerAmmoType.PuTongAmmo)
                {
                    XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                    if (healthScript != null && !healthScript.GetIsDeathNpc())
                    {
                        healthScript.OnDamageNpc(ammoScript.AmmoType, PlayerEnum.PlayerOne);
                    }
                }

                BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                if (buJiBaoScript != null)
                {
                    buJiBaoScript.RemoveBuJiBao(PlayerEnum.PlayerOne);                     //buJiBaoScript
                }
            }
        }

        if (hit.collider == null)
        {
            ammoScript.StartMoveAmmo(firePos, PlayerEnum.PlayerOne);
        }
        else
        {
            ammoScript.StartMoveAmmo(firePos, PlayerEnum.PlayerOne, null, hit.collider.gameObject);
        }

        if (isSpawnGaoBaoDan)
        {
            //Call OtherPort Show AmmoParticle
            PlayerScript.CallOtherPortSpawnPlayerAmmoParticle(1, 2, firePos);
        }
        else
        {
            //Call OtherPort Show AmmoParticle
            PlayerScript.CallOtherPortSpawnPlayerAmmoParticle(1, 0, firePos);
        }
    }
    void Update()
    {
        if (!XkGameCtrl.IsMoveOnPlayerDeath)
        {
            if (!XkGameCtrl.IsActivePlayerOne && !XkGameCtrl.IsActivePlayerTwo)
            {
                return;
            }
        }

        if (IsDeathNPC)
        {
            return;
        }

        if (!IsTeShuFireNpc)
        {
            return;
        }

        if (TimeTeShuFire.Length < 1)
        {
            return;
        }

        if (Network.peerType == NetworkPeerType.Server)
        {
            return;
        }

        if ((JiFenJieMianCtrl.GetInstance() != null && JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask()) ||
            GameOverCtrl.IsShowGameOver)
        {
            return;
        }

        if (!NpcScript.GetIsDoFireAnimation())
        {
            return;
        }

        GameObject obj  = null;
        Transform  tran = null;

        for (int i = 0; i < TimeTeShuFire.Length; i++)
        {
            TimeTeShuFire[i] += Time.deltaTime;
            if (TimeTeShuFire[i] >= TimeFireAmmo[i])
            {
                TimeTeShuFire[i] = 0f;                 //fire ammo
//				Debug.Log("teShuFireNpc -> i = "+i);

                if (i < AudioTeShuNpcFire.Length && AudioTeShuNpcFire[i] != null)
                {
                    if (AudioTeShuNpcFire[i].isPlaying)
                    {
                        AudioTeShuNpcFire[i].Stop();
                    }
                    AudioTeShuNpcFire[i].Play();
                }

                if (AmmoLZPrefabTeShu != null && AmmoLZPrefabTeShu[i] != null)
                {
                    obj = SpawnParticleCom.SpawnParticleObject(AmmoLZPrefabTeShu[i],
                                                               AmmoSpawnTranTeShu[i].position, AmmoSpawnTranTeShu[i].rotation);

                    tran        = obj.transform;
                    tran.parent = AmmoSpawnTranTeShu[i];
                }

                PlayerAmmoCtrl ammoPlayerScript = AmmoPrefabTeShu[i].GetComponent <PlayerAmmoCtrl>();
                if (ammoPlayerScript != null && !XkGameCtrl.GetInstance().IsCartoonShootTest)
                {
                    continue;
                }

                obj = GetNpcAmmoFromList(AmmoSpawnTranTeShu[i], AmmoPrefabTeShu[i]);
                if (obj == null)
                {
                    return;
                }
                tran        = obj.transform;
                tran.parent = XkGameCtrl.NpcAmmoArray;

                NpcAmmoCtrl ammoNpcScript = obj.GetComponent <NpcAmmoCtrl>();
                if (ammoNpcScript != null)
                {
                    ammoNpcScript.SetNpcScriptInfo(NpcScript);
                    ammoNpcScript.SetIsAimFeiJiPlayer(IsAimFeiJiPlayer);
                }
                else
                {
                    PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();
                    if (ammoScript != null)
                    {
                        Vector3 startPos    = tran.position;
                        Vector3 firePos     = tran.position;
                        Vector3 ammoForward = tran.forward;
                        firePos = Random.Range(300f, 400f) * ammoForward + startPos;
                        float      fireDisVal = Vector3.Distance(firePos, startPos);
                        RaycastHit hit;
                        LayerMask  FireLayer = XkGameCtrl.GetInstance().PlayerAmmoHitLayer;
                        if (Physics.Raycast(startPos, ammoForward, out hit, fireDisVal, FireLayer.value))
                        {
                            //Debug.Log("npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
                            firePos = hit.point;
                            XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                            if (healthScript != null)
                            {
                                healthScript.OnDamageNpc(ammoScript.AmmoType, PlayerEnum.Null);
                            }

                            BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                            if (buJiBaoScript != null)
                            {
                                buJiBaoScript.RemoveBuJiBao(PlayerEnum.Null);                                 //buJiBaoScript
                            }
                        }
                        ammoScript.StartMoveAmmo(firePos, PlayerEnum.Null, AmmoMovePath);
                    }
                }

//				if (AmmoLiZiPrefab != null) {
//					obj = (GameObject)Instantiate(AmmoLiZiPrefab, AmmoSpawnTran.position, AmmoSpawnTran.rotation);
//					tran = obj.transform;
//					tran.parent = XkGameCtrl.MissionCleanup;
//				}
            }
        }
    }