/// <summary>
    /// 设置是否爆炸.
    /// </summary>
    internal void SetIsExplore(bool isExplore)
    {
        if (IsExplore == isExplore)
        {
            return;
        }
        IsExplore = isExplore;

        if (IsExplore == true)
        {
            //隐藏攻击武器.
            SetHiddenObjArray(true);
            if (m_ExplorePrefab != null)
            {
                for (int i = 0; i < m_ExplorePoint.Length; i++)
                {
                    if (m_ExplorePoint[i] != null)
                    {
                        GameObject obj = (GameObject)Instantiate(m_ExplorePrefab, XkGameCtrl.MissionCleanup, m_ExplorePoint[i]);
                        XkGameCtrl.CheckObjDestroyThisTimed(obj);
                    }
                }
            }
        }
    }
    public void CallOtherPortDeath()
    {
        if (IsDeathNpc)
        {
            return;
        }
        IsDeathNpc = true;

        //ClearNpcAmmoList();
        if (DeathExplode != null)
        {
            if (!DeathExplode.activeSelf)
            {
                DeathExplode.SetActive(true);
            }
            GameObject objExplode = null;
            objExplode = (GameObject)Instantiate(DeathExplode, DeathExplodePoint.position, DeathExplodePoint.rotation);
            objExplode.transform.parent = XkGameCtrl.NpcAmmoArray;
            XkGameCtrl.CheckObjDestroyThisTimed(objExplode);
        }

        int max = DaPaoHiddenArray.Length;

        for (int i = 0; i < max; i++)
        {
            if (DaPaoHiddenArray[i] != null)
            {
                DaPaoHiddenArray[i].SetActive(false);
            }
        }
        ResetCannonInfo();
    }
    void CheckExplodePoint()
    {
        if (ExplodePoint.Length <= 0)
        {
            return;
        }

        GameObject obj  = null;
        Transform  tran = null;
        int        max  = ExplodePoint.Length;

        for (int i = 0; i < max; i++)
        {
            if (ExplodePrefab[i] != null && ExplodePoint[i] != null)
            {
                obj         = (GameObject)Instantiate(ExplodePrefab[i], ExplodePoint[i].position, ExplodePoint[i].rotation);
                tran        = obj.transform;
                tran.parent = XkGameCtrl.MissionCleanup;
                XkGameCtrl.CheckObjDestroyThisTimed(obj);
            }
        }

        max = HiddenExplodeObj.Length;
        for (int i = 0; i < max; i++)
        {
            if (HiddenExplodeObj[i] != null)
            {
                HiddenExplodeObj[i].SetActive(false);
            }
        }
    }
    /**
     * indexVal == -1 -> 打开小水晶1和2的开火蓄力.
     * indexVal == 0 -> 打开小水晶1的开火蓄力.
     * indexVal == 1 -> 打开小水晶2的开火蓄力.
     */
    void OpenXiaoShuiJingXuLi(int indexVal)
    {
//		Debug.Log("Unity:"+"OpenXiaoShuiJingXuLi --> indexVal "+indexVal);
        Transform  xuLiTr = null;
        GameObject obj    = null;

        switch (indexVal)
        {
        case 0:
        case 1:
            XiaoShuiJingFireState = indexVal;
            xuLiTr = XiaoShuiJingArray[indexVal].transform;
            obj    = (GameObject)Instantiate(XiaoShuiJingXuLiPrefab, xuLiTr.position, xuLiTr.rotation);
            XkGameCtrl.CheckObjDestroyThisTimed(obj);
            obj.transform.parent = XkGameCtrl.NpcAmmoArray;
            break;

        default:
            XiaoShuiJingFireState = 2;
            for (int i = 0; i < XiaoShuiJingArray.Length; i++)
            {
                xuLiTr = XiaoShuiJingArray[i].transform;
                obj    = (GameObject)Instantiate(XiaoShuiJingXuLiPrefab, xuLiTr.position, xuLiTr.rotation);
                XkGameCtrl.CheckObjDestroyThisTimed(obj);
                obj.transform.parent = XkGameCtrl.NpcAmmoArray;
            }
            break;
        }
        StartCoroutine(OpenXiaoShuiJingFire(indexVal));
    }
Esempio n. 5
0
	void SpawnPlayerAmmoParticle(GameObject ammoParticle, Vector3 pos, Quaternion rot)
	{
		if (ammoParticle == null) {
			return;
		}
		GameObject obj = (GameObject)Instantiate(ammoParticle, pos, rot);
		obj.transform.parent = XkGameCtrl.PlayerAmmoArray;
		XkGameCtrl.CheckObjDestroyThisTimed(obj);
	}
