Exemplo n.º 1
0
    /// <summary>
    ///
    /// </summary>
    public override void Damage(vp_DamageInfo damageInfo)
    {
        if (!enabled)
        {
            return;
        }

        if (!vp_Utility.IsActive(gameObject))
        {
            return;
        }

        base.Damage(damageInfo);

        FPPlayer.HUDDamageFlash.Send(damageInfo);

        // shake camera to left or right depending on direction of damage
        if (damageInfo.Source != null)
        {
            m_DamageAngle = vp_3DUtility.LookAtAngleHorizontal(
                FPCamera.Transform.position,
                FPCamera.Transform.forward,
                damageInfo.Source.position);

            // phase out the shake over 30 degrees to the sides to minimize
            // interference when aiming at the attacker. damage from straight
            // ahead will result in zero shake
            m_DamageAngleFactor = ((Mathf.Abs(m_DamageAngle) > 30.0f) ? 1 : (Mathf.Lerp(0, 1, (Mathf.Abs(m_DamageAngle) * 0.033f))));

            FPPlayer.HeadImpact.Send((damageInfo.Damage * CameraShakeFactor * m_DamageAngleFactor) * ((m_DamageAngle < 0.0f) ? 1 : -1));
        }
    }
Exemplo n.º 2
0
 public void Damage(vp_DamageInfo damageInfo)
 {
     if (healthScript)
     {
         damageInfo.Damage *= damageMultiplier;
         healthScript.Damage(damageInfo);
     }
 }
Exemplo n.º 3
0
    public override void Damage(vp_DamageInfo damageInfo)
    {
        base.Damage(damageInfo);

        if (CurrentHealth > 0)
        {
            animator.Play("hit", 0, 0f);
        }
    }
Exemplo n.º 4
0
 public override void Damage(vp_DamageInfo damageInfo)
 {
     if (zombieInfo)
     {
         zombieInfo.OnHit(damageInfo.OriginalSource.GetComponent <PlayerInfo> (), damageInfo.Damage * hpSysFactor, Vector3.zero);
     }
     base.Damage(damageInfo);
     Debug.Log("damaged with Info");
 }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        if (transform.position.y < -10)
        {
            vp_DamageInfo info = new vp_DamageInfo(1000f, null);

            SendMessage("Damage", info, SendMessageOptions.DontRequireReceiver);
        }
    }
Exemplo n.º 6
0
 public virtual void Damage(vp_DamageInfo info)
 {
     if (isDead)
     {
         return;
     }
     health = Mathf.Max(health - info.Damage, 0);
     if (health == 0)
     {
         Die();
     }
 }
Exemplo n.º 7
0
 public override void OnHit(RaycastHit hit, AS_Bullet bullet)
 {
     AddAudio(hit.point);
     if (damageManage)
     {
         damageManage.ApplyDamage(bullet.Damage, bullet.transform.forward * bullet.HitForce, 0f);
         vp_DamageInfo info = new vp_DamageInfo(bullet.Damage, bullet.source, vp_DamageInfo.DamageType.Bullet);
         // SendMessageUpwards("OnMessage_HUDDamageFlash", info, SendMessageOptions.DontRequireReceiver);
         gameObject.BroadcastMessage("OnMessage_HUDDamageFlash", info, SendMessageOptions.DontRequireReceiver);
     }
     base.OnHit(hit, bullet);
 }
	/// <summary>
	/// forwards damage in UFPS format to a damagehandler on the target object
	/// </summary>
	public virtual void Damage(vp_DamageInfo damageInfo)
	{

		if (!enabled)
			return;

		if (m_TargetDamageHandler != null)
			m_TargetDamageHandler.Damage(damageInfo);
		else
			Damage(damageInfo.Damage);

	}
Exemplo n.º 9
0
 public override void Damage(vp_DamageInfo info)
 {
     base.Damage(info);
     if (isDead)
     {
         return;
     }
     if (isDead)
     {
         ResetDeathRaise();
         animatedRagdollCharakter.ragdolled = true;
     }
 }
Exemplo n.º 10
0
 public void Damage(vp_DamageInfo damageInfo)
 {
     if (reciever)
     {
         damageInfo.Damage *= DamageMultiply;
         reciever.Damage(damageInfo);
     }
     if (reciever2)
     {
         damageInfo.Damage *= DamageMultiply;
         reciever2.Damage(damageInfo);
     }
 }
