public void DestroyCui(BasePlayer player) { CuiHelper.DestroyUi(player, "CockpitGuiOverlay"); CuiHelper.DestroyUi(player, "CrosshairGuiOverlay"); CuiHelper.DestroyUi(player, "DamageGuiOverlay"); CuiHelper.DestroyUi(player, "HealthGui"); DamagedHeli.Remove(player.userID); }
public void OnDestroy() { player = GetComponent <BasePlayer>(); DestroyCui(player); DamagedHeli.Remove(player.userID); HeliFlying.Remove(player.userID); if (helicopterBase == null) { return; } if (heliAI._currentState == PatrolHelicopterAI.aiState.DEATH) { heliAI.enabled = true; heli.bulletDamage = 0f; GameObject.Destroy(this); addplayerchute(); return; } helicopterBase.Kill(); GameObject.Destroy(this); }
////////////////////////////////////////////////////////////////////////////////////// private void FixedUpdate() { player = GetComponent <BasePlayer>(); if (player.IsDead() || !player.IsFlying) { heliAI._currentState = PatrolHelicopterAI.aiState.DEATH; } if (heliAI._currentState == PatrolHelicopterAI.aiState.DEATH) { heliAI.enabled = true; DestroyCui(player); GameObject.Destroy(this); return; } if (rocketMax <= 0) { hasRockets = false; } if (napalmMax <= 0) { hasNapalm = false; } Vector3 PlayerPOS = player.transform.position - player.eyes.BodyForward() * 5 + Vector3.down * 0.45f; CurrentPOS = helicopterBase.transform.position; Vector3 direction = Quaternion.Euler(input.current.aimAngles) * Vector3.fwd; heli.spotlightTarget = FindTarget(target); helicopterBase.transform.localPosition = PlayerPOS; helicopterBase.transform.rotation = Quaternion.Lerp(helicopterBase.transform.rotation, player.eyes.rotation, 2f * Time.deltaTime); helicopterBase.transform.eulerAngles = new Vector3(0, helicopterBase.transform.eulerAngles.y, 0); BaseCombatEntity helientity = helicopterBase.GetComponent <BaseCombatEntity>(); float health = helientity.Health(); HealthIndicator(player, health); if (health <= 3000f && ShowCockpitOverlay) { if (!DamagedHeli.ContainsKey(player.userID)) { if (ShowCockpitOverlay) { DamageOverlay(player); DamagedHeli.Add(player.userID, new HeliDamage { player = player }); } } } if (isReloading) { reloadtimer += Time.deltaTime; if (reloadtimer >= rocketNapalmReploadTime) { isReloading = false; rocketMax = RocketMax; hasRockets = true; napalmMax = NapalmMax; hasNapalm = true; reloadtimer = 0.0; } } if (rocketcycle) { rocketcycletimer += Time.deltaTime; if (rocketcycletimer >= rocketDelay) { rocketcycle = false; rocketcycletimer = 0.0; } } if (health > 3000f && ShowCockpitOverlay) { if (DamagedHeli.ContainsKey(player.userID)) { CuiHelper.DestroyUi(player, "DamageGuiOverlay"); DamagedHeli.Remove(player.userID); } } if (input.IsDown(BUTTON.RELOAD)) { isReloading = true; } if (input.IsDown(BUTTON.DUCK)) { Vector3 downPos = player.transform.position + Vector3.down * (UnityEngine.Time.deltaTime * 3f); player.ClientRPCPlayer(null, player, "ForcePositionTo", downPos); player.SendNetworkUpdate(); } if (input.IsDown(BUTTON.FIRE_PRIMARY)) { target = FindTarget(target); FireGuns(target); } if (input.IsDown(BUTTON.FIRE_SECONDARY)) { if (!hasRockets || isReloading) { return; } if (!rocketcycle) { leftTubeFiredLast = !leftTubeFiredLast; FireRocket(leftTubeFiredLast, direction, PlayerPOS, true); } rocketcycle = true; } if (input.IsDown(BUTTON.FIRE_THIRD)) { if (!hasNapalm || isReloading) { return; } if (!rocketcycle) { leftTubeFiredLast = !leftTubeFiredLast; FireRocket(leftTubeFiredLast, direction, PlayerPOS, false); } rocketcycle = true; } }