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


C# GameObject.BroadcastMessage方法代码示例

本文整理汇总了C#中UnityEngine.GameObject.BroadcastMessage方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.BroadcastMessage方法的具体用法?C# GameObject.BroadcastMessage怎么用?C# GameObject.BroadcastMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.GameObject的用法示例。


在下文中一共展示了GameObject.BroadcastMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShotHit

 protected void ShotHit(GameObject target)
 {
     if (target != null) { target.BroadcastMessage("TakeDamage", damage); }
 }
开发者ID:nallelcm,项目名称:TD,代码行数:4,代码来源:Tower.cs

示例2: FixedUpdate

    /// <summary>
    /// FixedUpdate del componente
    /// </summary>
    private void FixedUpdate()
    {
        RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
        if (hit.collider != null)
        {
            if (_currentHoverObject != hit.collider.gameObject)
            {
                if (_currentHoverObject != null) {
                     _currentHoverObject.BroadcastMessage("DisableOutline",SendMessageOptions.DontRequireReceiver);
                }
                _currentHoverObject = hit.collider.gameObject;
                //Debug.Log("HoverBegin: " + _currentHoverObject.name);
                // TODO: Llamar a quien le importe HoverBEGIN

				_currentHoverObject.BroadcastMessage("EnableOutline",SendMessageOptions.DontRequireReceiver);
            }
        }
        else
        {
            if (_currentHoverObject != null)
            {
                // TODO: Llamar a quien le importe HoverEND
				_currentHoverObject.BroadcastMessage("DisableOutline",SendMessageOptions.DontRequireReceiver);
                //Debug.Log("HoverEnd: " + _currentHoverObject.name);
                _currentHoverObject = null;
            }
        }
    }
开发者ID:carcolgar,项目名称:GameJam2016,代码行数:31,代码来源:InputManager.cs

示例3: OnParticleCollision

        private void OnParticleCollision(GameObject other)
        {
            int safeLength = m_ParticleSystem.GetSafeCollisionEventSize();

            if (m_CollisionEvents.Length < safeLength)
            {
                m_CollisionEvents = new ParticleCollisionEvent[safeLength];
            }

            int numCollisionEvents = m_ParticleSystem.GetCollisionEvents(other, m_CollisionEvents);
            int i = 0;

            while (i < numCollisionEvents)
            {
                if (Time.time > lastSoundTime + 0.2f)
                {
                    lastSoundTime = Time.time;
                }

                var col = m_CollisionEvents[i].collider;
                var attachedRigidbody = col.GetComponent<Rigidbody>();
                if (attachedRigidbody != null)
                {
                    Vector3 vel = m_CollisionEvents[i].velocity;
                    attachedRigidbody.AddForce(vel*force, ForceMode.Impulse);
                }

                other.BroadcastMessage("Extinguish", SendMessageOptions.DontRequireReceiver);

                i++;
            }
        }
开发者ID:CaptainStouf,项目名称:TheKinectAwakens,代码行数:32,代码来源:WaterHoseParticles.cs

示例4: OnCreate

    public void OnCreate( int id )
    {
        Destroy( currentPlayer );

        currentPlayer =  this.InstantiateAsChild( transform, prefabPlayerList[id].gameObject );
        currentPlayer.BroadcastMessage( createdMessage, SendMessageOptions.DontRequireReceiver );
        Debug.Log( createdMessage );
    }
开发者ID:hiroki-kitahara,项目名称:Shoooooooooooooting-kitahara,代码行数:8,代码来源:PlayerCreator.cs

示例5: ShootAlien

 IEnumerator ShootAlien(GameObject target)
 {
     BroadcastMessage("OnStartFire");
     target.BroadcastMessage("OnImHit");
     if(xenoWeaponType == XenoWeapon.DamageTypes.FLAME)
         target.BroadcastMessage("OnImOnFire");
     yield return new WaitForSeconds(0.5f);
     target.BroadcastMessage("OnImHit");
     yield return new WaitForSeconds(0.5f);
     target.BroadcastMessage("OnImHit");
     yield return new WaitForSeconds(0.5f);
     target.BroadcastMessage("OnImHit");
     yield return new WaitForSeconds(0.5f);
     target.BroadcastMessage("OnImHit");
     BroadcastMessage("OnStopFire");
     target.BroadcastMessage("OnDeath");
 }
开发者ID:mdeegler,项目名称:xeno,代码行数:17,代码来源:MarineData.cs

