Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        _Instance    = this;
        FenShuListP1 = new List <XKPlayerFenShuMove>();
        FenShuListP2 = new List <XKPlayerFenShuMove>();
        FenShuListP3 = new List <XKPlayerFenShuMove>();
        GameObject         obj           = null;
        XKPlayerFenShuMove fenShuMoveCom = null;

        for (int i = 0; i < MaxPlayerFS; i++)
        {
            obj = (GameObject)Instantiate(PlayerFenShuPre);
            obj.transform.parent        = transform;
            obj.transform.localScale    = new Vector3(1f, 1f, 1f);
            obj.transform.localPosition = Vector3.zero;
            fenShuMoveCom = obj.GetComponent <XKPlayerFenShuMove>();
            if (fenShuMoveCom != null)
            {
                fenShuMoveCom.Init(m_FenShuAtlasP1);
                fenShuMoveCom.SetActive(false);
            }
            FenShuListP1.Add(fenShuMoveCom);
        }

        for (int i = 0; i < MaxPlayerFS; i++)
        {
            obj = (GameObject)Instantiate(PlayerFenShuPre);
            obj.transform.parent        = transform;
            obj.transform.localScale    = new Vector3(1f, 1f, 1f);
            obj.transform.localPosition = Vector3.zero;
            fenShuMoveCom = obj.GetComponent <XKPlayerFenShuMove>();
            if (fenShuMoveCom != null)
            {
                fenShuMoveCom.Init(m_FenShuAtlasP2);
                fenShuMoveCom.SetActive(false);
            }
            FenShuListP2.Add(fenShuMoveCom);
        }

        for (int i = 0; i < MaxPlayerFS; i++)
        {
            obj = (GameObject)Instantiate(PlayerFenShuPre);
            obj.transform.parent        = transform;
            obj.transform.localScale    = new Vector3(1f, 1f, 1f);
            obj.transform.localPosition = Vector3.zero;
            fenShuMoveCom = obj.GetComponent <XKPlayerFenShuMove>();
            if (fenShuMoveCom != null)
            {
                fenShuMoveCom.Init(m_FenShuAtlasP3);
                fenShuMoveCom.SetActive(false);
            }
            FenShuListP3.Add(fenShuMoveCom);
        }
    }
    // Use this for initialization
    void Start()
    {
        _Instance  = this;
        FenShuList = new List <XKPlayerFenShuMove>();
        GameObject obj = null;

        for (int i = 0; i < MaxPlayerFS; i++)
        {
            obj = (GameObject)Instantiate(PlayerFenShuPre);
            obj.transform.parent        = transform;
            obj.transform.localScale    = new Vector3(1f, 1f, 1f);
            obj.transform.localPosition = Vector3.zero;
            FenShuList.Add(obj.GetComponent <XKPlayerFenShuMove>());
            obj.SetActive(false);
        }
    }
