示例#1
0
 void DelayActiveJiFenJieMian()
 {
     if (GameTimeBossCtrl.GetInstance().GetTimeBossResidual() > 0)
     {
         XKGlobalData.GetInstance().PlayAudioBossShengLi();
     }
     JiFenJieMianCtrl.GetInstance().ActiveJiFenJieMian();
 }
 void ChangeBossXTAlphaEnd(int timeVal)
 {
     if (GameTimeBossCtrl.GetInstance() != null)
     {
         GameTimeBossCtrl.GetInstance().ActiveIsCheckTimeSprite(timeVal);
     }
     StartFillBossXueTiao();
 }
 public void HiddenBossXueTiao()
 {
     if (BossZuDangCtrl.GetInstance() != null)
     {
         BossZuDangCtrl.GetInstance().SetIsActiveBossZuDang(false);
     }
     gameObject.SetActive(false);
     GameTimeBossCtrl.GetInstance().HiddenGameTime();
 }
    public void ShowGamePaiMing()
    {
        //Debug.Log("Unity:"+"ShowGamePaiMing...");
        int timeShengYu = GameTimeBossCtrl.GetInstance().GetTimeBossResidual();

        //timeShengYu = 51; //test.
        BossJiFenCtrl.GetInstance().ShowBossJiFenInfo(timeShengYu);

        int fenShuBoss = BossFenShuVal * timeShengYu;

        //Debug.Log("Unity:"+"fenShuBoss ****************** "+fenShuBoss);
        if (XkGameCtrl.IsActivePlayerOne)
        {
            XkGameCtrl.PlayerJiFenArray[0] += fenShuBoss;
            if (fenShuBoss > 0)
            {
                XKPlayerScoreCtrl.ChangePlayerScore(PlayerEnum.PlayerOne);
            }
        }
        if (XkGameCtrl.IsActivePlayerTwo)
        {
            XkGameCtrl.PlayerJiFenArray[1] += fenShuBoss;
            if (fenShuBoss > 0)
            {
                XKPlayerScoreCtrl.ChangePlayerScore(PlayerEnum.PlayerTwo);
            }
        }
        if (XkGameCtrl.IsActivePlayerThree)
        {
            XkGameCtrl.PlayerJiFenArray[2] += fenShuBoss;
            if (fenShuBoss > 0)
            {
                XKPlayerScoreCtrl.ChangePlayerScore(PlayerEnum.PlayerThree);
            }
        }
        if (XkGameCtrl.IsActivePlayerFour)
        {
            XkGameCtrl.PlayerJiFenArray[3] += fenShuBoss;
            if (fenShuBoss > 0)
            {
                XKPlayerScoreCtrl.ChangePlayerScore(PlayerEnum.PlayerFour);
            }
        }

        for (int i = 0; i < XkGameCtrl.PlayerJiFenArray.Length; i++)
        {
            XkGameCtrl.PlayerJiFenArray[i] = XkGameCtrl.PlayerJiFenArray[i] > MaxGameFenShu
                                ? MaxGameFenShu : XkGameCtrl.PlayerJiFenArray[i];
        }

        for (int i = 0; i < PlayerPaiMingObjArray.Length; i++)
        {
            PlayerPaiMingObjArray[i].SetActive(false);
        }
        XinJiLuObj.SetActive(false);
        HuangGuanObj.SetActive(false);

        int  countJF          = 0;
        bool isActiveXinJiLu  = false;
        bool isActivePlayerJF = false;

        //test start.

        /*XkGameCtrl.PlayerJiFenArray[0] = 123;
         * XkGameCtrl.PlayerJiFenArray[1] = 12345;
         * XkGameCtrl.PlayerJiFenArray[2] = 1234;
         * XkGameCtrl.PlayerJiFenArray[3] = 1234;*/
        //test end.
        int[] playerJFArray = XkGameCtrl.PlayerJiFenArray;
        if (PlayerJiFenList != null)
        {
            PlayerJiFenList.Clear();
            PlayerJiFenList = null;
        }

        PlayerJiFenList = new List <int>(playerJFArray);
        PlayerJiFenList.Sort();
        PlayerJiFenList.Reverse();
        int[] jiLuFenShuKey = { 0, 0, 0, 0 };
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                /*Debug.Log("Unity:"+"playerJFArray["+i+"] *** "+playerJFArray[i]
                 +", PlayerJiFenList["+j+"] *** "+PlayerJiFenList[j]);*/
                if (playerJFArray[i] == PlayerJiFenList[j] && jiLuFenShuKey[j] == 0)
                {
                    jiLuFenShuKey[j] = 1;
                    isActivePlayerJF = playerJFArray[i] > 0 ? true : false;
                    if (!isActivePlayerJF && j > 0)
                    {
                        break;
                    }

                    countJF++;
                    if (XKGlobalData.GameVersionPlayer == 0)
                    {
                        if (pcvr.IsHongDDShouBing)
                        {
                            string url = pcvr.GetInstance().m_PlayerHeadUrl[i];
                            XkGameCtrl.GetInstance().m_AsyImage.LoadPlayerHeadImg(url, PlayerNumUITexture[j]);
                        }
                        else
                        {
                            PlayerNumUITexture[j].mainTexture = PlayerTexture[i];
                        }
                    }
                    else
                    {
                        PlayerNumUITexture[j].mainTexture = PlayerTextureShR[i];
                    }

                    switch (j)
                    {
                    case 0:
                        isActivePlayerJF = true;
                        if (XinJiLuVal < PlayerJiFenList[j])
                        {
                            isActiveXinJiLu = true;
                            XinJiLuVal      = PlayerJiFenList[j];
                        }
                        SetPlayerJiFen(PlayerJF_1, PlayerJiFenList[j]);
                        break;

                    case 1:
                        SetPlayerJiFen(PlayerJF_2, PlayerJiFenList[j]);
                        break;

                    case 2:
                        SetPlayerJiFen(PlayerJF_3, PlayerJiFenList[j]);
                        break;

                    case 3:
                        SetPlayerJiFen(PlayerJF_4, PlayerJiFenList[j]);
                        break;
                    }
                    PlayerPaiMingObjArray[j].SetActive(isActivePlayerJF);
                    break;
                }
            }
        }

        if (countJF > 1)
        {
            HuangGuanObj.SetActive(true);
        }
        XinJiLuObj.SetActive(isActiveXinJiLu);

        if (GameJiLuFenShuCtrl.GetInstance() != null)
        {
            GameJiLuFenShuCtrl.GetInstance().ShowGameJiLuScore();
        }
        XKPlayerScoreCtrl.HiddenPlayerScore(PlayerEnum.Null);
    }
    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);
                //}
            }
        }
    }
    public void OnDamageNpc(int damageNpcVal         = 1, PlayerEnum playerSt = PlayerEnum.Null,
                            PlayerAmmoType pAmmoType = PlayerAmmoType.Null)
    {
        if (IsDeathNpc)
        {
            return;
        }

        switch (NpcJiFen)
        {
        case NpcJiFenEnum.Boss:
            if (!XKBossXueTiaoCtrl.GetInstance().GetIsCanSubXueTiaoAmount())
            {
                return;
            }
            break;
        }

        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 (NpcDamageCom != null)
        {
            NpcDamageCom.PlayNpcDamageEvent();
        }

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

        int indexVal = XkGameCtrl.PlayerActiveNum - 1;

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

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

        /*Debug.Log("Unity:"+"OnDamageNpc -> "
         +", nameNpc "+NpcNameInfo
         +", puTongAmmoNum "+puTongAmmoNum);*/
        if (PuTongAmmoCount >= puTongAmmoNum)
        {
            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();
            CheckNpcDeathExplode();
            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().GetTimeBossResidual() > 0)
                    {
                        XkGameCtrl.GetInstance().AddPlayerKillNpc(PlayerEnum.Null, NpcJiFen, JiFenVal);
                    }
                    break;

                default:
                    XkGameCtrl.GetInstance().AddPlayerKillNpc(playerSt, NpcJiFen, JiFenVal);
                    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);
            }
            else if (CannonScript != null)
            {
                CannonScript.OnRemoveCannon(playerSt, 1);
            }
        }
    }
