当前位置: 首页>>代码示例>>C#>>正文


C# Collider2D.BroadcastMessage方法代码示例

本文整理汇总了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");

            }
        }
开发者ID:andi475,项目名称:ludum-dare-33_unity,代码行数:8,代码来源:ShadTriggerController.cs

示例2: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D ent)
 {
     if (ent.tag == "Player")
     {
         print("broadcasting to player");
         ent.BroadcastMessage("Die", "Crushed");
     }
 }
开发者ID:ErrorMacro13,项目名称:SGP7thTentacleProject,代码行数:8,代码来源:CrushingWallBehavior.cs

示例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));
     }
 }
开发者ID:tntxtnt,项目名称:Tile1,代码行数:9,代码来源:ZombieDamage.cs

示例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);
     }
 }
开发者ID:robbybecker,项目名称:TimeyWimey,代码行数:10,代码来源:Hit.cs

示例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);
 }
开发者ID:tntxtnt,项目名称:Tile1,代码行数:13,代码来源:Arrow.cs

示例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);
		}
	}
开发者ID:SeiyaOhtake,项目名称:Manekin_pis,代码行数:17,代码来源:GoalTargetObject.cs

示例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;
        }
    }
开发者ID:andi475,项目名称:ludum-dare-33_unity,代码行数:18,代码来源:OvenController.cs

示例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;
     }
 }
开发者ID:k-yokozawa,项目名称:Unity_STG,代码行数:21,代码来源:SwordBullet.cs


注:本文中的UnityEngine.Collider2D.BroadcastMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。