本文整理汇总了C#中Collider.GetComponentInParent方法的典型用法代码示例。如果您正苦于以下问题:C# Collider.GetComponentInParent方法的具体用法?C# Collider.GetComponentInParent怎么用?C# Collider.GetComponentInParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collider
的用法示例。
在下文中一共展示了Collider.GetComponentInParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerStay
//Check if you're intersecting something
void OnTriggerStay(Collider other)
{
//Check if you're actually swinging - people just walking into weapons and dying would be bad
if (charWepCtrl.GetIsSwinging()) {
//Make sure it's not a child of yourself
if (!other.transform.IsChildOf (transform)) {
//Check if it's supposed to take damage
if (other.tag.Equals ("AI")) {
//Check if it's in the list of stuff you've hit during this swing
//If it is, skip it
if (!hitTrans.Contains (other.transform)) {
//Add it to the list of things hit during this swing
hitTrans.Add(other.transform);
//Deal the damage
other.GetComponentInParent<CharacterHealthMana>().ModHealth (-1 * charWepCtrl.GetDamage ());
//Do knockback
Vector3 force = KNOCKBACK_OFFSET + other.transform.root.position - transform.root.position;
force.Normalize ();
force *= charWepCtrl.GetKnockback ();
other.GetComponentInParent<CharacterMove>().AddKnockback(force);
}
}
}
}
}
示例2: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (taken)
return;
PlayerPickupHitbox hitbox = other.GetComponent<PlayerPickupHitbox>();
if (hitbox != null && !hitbox.GetComponentInParent<ShipAttributesOnline>().IsDead && other.GetComponentInParent<CustomOnlinePlayer>() != owner)
{
if (repairPotential > 0f)
{
float rnd = Random.Range(0, 3);
if (rnd == 0 || rnd == 1)
{
other.GetComponentInParent<HullOnline>().Repair(repairPotential);
OnPickup(hitbox.GetComponentInParent<CustomOnlinePlayer>(), "Hull");
}
else
{
other.GetComponentInParent<ShipAttributesOnline>().RepairAllSails(repairPotential);
OnPickup(hitbox.GetComponentInParent<CustomOnlinePlayer>(), "Sails");
}
}
else
{
OnPickup(hitbox.GetComponentInParent<CustomOnlinePlayer>());
}
taken = true;
NetworkServer.Destroy(this.gameObject);
}
}
示例3: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.name == "Shield")
{
}
if (other.tag == "Damage")
{
switch (other.name)
{
case "Canon dmg":
transform.parent.GetComponent<enemyHealth>().playerHealth -= 20;
break;
case "Mage dmg":
transform.parent.GetComponent<enemyHealth>().playerHealth -= 10;
break;
case "Player dmg":
if (other.GetComponentInParent<Buffer>().buffed)
buff = 2;
transform.parent.GetComponent<enemyHealth>().playerHealth -= (20 * buff);
buff = 1;
break;
case "Player dmg(Build)":
if (other.GetComponentInParent<attackPlayerCaster>().player.GetComponent<Buffer>().buffed)
buff = 2;
transform.parent.GetComponent<enemyHealth>().playerHealth -= (20 * buff);
buff = 1;
break;
case "Frozen dmg":
transform.parent.GetComponent<enemyHealth>().playerHealth -= 3;
GetComponent<FollowPath>().buff = 0.5f;
break;
}
}
}
示例4: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if(other.tag == "enemyweapon" && other.GetComponentInParent<LizardAnimationSelector>().attacking){
hp -= other.GetComponentInParent<LizardController>().damage;
other.GetComponentInParent<LizardController>().fitness += 10;
}
}
示例5: OnTriggerEnter
void OnTriggerEnter(Collider col)
{
if (col.GetComponentInParent<CarController>())
{
col.GetComponentInParent<CarController>().Reposition();
}
}
示例6: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.tag != Tags.RideOn)
{
return;
}
if (other.GetComponentInParent<ColorBlock>() != null)
{
if (other.GetComponentInParent<ColorBlock>().isDisappearance)
{
// カラーブロックのisTriggerがtrueになったときに入るのでリストから削除
hitList.RemoveAll((match) => match == other.gameObject);
if (hitList.Count == 0 && switchState)
{
SwitchOff();
switchState = false;
}
return;
}
}
if (!switchState)
{
SwitchOn();
switchState = true;
}
hitList.Add(other.gameObject);
}
示例7: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
//Debug.Log("A");
//Debug.Log(other.name);
if (other.GetComponent<CharacterStats>())
{
// Debug.Log("B");
CharacterInTrigger = true;
if (!Owner)
{
/// Debug.Log("C");
Owner = other.gameObject;
}
}//Debug.Log("END");
if (other.GetComponentInParent<CharacterStats>())
{
// Debug.Log("E");
CharacterInTrigger = true;
if (!Owner)
{
// Debug.Log("C");
Owner = other.GetComponentInParent<CharacterStats>().gameObject;
}
}
}/*
示例8: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.GetComponent<CharacterStats>())
{
// Debug.Log("1");
if (other.GetComponent<CharacterStats>().Id != charStat.Id)
{
// Debug.Log("2");
if (!enAi.Enemies.Contains(other.gameObject))
{
enAi.Enemies.Add(other.gameObject);
}
}
}
if (other.GetComponentInParent<CharacterStats>())
{
// Debug.Log("10");
if (other.GetComponentInParent<CharacterStats>().Id != charStat.Id)
{
// Debug.Log("20");
if (!enAi.Enemies.Contains(other.GetComponentInParent<CharacterStats>().gameObject))
{
enAi.Enemies.Add(other.GetComponentInParent<CharacterStats>().gameObject);
}
}
}
}
示例9: OnTriggerStay
void OnTriggerStay(Collider other)
{
//Get the players colliding with the trigger...
if (other.GetComponentInParent<Actor>())
{
other.GetComponentInParent<Actor>().m_Statistics.CalculateHealth(gameObject, TriggerDamagePerSecond * Time.deltaTime);
}
}
示例10: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.name.Equals("MagnetingSphere") && silverCoin)
{
this.GetComponent<Rigidbody>().velocity = (other.GetComponentInParent<Transform>().position - transform.position) * 40 * Time.deltaTime;
float distance = (other.GetComponentInParent<Transform>().position - transform.position).magnitude;
other.GetComponentInParent<MagnetController>().setStartingDistance(distance);
}
if (other.tag.Equals("Player") && !isCollected)
{
isCollected = true;
if (bomb)
other.GetComponent<BombController>().AddBomb(value);
else if (shield)
other.GetComponent<ShieldController>().ActiveShield(value); // get refenence to shield Controller and active player shield
else if (star)
GameMaster.instance.AddStars(value); // increase player score and add star
else if (bulletTime)
GameMaster.instance.BulletTimeOn(); // change timeScale to achive bullettime effect
else if (silverCoin)
GameMaster.instance.IncreaseScore(1);
else if (stamina)
other.GetComponent<StaminaController>().IncreaseStamina(value);
else if (magnet)
other.GetComponent<MagnetController>().UseMagnet();
else
{
PlayerController playerController = other.GetComponent<PlayerController>(); // Get reference to player controller
if (recoveryPackage)
playerController.IncreaseHealth(value);
else if (fuel)
playerController.Refuel(value);
else if (ammo)
playerController.AddAmmo(value);
else if (fireRate)
playerController.ChangeFireRate(value, activeTime);
else if (speed)
playerController.ChangeSpeed(value, activeTime);
else if (gun) // if there is any gun attached
{
playerController.ChangeWeapons(ref gun); // change player weapon
playerController.AddAmmo(value); // add aditional ammo
}
}
if (audioSource) // if there is sound attacheds
audioSource.Play();
animator.SetTrigger(collected);
StartCoroutine(DestroyAfterFinishAnimation());
}
}
示例11: OnTriggerStay
void OnTriggerStay(Collider other)
{
if ((this.gameObject.tag.Equals("Player") && other.GetComponentInParent<Player>() == null)
|| (this.gameObject.tag.Equals("Enemy") && other.GetComponentInParent<Enemy>() == null) || (this.gameObject.tag.Equals("EnemyScared") && other.GetComponentInParent<Enemy>() == null))
{
Vector3 distVec = (other.transform.position - transform.position);
print("working");
}
}
示例12: OnTriggerExit
void OnTriggerExit(Collider other)
{
if (other.tag == "PlayerCollider")
{
if (other.GetComponentInParent<PlayerController>().currTile == parentTile)
{
other.GetComponentInParent<PlayerController>().currTile = null;
}
}
}
示例13: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if ((this.gameObject.tag.Equals("Player") && other.GetComponentInParent<Player>() == null)
|| (this.gameObject.tag.Equals("Enemy") && other.GetComponentInParent<Enemy>() == null))
{
Vector3 distVec = (other.transform.position - transform.position);
this.batwolf.Seek(distVec * -1, true);
print("working");
}
}
示例14: OnTriggerEnter
//Call Caught command when player collides
protected virtual void OnTriggerEnter(Collider collider)
{
if (collider.GetComponentInParent<Transform>().tag == "Player") {
isTouch = true;
colliderId = collider.GetComponentInParent<PlayerIdentity>();
//Let's test this badboy out
/*Application.LoadLevel (Application.loadedLevel);
Debug.Log("Reloaded");*/
}
}
示例15: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.GetComponentInParent<HexTileInformation>() != null)
{
DestroySelf();
}
else if (other.GetComponentInParent<PlayerInformation>() != null)
{
other.GetComponentInParent<PlayerInformation>().CharacterState = CharacterState.Dead;
DestroySelf();
}
}