void MoveAmmoOnCompelteITween()
    {
        if (IsDestroyAmmo)
        {
            return;
        }
        IsDestroyAmmo = true;

        if (NpcHealthList != null)
        {
            NpcHealthList.Clear();
            NpcHealthList = null;
        }

        if (PaiJiPaoTiShi != null)
        {
            Destroy(PaiJiPaoTiShi);
        }

        if (AmmoType != PlayerAmmoType.ChuanTouAmmo)
        {
            SpawnAmmoParticleObj();
        }

        NpcAmmoCtrl.RemoveItweenComponents(gameObject);
        NpcAmmoCtrl.RemoveItweenComponents(gameObject, 1);
        if (AmmoType == PlayerAmmoType.GenZongAmmo ||
            AmmoType == PlayerAmmoType.PaiJiPaoAmmo)
        {
            CheckPlayerAmmoOverlapSphereHit();
        }
        DaleyHiddenPlayerAmmo();
    }
示例#2
0
	void HandleAmmoList(NpcAmmoCtrl scriptAmmo)
	{
		if (AmmoList.Contains(scriptAmmo)) {
			return;
		}
		AmmoList.Add(scriptAmmo);
	}
示例#3
0
 public static void SetKaQiuShaAmmoTrInfo(NpcAmmoCtrl ammoScript)
 {
     if (ammoScript == null)
     {
         return;
     }
     KaQiuShaAmmoTr = ammoScript.transform;
     AmmoSpeedVal   = ammoScript.MvSpeed / 3.6f;
 }
        /// <summary>
        /// 创建跟踪弹.
        /// </summary>
        void CreatGenZongDanAmmo(Transform spawnPoint, XKPlayerMoveCtrl playerCom)
        {
            if (GenZongDanPrefab == null || spawnPoint == null || playerCom == null)
            {
                return;
            }

            GameObject  obj        = (GameObject)Instantiate(GenZongDanPrefab, spawnPoint.position, spawnPoint.rotation);
            NpcAmmoCtrl ammoScript = obj.GetComponent <NpcAmmoCtrl>();

            if (ammoScript != null)
            {
                ammoScript.SetIsAimFeiJiPlayer(false);
                ammoScript.SetGenZongDanAimTarget(playerCom);
            }
        }
示例#5
0
 public void SpawnNpcAmmo()
 {
     for (int i = 0; i < 4; i++)
     {
         GameObject  obj        = GetNpcAmmoFromList(transform);
         NpcAmmoCtrl AmmoScript = obj.GetComponent <NpcAmmoCtrl>();
         Transform   tran       = obj.transform;
         tran.parent         = XkGameCtrl.NpcAmmoArray;
         tran.forward        = DirVecArray[i];
         tran.localPosition += new Vector3(0f, OffsetPY, 0f);
         if (AmmoScript != null)
         {
             AmmoScript.SetIsDestoryNpcAmmo();
             AmmoScript.SetIsAimFeiJiPlayer(false);
         }
     }
 }
示例#6
0
    void MoveAmmoOnCompelteITween()
    {
        if (IsDestroyAmmo)
        {
            return;
        }
        IsDestroyAmmo = true;

        if (NpcHealthList != null)
        {
            NpcHealthList.Clear();
            NpcHealthList = null;
        }

        if (PaiJiPaoTiShi != null)
        {
            Destroy(PaiJiPaoTiShi);
        }

        NpcAmmoCtrl.RemoveItweenComponents(gameObject);
        NpcAmmoCtrl.RemoveItweenComponents(gameObject, 1);
        if (AmmoType == PlayerAmmoType.Null)
        {
        }
        else
        {
            if (IsHitNpcAmmo == false)
            {
                CheckPlayerAmmoOverlapSphereHit();
            }
            //else
            //{
            //    SSDebug.Log("PlayerAmmo have hit npc! ************ AmmoType ===== " + AmmoType);
            //}
        }

        if (AmmoType != PlayerAmmoType.ChuanTouAmmo)
        {
            //创建子弹粒子.
            SpawnAmmoParticleObj();
        }
        DaleyHiddenPlayerAmmo();
    }
