本文整理汇总了C#中UnityEngine.Collider.CompareTag方法的典型用法代码示例。如果您正苦于以下问题:C# Collider.CompareTag方法的具体用法?C# Collider.CompareTag怎么用?C# Collider.CompareTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Collider
的用法示例。
在下文中一共展示了Collider.CompareTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if(!sequenceToPlay)
{
Debug.LogWarning("You have triggered a sequence in your scene, however, you didn't assign it a Sequence To Play", gameObject);
return;
}
if(sequenceToPlay.IsPlaying)
return;
if(other.CompareTag("MainCamera") && isMainCameraTrigger)
{
sequenceToPlay.Play();
return;
}
if(other.CompareTag("Player") && isPlayerTrigger)
{
sequenceToPlay.Play();
return;
}
if(other.gameObject == triggerObject)
{
sequenceToPlay.Play();
return;
}
}
示例2: OnTriggerExit
private void OnTriggerExit(Collider other)
{
if (other.CompareTag("Player") && this._hasPlayer)
{
this._hasPlayer = false;
if (this._activeWarmth)
{
LocalPlayer.GameObject.SendMessage("LeaveHomeWarmth");
}
}
if (other.CompareTag("FireTrigger") && this._activeWarmth)
{
Transform transform = base.GetComponentInParent<PrefabIdentifier>().transform;
bool activeWarmth = this._activeWarmth;
this._activeWarmth = false;
int childCount = transform.childCount;
for (int i = 0; i < childCount; i++)
{
Fire2 componentInChildren = transform.GetChild(i).GetComponentInChildren<Fire2>();
if (componentInChildren && componentInChildren.Lit && base.GetComponent<Collider>().bounds.Contains(componentInChildren.transform.position))
{
this._activeWarmth = true;
break;
}
}
if (this._hasPlayer && activeWarmth != this._activeWarmth)
{
LocalPlayer.GameObject.SendMessage((!this._activeWarmth) ? "LeaveHomeWarmth" : "HomeWarmth");
}
}
}
示例3: OnTriggerEnter
// 「Trigger」のコライダー接触時に呼ばれるコールバック
void OnTriggerEnter(Collider collider)
{
if (collider.CompareTag ("Enemy")) {
animator.SetTrigger ("Dead");
DoneGameController.Instance.state = DoneGameController.GameState.GameOver;
}
if (collider.CompareTag ("Goal")) {
animator.SetTrigger ("Clear");
DoneGameController.Instance.state = DoneGameController.GameState.GameClear;
}
}
示例4: OnTriggerEnter
//check if the character collects the powerups or the snags
void OnTriggerEnter(Collider other)
{
Debug.Log (isGrounded);
if(other.CompareTag("Powerup") && isGrounded)
{
control.PowerupCollected();
}
else if(other.CompareTag("Obstacle") && isGrounded)
{
control.AlcoholCollected();
}
Destroy(other.gameObject);
}
示例5: OnHit
private void OnHit(Collider other)
{
if (!other.CompareTag(Tags.Monster))
{
if (other.CompareTag(Tags.Hero))
{
//TODO: Hero bullet attack
battleProxy.DoAttackHero(AttackContext);
}
Script.SetState(BulletState.After);
Script.CallbackUpdate = null;
}
}
示例6: OnTriggerExit
void OnTriggerExit(Collider other)
{
if (other.CompareTag("Player1_") || other.CompareTag("Player2_") || other.CompareTag("Player3_") || other.CompareTag("Player4_"))
{
if (m_childStatic.isPlaying)
{
m_childStatic.Stop();
}
if (m_childParticles.isPlaying)
{
m_childParticles.Stop();
}
}
}
示例7: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
return;
if (Time.time < timer)
{
if (!targetsAlreadyTouched.Contains(other.gameObject.GetInstanceID()))
{
IDamageable damageable = other.GetComponent(typeof(IDamageable)) as IDamageable;
if (damageable == null)
{
return;
}
targetsAlreadyTouched.Add(other.gameObject.GetInstanceID());
damageable.TakeDirectDamage(DoDamage());
//Target spreading.
if (damageable is AlienBase)
{
AlienBase alien = damageable as AlienBase;
alien.SetTarget(damageSource.transform);
}
if (damageable is CocoonSpawner)
(damageable as CocoonSpawner).TriggerSpawning(damageSource.transform);
}
}
}
示例8: OnTriggerEnter
// OnTriggerEnter is called when the Collider other enters the trigger
public void OnTriggerEnter(Collider other)
{
int objLayer = 1 << other.gameObject.layer;
if (other.isTrigger && ignoreTriggers || other.CompareTag(playerTag) || (layersToFade & objLayer) != objLayer)
return;
// Retrieve all the renderers
Renderer[] rendererWeHit = other.gameObject.GetComponentsInChildren<Renderer>();
// Loop through the renderers
for (int idx = 0; idx < rendererWeHit.Length; idx++)
{
if (rendererWeHit[idx] != null) // just to be on the safe side :)
{
// If we changed this already we skip it, otherwise we proceed with the change
if (!modifiedShaders.ContainsKey(rendererWeHit[idx].GetInstanceID()))
{
ShaderData shaderData = new ShaderData();
shaderData.renderer = rendererWeHit[idx];
shaderData.shader = new Shader[rendererWeHit[idx].materials.Length];
shaderData.color = new Color[rendererWeHit[idx].materials.Length];
for (int j = 0; j < rendererWeHit[idx].materials.Length; j++)
{
shaderData.shader[j] = rendererWeHit[idx].materials[j].shader;
if (rendererWeHit[idx].materials[j].HasProperty("_Color"))
shaderData.color[j] = rendererWeHit[idx].materials[j].color;
rendererWeHit[idx].materials[j].shader = transparentShader;
rendererWeHit[idx].materials[j].color = fadingColorToUse;
}
// Add the shader to the list of those that have been changed
modifiedShaders.Add(rendererWeHit[idx].GetInstanceID(), shaderData);
}
}
}
}
示例9: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
GameController.NotifyPlayer("Don't forget to save, janitor !", Color.red, 3);
}
}
示例10: OnSceneObjectHit
protected override void OnSceneObjectHit(Collider collider)
{
if(collider.CompareTag(Tags.GameObstacle))
{
OnCollisionEventStart(Tags.GameObstacleAway);
}
}
示例11: OnTriggerEnter
public void OnTriggerEnter(Collider other) {
if (other.CompareTag("Player")) {
string savegame = PixelCrushers.DialogueSystem.PersistentDataManager.GetSaveData();
Debug.Log ("Recording: " + savegame);
Application.LoadLevel(newLevelName);
}
}
示例12: OnTriggerExit
private void OnTriggerExit(Collider otherCollider) {
// Making sure the object we have left is DynamicWater
if (_water != null && otherCollider.CompareTag(FluidVolume.DynamicWaterTagName) &&
otherCollider == _water.Collider) {
_water = null;
}
}
示例13: OnTriggerExit
void OnTriggerExit(Collider other)
{
if (String.IsNullOrEmpty(CollisionTag) || other.CompareTag(CollisionTag))
{
HandleGameEvent(EmitterGameEvent.TriggerExit);
}
}
示例14: OnTriggerEnter
private void OnTriggerEnter(Collider col)
{
if (String.IsNullOrEmpty(CollisionTag) || col.CompareTag(CollisionTag))
{
_collisionCount++;
this.enabled = true;
}
}
示例15: SetGrounded
void SetGrounded(bool value, Collider other) {
if (Character == null || other == null)
return;
if (other.CompareTag("Platform")) {
Character.IsGrounded = value;
}
}