本文整理汇总了C#中Collider.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Collider.SendMessage方法的具体用法?C# Collider.SendMessage怎么用?C# Collider.SendMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collider
的用法示例。
在下文中一共展示了Collider.SendMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerEnter
//Trigger
//Using no physics on lazers due to performance load and really don't want it to be too realistic. Lazers should always fire straight.
void OnTriggerEnter(Collider collidedWith)
{
//First a null guard
if (collidedWith == null || firingPlayer == null)
{
return;
}
//Now check for things you're supposed to pass through, including friendly fire
if (collidedWith.tag == "Boundary" || collidedWith.tag == "Crystals" || collidedWith.tag == firingPlayer.tag || collidedWith.tag == "Lazer")
{
return;
}
//Debug.Log("Collided Tag: " + collidedWith.tag + " and Player Tag: " + firingPlayer.tag);
//This is to tell the player getting hit. Used for taking health from player getting hit
collidedWith.SendMessage("Hit", damage);
collidedWith.SendMessage("CheckForKill", firingPlayer);
//When the lazer was instantiated it was given a reference to whoever instantiated it, stored in player.
//Sends a message back to the player to indicate whether or not the bullet hit the enemy
//The "AddToScore" is a method in the PlayerController script and points is a parameter of that method
firingPlayer.SendMessage("AddToScore", points);
//Play the explode animation
Instantiate(explodeAnimation, surfaceHitPosition, explodeAnimation.transform.rotation);
//Play the explode sound
PlayClipAt(audio.clip, surfaceHitPosition);
//Destroys the lazer gameobject
Destroy(gameObject);
}
示例2: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Enemy"))
{
Creep creep = other.GetComponent<Creep>();
if(creep != null)
{
if (children.Length == 0 )
{
other.SendMessage("OnDespawn", null, SendMessageOptions.DontRequireReceiver);
}
else
{
other.SendMessage("OnTargetNode", null, SendMessageOptions.DontRequireReceiver);
DirectToNextNode(creep);
}
}
}
else if(other.CompareTag("Tower"))
{
Debug.Log("Danger Value +");
_dangerValue += 1;
}
}
示例3: OnTriggerEnter
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Player")
{
col.SendMessage("TakeDamage", 0.2f);
GameObject efx = Instantiate(hitEfx, transform.position, transform.rotation) as GameObject;
Destroy(efx, 0.4f);
Destroy(this.gameObject, 0.1f);
}
if (col.gameObject.name.Contains("Plane"))
{
GameObject efx = Instantiate(hitEfx, transform.position, Quaternion.identity) as GameObject;
Destroy(efx, 0.4f);
Destroy(this.gameObject, 0.1f);
}
if (col.gameObject.tag == "Enemy" && col.gameObject != this.gameObject && !thrownByTag.Equals("Enemy")) //prevent self-hit
{
col.SendMessage("TakeDamage", 0.5f);
GameObject efx = Instantiate(hitEfx, transform.position, transform.rotation) as GameObject;
Destroy(efx, 0.4f);
}
sounds.FlaskHit();
}
示例4: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.name == "3rd Person Controller")
{
other.SendMessage("addDistance", Vector3.Distance(transform.position, other.transform.position));
other.SendMessage("addObject", this.name);
}
}
示例5: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (tag.Equals("exit") && other.tag.Equals("Player"))
other.SendMessage("exit_triggered", true);
else if (tag.Equals("teleporter") && other.tag.Equals("Player"))
other.SendMessage("teleporter_triggered", true);
else if (tag.Equals("teleporter_boss") && other.tag.Equals("Player"))
other.SendMessage("teleporter_boss_triggered", true);
}
示例6: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if(other.gameObject.CompareTag ("RightNote") || other.gameObject.CompareTag ("LeftNote")){
other.SendMessage("Clickable");
}
if(other.gameObject.CompareTag ("End")){
other.SendMessage("Fading");
}
}
示例7: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.isTrigger || (other.GetComponent<TeamMember>() != null && other.GetComponent<TeamMember>().team == team))
return;
other.SendMessage("TakeDamage", damage, SendMessageOptions.DontRequireReceiver);
other.SendMessage("DamageSplat", new ArrayList () {transform.position, vel}, SendMessageOptions.DontRequireReceiver);
if (penetrations <= 0)
Destroy(gameObject);
penetrations --;
}
示例8: OnTriggerEnter
void OnTriggerEnter(Collider other){
if(other.tag == "Player" || other.tag == "Enemy"){
other.SendMessage("BombMe", fire.getPlayer());
}else {
//Debug.LogWarning(other.tag);
if(other.tag == "Bomb" || other.tag == "Box" || other.tag == "Invisible")
other.SendMessage("DestroyMe");
if(other.tag != "Invisible")
Destroy(gameObject);
}
}
示例9: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.tag == "Hiro") {
other.GetComponent<HiroController>().reset();
other.transform.position = HiroSpawn.position;
other.SendMessage("SpawnSound");
} else if (other.tag == "Josie") {
other.transform.position = JosieSpawn.position;
other.SendMessage("SpawnSound");
}
}
示例10: OnTriggerEnter
public override void OnTriggerEnter(Collider otherObject)
{
if (otherObject.gameObject.CompareTag("Player"))
{
otherObject.SendMessage("KilledShark");
}
if (otherObject.gameObject.CompareTag("enemy"))
{
otherObject.SendMessage("BitShark");
}
}
示例11: OnTriggerEnter
void OnTriggerEnter(Collider otro)
{
if(otro.name == "Suelo"){
EliminarDisparo();
} else if (otro.tag == "Padre"){
EliminarDisparo();
otro.SendMessage("MuerePadre", SendMessageOptions.DontRequireReceiver);
} else if (otro.tag == "Hijo"){
EliminarDisparo();
otro.SendMessage("Muere", SendMessageOptions.DontRequireReceiver);
}
}
示例12: OnTriggerEnter
void OnTriggerEnter(Collider hit)
{
if (blockIndex.ToString ().Equals (hit.name.Replace ("Block", "")))
{
hit.SendMessage("RightPosition");
BlockIsRightPlace = true;
}
else
{
hit.SendMessage("WrongPosition");
BlockIsRightPlace = false;
}
}
示例13: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
float currentX = transform.position.x;
if (other.tag == "Player")
{
other.SendMessage("touchLineAndStop", currentX);
if (isLeftEnd)
other.SendMessage("touchLeftEnd");
else if (isRightEnd)
other.SendMessage("touchRightEnd");
}
}
示例14: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if(other.gameObject.CompareTag("Enemy") && !isEnemy)
{
other.SendMessage("Damage", damage);
Instantiate(hit,transform.position,transform.rotation);
Destroy(this.gameObject);
}
else if (other.gameObject.CompareTag("Friend") && isEnemy)
{
other.SendMessage("Damage", damage);
Instantiate(hit, transform.position, transform.rotation);
Destroy(this.gameObject);
}
}
示例15: OnTriggerEnter
public void OnTriggerEnter(Collider collider)
{
if (collider.tag == "Player")
{
collider.SendMessage("PickUpRune", gameObject);
}
}