示例#7
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.L))
        {
            StartAutoFire();
        }

        if (Time.realtimeSinceStartup < LastFireTime + 1f / Frequency)
        {
            return;
        }
        LastFireTime = Time.realtimeSinceStartup;

        if (!IsAutoFire)
        {
            return;
        }

        if (Time.realtimeSinceStartup - TimeStartFire > TimeFireVal)
        {
            return;
        }

        GameObject  obj        = (GameObject)Instantiate(AmmoNpcPrefab, AmmoSpawnPoint.position, AmmoSpawnPoint.rotation);
        NpcAmmoCtrl AmmoScript = obj.GetComponent <NpcAmmoCtrl>();

//		AmmoScript.SetIsAimPlayer(IsAimPlayer);
        AmmoScript.SetIsAimFeiJiPlayer(IsAimPlayer);
        Transform tran = obj.transform;

        tran.parent = XkGameCtrl.MissionCleanup;

        if (AmmoLiZi != null)
        {
            obj         = (GameObject)Instantiate(AmmoLiZi, AmmoSpawnPoint.position, AmmoSpawnPoint.rotation);
            tran        = obj.transform;
            tran.parent = XkGameCtrl.MissionCleanup;
            XkGameCtrl.CheckObjDestroyThisTimed(obj);
        }
    }
示例#8
0
    // Use this for initialization
    void Start()
    {
        if (AmmoNpcPrefab == null)
        {
            Debug.LogWarning("AmmoNpcPrefab is null");
            AmmoNpcPrefab.name = "null";
        }
        else
        {
            NpcAmmoCtrl ammoScript = AmmoNpcPrefab.GetComponent <NpcAmmoCtrl>();
            if (ammoScript == null)
            {
                Debug.LogWarning("AmmoNpcPrefab cannot find NpcAmmoCtrl");
                GameObject obj = null;
                obj.name = "null";
            }
        }

        if (AmmoSpawnPoint == null)
        {
            AmmoSpawnPoint = transform;
        }
    }
    bool CheckAmmoHitObj(GameObject hitObjNpc, PlayerEnum playerIndex)
    {
//		BuJiBaoCtrl buJiBaoScript = hitObjNpc.GetComponent<BuJiBaoCtrl>();
//		if (buJiBaoScript != null) {
//			buJiBaoScript.RemoveBuJiBao(playerIndex); //buJiBaoScript
//			return;
//		}

        bool isStopCheckHit = false;

        if (AmmoType != PlayerAmmoType.PaiJiPaoAmmo)
        {
            XKPlayerCheckCamera checkCam = hitObjNpc.GetComponent <XKPlayerCheckCamera>();
            if (checkCam != null)
            {
                MoveAmmoOnCompelteITween();
                return(true);
            }
        }

        XKNpcHealthCtrl healthScript = hitObjNpc.GetComponent <XKNpcHealthCtrl>();

        if (healthScript != null && !healthScript.GetIsDeathNpc())
        {
            /*Debug.Log("CheckAmmoHitObj -> OnDamageNpc: "
             +"AmmoType "+AmmoType
             +", AmmoName "+AmmoTran.name
             +", NpcName "+healthScript.GetNpcName()
             +", AmmoDamageDis "+AmmoDamageDis);*/
            bool isHitNpc = false;
            switch (AmmoType)
            {
            case PlayerAmmoType.ChuanTouAmmo:
            case PlayerAmmoType.PaiJiPaoAmmo:
                if (NpcHealthList == null)
                {
                    NpcHealthList = new List <XKNpcHealthCtrl>();
                }

                if (!NpcHealthList.Contains(healthScript))
                {
                    NpcHealthList.Add(healthScript);
                    isHitNpc = true;
                }
                break;

            default:
                MoveAmmoOnCompelteITween();
                isStopCheckHit = true;
                isHitNpc       = true;
                break;
            }

            if (isHitNpc)
            {
                healthScript.OnDamageNpc(DamageNpc, PlayerState, AmmoType);
                SpawnAmmoParticleObj();
            }
        }

        if (hitObjNpc != null)
        {
            NpcAmmoCtrl npcAmmoScript = hitObjNpc.GetComponent <NpcAmmoCtrl>();
            if (npcAmmoScript != null)
            {
                npcAmmoScript.MoveAmmoOnCompelteITween();
            }

            if (AmmoType == PlayerAmmoType.DaoDanAmmo ||
                AmmoType == PlayerAmmoType.GaoBaoAmmo ||
                AmmoType == PlayerAmmoType.PuTongAmmo ||
                AmmoType == PlayerAmmoType.SanDanAmmo)
            {
                if (hitObjNpc.layer != LayerMask.NameToLayer("Default"))
                {
                    MoveAmmoOnCompelteITween();
                    isStopCheckHit = true;
                }
            }
        }
        return(isStopCheckHit);
    }