Esempio n. 6
0
    void MoveYouLiangMarkOnCompelteITween()
    {
//		Debug.Log("Unity:"+"MoveYouLiangMarkOnCompelteITween...");
        YouLiangMark.SetActive(false);
        XKGlobalData.GetInstance().PlayJiaYouBaoZhaAudio();
        GameObject obj = (GameObject)Instantiate(ExplodeObj, YouLiangMark.transform.position, YouLiangMark.transform.rotation);

        XkGameCtrl.CheckObjDestroyThisTimed(obj);
        YouLiangAddCtrl.GetInstance().AddPlayerYouLiangDian();
    }
    /// <summary>
    /// 显示战车和boss的飞行彩票.
    /// </summary>
    void ShowCaiPiaoZhanCheBossFlyCaiPiao(SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState deCaiType, PlayerEnum indexPlayer, Vector3 startPos)
    {
        //Debug.LogWarning("Unity: ShowCaiPiaoZhanCheBossFlyCaiPiao -> deCaiType ========= " + deCaiType);
        if (m_ExplosionPrefab != null)
        {
            if (m_ExplosionPoint != null)
            {
                startPos = m_ExplosionPoint.transform.position;
                Destroy(m_ExplosionPoint);
            }
            GameObject objExplode = (GameObject)Instantiate(m_ExplosionPrefab, startPos, Quaternion.identity);
            objExplode.transform.parent = XkGameCtrl.NpcAmmoArray;
            XkGameCtrl.CheckObjDestroyThisTimed(objExplode);

            SSCaiPiaoLiZiManage caiPiaoLiZi = objExplode.GetComponent <SSCaiPiaoLiZiManage>();
            if (caiPiaoLiZi != null)
            {
                caiPiaoLiZi.ShowNumUI(m_CaiPiaoNum, indexPlayer);
            }
            else
            {
                Debug.LogWarning("CheckNpcDeathExplode -> caiPiaoLiZi was null.................");
            }
        }

        if (deCaiType == SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.ZhanChe)
        {
            if (XkGameCtrl.GetInstance().m_CaiPiaoFlyData != null)
            {
                //初始化飞出的彩票逻辑.
                XkGameCtrl.GetInstance().m_CaiPiaoFlyData.InitCaiPiaoFly(startPos, indexPlayer, SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.ZhanChe);
            }
            else
            {
                Debug.LogWarning("CreatLiZi -> m_CaiPiaoFlyData was null............");
            }
        }
        else if (deCaiType == SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.JPBoss)
        {
            if (SSUIRoot.GetInstance().m_GameUIManage != null)
            {
                SSUIRoot.GetInstance().m_GameUIManage.InitCaiPiaoAnimation(XkGameCtrl.GetInstance().m_CaiPiaoFlyData.m_JPBossCaiPiaoFlyDt.TimeLeiJiaVal, indexPlayer);
            }

            if (XkGameCtrl.GetInstance().m_CaiPiaoFlyData != null)
            {
                //初始化烟花粒子的产生.
                XkGameCtrl.GetInstance().m_CaiPiaoFlyData.InitPlayCaiPiaoYanHua();
            }
            else
            {
                Debug.LogWarning("CreatLiZi -> m_CaiPiaoFlyData was null............");
            }
        }
    }
    void CheckNpcDeathExplode()
    {
        if (DeathExplode == null)
        {
            return;
        }

        GameObject objExplode = null;

        objExplode = (GameObject)Instantiate(DeathExplode, DeathExplodePoint.position, DeathExplodePoint.rotation);
        objExplode.transform.parent = XkGameCtrl.NpcAmmoArray;
        XkGameCtrl.CheckObjDestroyThisTimed(objExplode);
    }
Esempio n. 9
0
    [RPC] void BuJiBaoSendRemoveObj()
    {
        if (IsDeath)
        {
            return;
        }
        IsDeath = true;

        if (ExplodeObj != null)
        {
            GameObject obj = (GameObject)Instantiate(ExplodeObj, transform.position, transform.rotation);
            XkGameCtrl.CheckObjDestroyThisTimed(obj);
        }
        DestroyNetObj(gameObject);
    }
    void MovePaiJiPaoAmmoOnCompelteITween()
    {
        if (IsInvoking("MoveTopPaiJiPaoAmmoCoreOnCompelteITween") == true)
        {
            CancelInvoke("MoveTopPaiJiPaoAmmoCoreOnCompelteITween");
        }

        Collider[] hits = Physics.OverlapSphere(AmmoTran.position, PaiJiPaoDamageDis, ~IgnoreLayers.value);
        foreach (Collider c in hits)
        {
            if (c.isTrigger)
            {
                continue;
            }

            XKPlayerMoveCtrl playerScript = c.GetComponent <XKPlayerMoveCtrl>();
            if (playerScript != null && !playerScript.GetIsWuDiState())
            {
                XkGameCtrl.GetInstance().SubGamePlayerHealth(playerScript.PlayerIndex, PlayerDamage);
            }
        }
        DestroyNpcAmmo(PaiJiPaoTiShi);

        if (AmmoSiSanScript == null)
        {
            AmmoSiSanScript = GetComponent <XKNpcAmmoSiSanCtrl>();
        }
        if (AmmoSiSanScript != null)
        {
            AmmoSiSanScript.SpawnNpcAmmo();
        }

        if (AmmoExplode != null)
        {
            GameObject expObj = (GameObject)Instantiate(AmmoExplode, AmmoTran.position, AmmoTran.rotation);
            if (XkGameCtrl.NpcAmmoArray != null)
            {
                expObj.transform.parent = XkGameCtrl.NpcAmmoArray;
            }
            XkGameCtrl.CheckObjDestroyThisTimed(expObj);
        }
        DestroyNpcAmmo(ObjAmmo);
    }
Esempio n. 11
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);
        }
    }
Esempio n. 12
0
    /// <summary>
    /// Removes the bu ji bao. playerSt == 0 -> hit TerrainLayer,
    /// playerSt == 1 -> PlayerOne, playerSt == 2 -> PlayerTwo.
    /// playerSt == 3 -> PlayerThree, playerSt == 4 -> PlayerFour.
    /// </summary>
    /// <param name="key">Key.</param>
    public void RemoveBuJiBao(PlayerEnum playerSt, int keyHit = 0)
    {
        if (IsDeath)
        {
            return;
        }
        IsDeath = true;
        CancelInvoke("DelayDestroyBuJiBao");
        if (playerSt != PlayerEnum.Null || keyHit == 1)
        {
            //XKGlobalData.GetInstance().PlayAudioHitBuJiBao();
            if (ExplodeObj != null)
            {
                GameObject obj = (GameObject)Instantiate(ExplodeObj, transform.position, transform.rotation);
                XkGameCtrl.CheckObjDestroyThisTimed(obj);
            }

            if (Network.peerType != NetworkPeerType.Server)
            {
                bool isMoveDaoJu = true;
                switch (BuJiBao)
                {
                case BuJiBaoType.FenShuDJ:
                    isMoveDaoJu = false;
                    XKPlayerFenShuCtrl.GetInstance().ShowPlayerFenShu(playerSt, FenShuVal);
                    break;

                case BuJiBaoType.JiSuDJ:
                    //isMoveDaoJu = false;
                    XKPlayerMoveCtrl.SetPlayerJiSuMoveSpeed(playerSt);
                    XKPlayerMoveCtrl.SetPlayerJiSuState(playerSt);
                    XKPlayerJiSuCtrl.GetInstance().ShowPlayerJiSu(playerSt);
                    break;

                case BuJiBaoType.YiLiaoBaoDJ:
                    isMoveDaoJu = false;
                    XkGameCtrl.AddPlayerHealth(playerSt, XKDaoJuGlobalDt.GetInstance().YiLiaoBaoXueLiangVal);
                    XKPlayerJiJiuBaoCtrl.GetInstance().ShowPlayerJiJiuBao(playerSt);
                    break;

                case BuJiBaoType.ShuangBeiFenShuDJ:
                    //isMoveDaoJu = false;
                    //XKDaoJuGlobalDt.SetTimeFenShuBeiLv(playerSt, FenShuBeiLv);
                    XKDaoJuGlobalDt.SetTimeFenShuBeiLv(playerSt, 2);
                    XKFenShuBeiLvCtrl.GetInstance().ShowPlayerFenShuBeiLv(playerSt);
                    break;

                case BuJiBaoType.QianHouFireDJ:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerQianHouFire(playerSt);
                    break;

                case BuJiBaoType.ChangChengJiQiang:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerChangChengFire(playerSt);
                    break;

                case BuJiBaoType.SanDanJiQiang:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerJiQiangSanDanFire(playerSt);
                    break;

                case BuJiBaoType.QiangJiJiQiang:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerQiangJiFire(playerSt);
                    break;

                case BuJiBaoType.PaiJiPaoDJ:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerIsPaiJiPaoFire(playerSt);
                    break;

                case BuJiBaoType.ZhuPaoSanDanDJ:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerIsSanDanZPFire(playerSt);
                    break;

                case BuJiBaoType.HuoLiAllOpenDJ:
                    //isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerIsHuoLiAllOpen(playerSt);
                    XKPlayerHuoLiAllOpenCtrl.GetInstance().ShowPlayerHuoLiOpen(playerSt);
                    break;

                case BuJiBaoType.ChuanTouDan:
                    isMoveDaoJu = false;
                    XKPlayerAutoFire.GetInstanceAutoFire(playerSt).SetAmmoStateZhuPao(PlayerAmmoType.ChuanTouAmmo);
                    break;

                case BuJiBaoType.DaoDan:
                case BuJiBaoType.GaoBaoDan:
                case BuJiBaoType.SanDan:
                case BuJiBaoType.GenZongDan:
                case BuJiBaoType.JianSuDan:
                case BuJiBaoType.NLHuDun:
                    isMoveDaoJu = false;
                    break;
                }

                if (isMoveDaoJu)
                {
                    DaoJuCtrl.GetInstance().MoveDaoJuObjToPlayer(playerSt, transform);
                }
            }
        }
        DestroyNetObj(gameObject);
    }
