Beispiel #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;
                }
            }
        }
Beispiel #2
0
 protected override void OnGetHit(Damager damager)
 {
     if (m_FlickeringCoroutine != null)
     {
         StopCoroutine(m_FlickeringCoroutine);
         playerSprite.color = m_OriginalColor;
     }
     m_FlickeringCoroutine = StartCoroutine(Flicker());
 }
Beispiel #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;
            }
        }
 protected override void OnDie(Damager damager)
 {
     OnDead.Invoke(damager, this);
 }
 protected override void OnGetHit(Damager damager)
 {
     OnTakeDamage.Invoke(damager, this);
     OnHealthSet.Invoke(this);
 }
Beispiel #6
0
 protected virtual void OnDie(Damager damager)
 {
 }
Beispiel #7
0
 protected virtual void OnGetHit(Damager damager)
 {
 }