Exemplo n.º 1
0
        public void DoDamage(int nDamage)
        {
            var hActor = m_hActorController.actorData.m_hActor;
            var hStat  = m_hActorController.actorData.m_hStatus.status;

            hStat.m_nHP -= nDamage;
            m_hActorController.actorData.m_hStatus.status = hStat;

            m_hActorController.takeDamageEvent?.Invoke();

            if (hStat.m_nHP <= 0)
            {
                m_hDeadEvent?.Invoke();

                gameObject.SetActive(false);

                m_hActorController.deadEvent?.Invoke();

                if (hActor.CompareTag(TagUtility.Name.player) && !Global_GameplayManager.winGame)
                {
                    Global_GameplayManager.PlayerDead();
                }
                else if (hActor.CompareTag(TagUtility.Name.boss) && !Global_GameplayManager.bossDead)
                {
                    Global_GameplayManager.bossDead = true;
                }

                return;
            }

            if (m_hActorController.actorData.m_hAnimation != null && m_hActorController.actorData.m_hAnimation.m_bPlayer)
            {
                var hAnim = m_hActorController.actorData.m_hAnimation.m_hSpineAnimationState;
                hAnim.SetAnimation(0,
                                   m_hActorController.actorData.m_hAnimation.m_sDamageAnimation, false);

                hAnim.SetEmptyAnimation(1, 0);

                m_hActorController.actorData.m_eCurrentAnimation = ActorAnimation.Hurting;
            }

            if (m_hActorController.actorData.m_hAudio && m_hTakeDamageSound)
            {
                m_hActorController.actorData.m_hAudio.PlayOneShot(m_hTakeDamageSound);
            }

            m_hActorController.actorData.m_eStateFlag |= ActorStateFlag.IsDamage;

            m_hActorController.actorData.m_eStateFlag &= ~ActorStateFlag.GroundPoundCasting;
            m_hActorController.actorData.m_eStateFlag &= ~ActorStateFlag.GroundPounding;

            m_fLastDamageTime = Time.time;
        }
Exemplo n.º 2
0
        private void Awake()
        {
            if (m_hInstance == null)
            {
                m_hInstance = this;
            }
            else if (m_hInstance != this)
            {
                Destroy(this);
                return;
            }

            Application.quitting += OnAppQuit;
        }