本文整理汇总了C#中Collision类的典型用法代码示例。如果您正苦于以下问题:C# Collision类的具体用法?C# Collision怎么用?C# Collision使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Collision类属于命名空间,在下文中一共展示了Collision类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if(side==BulletSide.FRIENDLY)
{
if(col.gameObject.tag==TagsStorage.ABIL_SHIELD)
deactivate();
if(col.gameObject.tag==TagsStorage.ENEMY_TAG)
{
col.gameObject.GetComponent<EnemySpaceship>().Attacked(damage);
deactivate();
}
}
if(side==BulletSide.ENEMY)
{
if(col.gameObject.tag==TagsStorage.FRIENDLY_TAG)
{
col.gameObject.GetComponent<FriendlySpaceship>().Attacked(damage);
deactivate();
}
if(col.gameObject.tag==TagsStorage.ABIL_SHIELD)
deactivate();
}
if(col.gameObject.tag==TagsStorage.ASTEROID_TAG)
deactivate();
}
示例2: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if (col.gameObject.name == "Wall")
{
Destroy (gameObject);
}
else if (col.gameObject.name == "BlueVirus"){
bVirus = col.gameObject.GetComponent<BlueVirus>();
bVirus.takeDamage (1,1);
Destroy (gameObject);
}
else if (col.gameObject.name == "RedVirus"){
Destroy (gameObject);
}
else if (col.gameObject.name == "GreenVirus"){
gVirus = col.gameObject.GetComponent<GreenVirus>();
gVirus.takeDamage (1,1);
Destroy (gameObject);
}else if(col.gameObject.name == "Boss"){
boss = col.gameObject.GetComponent<BossScript>();
boss.takeDamage(1, 1);
Destroy(gameObject);
}
}
示例3: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Ammo")
{
vie--;
if (vie <= 0)
{
isDead = true;
anim.SetBool("isWalking", false);
anim.SetBool("weapon", false);
anim.SetBool("isDead", true);
Player.score++;
if (!isDead)
{
GameObject.Find("score").GetComponent<Text>().text = "Score : " + Player.score;
}
isDead = true;
if (Application.loadedLevelName == "Jeu1")
{
Application.LoadLevel("Jeu2");
}
}
}
}
示例4: OnCollisionEnter
// Handle all collisions
void OnCollisionEnter(Collision collision)
{
if (gameObject.name == "1_Player_East")
{
PlayerPrefs.SetInt("NumPlayers", 1);
Application.LoadLevel(2);
}
if (gameObject.name == "1_Player_West")
{
PlayerPrefs.SetInt("NumPlayers", 1);
Application.LoadLevel(3);
}
if (gameObject.name == "2_Player_East")
{
PlayerPrefs.SetInt("NumPlayers", 2);
Application.LoadLevel(2);
}
if (gameObject.name == "2_Player_West")
{
PlayerPrefs.SetInt("NumPlayers", 2);
Application.LoadLevel(3);
}
if (collision.gameObject.GetComponent(typeof(SnowBall)) != null )
{
if( (collision.gameObject.GetComponent(typeof(SnowBall)) as SnowBall).BallLauncher == SnowBall.Launcher.Enemy)
{
GUIManager.currentScore = GUIManager.currentScore - HitPenalty;
if (PlayerPrefs.GetString("SelectedGameMode").Equals("HardMode"))
{
GameController.lives--;
}
}
}
}
示例5: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag == "BallTag")
{
GameOver(collision);
}
}
示例6: OnCollisionEnter
public void OnCollisionEnter(Collision col)
{
if(col.gameObject.transform.position.x < transform.position.x)
SendMessageUpwards("RotateDoorClock");//, col.gameObject.rigidbody.velocity.magnitude);
else
SendMessageUpwards("RotateDoorUnClock");
}
示例7: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag == "Bullet")
{
GetComponent<NavMeshAgent>().Warp(begin);
}
}
示例8: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
//Debug.Log(collision.relativeVelocity.magnitude);
if (collision.relativeVelocity.magnitude > 2){
audio.Play();
}
}
示例9: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if(particule)
GameObject.Instantiate(particule, transform.position, Quaternion.identity);
//on inflige des degas au ennemis si il sont dans la zone
EnemyController[] targets = FindObjectsOfType(System.Type.GetType("EnemyController")) as EnemyController[];
for (int i=0; i<targets.Length; i++)
{
Vector3 distance = transform.position-targets[i].transform.position;
if(distance.magnitude <= m_distance)
{
float damage = -m_damage + (-m_damage)/100 * targets[i].getSkillManager().getMagicResistance();
//gestion de la furie
if(m_furie)
damage += damage/100 * m_damageFurie;
//gestion des critique
if(m_factorCritique/100 < Random.value)
damage *= 2;
targets[i].healthUpdate(damage);
}
}
Destroy(this.gameObject);
}
示例10: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if (col.collider.CompareTag("Player") || col.collider.CompareTag("Item"))
{
isHurt = true;
}
}
示例11: OnCollisionEnter
void OnCollisionEnter(Collision c)
{
if (c.gameObject == GameObject.FindWithTag ("Boss"))
SetPv (5);
if (c.gameObject.tag == "fireennemy")
SetPv (1);
}
示例12: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
if(collision.collider.tag == "KillBox") {
Destroy(gameObject);
MultiManager.Instance.Board.DropHealth();
}
}
示例13: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if (!roadcols.Contains(col.collider.name))
{
if (col.collider.name.Equals("Road_Coll02_Side") && TriggerTimer.roundNo > rc2s)
{
Debug.Log("triggered");
rc2s++;
}
else
{
if (col.collider.name.Equals("Road_Coll_Side") && RoadCollHelper.inTrigger)
{
//do nothing
}
else
{
Debug.Log(col.collider.name);
Debug.Log(col.relativeVelocity.magnitude);
velo.Add(col.relativeVelocity.magnitude);
TriggerTimer.collisions++;
}
}
}
}
示例14: OnCollisionEnter
void OnCollisionEnter(Collision other)
{
if (other.gameObject.layer == LayerMask.NameToLayer("TrackWall"))
{
// Get Collision impact
float impact = Vector3.Dot(other.contacts[0].normal, other.relativeVelocity);
float hitDot = Vector3.Dot(other.contacts[0].normal, transform.forward);
if (Mathf.Abs(impact) > 1 && hitDot < 0.1f)
{
// Zero out relative Z velocity
r.PlayOneShot(r.settings.SFX_WALLHIT);
Vector3 lv = transform.InverseTransformDirection(r.body.velocity);
lv.y = 0;
lv.z = 0;
Vector3 wv = transform.TransformDirection(lv);
r.body.velocity = wv;
// Reduce engine power and thrust
enginePower *= 0.2f;
engineThrust *= 0.2f;
// Push ship away from wall
Vector3 dir = other.contacts[0].normal;
dir.y = 0;
r.body.AddForce(dir * Mathf.Abs(impact), ForceMode.Impulse);
// Spawn hit particle
GameObject particle = Instantiate(Resources.Load("Particles/CollisionHit") as GameObject) as GameObject;
particle.transform.position = other.contacts[0].point;
particle.transform.forward = -transform.forward;
// Ship take damage
r.shield -= Mathf.Abs(impact * 2);
}
}
if (other.gameObject.tag == "Ship")
{
//r.PlayOneShot(SHIP2SHIP SOUND);
// Stop Bounce
Vector3 lv = transform.InverseTransformDirection(r.body.velocity);
lv.y = 0;
Vector3 wv = transform.TransformDirection(lv);
if (!isShipGrounded)
r.body.velocity = wv;
// Slow ship down slightly
enginePower *= 0.8f;
engineThrust *= 0.8f;
// Push away from other ship
Vector3 dir = other.contacts[0].normal;
dir.y = 0;
r.body.AddForce(dir * 4, ForceMode.Impulse);
}
}
示例15: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
if (collision.collider.gameObject.tag.Equals("Player"))
{
collision.collider.rigidbody.AddForce(Vector3.forward * 100);
}
}