Esempio n. 13
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);
    }
    /// <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 = (GameObject)Instantiate(ExplodeObj, transform.position, transform.rotation);
                XkGameCtrl.CheckObjDestroyThisTimed(obj);
            }

            if (Network.peerType != NetworkPeerType.Server)
            {
                //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);
    }
    void CheckNpcDeathExplode(PlayerEnum indexPlayer = PlayerEnum.Null)
    {
        if (DeathExplode == null)
        {
            return;
        }


        if (NpcScript != null && NpcScript.IsCaiPiaoZhanChe)
        {
            SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState deCaiType = SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.ZhanChe;
            //彩票boss或战车npc.
            if (NpcScript.GetIsBossNpc())
            {
                deCaiType = SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.JPBoss;
                AudioBeiJingCtrl.StopGameBeiJingAudio();
            }

            if (XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage != null)
            {
                int value = XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage.m_GameCaiPiaoData.GetPrintCaiPiaoValueByDeCaiState(deCaiType, SSCaiPiaoDataManage.SuiJiDaoJuState.BaoXiang,
                                                                                                                                                    NpcScript.m_DaiJinQuanState);
                if (DeathExplodePoint != null)
                {
                    //Vector3 pos = XkGameCtrl.GetInstance().GetWorldObjToScreenPos(objExplode.transform.position);
                    SSCaiPiaoDataManage.GameCaiPiaoData.DaiJinQuanState daiJinQuanType = NpcScript.m_DaiJinQuanState;
                    SSUIRoot.GetInstance().m_GameUIManage.CreatZhanCheBossCaiPiaoZhuanPan(indexPlayer, value, DeathExplodePoint.position, deCaiType, DeathExplode, daiJinQuanType);
                    //SSCaiPiaoLiZiManage caiPiaoLiZi = objExplode.GetComponent<SSCaiPiaoLiZiManage>();
                    //if (caiPiaoLiZi != null)
                    //{
                    //    caiPiaoLiZi.ShowNumUI(value, indexPlayer);
                    //}
                    //else
                    //{
                    //    Debug.LogWarning("CheckNpcDeathExplode -> caiPiaoLiZi was null.................");
                    //}
                    if (deCaiType == SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.JPBoss)
                    {
                        //只给boss产生爆炸粒子.
                        GameObject objExplode = (GameObject)Instantiate(DeathExplode, DeathExplodePoint.position, DeathExplodePoint.rotation);
                        objExplode.transform.parent = XkGameCtrl.NpcAmmoArray;
                        XkGameCtrl.CheckObjDestroyThisTimed(objExplode);

                        SSCaiPiaoLiZiManage caiPiaoLiZi = objExplode.GetComponent <SSCaiPiaoLiZiManage>();
                        if (caiPiaoLiZi != null)
                        {
                            caiPiaoLiZi.ShowNumUI(value, indexPlayer);
                        }
                        else
                        {
                            Debug.LogWarning("CheckNpcDeathExplode -> caiPiaoLiZi was null.................");
                        }
                    }
                }
            }

            //if (deCaiType == SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.ZhanChe)
            //{
            //    if (XkGameCtrl.GetInstance().m_CaiPiaoFlyData != null)
            //    {
            //        //初始化飞出的彩票逻辑.
            //        XkGameCtrl.GetInstance().m_CaiPiaoFlyData.InitCaiPiaoFly(transform.position, indexPlayer, SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.ZhanChe);
            //    }
            //    else
            //    {
            //        Debug.LogWarning("CreatLiZi -> m_CaiPiaoFlyData was null............");
            //    }
            //}
            //else if (deCaiType == SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.JPBoss)
            //{
            //    if (SSUIRoot.GetInstance().m_GameUIManage != null)
            //    {
            //        SSUIRoot.GetInstance().m_GameUIManage.InitCaiPiaoAnimation(XkGameCtrl.GetInstance().m_CaiPiaoFlyData.m_JPBossCaiPiaoFlyDt.TimeLeiJiaVal, indexPlayer);
            //    }

            //    if (XkGameCtrl.GetInstance().m_CaiPiaoFlyData != null)
            //    {
            //        //初始化烟花粒子的产生.
            //        XkGameCtrl.GetInstance().m_CaiPiaoFlyData.InitPlayCaiPiaoYanHua();
            //    }
            //    else
            //    {
            //        Debug.LogWarning("CreatLiZi -> m_CaiPiaoFlyData was null............");
            //    }
            //}
        }
        else
        {
            GameObject objExplode = (GameObject)Instantiate(DeathExplode, DeathExplodePoint.position, DeathExplodePoint.rotation);
            objExplode.transform.parent = XkGameCtrl.NpcAmmoArray;
            XkGameCtrl.CheckObjDestroyThisTimed(objExplode);
        }
    }
