public override void StateChangeActionOff() { //Debug.Log("off"); fpsController.enabled = false; fpsController.GetComponent <Rigidbody>().isKinematic = true; fpsController.GetComponent <CharacterController>().enabled = false; walkingStateUI.SetActive(false); Cursor.lockState = CursorLockMode.None; Cursor.visible = true; }
protected override void OnPicked(PlayerCharacterController byPlayer) { var treasure = byPlayer.GetComponent <Treasure>(); var key = byPlayer.GetComponent <Key>(); if (key.hasKey) { treasure.hasTreasure = true; PlayPickupFeedback(); Destroy(gameObject); } }
void Start() { PlayerCharacterController playerCharacterController = GameObject.FindObjectOfType <PlayerCharacterController>(); DebugUtility.HandleErrorIfNullFindObject <PlayerCharacterController, PlayerHealthBar>( playerCharacterController, this); m_PlayerHealth = playerCharacterController.GetComponent <Health>(); m_PlayerArmor = playerCharacterController.GetComponent <Armor>(); DebugUtility.HandleErrorIfNullGetComponent <Health, PlayerHealthBar>(m_PlayerHealth, this, playerCharacterController.gameObject); DebugUtility.HandleErrorIfNullGetComponent <Armor, PlayerHealthBar>(m_PlayerArmor, this, playerCharacterController.gameObject); }
protected override void OnPicked(PlayerCharacterController byPlayer) { var key = byPlayer.GetComponent <Key>(); key.hasKey = true; PlayPickupFeedback(); Destroy(gameObject); }
void OnPicked(PlayerCharacterController player) { PlayerCharacterController playerPlayerCharacterController = player.GetComponent <PlayerCharacterController>(); playerPlayerCharacterController.SetGravity(NewGravity, jumppower); m_Pickup.PlayPickupFeedback(); Destroy(gameObject); }
//FixedUpdate is required to move player (respawn) void FixedUpdate() { if (gameIsEnding) { float timeRatio = 1 - (m_TimeEndBsod - Time.time) / endSceneLoadDelay; endGameFadeCanvasGroup.alpha = timeRatio; AudioUtility.SetMasterVolume(1 - timeRatio); // See if it's time to respawn if (Time.time >= m_TimeEndBsod) { Health playerHealth = m_Player.GetComponent <Health>(); playerHealth.Resurrect(); playerHealth.invincible = true; disableInvincibilityAfterBsod = true; gameIsEnding = false; m_TimeEndBsod = Time.time + endSceneLoadDelay; //when should the fade in complete } } else if (endGameFadeCanvasGroup.alpha > 0) //BSOD is active { float timeRatio = (m_TimeEndBsod - Time.time) / endSceneLoadDelay; endGameFadeCanvasGroup.alpha = timeRatio; //1 = BSOD AudioUtility.SetMasterVolume(1 - timeRatio); } else if (disableInvincibilityAfterBsod) { Health playerHealth = m_Player.GetComponent <Health>(); playerHealth.invincible = false; disableInvincibilityAfterBsod = false; endGameFadeCanvasGroup.gameObject.SetActive(false); } else { // Test if player died if (m_Player.isDead) { gameIsEnding = true; endGameFadeCanvasGroup.gameObject.SetActive(true); m_TimeEndBsod = Time.time + endSceneLoadDelay; //when should the fade out complete } } }
void OnPicked(PlayerCharacterController player) { Health playerHealth = player.GetComponent <Health>(); if (playerHealth && player.key) { m_Pickup.PlayPickupFeedback(); Destroy(gameObject); } }
void OnPicked(PlayerCharacterController player) { PlayerCharacterController playercontroller = player.GetComponent <PlayerCharacterController>(); DebugUtility.HandleErrorIfNullGetComponent <PlayerCharacterController, PoisonPickUp>(playercontroller, this, gameObject); PlayerWeaponsManager weaponcontroller = player.GetComponent <PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullGetComponent <PlayerWeaponsManager, PoisonPickUp>(weaponcontroller, this, gameObject); playercontroller.poisonTaken(SpeedDecreaseAmount); int numberofweapons = weaponcontroller.m_WeaponSlots.Length; for (int i = 0; i < numberofweapons; i++) { WeaponController temp = weaponcontroller.m_WeaponSlots[i]; temp.poisonTaken(); } m_Pickup.PlayPickupFeedback(); Destroy(gameObject); }
void OnPick(PlayerCharacterController p) { Ammo PlayerAmmo = p.GetComponent <Ammo>(); if (PlayerAmmo) { PlayerAmmo.AddAmmo(); pickup.PlayPickupFeedback(); Destroy(gameObject); } }
void OnPicked(PlayerCharacterController player) { Health playerHealth = player.GetComponent <Health>(); if (playerHealth && playerHealth.canPickup()) { playerHealth.Heal(healAmount); m_Pickup.PlayPickupFeedback(); Destroy(gameObject); } }
void Update() { if (Input.GetKeyDown(activateKey)) { m_PlayerCharacterController.transform.SetPositionAndRotation(transform.position, transform.rotation); Health playerHealth = m_PlayerCharacterController.GetComponent <Health>(); if (playerHealth) { playerHealth.Heal(999); } } }
void OnPicked(PlayerCharacterController player) { Health playerHealth = player.GetComponent <Health>(); if (playerHealth && playerHealth.canPickup()) { float healing = playerHealth.Heal(healAmount); TelemetryLogger.LogCollect("Healing", transform.position, name, healing); m_Pickup.PlayPickupFeedback(); Destroy(gameObject); } }
protected override void OnPicked(PlayerCharacterController byPlayer) { var jetpack = byPlayer.GetComponent <Jetpack>(); if (!jetpack) { return; } if (jetpack.TryUnlock()) { PlayPickupFeedback(); Destroy(gameObject); } }
private void OnCollisionEnter(UnityEngine.Collision collision) { if (collision.gameObject.name == "Player") { PlayerCharacterController playerCharacterController = GameObject.FindObjectOfType <PlayerCharacterController>(); DebugUtility.HandleErrorIfNullFindObject <PlayerCharacterController, PlayerHealthBar>(playerCharacterController, this); m_PlayerHealth = playerCharacterController.GetComponent <Health>(); DebugUtility.HandleErrorIfNullGetComponent <Health, PlayerHealthBar>(m_PlayerHealth, this, playerCharacterController.gameObject); m_PlayerHealth.currentHealth -= damage; missleRespawn.missileCount--; Destroy(gameObject); return; } }
void Start() { // Subscribe to player damage events PlayerCharacterController playerCharacterController = FindObjectOfType <PlayerCharacterController>(); DebugUtility.HandleErrorIfNullFindObject <PlayerCharacterController, FeedbackFlashHUD>(playerCharacterController, this); m_PlayerHealth = playerCharacterController.GetComponent <Health>(); DebugUtility.HandleErrorIfNullGetComponent <Health, FeedbackFlashHUD>(m_PlayerHealth, this, playerCharacterController.gameObject); m_GameFlowManager = FindObjectOfType <GameFlowManager>(); DebugUtility.HandleErrorIfNullFindObject <GameFlowManager, FeedbackFlashHUD>(m_GameFlowManager, this); m_PlayerHealth.onDamaged += OnTakeDamage; m_PlayerHealth.onHealed += OnHealed; }
void Update() { Weapon weapon = Player.GetComponent <WeaponInventory>().Weapon; IReloadableWeapon reloadableWeapon = weapon == null ? null : weapon.GetComponent <IReloadableWeapon>(); Image image = GetComponent <Image>(); bool reloading = reloadableWeapon != null && reloadableWeapon.IsReloading; if (reloadableWeapon != null) { image.sprite = Sprites[reloadableWeapon.IsReloading ? (int)(reloadableWeapon.ReloadingProgress * (Sprites.Length - 1)) : Sprites.Length - 1]; } image.color = new Color(1f, 1f, 1f, reloading ? Mathf.Min(image.color.a + Time.deltaTime / FadeInDuration, 1f) : Mathf.Max(image.color.a - Time.deltaTime / FadeOutDuration, 0f) ); }
void OnPicked(PlayerCharacterController byPlayer) { PlayerWeaponsManager playerWeaponsManager = byPlayer.GetComponent <PlayerWeaponsManager>(); if (playerWeaponsManager) { if (playerWeaponsManager.AddWeapon(weaponPrefab)) { // Handle auto-switching to weapon if no weapons currently if (playerWeaponsManager.GetActiveWeapon() == null) { playerWeaponsManager.SwitchWeapon(true); } m_Pickup.PlayPickupFeedback(); } } }
void OnPicked(PlayerCharacterController byPlayer) { var jetpack = byPlayer.GetComponent <Jetpack>(); if (!jetpack) { return; } if (jetpack.TryUnlock()) { m_Pickup.PlayPickupFeedback(); TelemetryLogger.LogCollect("Ability", transform.position, "Jetpack"); Destroy(gameObject); } }
void OnPicked(PlayerCharacterController byPlayer) { if (Online) { } var jetpack = byPlayer.GetComponent <Jetpack>(); if (!jetpack) { return; } if (jetpack.TryUnlock()) { m_Pickup.PlayPickupFeedback(); Destroy(gameObject); } }
void OnPicked(PlayerCharacterController byPlayer) { Debug.Log($"WeaponPickup OnPicked() weaponName={weaponPrefab.weaponName}"); PlayerWeaponsManager playerWeaponsManager = byPlayer.GetComponent <PlayerWeaponsManager>(); if (playerWeaponsManager) { if (playerWeaponsManager.AddWeapon(weaponPrefab, weaponPrefab.weaponName)) { // Handle auto-switching to weapon if no weapons currently if (playerWeaponsManager.GetActiveWeapon() == null) { playerWeaponsManager.SwitchWeapon(true); } m_Pickup.PlayPickupFeedback(); Destroy(gameObject); } } }
public void SetTarget(PlayerCharacterController _target) { if (_target == null) { Debug.LogError("<Color=Red><a>Missing</a></Color> controller for PlayerUI.SetTarget.", this); return; } //cache references for efficiency target = _target; CharacterController characterController = _target.GetComponent <CharacterController> (); // Get data from the Player that won't change during the lifetime of this Component if (characterController != null) { characterControllerHeight = characterController.height; } if (playerNameText != null) { playerNameText.text = "Player"; } }
void OnPicked(PlayerCharacterController byPlayer) { PlayerWeaponsManager playerWeaponsManager = byPlayer.GetComponent <PlayerWeaponsManager>(); if (playerWeaponsManager) { if (playerWeaponsManager.AddWeapon(weaponPrefab)) { // Handle auto-switching to weapon if no weapons currently if (playerWeaponsManager.GetActiveWeapon() == null) { playerWeaponsManager.SwitchWeapon(true); } m_Pickup.PlayPickupFeedback(); TelemetryLogger.LogCollect("Weapon", transform.position, weaponPrefab.weaponName, playerWeaponsManager.GetWeaponsHeldCount()); Destroy(gameObject); } } }
// Start is called before the first frame update void Start() { PlayerCharacterController playerCharacterController = GameObject.FindObjectOfType <PlayerCharacterController>(); m_PlayerHealth = playerCharacterController.GetComponent <Health>(); }