Ejemplo n.º 3
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);
    }
    public void OnDamageNpc(int damageNpcVal         = 1,
                            PlayerEnum playerSt      = PlayerEnum.Null,
                            PlayerAmmoType pAmmoType = PlayerAmmoType.Null,
                            bool isAiFireAmmo        = false)
    {
        if (IsDeathNpc)
        {
            return;
        }

        if (pAmmoType == PlayerAmmoType.SanDanAmmo)
        {
            if (Time.time - TimeSanDanDamage < XKPlayerGlobalDt.GetInstance().TimeShouDongDaoDan)
            {
                //对于玩家的主炮散弹在同一次发射内只计算一次伤害.
                //SSDebug.LogWarning("************* pAmmoType ====== " + pAmmoType);
                return;
            }
            TimeSanDanDamage = Time.time;
        }

        if (pAmmoType == PlayerAmmoType.ChuanTouAmmo)
        {
            if (XKPlayerMvFanWei.GetInstanceQian() != null && XKPlayerCamera.GetInstanceFeiJi() != null)
            {
                Vector3 forwardVecCam = XKPlayerCamera.GetInstanceFeiJi().transform.forward;
                Vector3 posA          = transform.position;
                Vector3 posB          = XKPlayerMvFanWei.GetInstanceQian().transform.position;
                forwardVecCam.y = posA.y = posB.y = 0f;
                Vector3 vecBA = posA - posB;
                if (Vector3.Dot(forwardVecCam, vecBA) >= 0f)
                {
                    //npc在镜头前方范围之外,不受玩家子弹伤害.
                    return;
                }
            }
        }

        if (IsBackDaiJinQuanNpcBlood == true)
        {
            //代金券npc重置血值后,给一定时间的无敌状态.
            if (Time.time - m_TimeLastBackDaiJinQuanNpcBlood <= 0.5f)
            {
                return;
            }
            else
            {
                IsBackDaiJinQuanNpcBlood = false;
            }
        }

        //switch (NpcJiFen)
        //{
        //    case NpcJiFenEnum.Boss:
        //        if (!XKBossXueTiaoCtrl.GetInstance().GetIsCanSubXueTiaoAmount())
        //        {
        //            if (NpcDamageCom != null)
        //            {
        //                NpcDamageCom.PlayNpcDamageEvent();
        //            }
        //            return;
        //        }
        //        break;
        //}


        if (NpcDamageCom != null)
        {
            NpcDamageCom.PlayNpcDamageEvent();
        }

        if (NpcScript != null)
        {
            if (NpcScript.IsCaiPiaoZhanChe == true && NpcScript.IsEnterCameraBox == false)
            {
                //彩票战车和boss没有进入摄像机盒子,不计算伤害.
                return;
            }
        }

        if (CountActivePlayer != XkGameCtrl.PlayerActiveNum)
        {
            if (CountActivePlayer != 0)
            {
                //fix PuTongAmmoCount.
                int indexValTmp      = CountActivePlayer - 1;
                int puTongAmmoNumTmp = MaxPuTongAmmo[indexValTmp];
                indexValTmp = XkGameCtrl.PlayerActiveNum - 1;
                if (indexValTmp >= 0)
                {
                    float healthPer = (float)PuTongAmmoCount / puTongAmmoNumTmp;
                    //int oldPuTongAmmoCount = PuTongAmmoCount;
                    PuTongAmmoCount = (int)(healthPer * MaxPuTongAmmo[indexValTmp]);

                    /*Debug.Log("Unity:"+"fix npc health -> PuTongAmmoCount "+PuTongAmmoCount
                     +", oldPuTongAmmoCount "+oldPuTongAmmoCount);*/
                }
            }
            CountActivePlayer = XkGameCtrl.PlayerActiveNum;
        }

        if (NpcScript == null || (NpcScript != null && !NpcScript.GetIsWuDi()))
        {
            PuTongAmmoCount += damageNpcVal;
        }

        int indexVal = XkGameCtrl.PlayerActiveNum - 1;

        indexVal = indexVal < 0 ? 0 : indexVal;
        int puTongAmmoNum = MaxPuTongAmmo[indexVal];

        if (NpcScript != null)
        {
            if (NpcScript.IsZhanCheNpc || NpcScript.IsJPBossNpc)
            {
                if (XkGameCtrl.GetInstance().m_GamePlayerAiData.IsActiveAiPlayer == true)
                {
                    //当没有玩家激活游戏时,彩票战车和JPBoss采用原血量的一定比例来计算.
                    puTongAmmoNum = (int)(XkGameCtrl.GetInstance().m_ZhanCheBossBloodPer *puTongAmmoNum);
                }
            }
        }

        /*if (NpcJiFen == NpcJiFenEnum.Boss)
         * {
         *              float bossAmount = (float)(puTongAmmoNum - PuTongAmmoCount) / puTongAmmoNum;
         *              bossAmount = bossAmount < 0f ? 0f : bossAmount;
         *  if (XKBossXueTiaoCtrl.GetInstance() != null)
         *  {
         *      XKBossXueTiaoCtrl.GetInstance().SetBloodBossAmount(bossAmount, this);
         *  }
         *      }*/

        if (NpcScript != null)
        {
            if (NpcScript.IsCaiPiaoZhanChe == true)
            {
                if (XkGameCtrl.GetInstance() != null && XKPlayerFenShuCtrl.GetInstance() != null)
                {
                    if (pAmmoType == PlayerAmmoType.DaoDanAmmo ||
                        pAmmoType == PlayerAmmoType.PaiJiPaoAmmo ||
                        pAmmoType == PlayerAmmoType.ChuanTouAmmo ||
                        pAmmoType == PlayerAmmoType.SanDanAmmo ||
                        pAmmoType == PlayerAmmoType.ChongJiBoAmmo)
                    {
                        int jiFenVal = XkGameCtrl.GetInstance().m_DaoDanHitBossJiFen;
                        //XKPlayerFenShuCtrl.GetInstance().ShowPlayerFenShu(playerSt, GetJiFen(jiFenVal));
                        XKPlayerFenShuCtrl.GetInstance().ShowPlayerFenShu(playerSt, jiFenVal);
                    }
                }

                float bloodAmount = (float)(puTongAmmoNum - PuTongAmmoCount) / puTongAmmoNum;
                bloodAmount = bloodAmount < 0f ? 0f : bloodAmount;

                bool isCanJiBao = true;
                if (XkGameCtrl.GetInstance().m_GamePlayerAiData.IsActiveAiPlayer == true)
                {
                    //没有玩家激活游戏时,Ai都认为是可以击爆战车或Boss.
                }
                else
                {
                    //有玩家激活游戏.
                    if (XkGameCtrl.GetInstance().m_CaiPiaoHealthDt != null)
                    {
                        isCanJiBao = XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.m_CurrentTotalHealthDt.IsCanJiBao;
                    }
                }

                if (isCanJiBao == false)
                {
                    //不允许被玩家击爆的代金券npc.
                    if (IsBloodToStage02 == false)
                    {
                        if (bloodAmount <= 0.24f)
                        {
                            //强制保留一定的血量.
                            m_BloodAmoutValue      = bloodAmount = 0.24f;
                            IsBloodToStage02       = true;
                            m_TimeLastBloodToStage = Time.time;
                            PuTongAmmoCount        = puTongAmmoNum - 1;
                        }
                    }
                    else if (IsBloodToStage01 == false)
                    {
                        float minBloodAmount = 0.12f; //最小极限血值.
                        if (m_BloodAmoutValue > minBloodAmount)
                        {
                            //血值已经降到最低阶段.
                            float dTimeVal = 0.4f;
                            if (XkGameCtrl.GetInstance().m_CaiPiaoHealthDt != null)
                            {
                                dTimeVal = XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.m_TimeNoDead;
                            }

                            if (Time.time - m_TimeLastBloodToStage >= dTimeVal)
                            {
                                //每次间隔一定时间减少一定血值.
                                m_TimeLastBloodToStage = Time.time;
                                float subBloodAmount = 0.02f; //每次减少的血值.
                                if (m_BloodAmoutValue > minBloodAmount)
                                {
                                    m_BloodAmoutValue -= subBloodAmount;
                                    if (m_BloodAmoutValue < minBloodAmount)
                                    {
                                        //强制保护的血值信息.
                                        m_BloodAmoutValue = minBloodAmount;
                                        IsBloodToStage01  = true;
                                    }
                                }
                            }
                        }
                        bloodAmount     = m_BloodAmoutValue;
                        PuTongAmmoCount = puTongAmmoNum - 1; //强制保留一定的血值.
                    }
                    else
                    {
                        float minBloodAmount = 0.03f; //最小极限血值.
                        if (m_BloodAmoutValue > minBloodAmount)
                        {
                            //血值已经降到最低阶段.
                            float dTimeVal = 0.4f;
                            if (XkGameCtrl.GetInstance().m_CaiPiaoHealthDt != null)
                            {
                                dTimeVal = XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.m_TimeNoDead;
                            }

                            if (Time.time - m_TimeLastBloodToStage >= dTimeVal)
                            {
                                //每次间隔一定时间减少一定血值.
                                m_TimeLastBloodToStage = Time.time;
                                float subBloodAmount = 0.01f; //每次减少的血值.
                                if (m_BloodAmoutValue > minBloodAmount)
                                {
                                    m_BloodAmoutValue -= subBloodAmount;
                                    if (m_BloodAmoutValue < minBloodAmount)
                                    {
                                        //强制保护的血值信息.
                                        m_BloodAmoutValue = minBloodAmount;
                                    }
                                }
                            }
                        }
                        bloodAmount     = m_BloodAmoutValue;
                        PuTongAmmoCount = puTongAmmoNum - 1; //强制保留一定的血值.
                    }
                }

                //彩票战车和boss的血条UI信息更新.
                SSUIRoot.GetInstance().m_GameUIManage.SetDaiJinQuanNpcXueTiaoAmount(bloodAmount);

                if (XkGameCtrl.GetInstance().m_GamePlayerAiData.IsActiveAiPlayer == true)
                {
                    //没有玩家激活游戏时,Ai都认为是不可以击爆JPBoss特殊武器的.
                }
                else
                {
                    //JPBoss受到玩家子弹伤害.
                    if (NpcScript.IsJPBossNpc == true)
                    {
                        NpcScript.OnDamageJPBossWeapon(bloodAmount);
                    }
                }
            }
        }

        /*Debug.Log("Unity:"+"OnDamageNpc -> "
         +", nameNpc "+NpcNameInfo
         +", puTongAmmoNum "+puTongAmmoNum);*/
        if (PuTongAmmoCount >= puTongAmmoNum)
        {
            if (NpcScript != null)
            {
                if (NpcScript.IsZhanCheNpc)
                {
                    //战车npc是否可以被击爆的判断.
                    if (XkGameCtrl.GetInstance().IsCaiPiaoHuLuePlayerIndex == false && NpcScript.m_IndexPlayerJiBao != playerSt)
                    {
                        //不是可以击爆战车npc的玩家.
                        return;
                    }

                    if (XkGameCtrl.GetInstance().m_GamePlayerAiData.IsActiveAiPlayer == true)
                    {
                        //没有激活任何玩家.
                    }
                    else
                    {
                        if (!XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage.m_GameCaiPiaoData.GetIsChuCaiPiaoByDeCaiState(SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.ZhanChe, NpcScript.m_DaiJinQuanState))
                        {
                            //战车彩池的彩票积累的不够.
                            return;
                        }
                    }
                }

                if (NpcScript.IsJPBossNpc)
                {
                    //JPBoss是否可以被击爆的判断.
                    if (XkGameCtrl.GetInstance().IsCaiPiaoHuLuePlayerIndex == false && NpcScript.m_IndexPlayerJiBao != playerSt)
                    {
                        //不是可以击爆JPBoss的玩家.
                        return;
                    }

                    if (XkGameCtrl.GetInstance().m_GamePlayerAiData.IsActiveAiPlayer == true)
                    {
                        //没有激活任何玩家.
                    }
                    else
                    {
                        if (!XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage.m_GameCaiPiaoData.GetIsChuCaiPiaoByDeCaiState(SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.JPBoss))
                        {
                            //JPBoss彩池的彩票积累的不够.
                            return;
                        }
                    }
                }
            }

            if (IsDeathNpc)
            {
                return;
            }
            IsDeathNpc = true;

            if (IsOpenCameraShake)
            {
                XKPlayerCamera.GetInstanceFeiJi().HandlePlayerCameraShake();
            }

            if (NpcJiFen == NpcJiFenEnum.Boss && BossXieZiScript != null)
            {
                BossXieZiScript.ResetBossXieZiShouBiInfo();
            }

            if (BoxColCom != null)
            {
                BoxColCom.enabled = false;
            }
            CheckSpawnDaoJuCom(playerSt);
            CheckNpcDeathExplode(playerSt);
            CheckHiddenNpcObjArray();

//			bool isAddKillNpcNum = true;
//			if (NpcScript != null && CannonScript != null) {
//				if (NpcScript.GetIsDeathNPC()) {
//					isAddKillNpcNum = false;
//					Debug.Log("Unity:"+"name "+NpcScript.name+", isAddKillNpcNum "+isAddKillNpcNum);
//				}
//			}

            if (!IsYouTongNpc)
            {
                switch (NpcJiFen)
                {
                case NpcJiFenEnum.Boss:
                    if (GameTimeBossCtrl.GetInstance() != null &&
                        GameTimeBossCtrl.GetInstance().GetTimeBossResidual() > 0)
                    {
                        XkGameCtrl.GetInstance().AddPlayerKillNpc(PlayerEnum.Null, NpcJiFen, GetJiFen());
                    }
                    break;

                default:
                    XkGameCtrl.GetInstance().AddPlayerKillNpc(playerSt, NpcJiFen, GetJiFen());
                    ShowPiaoFen(playerSt);
                    break;
                }
//				if (isAddKillNpcNum) {
//					switch (NpcJiFen) {
//					case NpcJiFenEnum.Boss:
//						if (GameTimeBossCtrl.GetInstance().GetTimeBossResidual() > 0) {
//							XkGameCtrl.GetInstance().AddPlayerKillNpc(PlayerEnum.Null, NpcJiFen, JiFenVal);
//						}
//						break;
//					default:
//						XkGameCtrl.GetInstance().AddPlayerKillNpc(playerSt, NpcJiFen, JiFenVal);
//						break;
//					}
//				}
            }
            else
            {
                CheckYouTongDamageNpc();
            }

            if (NpcScript != null)
            {
                if (CannonScript != null)
                {
                    CannonScript.OnRemoveCannon(playerSt, 1);
                }

                if (NpcJiFen != NpcJiFenEnum.Boss && NpcScript.GetIsBossNpc())
                {
                    return;
                }
                NpcScript.TriggerRemovePointNpc(1, CannonScript, pAmmoType);

                if (NpcScript.IsCaiPiaoZhanChe)
                {
                    SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState deCaiType = SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.ZhanChe;
                    //彩票boss或战车npc.
                    if (NpcScript.GetIsBossNpc())
                    {
                        deCaiType = SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.JPBoss;
                    }
                    else
                    {
                        if (XkPlayerCtrl.GetInstanceFeiJi() != null)
                        {
                            XkPlayerCtrl.GetInstanceFeiJi().AddGetZhanCheDaiJinQuanPlayer(XKPlayerMoveCtrl.GetInstance(playerSt));
                        }
                    }

                    if (XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage != null)
                    {
                        if (isAiFireAmmo == false)
                        {
                            //只有被玩家击爆的代金券npc才允许出彩.
                            XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage.m_GameCaiPiaoData.SubGameDeCaiValByDeCaiState(playerSt, deCaiType,
                                                                                                                                               SSCaiPiaoDataManage.SuiJiDaoJuState.BaoXiang, NpcScript.m_DaiJinQuanState);
                        }
                        //else
                        //{
                        //被Ai坦克击爆的代金券npc不允许出彩.
                        //SSDebug.Log("The DaiJinQuan was killed by AiTank");
                        //}
                    }
                }
                else
                {
                    //普通npc被击杀.
                    //if (XkGameCtrl.GetInstance().m_PlayerJiChuCaiPiaoData != null && DeathExplodePoint != null)
                    //{
                    //    //随机送出正常得彩.
                    //    XkGameCtrl.GetInstance().m_PlayerJiChuCaiPiaoData.CheckPlayerSongPiaoInfo(playerSt, DeathExplodePoint.position);
                    //}
                }
            }
            else if (CannonScript != null)
            {
                CannonScript.OnRemoveCannon(playerSt, 1);
                //炮台类npc被击杀.
                //if (XkGameCtrl.GetInstance().m_PlayerJiChuCaiPiaoData != null && DeathExplodePoint != null)
                //{
                //    //随机送出正常得彩.
                //    XkGameCtrl.GetInstance().m_PlayerJiChuCaiPiaoData.CheckPlayerSongPiaoInfo(playerSt, DeathExplodePoint.position);
                //}
            }
        }
    }
    /// <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);
    }