Esempio n. 16
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);
    }
    void CheckPlayerTwoFireBt()
    {
//		if (XKPlayerCamera.IndexPlayerNum != 1) {
//			SetQianGuanTwRot(PlayerEnum.PlayerTwo, false);
//			return;
//		}

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

        if (!XkGameCtrl.IsActivePlayerTwo)
        {
            SetQianGuanTwRot(PlayerEnum.PlayerTwo, false);
            return;
        }

        if (!IsActiveFireBtTwo)
        {
            SetQianGuanTwRot(PlayerEnum.PlayerTwo, false);
            return;
        }
        SetQianGuanTwRot(PlayerEnum.PlayerTwo, true);

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

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

        if (GunCamera[1] == null)
        {
            return;
        }

//		if (GameOverCtrl.IsShowGameOver || JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask()) {
//			IsActiveFireBtTwo = false;
//			return;
//		}

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

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

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

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

        CheckFireAudioPlayerTwo();

        bool isSpawnGaoBaoDan = false;

        if (XkGameCtrl.GaoBaoDanNumPTwo <= 0)
        {
            if (AmmoParticle[0] != null && AmmoParticleObj[1] == null)
            {
                obj = (GameObject)Instantiate(AmmoParticle[0], ammoSpawnPos, AmmoStartPosTwo[0].rotation);
                AmmoParticleObj[1]   = obj;
                obj.transform.parent = AmmoStartPosTwo[0];
                XkGameCtrl.CheckObjDestroyThisTimed(obj);
            }
            obj = GetPlayerAmmo(PlayerAmmoType.PuTongAmmo, ammoSpawnPos, AmmoStartPosTwo[0].rotation);
        }
        else
        {
            isSpawnGaoBaoDan = true;
            if (GaoBaoAmmoParticle[0] != null)
            {
                obj = (GameObject)Instantiate(GaoBaoAmmoParticle[0], ammoSpawnPos, AmmoStartPosTwo[0].rotation);
                obj.transform.parent = AmmoStartPosTwo[0];
                XkGameCtrl.CheckObjDestroyThisTimed(obj);
            }
            XkGameCtrl.GetInstance().SubGaoBaoDanNumPTwo();
            obj = GetPlayerAmmo(PlayerAmmoType.GaoBaoAmmo, ammoSpawnPos, AmmoStartPosTwo[0].rotation);
        }
        obj.transform.parent = XkGameCtrl.PlayerAmmoArray;
        PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();

        ammoScript.SetIsDonotHurtNpc(false);

        Vector3 mousePosInput = Input.mousePosition;

        if (pcvr.bIsHardWare)
        {
            mousePosInput = pcvr.CrossPositionTwo;
        }
        mousePosInput = GetPlayerMousePos(PlayerEnum.PlayerTwo, mousePosInput);

        Vector3    firePos     = Vector3.zero;
        Vector3    mousePos    = mousePosInput + Vector3.forward * OffsetForward;
        Vector3    posTmp      = GunCamera[1].ScreenToWorldPoint(mousePos);
        Vector3    ammoForward = Vector3.Normalize(posTmp - ammoSpawnPos);
        Ray        ray         = GunCamera[1].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.PlayerTwo);
                    }
                }

                BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                if (buJiBaoScript != null)
                {
                    buJiBaoScript.RemoveBuJiBao(PlayerEnum.PlayerTwo);                     //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.PlayerTwo);
                    }
                }

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

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

        if (isSpawnGaoBaoDan)
        {
            //Call OtherPort Show AmmoParticle
            PlayerScript.CallOtherPortSpawnPlayerAmmoParticle(2, 2, firePos);
        }
        else
        {
            //Call OtherPort Show AmmoParticle
            PlayerScript.CallOtherPortSpawnPlayerAmmoParticle(2, 0, firePos);
        }
    }
    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);
    }