示例#10
0
    IEnumerator SpawnDuoPaoAmmo()
    {
        CountPaoGuanAni++;
        if (CountPaoGuanAni > 1)
        {
            //Debug.LogWarning("Unity:"+"PlayPaoGuanAnimation -> CountPaoGuanAni "+CountPaoGuanAni);
            yield break;
        }

        if (!IsDouGuanDaPao)
        {
            yield break;
        }

        int countMax = SpawnAmmoPoint.Length;
        int count    = countMax;

        do
        {
            if (IsDeathNpc || GameOverCtrl.IsShowGameOver)
            {
                Debug.Log("Unity:" + this.name + " -> IsDeathNpc " + IsDeathNpc
                          + ", IsShowGameOver " + GameOverCtrl.IsShowGameOver);
                yield break;
            }

            if (!IsDoFireAnimation ||
                IsStopAnimation ||
                Time.realtimeSinceStartup - TimeStartSpawn < TimeFireDelay ||
                JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask())
            {
                yield return(new WaitForSeconds(0.1f));

                continue;
            }

            count--;
            if (count < 0 || count >= SpawnAmmoPoint.Length)
            {
                yield break;
            }

            PlayAudioCannonFire();
            GameObject obj = GetNpcAmmoFromList(SpawnAmmoPoint[count]);
            if (obj == null)
            {
                Debug.Log("Unity:" + this.name + " is not find ammo!");
                yield break;
            }

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

            if (!XkGameCtrl.IsNoFireLiZi)
            {
                obj = (GameObject)Instantiate(DaPaoAmmoLiZi, SpawnAmmoPoint[count].position, SpawnAmmoPoint[count].rotation);
                XkGameCtrl.CheckObjDestroyThisTimed(obj);
                obj.transform.parent = SpawnAmmoPoint[count];
            }

            yield return(new WaitForSeconds(TimeAmmoUnit));

            if (count <= 0)
            {
                yield return(new WaitForSeconds(TimeAmmoWait));

                count = countMax;
                continue;
            }
        } while (true);
    }