Exemplo n.º 11
0
    /// <summary>
    /// applies damage to the player in UFPS 'vp_DamageInfo' format, sends a damage
    /// flash message to the HUD and twists the camera briefly
    /// NOTE: local player can't damage self with 'vp_DamageInfo.DamageType.Bullet'
    /// </summary>
    public static void Damage(vp_DamageInfo damageInfo)
    {
        if (m_FPDamageHandler == null)
        {
            return;
        }

        if ((damageInfo.Source == m_FPDamageHandler.transform) && damageInfo.Type == vp_DamageInfo.DamageType.Bullet)
        {
            return;
        }

        m_FPDamageHandler.Damage(damageInfo);
    }
Exemplo n.º 12
0
    /// <summary>
    /// forwards damage in UFPS format to a damagehandler on the target object
    /// </summary>
    public virtual void Damage(vp_DamageInfo damageInfo)
    {
        if (!enabled)
        {
            return;
        }

        if (m_TargetDamageHandler != null)
        {
            m_TargetDamageHandler.Damage(damageInfo);
        }
        else
        {
            Damage(damageInfo.Damage);
        }
    }
Exemplo n.º 13
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);
    }
Exemplo n.º 14
0
    void OnCollisionEnter(Collision info)
    {
        if (!owner.PartOfMe(info.transform))
        {
            if (info.relativeVelocity.magnitude > minForceForRagdoll)
            {
                float         damage     = (info.relativeVelocity.magnitude - minForceForRagdoll) * forceMultToDamage;
                vp_DamageInfo damageInfo = new vp_DamageInfo(damage, info.transform);
                Damage(damageInfo);

                ForceForRagdoll(info.relativeVelocity.magnitude);

                if (rigidbody.isKinematic)
                {
                    hitForces.Add(new HitInfo()
                    {
                        force = info.relativeVelocity, position = info.contacts[0].point
                    });
                }
            }
        }
    }
Exemplo n.º 15
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)
    }
Exemplo n.º 16
0
 public override void Damage(vp_DamageInfo info)
 {
     base.Damage(info);
 }
Exemplo n.º 17
0
 public override void Damage(vp_DamageInfo info)
 {
     base.Damage(info);
     Events.Instance.BaseHealthChanged.Send(this);
 }
Exemplo n.º 18
0
 public override void Damage(vp_DamageInfo damageInfo)
 {
     harvestableComponent.Hit((int)damageInfo.Damage);
 }
    public virtual void Damage(vp_DamageInfo damageInfo)
    {
        if (!enabled)
        {
            return;
        }

        if (!vp_Utility.IsActive(gameObject))
        {
            return;
        }

        // damage is always done in singleplayer, but only in multiplayer if you are the master
        if (!vp_Gameplay.IsMaster)
        {
            return;
        }

        if (CurrentHealth <= 0.0f)
        {
            return;
        }

        if (damageInfo != null)
        {
            if (damageInfo.Source != null)
            {
                Source = damageInfo.Source;
            }
            if (damageInfo.OriginalSource != null)
            {
                OriginalSource = damageInfo.OriginalSource;
            }
            //Debug.Log("Damage! Source: " + damageInfo.Source + " ... " + "OriginalSource: " + damageInfo.OriginalSource);
        }

        // if we somehow shot ourselves with a bullet, ignore it
        if ((damageInfo.Type == vp_DamageInfo.DamageType.Bullet) && (m_Source == Transform))
        {
            return;
        }

        // subtract damage from health
        CurrentHealth = Mathf.Min(CurrentHealth - damageInfo.Damage, MaxHealth);

        // in multiplayer, report damage for score tracking purposes
        if (vp_Gameplay.IsMultiplayer && (damageInfo.Source != null))
        {
            vp_GlobalEvent <Transform, Transform, float> .Send("TransmitDamage", Transform.root, damageInfo.OriginalSource, damageInfo.Damage);
        }

        // detect and transmit death as event
        if (CurrentHealth <= 0.0f)
        {
            // send the 'Die' message, to be picked up by vp_DamageHandlers and vp_Respawners
            if (m_InstaKill)
            {
                SendMessage("Die");
            }
            else
            {
                vp_Timer.In(UnityEngine.Random.Range(MinDeathDelay, MaxDeathDelay), delegate() { SendMessage("Die"); });
            }
        }
    }