Esempio n. 19
0
    /// <summary>
    /// particleType == 0 ---> 普通子弹.
    /// particleType == 1 ---> 导弹.
    /// particleType == 2 ---> 高爆弹.
    /// </summary>
    public void SpawnPlayerAmmoParticle(int playerIndex, int particleType, Vector3 firePos)
    {
        if (playerIndex > 2 || playerIndex < 1)
        {
            playerIndex = 1;
        }

        if (particleType > 2 || particleType < 0)
        {
            particleType = 0;
        }

        int        ammoSpawnIndex = 0;  //real ammo spawnPoint.
        GameObject obj            = null;

        switch (playerIndex)
        {
        case 1:
            if (particleType == 0)
            {
//				if (PlayerAudio[0].isPlaying) {
//					PlayerAudio[0].Stop();
//				}
//				PlayerAudio[0].Play();

                if (AmmoParticle[ammoSpawnIndex] != null)
                {
                    obj = SpawnParticleCom.SpawnParticleObject(AmmoParticle[ammoSpawnIndex], AmmoStartPosOne[ammoSpawnIndex].position,
                                                               AmmoStartPosOne[ammoSpawnIndex].rotation);
                    obj.transform.parent = AmmoStartPosOne[ammoSpawnIndex];
                }

                OtherPortSpawnPlayerAmmo(PlayerAmmoType.PuTongAmmo,
                                         AmmoStartPosOne[ammoSpawnIndex].position,
                                         AmmoStartPosOne[ammoSpawnIndex].rotation,
                                         firePos);
            }
            else if (particleType == 2)
            {
//				if (PlayerAudio[1].isPlaying) {
//					PlayerAudio[1].Stop();
//				}
//				PlayerAudio[1].Play();

                if (GaoBaoAmmoParticle[ammoSpawnIndex] != null)
                {
                    obj = SpawnParticleCom.SpawnParticleObject(GaoBaoAmmoParticle[ammoSpawnIndex], AmmoStartPosOne[ammoSpawnIndex].position,
                                                               AmmoStartPosOne[ammoSpawnIndex].rotation);
                    obj.transform.parent = AmmoStartPosOne[ammoSpawnIndex];
                }

                OtherPortSpawnPlayerAmmo(PlayerAmmoType.GaoBaoAmmo,
                                         AmmoStartPosOne[ammoSpawnIndex].position,
                                         AmmoStartPosOne[ammoSpawnIndex].rotation,
                                         firePos);
            }
            else if (particleType == 1)
            {
                if (PlayerAudio[2].isPlaying)
                {
                    PlayerAudio[2].Stop();
                }
                PlayerAudio[2].Play();
                if (DaoDanAmmoParticle[ammoSpawnIndex] != null)
                {
                    obj = SpawnParticleCom.SpawnParticleObject(DaoDanAmmoParticle[ammoSpawnIndex], DaoDanAmmoPosOne[ammoSpawnIndex].position,
                                                               DaoDanAmmoPosOne[ammoSpawnIndex].rotation);
                    obj.transform.parent = DaoDanAmmoPosOne[ammoSpawnIndex];
                }

                OtherPortSpawnPlayerAmmo(PlayerAmmoType.DaoDanAmmo,
                                         DaoDanAmmoPosOne[ammoSpawnIndex].position,
                                         DaoDanAmmoPosOne[ammoSpawnIndex].rotation,
                                         firePos);
            }
            break;

        case 2:
            if (particleType == 0)
            {
//				if (PlayerAudio[3].isPlaying) {
//					PlayerAudio[3].Stop();
//				}
//				PlayerAudio[3].Play();

                if (AmmoParticle[ammoSpawnIndex] != null)
                {
                    obj = SpawnParticleCom.SpawnParticleObject(AmmoParticle[ammoSpawnIndex], AmmoStartPosTwo[ammoSpawnIndex].position,
                                                               AmmoStartPosTwo[ammoSpawnIndex].rotation);
                    obj.transform.parent = AmmoStartPosTwo[ammoSpawnIndex];
                }

                OtherPortSpawnPlayerAmmo(PlayerAmmoType.PuTongAmmo,
                                         AmmoStartPosTwo[ammoSpawnIndex].position,
                                         AmmoStartPosTwo[ammoSpawnIndex].rotation,
                                         firePos);
            }
            else if (particleType == 2)
            {
//				if (PlayerAudio[4].isPlaying) {
//					PlayerAudio[4].Stop();
//				}
//				PlayerAudio[4].Play();

                if (GaoBaoAmmoParticle[ammoSpawnIndex] != null)
                {
                    obj = SpawnParticleCom.SpawnParticleObject(GaoBaoAmmoParticle[ammoSpawnIndex], AmmoStartPosTwo[ammoSpawnIndex].position,
                                                               AmmoStartPosTwo[ammoSpawnIndex].rotation);
                    obj.transform.parent = AmmoStartPosTwo[ammoSpawnIndex];
                }

                OtherPortSpawnPlayerAmmo(PlayerAmmoType.GaoBaoAmmo,
                                         AmmoStartPosTwo[ammoSpawnIndex].position,
                                         AmmoStartPosTwo[ammoSpawnIndex].rotation,
                                         firePos);
            }
            else if (particleType == 1)
            {
                if (PlayerAudio[5].isPlaying)
                {
                    PlayerAudio[5].Stop();
                }
                PlayerAudio[5].Play();

                if (DaoDanAmmoParticle[ammoSpawnIndex] != null)
                {
                    obj = SpawnParticleCom.SpawnParticleObject(DaoDanAmmoParticle[ammoSpawnIndex], DaoDanAmmoPosTwo[ammoSpawnIndex].position,
                                                               DaoDanAmmoPosTwo[ammoSpawnIndex].rotation);
                    obj.transform.parent = DaoDanAmmoPosTwo[ammoSpawnIndex];
                }

                OtherPortSpawnPlayerAmmo(PlayerAmmoType.DaoDanAmmo,
                                         DaoDanAmmoPosTwo[ammoSpawnIndex].position,
                                         DaoDanAmmoPosTwo[ammoSpawnIndex].rotation,
                                         firePos);
            }
            break;
        }

        if (obj != null)
        {
            obj.transform.localPosition    = Vector3.zero;
            obj.transform.localEulerAngles = Vector3.zero;
            XkGameCtrl.CheckObjDestroyThisTimed(obj);
        }
    }
