Exemple #1
0
        /// <summary>
        /// 获得损害
        /// </summary>
        /// </summary>
        /// <param name="damage"></param>
        /// <returns></returns>
        public bool GetDamage(int damage, int deathDir)
        {
            if (!m_CharacterController.IsAlive())
            {
                return(false);
            }

            m_CharacterController.Hit();
            SubtractHealth(damage);

            if (health <= 0)
            {
                m_CharacterController.Die(deathDir);

                //一半的几率会爆炸,只是简单的特效展示
                if (Random.Range(0, 100) > 50)
                {
                    FXDisplay explosionFXDisplay = ObjPoolMgr.Instance.SpawnObj <FXDisplay>(explosionPrefName);
                    explosionFXDisplay.transform.position = transform.position;
                    explosionFXDisplay.ShowFX();
                    GameMgr.Instance.shakeCamera.ExplosionShake();
                }

                return(false);
            }

            return(true);
        }