Exemplo n.º 20
0
 public override void Damage(vp_DamageInfo damageInfo)
 {
     ai.GotHit(damageInfo.Damage * damageMultiplier);
 }
	/// <summary>
	/// 
	/// </summary>
	public override void Damage(vp_DamageInfo damageInfo)
	{

		if (!enabled)
			return;

		if (!vp_Utility.IsActive(gameObject))
			return;

		base.Damage(damageInfo);

		FPPlayer.HUDDamageFlash.Send(damageInfo);

		// shake camera to left or right depending on direction of damage
		if (damageInfo.Source != null)
		{

			m_DamageAngle = vp_3DUtility.LookAtAngleHorizontal(
				FPCamera.Transform.position,
				FPCamera.Transform.forward,
				damageInfo.Source.position);

			// phase out the shake over 30 degrees to the sides to minimize
			// interference when aiming at the attacker. damage from straight
			// ahead will result in zero shake
			m_DamageAngleFactor = ((Mathf.Abs(m_DamageAngle) > 30.0f) ? 1 : (Mathf.Lerp(0, 1, (Mathf.Abs(m_DamageAngle) * 0.033f))));

			FPPlayer.HeadImpact.Send((damageInfo.Damage * CameraShakeFactor * m_DamageAngleFactor) * ((m_DamageAngle < 0.0f) ? 1 : -1));

		}

	}
	public virtual void Damage(vp_DamageInfo damageInfo)
	{

		if (!enabled)
			return;

		if (!vp_Utility.IsActive(gameObject))
			return;

		// damage is always done in singleplayer, but only in multiplayer if you are the master
		if (!vp_Gameplay.isMaster)
			return;

		if (CurrentHealth <= 0.0f)
			return;

		if (damageInfo != null)
		{
			if (damageInfo.Source != null)
				Source = damageInfo.Source;
			if (damageInfo.OriginalSource != null)
				OriginalSource = damageInfo.OriginalSource;
			//Debug.Log("Damage! Source: " + damageInfo.Source + " ... " + "OriginalSource: " + damageInfo.OriginalSource);
		}

		// if we somehow shot ourselves with a bullet, ignore it
		if ((damageInfo.Type == vp_DamageInfo.DamageType.Bullet) && (m_Source == Transform))
			return;

		//Calculate damage location, check for headshot
		if (HeadShotRangeBottom != 0 && HeadShotRangeTop != 0 && HeadShotDamageMultiple != 0) {
			Vector3 localHitPoint = transform.InverseTransformPoint(damageInfo.WorldHitPoint);
			Debug.Log (localHitPoint);

			if (HeadShotRangeBottom <= localHitPoint.y && localHitPoint.y <= HeadShotRangeTop) {
				damageInfo.Damage = damageInfo.Damage * HeadShotDamageMultiple;
				Debug.Log ("headshot damage: " + damageInfo.Damage.ToString());
			}
		}

		if (damageHalo != null) {
			GameObject.Instantiate (damageHalo, damageInfo.WorldHitPoint, gameObject.transform.rotation);
		}

		// subtract damage from health
		CurrentHealth = Mathf.Min(CurrentHealth - damageInfo.Damage, MaxHealth);

		// in multiplayer, report damage for score tracking purposes
		if (vp_Gameplay.isMultiplayer && (damageInfo.Source != null))
			vp_GlobalEvent<Transform, Transform, float>.Send("TransmitDamage", Transform.root, damageInfo.OriginalSource, damageInfo.Damage);

		// detect and transmit death as event
		if (CurrentHealth <= 0.0f)
		{
			// send the 'Die' message, to be picked up by vp_DamageHandlers and vp_Respawners
			if (m_InstaKill)
				SendMessage("Die");
			else
				vp_Timer.In(UnityEngine.Random.Range(MinDeathDelay, MaxDeathDelay), delegate() { SendMessage("Die"); });
		}

	}