Esempio n. 20
0
    //static int TestCount = 0;
    void SpawnAmmoParticleObj(XKNpcHealthCtrl healthScript = null)
    {
        if (AmmoType != PlayerAmmoType.ChuanTouAmmo)
        {
            //不是穿甲弹.
            if (IsCreatAmmoParticle == true)
            {
                //已经创建过爆炸粒子.
                return;
            }
            IsCreatAmmoParticle = true;
        }

        //if (AmmoType == PlayerAmmoType.DaoDanAmmo)
        //{
        //    TestCount++;
        //    SSDebug.LogWarning("SpawnAmmoParticleObj -> healthScript ============= " + healthScript
        //        + ", TestCount == " + TestCount
        //        + ", time == " + Time.time.ToString("f3"));
        //}

        //if (TestCount >= 100)
        //{
        //    TestCount = 0;
        //}

#if USE_SPHERE_HIT
        GameObject objParticle = null;
        GameObject hitObj      = CheckPlayerAmmoOverlapSphereHit(1);
        if (hitObj == null)
        {
            switch (AmmoType)
            {
            case PlayerAmmoType.PuTongAmmo:
                break;

            default:
                objParticle = AmmoExplode;
                break;
            }
        }
        else
        {
            string tagHitObj = hitObj.tag;
            switch (AmmoType)
            {
            case PlayerAmmoType.PuTongAmmo:
                XKAmmoParticleCtrl ammoParticleScript = hitObj.GetComponent <XKAmmoParticleCtrl>();
                if (ammoParticleScript != null && ammoParticleScript.PuTongAmmoLZ != null)
                {
                    objParticle = ammoParticleScript.PuTongAmmoLZ;
                }
                else
                {
                    switch (tagHitObj)
                    {
                    case "metal":
                        objParticle = MetalParticle;
                        break;

                    case "concrete":
                        objParticle = ConcreteParticle;
                        break;

                    case "dirt":
                        objParticle = DirtParticle;
                        break;

                    case "wood":
                        objParticle = WoodParticle;
                        break;

                    case "water":
                        objParticle = WaterParticle;
                        break;

                    case "sand":
                        objParticle = SandParticle;
                        break;

                    case "glass":
                        objParticle = GlassParticle;
                        break;

                    default:
                        objParticle = AmmoExplode;
                        break;
                    }
                }
                break;

            default:
                switch (tagHitObj)
                {
                case "dirt":
                    objParticle = DirtParticle;
                    break;

                case "water":
                    objParticle = WaterParticle;
                    break;

                default:
                    objParticle = AmmoExplode;
                    break;
                }
                break;
            }
        }

        if (objParticle == null)
        {
            return;
        }

        Vector3    pos = AmmoTran.position;
        Quaternion rot = AmmoTran.rotation;
        if (AmmoType == PlayerAmmoType.ChongJiBoAmmo)
        {
            if (healthScript != null)
            {
                //获取距离冲击波子弹最近的爆炸产生点.
                Transform tr = healthScript.GetAmmoLiZiMinDisSpawnPoint(transform);
                if (tr != null)
                {
                    //冲击波子弹.
                    pos = tr.position;
                    rot = tr.rotation;
                }
            }
            else
            {
                //冲击波子弹没有击中npc时不产生自爆粒子.
                return;
            }
        }
        GameObject obj  = (GameObject)Instantiate(objParticle, pos, rot);
        Transform  tran = obj.transform;
        tran.parent = XkGameCtrl.PlayerAmmoArray;
        XkGameCtrl.CheckObjDestroyThisTimed(obj);

        SSPlayerAmmoBaoJi baoJiAmmo = obj.GetComponent <SSPlayerAmmoBaoJi>();
        if (baoJiAmmo != null)
        {
            bool isDisplayBaoJi = false;
            if (healthScript != null)
            {
                if (healthScript.GetIsDaiJinQuanNpc() == true)
                {
                    //代金券npc.
                    isDisplayBaoJi = true;
                }

                //if (XkGameCtrl.GetInstance().m_SSDebugBaoJi != null)
                //{
                //    //测试爆击代金券npc.
                //    XkGameCtrl.GetInstance().m_SSDebugBaoJi.IsHitDaiJinQuanNpc = healthScript.GetIsDaiJinQuanNpc();
                //}
            }
            //else
            //{
            //    if (XkGameCtrl.GetInstance().m_SSDebugBaoJi != null)
            //    {
            //        //测试爆击代金券npc.
            //        XkGameCtrl.GetInstance().m_SSDebugBaoJi.IsHitDaiJinQuanNpc = false;
            //    }
            //}

            if (isDisplayBaoJi == true)
            {
                //初始化子弹爆炸粒子上的暴击效果.
                baoJiAmmo.Init(PlayerState);
            }
            else
            {
                //隐藏子弹爆炸粒子上的暴击效果.
                baoJiAmmo.HiddenBaoJi();
            }
        }
#else
        GameObject objParticle = null;
        GameObject obj         = null;
        Transform  tran        = null;
        Vector3    hitPos      = transform.position;
        RaycastHit hit;
        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);
            if (hit.collider != null)
            {
                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;
                    }
                }
            }
            else
            {
                objParticle = AmmoExplode;
            }
        }
        else
        {
            float disVal = Vector3.Distance(AmmoEndPos, AmmoStartPos) + 10f;
            Physics.Raycast(AmmoStartPos, forwardVal, out hit, disVal, PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
                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;
        }

        hitPos = explodePos;
        switch (AmmoType)
        {
        case PlayerAmmoType.DaoDanAmmo:
            Vector3 AmmoPos = transform.position - (transform.forward * 3f);
            Physics.Raycast(AmmoPos, forwardVal, out hit, 13f, XkGameCtrl.GetInstance().LandLayer);
            if (hit.collider != null)
            {
                Vector3    normalVal = hit.normal;
                Quaternion rotVal    = Quaternion.LookRotation(normalVal);
                obj = (GameObject)Instantiate(objParticle, hitPos, rotVal);
                obj.transform.up = normalVal;
            }
            else
            {
                obj = (GameObject)Instantiate(objParticle, hitPos, transform.rotation);
            }
            break;

        case PlayerAmmoType.ChuanTouAmmo:
            obj = (GameObject)Instantiate(objParticle, explodePos, transform.rotation);
            break;

        default:
            obj = (GameObject)Instantiate(objParticle, hitPos, transform.rotation);
            break;
        }
        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;
            }
        }
