本文整理汇总了C#中UnityEngine.Collider2D.BroadcastMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Collider2D.BroadcastMessage方法的具体用法?C# Collider2D.BroadcastMessage怎么用?C# Collider2D.BroadcastMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Collider2D
的用法示例。
在下文中一共展示了Collider2D.BroadcastMessage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerEnter2D
private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
other.BroadcastMessage("GearUp", "watering_can");
}
}
示例2: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D ent)
{
if (ent.tag == "Player")
{
print("broadcasting to player");
ent.BroadcastMessage("Die", "Crushed");
}
}
示例3: OnTriggerStay2D
void OnTriggerStay2D(Collider2D other)
{
if (other.CompareTag("Player"))
{
bool forceRight = (other.transform.position - transform.position).x > 0;
Vector2 force = new Vector2(forceRight ? 1f : -1f, 0.5f);
other.BroadcastMessage("ApplyDamage", new Damage(damage, force.normalized * pushForce));
}
}
示例4: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
other.BroadcastMessage("RechargeTime");
GameObject.FindGameObjectWithTag("GameController").BroadcastMessage("IncreaseScore");
GameObject.Instantiate(explosion, transform.position, Quaternion.identity);
Destroy(this.gameObject);
}
}
示例5: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Enemy"))
{
knockbackDirection = knockbackDirection * knockbackForce;
if (rb2d.velocity.x < 0) knockbackDirection.x *= -1f;
other.BroadcastMessage("ApplyDamage", new Damage(baseDamage, knockbackDirection));
SoundManager.instance.PlaySingle(hitSound);
Destroy(gameObject);
}
else if (other.CompareTag("Ground"))
Destroy(gameObject);
}
示例6: OnTriggerEnter2D
void OnTriggerEnter2D (Collider2D col)
{
if (col.tag == "Player") {
// Stop walking
col.GetComponent <Manekin_Pis>().WalkSpeed = 0f;
// anim.SetTrigger ("Goal");
// Stop Pis
col.BroadcastMessage("UnableShot");
// reset Camera offset
Camera.main.GetComponent<FollowCamera>().offset = Vector3.zero;
// Go to result scene after waitTime sec.
Invoke ("GetGoal", waitTime);
}
}
示例7: OnTriggerEnter2D
private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player" && !triggered){
other.BroadcastMessage("work", 1f);
new WaitForSeconds(0.5f);
fire_in_oven.transform.localScale = new Vector2 (0.4f, 1f);
fire_nozzles = GameObject.FindGameObjectsWithTag("fire_nozzle");
foreach (GameObject fire_nozzle in fire_nozzles) {
fire_nozzle.BroadcastMessage("TurnOn");
}
triggered = true;
}
}
示例8: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D c)
{
var layerName = LayerMask.LayerToName (c.gameObject.layer);
switch (layerName)
{
case "Enemy":
if( colliderIdList.Contains(c.GetInstanceID() ) )
{
return;
}
c.BroadcastMessage("Damage");
//if( !isMultiHit )
colliderIdList.Add (c.GetInstanceID());
break;
case "EnemyBullet":
Destroy(c.gameObject);
break;
default:
break;
}
}