示例#1
0
        void OnSceneGUI()
        {
            Damager damager = (Damager)target;

            if (!damager.enabled)
            {
                return;
            }

            Matrix4x4 handleMatrix = damager.transform.localToWorldMatrix;

            handleMatrix.SetRow(0, Vector4.Scale(handleMatrix.GetRow(0), new Vector4(1f, 1f, 0f, 1f)));
            handleMatrix.SetRow(1, Vector4.Scale(handleMatrix.GetRow(1), new Vector4(1f, 1f, 0f, 1f)));
            handleMatrix.SetRow(2, new Vector4(0f, 0f, 1f, damager.transform.position.z));
            using (new Handles.DrawingScope(handleMatrix))
            {
                s_BoxBoundsHandle.center = damager.offset;
                s_BoxBoundsHandle.size   = damager.size;

                s_BoxBoundsHandle.SetColor(s_EnabledColor);
                EditorGUI.BeginChangeCheck();
                s_BoxBoundsHandle.DrawHandle();
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(damager, "Modify Damager");

                    damager.size   = s_BoxBoundsHandle.size;
                    damager.offset = s_BoxBoundsHandle.center;
                }
            }
        }
示例#2
0
 protected override void OnGetHit(Damager damager)
 {
     if (m_FlickeringCoroutine != null)
     {
         StopCoroutine(m_FlickeringCoroutine);
         playerSprite.color = m_OriginalColor;
     }
     m_FlickeringCoroutine = StartCoroutine(Flicker());
 }
示例#3
0
        public void TakeDamage(Damager damager, bool ignoreInvincible = false)
        {
            if ((m_Invulnerable && !ignoreInvincible) || m_CurrentHealth <= 0)
            {
                return;
            }

            m_CurrentHealth -= damager.damage;
            OnGetHit(damager);
            EnableInvulnerability();
            if (m_CurrentHealth <= 0)
            {
                OnDie(damager);
                m_ResetHealthOnSceneReload = true;
            }
        }
示例#4
0
 protected override void OnDie(Damager damager)
 {
     OnDead.Invoke(damager, this);
 }
示例#5
0
 protected override void OnGetHit(Damager damager)
 {
     OnTakeDamage.Invoke(damager, this);
     OnHealthSet.Invoke(this);
 }
示例#6
0
 protected virtual void OnDie(Damager damager)
 {
 }
示例#7
0
 protected virtual void OnGetHit(Damager damager)
 {
 }