#endif
    }
    /// <summary>
    /// Removes the bu ji bao. playerSt == 0 -> hit TerrainLayer,
    /// playerSt == 1 -> PlayerOne, playerSt == 2 -> PlayerTwo.
    /// playerSt == 3 -> PlayerThree, playerSt == 4 -> PlayerFour.
    /// </summary>
    /// <param name="key">Key.</param>
    public void RemoveBuJiBao(PlayerEnum playerSt, int keyHit = 0)
    {
        if (IsDeath)
        {
            return;
        }
        IsDeath = true;
        CancelInvoke("DelayDestroyBuJiBao");
        if (playerSt != PlayerEnum.Null || keyHit == 1)
        {
            //XKGlobalData.GetInstance().PlayAudioHitBuJiBao();
            if (ExplodeObj != null)
            {
                GameObject obj = (GameObject)Instantiate(ExplodeObj, transform.position, transform.rotation);
                if (obj != null)
                {
                    obj.transform.SetParent(XkGameCtrl.PlayerAmmoArray);
                }

                XkGameCtrl.CheckObjDestroyThisTimed(obj);
                if (obj != null && IsCaiPiaoDaoJu)
                {
                    if (XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage != null)
                    {
                        int value = XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage.m_GameCaiPiaoData.GetPrintCaiPiaoValueByDeCaiState(SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.SuiJiDaoJu, DaoJuType);
                        SSCaiPiaoLiZiManage caiPiaoLiZi = obj.GetComponent <SSCaiPiaoLiZiManage>();
                        if (caiPiaoLiZi != null)
                        {
                            caiPiaoLiZi.ShowNumUI(value, playerSt);
                        }
                        else
                        {
                            Debug.LogWarning("CreatLiZi -> caiPiaoLiZi was null.................");
                        }
                    }

                    if (XkGameCtrl.GetInstance().m_CaiPiaoFlyData != null)
                    {
                        //初始化飞出的彩票逻辑.
                        XkGameCtrl.GetInstance().m_CaiPiaoFlyData.InitCaiPiaoFly(obj.transform.position, playerSt, SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.SuiJiDaoJu);
                    }
                    else
                    {
                        Debug.LogWarning("CreatLiZi -> m_CaiPiaoFlyData was null............");
                    }
                }
            }

            if (Network.peerType != NetworkPeerType.Server)
            {
                bool isMoveDaoJu = true;
                switch (BuJiBao)
                {
                case BuJiBaoType.FenShuDJ:
                    isMoveDaoJu = false;
                    XKPlayerFenShuCtrl.GetInstance().ShowPlayerFenShu(playerSt, FenShuVal);
                    break;

                case BuJiBaoType.JiSuDJ:
                    //isMoveDaoJu = false;
                    XKPlayerMoveCtrl.SetPlayerJiSuMoveSpeed(playerSt);
                    XKPlayerMoveCtrl.SetPlayerJiSuState(playerSt);
                    XKPlayerJiSuCtrl.GetInstance().ShowPlayerJiSu(playerSt);
                    break;

                case BuJiBaoType.YiLiaoBaoDJ:
                    isMoveDaoJu = false;
                    XkGameCtrl.AddPlayerHealth(playerSt, XKDaoJuGlobalDt.GetInstance().YiLiaoBaoXueLiangVal);
                    XKPlayerJiJiuBaoCtrl.GetInstance().ShowPlayerJiJiuBao(playerSt);
                    break;

                case BuJiBaoType.ShuangBeiFenShuDJ:
                    isMoveDaoJu = false;
                    //XKDaoJuGlobalDt.SetTimeFenShuBeiLv(playerSt, FenShuBeiLv);
                    //XKDaoJuGlobalDt.SetTimeFenShuBeiLv(playerSt, 2);
                    //XKFenShuBeiLvCtrl.GetInstance().ShowPlayerFenShuBeiLv(playerSt);
                    break;

                case BuJiBaoType.QianHouFireDJ:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerQianHouFire(playerSt);
                    break;

                case BuJiBaoType.ChangChengJiQiang:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerChangChengFire(playerSt);
                    break;

                case BuJiBaoType.SanDanJiQiang:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerJiQiangSanDanFire(playerSt);
                    break;

                case BuJiBaoType.QiangJiJiQiang:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerQiangJiFire(playerSt);
                    break;

                case BuJiBaoType.PaiJiPaoDJ:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerIsPaiJiPaoFire(playerSt);
                    break;

                case BuJiBaoType.ZhuPaoSanDanDJ:
                    isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerIsSanDanZPFire(playerSt);
                    break;

                case BuJiBaoType.HuoLiAllOpenDJ:
                    //isMoveDaoJu = false;
                    XKDaoJuGlobalDt.SetPlayerIsHuoLiAllOpen(playerSt);
                    XKPlayerHuoLiAllOpenCtrl.GetInstance().ShowPlayerHuoLiOpen(playerSt);
                    break;

                case BuJiBaoType.ChuanTouDan:
                    isMoveDaoJu = false;
                    XKPlayerAutoFire.GetInstanceAutoFire(playerSt).SetAmmoStateZhuPao(PlayerAmmoType.ChuanTouAmmo);
                    break;

                case BuJiBaoType.DaoDan:
                case BuJiBaoType.GaoBaoDan:
                case BuJiBaoType.SanDan:
                case BuJiBaoType.GenZongDan:
                case BuJiBaoType.JianSuDan:
                case BuJiBaoType.NLHuDun:
                    isMoveDaoJu = false;
                    break;
                }

                if (isMoveDaoJu)
                {
                    DaoJuCtrl.GetInstance().MoveDaoJuObjToPlayer(playerSt, transform);
                }
            }
        }
        DestroyNetObj(gameObject);
    }
Esempio n. 22
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;
//				}
            }
        }
    }
    void ClickDaoDanBtOneEvent(ButtonState state)
    {
//		if (XKPlayerCamera.IndexPlayerNum != 0) {
//			return;
//		}

        if (XKTriggerClosePlayerUI.IsClosePlayerUI)
        {
            return;
        }

        if (!gameObject.activeSelf)
        {
            return;
        }

        if (!ScreenDanHeiCtrl.IsStartGame)
        {
            return;
        }

        if (!XkGameCtrl.IsActivePlayerOne)
        {
            return;
        }

        if (state != ButtonState.DOWN)
        {
            return;
        }

        if (XkGameCtrl.GetInstance().GetDaoDanNumPOne() <= 0)
        {
            XKGlobalData.GetInstance().PlayDaoDanJingGaoAudio();
            return;
        }

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

        if (GunCamera[0] == null)
        {
            return;
        }

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

        if (Time.realtimeSinceStartup - DaoDanTimeVal[0] < DaoDanTimeMin)
        {
            XKGlobalData.GetInstance().PlayDaoDanJingGaoAudio();
            return;
        }
        DaoDanTimeVal[0] = Time.realtimeSinceStartup;

        Vector3    ammoSpawnPos = DaoDanAmmoPosOne[0].position;
        GameObject obj          = null;

        if (DaoDanAmmoParticle[0] != null)
        {
            obj = (GameObject)Instantiate(DaoDanAmmoParticle[0], ammoSpawnPos, DaoDanAmmoPosOne[0].rotation);
            obj.transform.parent = XkGameCtrl.PlayerAmmoArray;
            XkGameCtrl.CheckObjDestroyThisTimed(obj);
        }

        if (PlayerAudio[2].isPlaying)
        {
            PlayerAudio[2].Stop();
        }
        PlayerAudio[2].Play();

        obj = SpawnPlayerAmmo(DaoDanAmmo, ammoSpawnPos, DaoDanAmmoPosOne[0].rotation);
        obj.transform.parent = XkGameCtrl.PlayerAmmoArray;
        PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();

        XkGameCtrl.GetInstance().SubDaoDanNumPOne();

        Vector3 mousePosInput = Input.mousePosition;

        if (pcvr.bIsHardWare)
        {
            mousePosInput = pcvr.CrossPositionOne;
        }
        mousePosInput = GetPlayerMousePos(PlayerEnum.PlayerOne, mousePosInput);

        Vector3 firePos     = Vector3.zero;
        Vector3 mousePos    = mousePosInput + Vector3.forward * OffsetForward;
        Vector3 posTmp      = GunCamera[0].ScreenToWorldPoint(mousePos);
        Vector3 ammoForward = Vector3.Normalize(posTmp - ammoSpawnPos);

        firePos = FirePosValTmp * ammoForward + ammoSpawnPos;
        Ray        ray = GunCamera[0].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;

                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;

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

        //Call OtherPort Show DaoDanAmmoParticle
        PlayerScript.CallOtherPortSpawnPlayerAmmoParticle(1, 1, firePos);
    }
