本文整理汇总了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); }
}
示例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;
}
}
}
示例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++;
}
}
示例4: OnCreate
public void OnCreate( int id )
{
Destroy( currentPlayer );
currentPlayer = this.InstantiateAsChild( transform, prefabPlayerList[id].gameObject );
currentPlayer.BroadcastMessage( createdMessage, SendMessageOptions.DontRequireReceiver );
Debug.Log( createdMessage );
}
示例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");
}
示例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);
}
}
示例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");
}
示例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;
}
示例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);
}
示例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;
}
}
}
示例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);
}
}
示例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();
}
示例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();
}
}
}
示例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);
}
}
示例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);
}
}