示例#11
0
    IEnumerator PlayPaoGuanAnimation()
    {
        CountPaoGuanAni++;
        if (CountPaoGuanAni > 1)
        {
            //Debug.LogWarning("Unity:"+"PlayPaoGuanAnimation -> CountPaoGuanAni "+CountPaoGuanAni);
            yield break;
        }

        int   count         = 0;
        int   maxCount      = 1;
        float speed         = PaoGuanZhenFu / maxCount;
        bool  isBackPaoGuan = false;
        bool  isFireAmmo    = false;

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

            if (IsStopAnimation ||
                !IsDoFireAnimation ||
                Time.realtimeSinceStartup - TimeStartSpawn < TimeFireDelay ||
                JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask())
            {
                yield return(new WaitForSeconds(0.1f));

                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.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("Unity:"+"npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
                                firePos = hit.point;
                                XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                                if (healthScript != null)
                                {
                                    healthScript.OnDamageNpc(ammoScript.DamageNpc, PlayerEnum.Null);
                                }

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

                    if (!XkGameCtrl.IsNoFireLiZi)
                    {
                        obj  = (GameObject)Instantiate(DaPaoAmmoLiZi, SpawnAmmoPoint[0].position, SpawnAmmoPoint[0].rotation);
                        tran = obj.transform;
                        XkGameCtrl.CheckObjDestroyThisTimed(obj);
                        tran.parent = SpawnAmmoPoint[0];
                    }
                }
            }
            else
            {
                PaoGuan.position += PaoGuan.forward * speed;
                count--;
                if (count <= 0)
                {
                    IsPlayPaoGuanAnimation = false;
                    isBackPaoGuan          = false;
                    isFireAmmo             = false;
                    count = 0;

                    yield return(new WaitForSeconds(TimeDanGuanFire));

                    IsPlayPaoGuanAnimation = true;
                    continue;
                }
            }
            yield return(new WaitForSeconds(PaoGuanShenSuoSD));
        } while (true);
    }
        /// <summary>
        /// 创建跟踪弹.
        /// </summary>
        internal void CheckIsCreatGenZongDan()
        {
            if (Time.time - TimeLast < TimeVal)
            {
                return;
            }
            TimeLast = Time.time;

            if (GenZongDanPrefab == null)
            {
                return;
            }

            NpcAmmoCtrl npcAmmoCom = GenZongDanPrefab.GetComponent <NpcAmmoCtrl>();

            if (npcAmmoCom == null || npcAmmoCom.AmmoType != PlayerAmmoType.GenZongAmmo)
            {
                SSDebug.LogWarning("npcAmmoType is not GenZongAmmo!");
                return;
            }

            int randVal = 0;
            XKPlayerMoveCtrl playerCom = null;

            if (PlayerComList.Count > 0)
            {
                randVal   = Random.Range(0, 100) % PlayerComList.Count;
                playerCom = PlayerComList[randVal];
            }
            //playerCom = XKPlayerMoveCtrl.GetInstance(PlayerEnum.PlayerOne); //test.

            if (playerCom == null)
            {
                return;
            }

            int max = 0;
            int zhanCheDaiJinQuanCount = playerCom.GetZhanCheDaiJinQuanCount();

            if (zhanCheDaiJinQuanCount > 1)
            {
                max = 2;
            }
            else if (zhanCheDaiJinQuanCount == 1)
            {
                max = 1;
            }

            //max = 1; //test
            if (max == 0)
            {
                return;
            }

            Transform point = null;

            for (int i = 0; i < max; i++)
            {
                if (i == 0)
                {
                    if (SpawnPointArray01.Length == 0)
                    {
                        continue;
                    }
                    randVal = Random.Range(0, 100) % SpawnPointArray01.Length;
                    point   = SpawnPointArray01[randVal];
                }
                else
                {
                    if (SpawnPointArray02.Length == 0)
                    {
                        continue;
                    }
                    randVal = Random.Range(0, 100) % SpawnPointArray02.Length;
                    point   = SpawnPointArray02[randVal];
                }
                CreatGenZongDanAmmo(point, playerCom);
            }
        }
