void OnCollisionEnter(Collision collision) { //Debug.Log("Unity:"+"**********OnCollisionEnter-> collision "+collision.gameObject.name); XKPlayerMoveCtrl playerScript = collision.gameObject.GetComponent <XKPlayerMoveCtrl>(); if (playerScript == null) { return; } if (NpcJiFen == NpcJiFenEnum.Boss || !IsCanHitNpc) { if (Time.realtimeSinceStartup - TimeHitBoss < 1f) { return; } TimeHitBoss = Time.realtimeSinceStartup; Vector3 pushDir = Vector3.zero; Vector3 playerPos = playerScript.transform.position; Vector3 hitPos = transform.position; playerPos.y = hitPos.y = 0f; pushDir = playerPos - hitPos; playerScript.PushPlayerTanKe(pushDir); if (!playerScript.GetIsWuDiState()) { XkGameCtrl.GetInstance().SubGamePlayerHealth(playerScript.PlayerIndex, PlayerDamage); } return; } if (IsDeathNpc) { return; } if (!playerScript.GetIsWuDiState()) { XkGameCtrl.GetInstance().SubGamePlayerHealth(playerScript.PlayerIndex, PlayerDamage); } CheckNpcDeathExplode(); if (!IsYouTongNpc) { XkGameCtrl.GetInstance().AddPlayerKillNpc(playerScript.PlayerIndex, NpcJiFen, GetJiFen()); ShowPiaoFen(playerScript.PlayerIndex); } if (NpcScript != null) { IsDeathNpc = true; NpcScript.TriggerRemovePointNpc(1); } else if (CannonScript != null) { IsDeathNpc = true; CannonScript.OnRemoveCannon(PlayerEnum.Null, 1); } CheckHiddenNpcObjArray(); }
void OnTriggerExit(Collider other) { XKNpcMoveCtrl npcMoveCom = other.gameObject.GetComponent <XKNpcMoveCtrl>(); if (npcMoveCom != null && npcMoveCom.IsCaiPiaoZhanChe) { //Debug.Log("Unity: OnTriggerExit******************name === " + npcMoveCom.name); if (npcMoveCom.GetIsBossNpc() == true) { //Boss走出镜头范围. if (XkGameCtrl.GetInstance() != null && XkGameCtrl.GetInstance().m_AiPathGroup != null && XkGameCtrl.GetInstance().m_AiPathGroup.m_CameraMoveType != AiPathGroupCtrl.MoveState.YuLe) { XkGameCtrl.GetInstance().m_AiPathGroup.SetCameraMoveType(AiPathGroupCtrl.MoveState.Default); } npcMoveCom.TriggerRemovePointNpc(0); //boss删除后切换背景音效. AudioBeiJingCtrl.StopGameBeiJingAudio(); //镜头继续移动. XkGameCtrl.GetInstance().SetGameCameraIsMoveing(true, NpcJiFenEnum.Boss); } else { //彩票战车npc走出镜头范围. npcMoveCom.TriggerRemovePointNpc(0); //镜头继续移动. XkGameCtrl.GetInstance().SetGameCameraIsMoveing(true, NpcJiFenEnum.CheLiang); } } }
void OnCollisionEnter(Collision collision) { PlayerZhiShengJiCtrl playerScript = collision.gameObject.GetComponent <PlayerZhiShengJiCtrl>(); if (playerScript == null) { return; } if (IsDeathNpc) { return; } // Debug.Log("**********OnCollisionEnter-> collision "+collision.gameObject.name); if (playerScript.GetPlayerType() != PlayerTypeEnum.TanKe) { return; } if (XkGameCtrl.GameJiTaiSt != GameJiTaiType.TanKeJiTai) { return; } bool isSetDianJiState = false; if (!IsYouTongNpc) { isSetDianJiState = true; XkGameCtrl.GetInstance().AddPlayerKillNpc(PlayerEnum.Null, NpcJiFen); XkGameCtrl.GetInstance().AddYouLiangDian(YouLiangDian, PlayerEnum.Null); YouLiangDianUICtrl.GetInstance().HandleNpcYouLiangDian(YouLiangDian, transform); } if (NpcScript != null) { IsDeathNpc = true; isSetDianJiState = true; NpcScript.TriggerRemovePointNpc(1); } else if (CannonScript != null) { IsDeathNpc = true; isSetDianJiState = true; CannonScript.OnRemoveCannon(PlayerEnum.Null, 1); } if (isSetDianJiState) { XKPlayerAutoFire.SetPlayerZuoYiDianJiState(PlayerEnum.PlayerOne, 2); XKPlayerAutoFire.SetPlayerZuoYiDianJiState(PlayerEnum.PlayerTwo, 2); } CheckHiddenNpcObjArray(); }
void OnTriggerExit(Collider other) { XKNpcMoveCtrl npcMoveCom = other.gameObject.GetComponent <XKNpcMoveCtrl>(); if (npcMoveCom != null && npcMoveCom.IsCaiPiaoZhanChe) { //Debug.Log("Unity: OnTriggerExit******************name === " + npcMoveCom.name); bool isExit = false; switch (m_TriggerState) { case TriggerState.JPBoss: { if (npcMoveCom.IsEnterCameraBox == true && npcMoveCom.GetIsBossNpc() == true) { isExit = true; } if (npcMoveCom.IsCaiPiaoZhanChe == false) { //普通npc走出JPBoss的镜头范围盒子. if (XkPlayerCtrl.GetInstanceFeiJi() != null) { if (XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage != null) { XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.RemovePuTongNpcToBuJiDt(npcMoveCom.gameObject); } } } break; } case TriggerState.ZhanCheBoss: { if (npcMoveCom.IsEnterCameraBox == true && npcMoveCom.GetIsBossNpc() == false) { isExit = true; } break; } } if (isExit == false) { return; } if (npcMoveCom.GetIsBossNpc() == true) { //Boss走出镜头范围. if (XkGameCtrl.GetInstance() != null && XkGameCtrl.GetInstance().m_AiPathGroup != null && XkGameCtrl.GetInstance().m_AiPathGroup.m_CameraMoveType != AiPathGroupCtrl.MoveState.YuLe) { XkGameCtrl.GetInstance().m_AiPathGroup.SetCameraMoveType(AiPathGroupCtrl.MoveState.Default); } npcMoveCom.TriggerRemovePointNpc(0); //boss删除后切换背景音效. AudioBeiJingCtrl.StopGameBeiJingAudio(); //镜头继续移动. XkGameCtrl.GetInstance().SetGameCameraIsMoveing(true, NpcJiFenEnum.Boss); } else { //彩票战车npc走出镜头范围. npcMoveCom.TriggerRemovePointNpc(0); //镜头继续移动. XkGameCtrl.GetInstance().SetGameCameraIsMoveing(true, NpcJiFenEnum.CheLiang); //SSDebug.LogWarning("SSTriggerCamerBox::OnTriggerExit -> time ==================== " + Time.time); } } }