本文整理汇总了C#中PlayerStats.BloodEffects方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerStats.BloodEffects方法的具体用法?C# PlayerStats.BloodEffects怎么用?C# PlayerStats.BloodEffects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerStats
的用法示例。
在下文中一共展示了PlayerStats.BloodEffects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExplodeAndDamage
public void ExplodeAndDamage()
{
colRadius = GetComponent<SphereCollider> ().radius;
Collider[] hitColliders = Physics.OverlapSphere(transform.position, colRadius, colliderLayerMask);
foreach(Collider other in hitColliders){
if ((other.gameObject.transform.parent.tag == Tags.enemy || other.gameObject.transform.parent.tag == Tags.npc || other.gameObject.transform.parent.tag == Tags.neutral) && !other.isTrigger) {
enemyStats = other.gameObject.transform.GetComponentInParent<EnemyStats>();
RaycastHit hit;
originStart = gameObject.transform;
//Debug.Log (originStart);
direction = other.transform.position - transform.position;
//Debug.Log (direction);
if(Physics.Raycast (originStart.position, direction.normalized, out hit, direction.magnitude, obstacleLayerMask)){
//Debug.Log ("Hit environment!");
if(hit.distance > direction.magnitude){
//Debug.Log ("Damage Enemy");
//Calculate Damage:
float damage = (minDamage-maxDamage)/colRadius*direction.magnitude + maxDamage;
enemyStats.enemyHealth -= damage;
enemyStats.explosionForce = explosionForce*(damage-minDamage)/(maxDamage-minDamage);
enemyStats.explosionLocation = transform.position;
//enemyStats.explosionRadius = colRadius;
Quaternion newRotation = Quaternion.LookRotation(new Vector3(other.transform.position.x - transform.position.x, 0.0f, other.transform.position.z-transform.position.z), Vector3.up);
newRotation *= Quaternion.Euler(90,0,0);
enemyStats.BloodEffects("highVelocityBlunt", other.transform.position, newRotation);
//Instantiate (blood, other.transform.position, newRotation);
//Destroy (other.gameObject);
}
}
else {
//Debug.Log ("Damage Enemy");
float damage = (minDamage-maxDamage)/colRadius*direction.magnitude + maxDamage;
enemyStats.enemyHealth -= damage;
enemyStats.explosionForce = explosionForce*(damage-minDamage)/(maxDamage-minDamage);
enemyStats.explosionLocation = transform.position;
//enemyStats.explosionRadius = colRadius;
Quaternion newRotation = Quaternion.LookRotation(new Vector3(other.transform.position.x - transform.position.x, 0.0f, other.transform.position.z-transform.position.z), Vector3.up);
newRotation *= Quaternion.Euler(90,0,0);
enemyStats.BloodEffects("highVelocityBlunt", other.transform.position, newRotation);
//Instantiate (blood, other.transform.position, newRotation);
//Destroy (other.gameObject);
}
}
if (other.gameObject.transform.parent.tag == Tags.player && !other.isTrigger) {
playerStats = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<PlayerStats>();
//Debug.Log (other.gameObject.name);
RaycastHit hit;
originStart = gameObject.transform;
//Debug.Log (originStart);
direction = other.transform.position - transform.position;
//Debug.Log (direction);
if(Physics.Raycast (originStart.position, direction.normalized, out hit, direction.magnitude, obstacleLayerMask)){
//Debug.Log ("Hit environment!");
if(hit.distance > direction.magnitude){
//Debug.Log ("But it was behind the explosion!");
float damage = (minDamage-maxDamage)/colRadius*direction.magnitude + maxDamage;
//Debug.Log ("Damage Player");
playerStats.playerHealth -= damage;
playerStats.explosionForce = explosionForce*(damage-minDamage)/(maxDamage-minDamage);
playerStats.explosionLocation = transform.position;
//playerStats.explosionRadius = colRadius;
Quaternion newRotation = Quaternion.LookRotation(new Vector3(other.transform.position.x - transform.position.x, 0.0f, other.transform.position.z-transform.position.z), Vector3.up);
newRotation *= Quaternion.Euler(90,0,0);
playerStats.BloodEffects("highVelocityBlunt", other.transform.position, newRotation);
//Instantiate (blood, other.transform.position, newRotation);
//Destroy (other.gameObject);
}
}
else {
float damage = (minDamage-maxDamage)/colRadius*direction.magnitude + maxDamage;
playerStats.playerHealth -= damage;
playerStats.explosionForce = explosionForce*(damage-minDamage)/(maxDamage-minDamage);
playerStats.explosionLocation = transform.position;
//playerStats.explosionRadius = colRadius;
Quaternion newRotation = Quaternion.LookRotation(new Vector3(other.transform.position.x - transform.position.x, 0.0f, other.transform.position.z-transform.position.z), Vector3.up);
newRotation *= Quaternion.Euler(90,0,0);
playerStats.BloodEffects("highVelocityBlunt", other.transform.position, newRotation);
//Instantiate (blood, other.transform.position, newRotation);
}
}
// Explosion affecting other Physics objects...
if (other.gameObject.transform.parent.tag == Tags.physicsInteractable && !other.isTrigger) {
RaycastHit hit;
originStart = gameObject.transform;
//Determine vector to explosion interactable collider parent
direction = other.transform.parent.position - transform.position;
//Test to see if an obstacle is within range...
//.........这里部分代码省略.........