void Start() { CheckNpcRigidbody(); if (NpcJiFen == NpcJiFenEnum.Boss) { if (XKBossXueTiaoCtrl.GetInstance() != null) { XKBossXueTiaoCtrl.GetInstance().SetBloodBossAmount(-1f, this); } } gameObject.layer = LayerMask.NameToLayer(XkGameCtrl.NpcLayerInfo); BoxColCom = GetComponent <BoxCollider>(); NpcDamageCom = GetComponent <XKNpcDamageCtrl>(); if (MaxPuTongAmmo.Length < 4) { MaxPuTongAmmo = new int[4]; } Invoke("CheckDisGameCamera", 2f); NpcScript = GetComponentInParent <XKNpcMoveCtrl>(); if (NpcScript != null && NpcJiFen == NpcJiFenEnum.Boss) { NpcScript.SetIsBossNpc(true); } }
void OnTriggerEnter(Collider other) { if (other.GetComponent <XkPlayerCtrl>() == null) { return; } XKBossXueTiaoCtrl.GetInstance().OpenBossXueTiao(TimeBoss); }
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); } } }
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); } } } }
void CheckTimeSpriteVal() { if (Time.realtimeSinceStartup - TimeLast < 0.03f) { return; } TimeLast = Time.realtimeSinceStartup; if (!IsCheckTimeSprite) { return; } if (TimeSprite[3].spriteName != TimeMiaoGeWeiStr) { TimeMiaoGeWeiStr = TimeSprite[3].spriteName; TimeBossUse++; } if (TimeSprite[3].spriteName == "timeJiFenBoss_9" && TimeSprite[2].spriteName == "p1_0" && TimeSprite[1].spriteName == "p1_0" && TimeSprite[0].spriteName == "p1_0") { XKBossXueTiaoCtrl.GetInstance().SetBloodBossAmount(0f); Debug.Log("bossTimeOver..."); return; } if (TimeSprite[3].spriteName != "timeJiFenBoss_0") { IsAddTime = false; return; } if (IsAddTime) { return; } IsAddTime = true; int[] timeArray = { 0, 0, 0, 0 }; string timeName = "p1_"; TimeVal[2]--; if (TimeVal[2] < 0) { TimeVal[2] = 5; timeArray[2] = 1; } TimeSprite[2].spriteName = timeName + TimeVal[2]; if (TimeVal[2] == 5 && timeArray[2] == 1) { TimeVal[1]--; if (TimeVal[1] < 0) { TimeVal[1] = 9; timeArray[1] = 1; } } TimeSprite[1].spriteName = timeName + TimeVal[1]; if (TimeVal[1] == 9 && timeArray[1] == 1) { TimeVal[0]--; if (TimeVal[0] < 0) { TimeVal[0] = 9; } } TimeSprite[0].spriteName = timeName + TimeVal[0]; }