コード例 #1
0
 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;
 }
コード例 #2
0
ファイル: TreasurePickup.cs プロジェクト: daniellanikov/unity
        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);
            }
        }
コード例 #3
0
ファイル: PlayerHealthBar.cs プロジェクト: AndyZYZ/RogueFPS1
        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);
        }
コード例 #4
0
ファイル: KeyPickup.cs プロジェクト: daniellanikov/unity
        protected override void OnPicked(PlayerCharacterController byPlayer)
        {
            var key = byPlayer.GetComponent <Key>();

            key.hasKey = true;
            PlayPickupFeedback();
            Destroy(gameObject);
        }
コード例 #5
0
    void OnPicked(PlayerCharacterController player)
    {
        PlayerCharacterController playerPlayerCharacterController = player.GetComponent <PlayerCharacterController>();

        playerPlayerCharacterController.SetGravity(NewGravity, jumppower);

        m_Pickup.PlayPickupFeedback();

        Destroy(gameObject);
    }
コード例 #6
0
    //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
            }
        }
    }
コード例 #7
0
    void OnPicked(PlayerCharacterController player)
    {
        Health playerHealth = player.GetComponent <Health>();

        if (playerHealth && player.key)
        {
            m_Pickup.PlayPickupFeedback();

            Destroy(gameObject);
        }
    }
コード例 #8
0
    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);
    }
コード例 #9
0
    void OnPick(PlayerCharacterController p)
    {
        Ammo PlayerAmmo = p.GetComponent <Ammo>();

        if (PlayerAmmo)
        {
            PlayerAmmo.AddAmmo();
            pickup.PlayPickupFeedback();
            Destroy(gameObject);
        }
    }
コード例 #10
0
    void OnPicked(PlayerCharacterController player)
    {
        Health playerHealth = player.GetComponent <Health>();

        if (playerHealth && playerHealth.canPickup())
        {
            playerHealth.Heal(healAmount);
            m_Pickup.PlayPickupFeedback();

            Destroy(gameObject);
        }
    }
コード例 #11
0
 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);
         }
     }
 }
コード例 #12
0
ファイル: HealthPickup.cs プロジェクト: CorbenG/FPSTelemetry
    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);
        }
    }
コード例 #13
0
ファイル: JetpackPickup.cs プロジェクト: LV9652/Sniper
        protected override void OnPicked(PlayerCharacterController byPlayer)
        {
            var jetpack = byPlayer.GetComponent <Jetpack>();

            if (!jetpack)
            {
                return;
            }

            if (jetpack.TryUnlock())
            {
                PlayPickupFeedback();
                Destroy(gameObject);
            }
        }
コード例 #14
0
    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;
        }
    }
コード例 #15
0
    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;
    }
コード例 #16
0
    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)
                                );
    }
コード例 #17
0
    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();
            }
        }
    }
コード例 #18
0
ファイル: JetpackPickup.cs プロジェクト: CorbenG/FPSTelemetry
    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);
        }
    }
コード例 #19
0
    void OnPicked(PlayerCharacterController byPlayer)
    {
        if (Online)
        {
        }

        var jetpack = byPlayer.GetComponent <Jetpack>();

        if (!jetpack)
        {
            return;
        }

        if (jetpack.TryUnlock())
        {
            m_Pickup.PlayPickupFeedback();

            Destroy(gameObject);
        }
    }
コード例 #20
0
    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);
            }
        }
    }
コード例 #21
0
        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";
            }
        }
コード例 #22
0
    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);
            }
        }
    }
コード例 #23
0
    // Start is called before the first frame update
    void Start()
    {
        PlayerCharacterController playerCharacterController = GameObject.FindObjectOfType <PlayerCharacterController>();

        m_PlayerHealth = playerCharacterController.GetComponent <Health>();
    }