示例6: LoadWorld

    public static void LoadWorld()
    {
        GameObject.Destroy(GameObject.Find("MenuCamera"));
        if (uLink.Network.isServer)
        {
            IsWhite = true;
        }
        else
        {
            IsWhite = false;
        }

        // disable the wrong spawn
        if (IsWhite)
            GameObject.FindWithTag(Registry.Tag.SpawnBlack).SetActive(false);
        else
            GameObject.FindWithTag(Registry.Tag.SpawnWhite).SetActive(false);

        // player has been instantiated already, so we can get this reference
        Player = GameObject.FindWithTag(Registry.Tag.Player);
        //Debug.Log(Player);

        // camera setup (make sure this comes after the player is loaded)
        CameraTarget = GameObject.Instantiate(Resources.Load(Registry.Prefab.CameraTarget)) as GameObject;
        CameraTarget.BroadcastMessage("SetTarget", Player);

        // land on branch
        if(IsWhite)
        {
            Player.GetComponent<PlayerState>().LandTarget = GameObject.FindGameObjectWithTag(Registry.Tag.SpawnWhite).transform;
        }
        else
        {
            Player.GetComponent<PlayerState>().LandTarget = GameObject.FindGameObjectWithTag(Registry.Tag.SpawnBlack).transform;
        }
        Player.GetComponent<PlayerInput>().SetTrigger(Registry.Animator.Land);

        // if server, load in all objects that must be networked
        if (uLink.Network.isServer)
        {
            Debug.Log("Server load objects");

            uLink.Network.Instantiate(uLink.Network.player, Registry.Prefab.EggProxy, Registry.Prefab.Egg, Registry.Prefab.Egg, new Vector3(-2400f, -873f, 227f), Quaternion.identity, 0);
            uLink.Network.Instantiate(uLink.Network.player, Registry.Prefab.EggProxy, Registry.Prefab.Egg, Registry.Prefab.Egg, new Vector3(-2400f, -873f, -267f), Quaternion.identity, 0);

            // CHASE TEST
            //uLink.Network.Instantiate(uLink.Network.player, Registry.Prefab.EggProxy, Registry.Prefab.Egg, Registry.Prefab.Egg, new Vector3(-2400f, -882f, 0f), Quaternion.identity, 0);
            //uLink.Network.Instantiate(uLink.Network.player, Registry.Prefab.EggProxy, Registry.Prefab.Egg, Registry.Prefab.Egg, new Vector3(-2400f, -882f, 0f), Quaternion.identity, 0);

            // outside
            GameObject.Instantiate(Resources.Load(Registry.Prefab.FireballZone), new Vector3(-1314f, -10f, -637f), Quaternion.identity);

            // torch room
            GameObject.Instantiate(Resources.Load(Registry.Prefab.FireballZoneMini), new Vector3(-2392f, -874f, -232f), Quaternion.identity);
            GameObject.Instantiate(Resources.Load(Registry.Prefab.FireballZoneMini), new Vector3(-2412f, -874f, -232f), Quaternion.identity);
        }
    }
开发者ID:davidsiekut,项目名称:BirdSimulator2015,代码行数:57,代码来源:GameController.cs

示例7: CheckSonarPoint_Enter

 private void CheckSonarPoint_Enter(GameObject target)
 {
     if (!target.CompareTag("Sonar")) return;
     ColorFader fader = target.GetComponent<ColorFader>();
     if (fader==null) return;
     if (fader.SonarInside()) return;
     Debug.Log("CheckSonarPoint");
     target.BroadcastMessage("OnSonarInside");
 }
开发者ID:negimochi,项目名称:EchoHiker,代码行数:9,代码来源:SonarCamera.cs

示例8: setTarget

 public static void setTarget(GameObject target, string targetName, int targetType)
 {
     if(Globals.target != null){
         Globals.target.BroadcastMessage("RemoveTarget");
     }
     target.BroadcastMessage("SetTarget");
     Globals.target = target;
     Globals.targetName = targetName;
     Globals.targetType = targetType;
 }
开发者ID:CodyTRandall,项目名称:Scripts,代码行数:10,代码来源:Globals.cs

示例9: AttackTarget

    private int marineCheckCount = 0; //counter to deterine which marine is currently being evaluated for targeting

    #endregion Fields

    #region Methods

    public IEnumerator AttackTarget(GameObject finalMarineTarget)
    {
        gameObject.BroadcastMessage("OnStartFire");
        Debug.Log("attack animation: "+Time.time);
        yield return new WaitForSeconds(0.5f);
        StartCoroutine(BloodSplatter(finalMarineTarget));
        finalMarineTarget.BroadcastMessage("OnBeingAttacked");
        yield return new WaitForSeconds(3.0f);
        unitStatus = UnitStatus.MOVED;
        Debug.Log("done attacking: "+Time.time);
    }
开发者ID:mdeegler,项目名称:xeno,代码行数:17,代码来源:AlienData.cs

示例10: AddJogadores

 // Methods adjacents
 private void AddJogadores(GameObject obj)
 {
     print("chegouAqui");
     for(int i = 0; i < listaJogadores.Length; i++){
         if(listaJogadores[i] == null){
             listaJogadores[i] = obj;
             obj.BroadcastMessage("AddLayer", i + 10);
                 break;
         }
     }
 }