示例#13
0
//	public void SetNpcIsDoFire(NpcMark script)
//	{
//		//Debug.Log("Unity:"+"SetNpcIsDoFire -> IsFireFeiJiNpc "+script.IsFireFeiJiNpc);
//		if (!NpcScript.IsAniMove) {
//			return;
//		}
//
//		if (SpawnPointScript == null) {
//			return;
//		}
//
//		Transform npcPath = SpawnPointScript.NpcPath;
//		Transform markPar = script.transform.parent;
//		if (npcPath != markPar) {
//			return;
//		}
//		//Debug.Log("Unity:"+"***********SetNpcIsDoFire -> IsFireFeiJiNpc "+script.IsFireFeiJiNpc);
//		NpcScript.SetIsDoFireAnimation(script.IsFireFeiJiNpc);
//		NpcScript.SetFeiJiMarkInfo(script);
//	}

    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;
        }

        if (XkGameCtrl.CheckNpcIsMoveToCameraBack(transform))
        {
            return;
        }

        if (XkGameCtrl.GetInstance().IsCreatAmmoOnBoss == false)
        {
            if (XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.GetIsHaveCaiPiaoBoss() == true)
            {
                if (NpcScript != null && NpcScript.IsCaiPiaoZhanChe == true)
                {
                }
                else
                {
                    //有彩票boss产生,不再继续发射子弹.
                    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("Unity:"+"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 && AmmoLZObjTeShu[i] == null) {
                if (AmmoLZPrefabTeShu != null && AmmoLZPrefabTeShu[i] != null)
                {
                    obj = (GameObject)Instantiate(AmmoLZPrefabTeShu[i],
                                                  AmmoSpawnTranTeShu[i].position, AmmoSpawnTranTeShu[i].rotation);

                    tran = obj.transform;
                    //AmmoLZObjTeShu[i] = obj;
                    XkGameCtrl.CheckObjDestroyThisTimed(obj);
                    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("Unity:"+"npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
                            firePos = hit.point;
                            XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                            if (healthScript != null)
                            {
                                healthScript.OnDamageNpc(ammoScript.DamageNpc, PlayerEnum.Null);
                            }

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

//				if (AmmoLiZiPrefab != null) {
//					obj = (GameObject)Instantiate(AmmoLiZiPrefab, AmmoSpawnTran.position, AmmoSpawnTran.rotation);
//					tran = obj.transform;
//					tran.parent = XkGameCtrl.MissionCleanup;
//				}
            }
        }
    }
示例#14
0
    bool CheckAmmoHitObj(GameObject hitObjNpc, PlayerEnum playerIndex)
    {
//		BuJiBaoCtrl buJiBaoScript = hitObjNpc.GetComponent<BuJiBaoCtrl>();
//		if (buJiBaoScript != null) {
//			buJiBaoScript.RemoveBuJiBao(playerIndex); //buJiBaoScript
//			return;
//		}

        bool isStopCheckHit = false;

        if (AmmoType != PlayerAmmoType.PaiJiPaoAmmo)
        {
            XKPlayerCheckCamera checkCam = hitObjNpc.GetComponent <XKPlayerCheckCamera>();
            if (checkCam != null)
            {
                IsHitNpcAmmo = true;
                //SSDebug.LogWarning("MoveAmmoOnCompelteITween ============== 55555555555555555");
                MoveAmmoOnCompelteITween();
                return(true);
            }
        }

        XKNpcHealthCtrl healthScript = hitObjNpc.GetComponent <XKNpcHealthCtrl>();

        if (healthScript != null && !healthScript.GetIsDeathNpc())
        {
            /*Debug.Log("Unity:"+"CheckAmmoHitObj -> OnDamageNpc: "
             +"AmmoType "+AmmoType
             +", AmmoName "+AmmoTran.name
             +", NpcName "+healthScript.GetNpcName()
             +", AmmoDamageDis "+AmmoDamageDis);*/
            bool isHitNpc = false;
            switch (AmmoType)
            {
            case PlayerAmmoType.ChuanTouAmmo:
            case PlayerAmmoType.PaiJiPaoAmmo:
            {
                if (NpcHealthList == null)
                {
                    NpcHealthList = new List <XKNpcHealthCtrl>();
                }

                if (!NpcHealthList.Contains(healthScript))
                {
                    NpcHealthList.Add(healthScript);
                    isHitNpc = true;
                }
                break;
            }

            default:
            {
                IsHitNpcAmmo = true;
                //MoveAmmoOnCompelteITween();
                isStopCheckHit = true;
                isHitNpc       = true;
                break;
            }
            }

            if (isHitNpc)
            {
                int baoJiDamage = 0;
                if (AmmoType == PlayerAmmoType.ChuanTouAmmo ||
                    AmmoType == PlayerAmmoType.DaoDanAmmo ||
                    AmmoType == PlayerAmmoType.PaiJiPaoAmmo ||
                    AmmoType == PlayerAmmoType.SanDanAmmo ||
                    AmmoType == PlayerAmmoType.ChongJiBoAmmo)
                {
                    //获取玩家对代金券npc的暴击伤害.
                    XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.CheckPlayerBaoJiDengJi(AmmoType, PlayerState, healthScript);
                    if (XkGameCtrl.GetInstance().m_CaiPiaoHealthDt != null && healthScript.GetIsDaiJinQuanNpc() == true)
                    {
                        baoJiDamage = XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.GetBaoJiDamage(PlayerState);
                    }
                }

                //if (XkGameCtrl.GetInstance().m_CaiPiaoHealthDt != null && healthScript.GetIsDaiJinQuanNpc() == true)
                //{
                //    if (AmmoType == PlayerAmmoType.ChuanTouAmmo
                //        || AmmoType == PlayerAmmoType.DaoDanAmmo
                //        || AmmoType == PlayerAmmoType.PaiJiPaoAmmo
                //        || AmmoType == PlayerAmmoType.SanDanAmmo)
                //    {
                //        //获取玩家对代金券npc的暴击伤害.
                //        XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.CheckPlayerBaoJiDengJi(AmmoType, PlayerState, healthScript);
                //        baoJiDamage = XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.GetBaoJiDamage(PlayerState);
                //    }
                //}
                healthScript.OnDamageNpc(DamageNpc + baoJiDamage, PlayerState, AmmoType, IsAiFireAmmo);
                SpawnAmmoParticleObj(healthScript);
            }

            if (isStopCheckHit == true)
            {
                //停止子弹的伤害检测.
                if (AmmoType == PlayerAmmoType.ChongJiBoAmmo)
                {
                    //冲击波子弹不允许调用MoveAmmoOnCompelteITween.
                }
                else
                {
                    //SSDebug.LogWarning("MoveAmmoOnCompelteITween ============== 44444444444444444");
                    MoveAmmoOnCompelteITween();
                }
            }
        }

        if (hitObjNpc != null)
        {
            NpcAmmoCtrl npcAmmoScript = hitObjNpc.GetComponent <NpcAmmoCtrl>();
            if (npcAmmoScript != null)
            {
                npcAmmoScript.MoveAmmoOnCompelteITween();
            }

            if (AmmoType == PlayerAmmoType.DaoDanAmmo ||
                AmmoType == PlayerAmmoType.GaoBaoAmmo ||
                AmmoType == PlayerAmmoType.PuTongAmmo ||
                AmmoType == PlayerAmmoType.SanDanAmmo ||
                AmmoType == PlayerAmmoType.ChongJiBoAmmo)
            {
                if (hitObjNpc.layer != LayerMask.NameToLayer("Default"))
                {
                    //SSDebug.Log("hitObjNpc ===================================== " + hitObjNpc.name);
                    IsHitNpcAmmo = true;
                    if (AmmoType == PlayerAmmoType.ChongJiBoAmmo)
                    {
                        //冲击波子弹不允许在这里调用MoveAmmoOnCompelteITween,否则会被瞬间删除.
                    }
                    else
                    {
                        //SSDebug.LogWarning("MoveAmmoOnCompelteITween ============== 333333333333333");
                        MoveAmmoOnCompelteITween();
                    }
                    isStopCheckHit = true;
                }
            }
        }
        return(isStopCheckHit);
    }
    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);
    }
    IEnumerator SpawnDuoPaoAmmo()
    {
        CountPaoGuanAni++;
        if (CountPaoGuanAni > 1)
        {
            //Debug.LogWarning("Unity:"+"PlayPaoGuanAnimation -> CountPaoGuanAni "+CountPaoGuanAni);
            yield break;
        }

        if (!IsDouGuanDaPao)
        {
            yield break;
        }

        int countMax = SpawnAmmoPoint.Length;
        int count    = countMax;

        do
        {
            if (IsDeathNpc || GameOverCtrl.IsShowGameOver)
            {
                //Debug.Log("Unity:"+this.name+" -> IsDeathNpc "+IsDeathNpc
                //          +", IsShowGameOver "+GameOverCtrl.IsShowGameOver);
                yield break;
            }

            if (!IsDoFireAnimation ||
                IsStopAnimation ||
                Time.realtimeSinceStartup - TimeStartSpawn < TimeFireDelay ||
                (JiFenJieMianCtrl.GetInstance() && JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask()))
            {
                yield return(new WaitForSeconds(0.1f));

                continue;
            }

            if (IsJPBossTeShuWeapon == true)
            {
                //JPBoss的特殊武器.
                if (IsActiveJPBossTeShuWeapon == false)
                {
                    //JPBoss的特殊武器没有激活.
                    yield return(new WaitForSeconds(0.1f));

                    continue;
                }
            }

            if (XkGameCtrl.GetInstance().IsCreatAmmoOnBoss == false)
            {
                if (XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.GetIsHaveCaiPiaoBoss() == true)
                {
                    if (NpcMoveScript != null && NpcMoveScript.IsCaiPiaoZhanChe == true)
                    {
                    }
                    else
                    {
                        //有彩票boss产生,不再继续发射子弹.
                        yield return(new WaitForSeconds(0.1f));

                        continue;
                    }
                }
            }

            count--;
            if (count < 0 || count >= SpawnAmmoPoint.Length)
            {
                yield break;
            }

            PlayAudioCannonFire();
            GameObject obj = GetNpcAmmoFromList(SpawnAmmoPoint[count]);
            if (obj == null)
            {
                Debug.Log("Unity:" + this.name + " is not find ammo!");
                yield break;
            }

            //if (IsJPBossTeShuWeapon == true)
            //{
            //    if (NpcMoveScript != null && NpcMoveScript.IsJPBossNpc)
            //    {
            //        SSDebug.LogWarning("SpawnDuoPaoAmmo........................................................ name == " + gameObject.name);
            //    }
            //}
            NpcAmmoCtrl AmmoScript = obj.GetComponent <NpcAmmoCtrl>();
            AmmoScript.SetIsAimFeiJiPlayer(false);
            obj.transform.parent = XkGameCtrl.NpcAmmoArray;

            obj = (GameObject)Instantiate(DaPaoAmmoLiZi, SpawnAmmoPoint[count].position, SpawnAmmoPoint[count].rotation);
            XkGameCtrl.CheckObjDestroyThisTimed(obj);
            obj.transform.parent = SpawnAmmoPoint[count];

            yield return(new WaitForSeconds(TimeAmmoUnit));

            if (count <= 0)
            {
                yield return(new WaitForSeconds(TimeAmmoWait));

                count = countMax;
                continue;
            }
        } while (true);
    }
示例#17
0
    void StartSpawnNpcAmmo()
    {
        if (XkGameCtrl.CheckNpcIsMoveToCameraBack(transform))
        {
            return;
        }

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

        GameObject obj  = null;
        Transform  tran = null;

        if (AmmoLiZiPrefab != null && AmmoLiZiObj == null)
        {
            obj         = (GameObject)Instantiate(AmmoLiZiPrefab, AmmoSpawnTran.position, AmmoSpawnTran.rotation);
            tran        = obj.transform;
            tran.parent = XkGameCtrl.NpcAmmoArray;
            AmmoLiZiObj = obj;
            XkGameCtrl.CheckObjDestroyThisTimed(obj);
        }

        if (AmmoPrefab == null)
        {
            return;
        }

        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);
            for (int i = 0; i < AmmoSpawnArray.Length; i++)
            {
                if (AmmoSpawnArray[i] != null)
                {
                    obj = (GameObject)Instantiate(AmmoPrefab,
                                                  AmmoSpawnArray[i].position,
                                                  AmmoSpawnArray[i].rotation);
                    tran        = obj.transform;
                    tran.parent = XkGameCtrl.NpcAmmoArray;
                    AmmoScript  = obj.GetComponent <NpcAmmoCtrl>();
                    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("Unity:"+"npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
                    firePos = hit.point;
                    XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                    if (healthScript != null)
                    {
                        healthScript.OnDamageNpc(ammoScript.DamageNpc, PlayerEnum.Null);
                    }

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

        int countMax = SpawnAmmoPoint.Length;
        int count    = countMax;

        do
        {
            if ((JiFenJieMianCtrl.GetInstance() != null && JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask()) ||
                IsDeathNpc ||
                GameOverCtrl.IsShowGameOver)
            {
                yield break;
            }

            count--;
            PlayAudioCannonFire();

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

            NpcAmmoCtrl AmmoScript = obj.GetComponent <NpcAmmoCtrl>();
            if (IsHiddenAmmoSpawnPoint)
            {
                if ((count + 1) == countMax)
                {
                    XKTriggerStopMovePlayer.SetKaQiuShaAmmoTrInfo(AmmoScript);
                }
                AmmoScript.SetIsCannotAddNpcAmmoList();
            }
            AmmoScript.SetIsAimPlayer(false);
            AmmoScript.SetIsAimFeiJiPlayer(false);
            Transform tran = obj.transform;
            tran.parent = XkGameCtrl.NpcAmmoArray;
            if (IsHiddenAmmoSpawnPoint)
            {
                SpawnAmmoPoint[count].gameObject.SetActive(false);
            }
            else
            {
                if (!SpawnAmmoPoint[count].gameObject.activeSelf)
                {
                    SpawnAmmoPoint[count].gameObject.SetActive(true);
                }
            }

            if (DaPaoAmmoLiZiObj[count] == null && DaPaoAmmoLiZi != null)
            {
                obj  = (GameObject)Instantiate(DaPaoAmmoLiZi, SpawnAmmoPoint[count].position, SpawnAmmoPoint[count].rotation);
                tran = obj.transform;
                DaPaoAmmoLiZiObj[count] = obj;
                XkGameCtrl.CheckObjDestroyThisTimed(obj);

                if (IsHiddenAmmoSpawnPoint)
                {
                    tran.parent = XkGameCtrl.NpcAmmoArray;
                }
                else
                {
                    tran.parent = SpawnAmmoPoint[count];
                }
            }

            yield return(new WaitForSeconds(TimeAmmoUnit));

            if (!IsDoFireAnimation || IsStopAnimation)
            {
                yield break;
            }

            if (count <= 0)
            {
                yield return(new WaitForSeconds(TimeAmmoWait));

                if (!IsDoFireAnimation || IsStopAnimation || IsHiddenAmmoSpawnPoint)
                {
                    if (IsHiddenAmmoSpawnPoint)
                    {
                        IsDonnotSpawnAmmo = true;
                    }
                    yield break;
                }
                else
                {
                    count = countMax;
                    continue;
                }
            }
        } while (count > 0);
    }
    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);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (!IsSpawnAmmo || TimeTeShuFire.Length < 1)
        {
            return;
        }

        if (CountAmmo >= MaxAmmo)
        {
            //停止发射子弹.
            IsSpawnAmmo = false;
            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 (CountAmmo >= MaxAmmo)
                {
                    return;
                }

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

                if (AmmoLZPrefabTeShu != null &&
                    AmmoLZPrefabTeShu.Length >= TimeTeShuFire.Length &&
                    AmmoLZPrefabTeShu[i] != null &&
                    AmmoLZObjTeShu[i] == null)
                {
                    obj = (GameObject)Instantiate(AmmoLZPrefabTeShu[i],
                                                  AmmoSpawnTranTeShu[i].position, AmmoSpawnTranTeShu[i].rotation);

                    tran = obj.transform;
                    AmmoLZObjTeShu[i] = obj;
                    XkGameCtrl.CheckObjDestroyThisTimed(obj);
                    tran.parent = AmmoSpawnTranTeShu[i];
                }

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

                NpcAmmoCtrl ammoNpcScript = obj.GetComponent <NpcAmmoCtrl>();
                if (ammoNpcScript != null)
                {
                    ammoNpcScript.SetAmmoTargetObject(null);
                    ammoNpcScript.SetNpcScriptInfo(NpcScript);
                    ammoNpcScript.SetIsAimFeiJiPlayer(false);
                }
                CountAmmo++;
            }
        }
    }