示例#7
0
    public void OnDamageNpc(int damageNpcVal         = 1, PlayerEnum playerSt = PlayerEnum.Null,
                            PlayerAmmoType pAmmoType = PlayerAmmoType.Null)
    {
        if (IsDeathNpc)
        {
            return;
        }

        //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 (NpcJiFen == NpcJiFenEnum.Boss)
        {
            float bossAmount = (float)(puTongAmmoNum - PuTongAmmoCount) / puTongAmmoNum;
            bossAmount = bossAmount < 0f ? 0f : bossAmount;
            XKBossXueTiaoCtrl.GetInstance().SetBloodBossAmount(bossAmount, this);
        }

        /*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))
                        {
                            //战车彩池的彩票积累的不够.
                            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().GetTimeBossResidual() > 0)
                    {
                        XkGameCtrl.GetInstance().AddPlayerKillNpc(PlayerEnum.Null, NpcJiFen, JiFenVal);
                    }
                    break;

                default:
                    XkGameCtrl.GetInstance().AddPlayerKillNpc(playerSt, NpcJiFen, JiFenVal);
                    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;
                    }

                    if (XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage != null)
                    {
                        XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage.m_GameCaiPiaoData.SubGameDeCaiValByDeCaiState(playerSt, deCaiType);
                    }
                }
                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);
                }
            }
        }
    }