Exemplo n.º 23
0
	public virtual void Damage(vp_DamageInfo projectileInfo)
	{

		if (!enabled)
			return;

		if (!vp_Utility.IsActive(gameObject))
			return;

		if (CurrentHealth <= 0.0f)
			return;

		CurrentHealth = Mathf.Min(CurrentHealth - projectileInfo.Damage, MaxHealth);

		if (vp_Gameplay.isMaster)
		{

			// only do this in multiplayer
			if (vp_Gameplay.isMultiplayer && (projectileInfo.Sender != null))
				vp_GlobalEvent<Transform, Transform, float>.Send("Damage", transform.root, projectileInfo.Sender, projectileInfo.Damage, vp_GlobalEventMode.REQUIRE_LISTENER);

			// do this in multiplayer and singleplayer
			if (CurrentHealth <= 0.0f)
				vp_Timer.In(UnityEngine.Random.Range(MinDeathDelay, MaxDeathDelay), delegate()
				{
					SendMessage("Die");		// picked up by vp_DamageHandlers and vp_Respawners
				});

		}


		// TIP: if you want to do things like play a special impact
		// sound upon every hit (but only if the object survives)
		// this is the place

	}
Exemplo n.º 24
0
	public virtual void Damage(vp_DamageInfo damageInfo)
	{

		if (!enabled)
			return;

		if (!vp_Utility.IsActive(gameObject))
			return;

		if (CurrentHealth <= 0.0f)
			return;

		if (damageInfo != null)
		{
			if(damageInfo.Source != null)
				Source = damageInfo.Source;
			if (damageInfo.OriginalSource != null)
				OriginalSource = damageInfo.OriginalSource;
			//Debug.Log("Damage! Source: " + damageInfo.Source + " ... " + "OriginalSource: " + damageInfo.OriginalSource);
		}

		CurrentHealth = Mathf.Min(CurrentHealth - damageInfo.Damage, MaxHealth);

		if (vp_Gameplay.isMaster)
		{

			// only do this in multiplayer
			if (vp_Gameplay.isMultiplayer && (damageInfo.Source != null))
				vp_GlobalEvent<Transform, Transform, float>.Send("Damage", Transform.root, damageInfo.OriginalSource, damageInfo.Damage, vp_GlobalEventMode.REQUIRE_LISTENER);

			// do this in multiplayer and singleplayer
			if (CurrentHealth <= 0.0f)
			{
				// send the 'Die' message, to be picked up by vp_DamageHandlers and vp_Respawners
				if (m_InstaKill)
					SendMessage("Die");
				else
					vp_Timer.In(UnityEngine.Random.Range(MinDeathDelay, MaxDeathDelay), delegate()	{	SendMessage("Die");	});
			}

		}

		// TIP: if you want to do things like play a special impact
		// sound upon every hit (but only if the object survives)
		// this is the place

	}
Exemplo n.º 25
0
    public virtual void Damage(vp_DamageInfo damageInfo)
    {
        if (!enabled)
            return;

        if (!vp_Utility.IsActive(gameObject))
            return;

        // damage is always done in singleplayer, but only in multiplayer if you are the master
        if (!vp_Gameplay.isMaster)
            return;

        if (CurrentHealth <= 0.0f)
            return;

        if (damageInfo != null)
        {
            if (damageInfo.Source != null)
                Source = damageInfo.Source;
            if (damageInfo.OriginalSource != null)
                OriginalSource = damageInfo.OriginalSource;
            //Debug.Log("Damage! Source: " + damageInfo.Source + " ... " + "OriginalSource: " + damageInfo.OriginalSource);
        }

        // if we somehow shot ourselves with a bullet, ignore it
        if ((damageInfo.Type == vp_DamageInfo.DamageType.Bullet) && (m_Source == Transform))
            return;

        // subtract damage from health
        CurrentHealth = Mathf.Min(CurrentHealth - damageInfo.Damage, MaxHealth);

        // in multiplayer, report damage for score tracking purposes
        if (vp_Gameplay.isMultiplayer && (damageInfo.Source != null))
            vp_GlobalEvent<Transform, Transform, float>.Send("TransmitDamage", Transform.root, damageInfo.OriginalSource, damageInfo.Damage);

        // detect and transmit death as event
        if (CurrentHealth <= 0.0f)
        {
            // send the 'Die' message, to be picked up by vp_DamageHandlers and vp_Respawners
            if (m_InstaKill)
                SendMessage("Die");
            else
                vp_Timer.In(UnityEngine.Random.Range(MinDeathDelay, MaxDeathDelay), delegate() { SendMessage("Die"); });
        }
    }
Exemplo n.º 26
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)

	}
Exemplo n.º 27
0
 public override void Damage(vp_DamageInfo info)
 {
     base.Damage(info);
     currentUpwardsVelocity = 0.0f;
 }