Esempio n. 24
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 SpawnAmmoParticleObj()
    {
                #if USE_SPHERE_HIT
        GameObject objParticle = null;
        GameObject hitObj      = CheckPlayerAmmoOverlapSphereHit();
        if (hitObj == null)
        {
            switch (AmmoType)
            {
            case PlayerAmmoType.PuTongAmmo:
                break;

            default:
                objParticle = AmmoExplode;
                break;
            }
        }
        else
        {
            string tagHitObj = hitObj.tag;
            switch (AmmoType)
            {
            case PlayerAmmoType.PuTongAmmo:
                XKAmmoParticleCtrl ammoParticleScript = hitObj.GetComponent <XKAmmoParticleCtrl>();
                if (ammoParticleScript != null && ammoParticleScript.PuTongAmmoLZ != null)
                {
                    objParticle = ammoParticleScript.PuTongAmmoLZ;
                }
                else
                {
                    switch (tagHitObj)
                    {
                    case "metal":
                        objParticle = MetalParticle;
                        break;

                    case "concrete":
                        objParticle = ConcreteParticle;
                        break;

                    case "dirt":
                        objParticle = DirtParticle;
                        break;

                    case "wood":
                        objParticle = WoodParticle;
                        break;

                    case "water":
                        objParticle = WaterParticle;
                        break;

                    case "sand":
                        objParticle = SandParticle;
                        break;

                    case "glass":
                        objParticle = GlassParticle;
                        break;

                    default:
                        objParticle = AmmoExplode;
                        break;
                    }
                }
                break;

            default:
                switch (tagHitObj)
                {
                case "dirt":
                    objParticle = DirtParticle;
                    break;

                case "water":
                    objParticle = WaterParticle;
                    break;

                default:
                    objParticle = AmmoExplode;
                    break;
                }
                break;
            }
        }

        if (objParticle == null)
        {
            return;
        }

        GameObject obj  = (GameObject)Instantiate(objParticle, AmmoTran.position, AmmoTran.rotation);
        Transform  tran = obj.transform;
        tran.parent = XkGameCtrl.PlayerAmmoArray;
        XkGameCtrl.CheckObjDestroyThisTimed(obj);
                #else
        GameObject objParticle = null;
        GameObject obj         = null;
        Transform  tran        = null;
        Vector3    hitPos      = transform.position;

        RaycastHit hit;
        Vector3    forwardVal = Vector3.Normalize(AmmoEndPos - AmmoStartPos);
        if (AmmoType == PlayerAmmoType.PuTongAmmo)
        {
            float disVal = Vector3.Distance(AmmoEndPos, AmmoStartPos) + 10f;
            Physics.Raycast(AmmoStartPos, forwardVal, out hit, disVal, NpcAmmoHitLayer);
            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;
                    }
                }
            }
            else
            {
                objParticle = AmmoExplode;
            }
        }
        else
        {
            float disVal = Vector3.Distance(AmmoEndPos, AmmoStartPos) + 10f;
            Physics.Raycast(AmmoStartPos, forwardVal, out hit, disVal, NpcAmmoHitLayer);
            if (hit.collider != null)
            {
                hitPos = hit.point;
                string tagHitObj = hit.collider.tag;
                switch (tagHitObj)
                {
                case "dirt":
                    if (DirtParticle != null)
                    {
                        objParticle = DirtParticle;
                    }
                    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 = (GameObject)Instantiate(objParticle, hitPos, rotVal);
                obj.transform.up = normalVal;
            }
            else
            {
                obj = (GameObject)Instantiate(objParticle, hitPos, transform.rotation);
            }
        }
        else
        {
            obj = (GameObject)Instantiate(objParticle, hitPos, transform.rotation);
        }

        tran        = obj.transform;
        tran.parent = XkGameCtrl.NpcAmmoArray;

        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;
            }
        }
                #endif
    }
    public void OnRemoveCannon(PlayerEnum playerSt, int key)
    {
        if (IsDeathNpc)
        {
            return;
        }
        IsDeathNpc = true;

        //ClearNpcAmmoList();
        if (key == 1)
        {
            //XkGameCtrl.GetInstance().AddPlayerKillNpc(playerSt, NpcJiFenEnum.CheLiang);
            if (DeathExplode != null)
            {
                if (!DeathExplode.activeSelf)
                {
                    DeathExplode.SetActive(true);
                }
                GameObject objExplode = null;
                objExplode = (GameObject)Instantiate(DeathExplode, DeathExplodePoint.position, DeathExplodePoint.rotation);
                objExplode.transform.parent = XkGameCtrl.NpcAmmoArray;
                XkGameCtrl.CheckObjDestroyThisTimed(objExplode);
            }
        }
        XkGameCtrl.GetInstance().RemoveNpcTranFromList(CannonTran);

        float timeVal = 0f;

        if (DaPaoHiddenArray.Length <= 0)
        {
            gameObject.SetActive(false);
            ResetCannonInfo();
            //Destroy(gameObject);
        }
        else
        {
            int max = DaPaoHiddenArray.Length;
            for (int i = 0; i < max; i++)
            {
                if (DaPaoHiddenArray[i] != null)
                {
                    DaPaoHiddenArray[i].SetActive(false);
                }
            }
            timeVal = 3f;
        }

        if (IsHiddenAmmoSpawnPoint)
        {
            ResetCannonInfo();
        }

        if (DaPaoCtrlScript == null)
        {
            DaPaoCtrlScript = GetComponentInParent <XKDaPaoCtrl>();
            //if (DaPaoCtrlScript != null) {
            //Debug.Log("find XKDaPaoCtrl script...");
            //}
        }

        if (key == 1 && DaPaoCtrlScript != null && NpcMoveScript == null)
        {
            //Debug.Log("XKDaPaoCtrl -> OnRemoveCannon...");
            DaPaoCtrlScript.OnRemoveCannon(PlayerEnum.Null, 1, timeVal);
        }
    }
Esempio n. 28
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;
            }
        }
    }
    // 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++;
            }
        }
    }