Пример #1
0
    /// <summary>
    /// assembles damage in UFPS format from individual parameters and sends it to
    /// the player, resulting in damage, a HUD damage flash and brief camera twist
    /// NOTE: local player can't damage self with 'vp_DamageInfo.DamageType.Bullet'
    /// </summary>
    public static void Damage(float damage, Transform source, vp_DamageInfo.DamageType type = vp_DamageInfo.DamageType.Unknown)
    {
        if (m_FPDamageHandler == null)
        {
            return;
        }

        if ((source == m_FPDamageHandler.transform) && type == vp_DamageInfo.DamageType.Bullet)
        {
            return;
        }

        vp_DamageInfo damageInfo = new vp_DamageInfo(damage, source, type);

        m_FPDamageHandler.Damage(damageInfo);
    }
Пример #2
0
    /// <summary>
    /// picks up an incoming HUD damage flash message and composes
    /// the data needed to draw the various effects
    /// </summary>
    protected virtual void OnMessage_HUDDamageFlash(vp_DamageInfo damageInfo)
    {
        if (damageInfo == null || damageInfo.Damage == 0.0f)
        {
            m_PainColor.a  = 0.0f;
            m_SplatColor.a = 0.0f;
            return;
        }

        m_LatestIncomingDamageType = damageInfo.Type;

        m_PainColor.a += (damageInfo.Damage * PainIntensity);

        if (damageInfo.Source != null)
        {
            m_LastInflictorTime = Time.time;
            bool create = true;
            // update damage time for existing inflictors and see if we
            // need to create a new inflictor
            foreach (Inflictor i in m_Inflictors)
            {
                if (i.Transform == damageInfo.Source.transform)
                {
                    i.DamageTime = Time.time;
                    create       = false;
                }
            }
            if (create)
            {
                m_Inflictors.Add(new Inflictor(damageInfo.Source, Time.time));
            }
        }

        // BLUR: uncomment to enable on Unity Pro
        //if (m_PainBlur != null)
        //	m_PainBlur.enabled = true;	// activate the pain blur component (if any)
    }
Пример #3
0
	/// <summary>
	/// picks up an incoming HUD damage flash message and composes
	/// the data needed to draw the various effects
	/// </summary>
	protected virtual void OnMessage_HUDDamageFlash(vp_DamageInfo damageInfo)
	{

		if (damageInfo == null || damageInfo.Damage == 0.0f)
		{
			m_PainColor.a = 0.0f;
			return;
		}

		m_LatestIncomingDamageType = damageInfo.Type;

		m_PainColor.a += (damageInfo.Damage * PainIntensity);

		if (damageInfo.Source != null)
		{
			m_LastInflictorTime = Time.time;
			bool create = true;
			// update damage time for existing inflictors and see if we
			// need to create a new inflictor
			foreach (Inflictor i in m_Inflictors)
			{
				if (i.Transform == damageInfo.Source.transform)
				{
					i.DamageTime = Time.time;
					create = false;
				}
			}
			if (create)
				m_Inflictors.Add(new Inflictor(damageInfo.Source, Time.time));
		}

		// BLUR: uncomment to enable on Unity Pro
		//if (m_PainBlur != null)
		//	m_PainBlur.enabled = true;	// activate the pain blur component (if any)

	}