开发者ID:vitormartins1,项目名称:paintball-nave,代码行数:12,代码来源:Server.cs

示例11: TargetHit

    public static void TargetHit(GameObject objectHit)
    {
        if(objectHit.tag == "TargetToHit")
        {

            //Debug.Log("Target hit: " + objectHit.name + " damage: " + damageDealing);
            objectHit.BroadcastMessage("TagSkade", damageDealing, SendMessageOptions.DontRequireReceiver);
        }
        

    }
开发者ID:timKofoed,项目名称:MatchShooter,代码行数:11,代码来源:GunController.cs

示例12: Start

    // ロード終了時
    //    void OnLevelWasLoaded(int level)
    //    {
    //        Debug.Log("OnLevelWasLoaded : level=" + level + " - " + Application.loadedLevelName);
    // ロード終了時にすると、単体デバッグができないのでStartにしておく
    void Start()
    {
        root = GameObject.Find("/Root");
        ui = GameObject.Find("/UI");

        if (root)
        {
            SetHighScore();
            root.BroadcastMessage("OnFadeOut", gameObject);
        }
        else OnIntermissionEnd();
    }
开发者ID:negimochi,项目名称:EchoHiker,代码行数:17,代码来源:TitleAdapter.cs

示例13: Update

	// Update is called once per frame
	void Update() {
		RaycastHit info;

		Debug.DrawRay( transform.position, transform.forward, Color.red );

		if ( Physics.Raycast( transform.position, transform.forward, out info, HighlightDistance, gazeLayer ) ) {
			EnableGazeReticle();

			var gazed = info.collider.gameObject;
			if ( gazed != lastGazed ) {
				ignoreGaze = false;
				ResetScale();

				if ( lastGazed != null ) {
					lastGazed.BroadcastMessage( "OnLostGaze", SendMessageOptions.DontRequireReceiver );
				}

				lastGazed = gazed;
				lastGazed.BroadcastMessage( "OnGaze", SendMessageOptions.DontRequireReceiver );
			} else {
				if ( info.distance > GazeDistance ) {
					ignoreGaze = false;
					ResetScale();
					return;
				}

				if ( ignoreGaze ) {
					ResetScale();
					return;
				}

				var scale = Mathf.Min( Gazer.transform.localScale.x + ( Time.deltaTime * ( 1 / GazeTime ) ), 1 );
				Gazer.transform.localScale = new Vector3( scale, 1, scale );

				if ( scale == 1 ) {
					ignoreGaze = true;
					lastGazed.BroadcastMessage( "OnGazed", SendMessageOptions.RequireReceiver );
				}
			}
		} else {
			ignoreGaze = false;

			if ( lastGazed != null ) {
				lastGazed.BroadcastMessage( "OnLostGaze", SendMessageOptions.DontRequireReceiver );
				lastGazed = null;
			}

			if ( ResetScale() ) {
				DisableGazeReticle();
			}
		}
	}
开发者ID:Miguel-Barreiro,项目名称:Oculus-FPS,代码行数:53,代码来源:Reticle.cs

示例14: FixedUpdate

	public void FixedUpdate()
	{
		Control = GameObject.FindWithTag("Controller");
		Nord = GameObject.FindWithTag("Nord");
		Orc = GameObject.FindWithTag("Orc");
		Control.BroadcastMessage("Set");
		if (Vector3.Distance(Nord.transform.position, targetOrc.position) > 4f)
		{
		float step = speed * Time.deltaTime;
		Nord.transform.position = Vector3.MoveTowards(Nord.transform.position, targetOrc.position, step);
		Orc.transform.position = Vector3.MoveTowards(Orc.transform.position, targetNord.position, step);
		}
		else
		{

			animN.CrossFade ("Idle");
			animO.CrossFade ("Idle");

			Control.BroadcastMessage("AttackN1");
			Destroy(this);	
		}
	}
开发者ID:JuriyK,项目名称:NordsFight,代码行数:22,代码来源:Move.cs

示例15: CharacterDied

 public void CharacterDied(GameObject character, CharacterType type)
 {
     if (type == CharacterType.Character1) {
         firstActive = false;
     } else if (type == CharacterType.Character2) {
         secondActive = false;
     } else if (type == CharacterType.Character3) {
         thirdActive = false;
     }
     character.BroadcastMessage("CharacterDied");
     CheckForEnemyCountUpdates();
     CheckIfAllCharactersDead();
     if (GameState.activeCharacter.GetComponent<CharacterState>().dead) {
         dyingWithouSwitching = true;
         Invoke("AutoSwitchIfNeeded", 2.0f);
     }
 }
开发者ID:5thFloorGames,项目名称:FollowTheLight,代码行数:17,代码来源:CharacterManager.cs


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