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();
	}
Example #2
0
    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);
        }
    }
Example #3
0
    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");
                }
            }
        }
    }
Example #4
0
    // 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--;
                }
            }
        }
    }
 void OnCollisionEnter(Collision collision)
 {
     if(collision.gameObject.tag == "BallTag")
     {
         GameOver(collision);
     }
 }
Example #6
0
	public void OnCollisionEnter(Collision col)
	{
		if(col.gameObject.transform.position.x < transform.position.x)
			SendMessageUpwards("RotateDoorClock");//, col.gameObject.rigidbody.velocity.magnitude);
		else
			SendMessageUpwards("RotateDoorUnClock");
	}
Example #7
0
 void OnCollisionEnter(Collision collision)
 {
     if(collision.gameObject.tag == "Bullet")
     {
         GetComponent<NavMeshAgent>().Warp(begin);
     }
 }
 void OnCollisionEnter(Collision collision)
 {
     //Debug.Log(collision.relativeVelocity.magnitude);
     if (collision.relativeVelocity.magnitude > 2){
         audio.Play();
     }
 }
    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);
    }
Example #10
0
 void OnCollisionEnter(Collision col)
 {
     if (col.collider.CompareTag("Player") || col.collider.CompareTag("Item"))
     {
         isHurt = true;
     }
 }
Example #11
0
 void OnCollisionEnter(Collision c)
 {
     if (c.gameObject == GameObject.FindWithTag ("Boss"))
         SetPv (5);
     if (c.gameObject.tag == "fireennemy")
         SetPv (1);
 }
Example #12
0
 void OnCollisionEnter(Collision collision)
 {
     if(collision.collider.tag == "KillBox") {
         Destroy(gameObject);
         MultiManager.Instance.Board.DropHealth();
     }
 }
Example #13
0
    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++;
                }
            }
        }
    }
Example #14
0
    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);
        }
    }
Example #15
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.gameObject.tag.Equals("Player"))
     {
         collision.collider.rigidbody.AddForce(Vector3.forward * 100);
     }
 }
	virtual protected void OnCollide( Collision collision )
	{
		if ( collision.gameObject.CompareTag( "Player" ) ) return;

		// Kill enemy
		if ( ( !HasHitUnit ) && ( collision != null ) && ( collision.transform.gameObject.layer == LayerMask.NameToLayer( "Enemy" ) ) )
		{
			EnemyUnitBaseScript enemyunit = collision.transform.GetComponent<EnemyUnitBaseScript>();
			if ( enemyunit )
			{
				enemyunit.Die_Killed();
            }

			Destroy( collision.transform.gameObject );

			// Flag as hit so no other units are destroyed this frame
			HasHitUnit = true;

			// Virtual override for child classes
			OnUnitHit( collision );
        }

		// Kill protectile
		Destroy( transform.parent.gameObject );

		// Spawn projectile death effect
		GameObject effect = (GameObject) Instantiate( DeathEffectPrefab, transform.position, Quaternion.Euler( Vector3.zero ) );
		effect.transform.SetParent( GameObject.Find( "GameObjectContainer" ).transform );
	}
    void OnCollisionEnter(Collision theCollision)
    {
        CarDriver otherObjectsScript = theCollision.gameObject.GetComponent<CarDriver> ();

        if(otherObjectsScript != null)
            otherObjectsScript.Respawn();
    }
Example #18
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.name == "Player")
     {
         clearText.SetActive(true);
     }
 }
 void OnCollisionEnter(Collision collision)
 {
     if(runnerController!=null)
     {
         runnerController.Runnercollision(collision);
     }
 }
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "Projectile")
     {
         explode = true;
     }
 }
 void OnCollisionEnter(Collision theObject)
 {
     if(beenHit == false && theObject.gameObject.name == "coconut")
     {
         StartCoroutine("targetHit");
     }
 }
Example #22
0
 void OnCollisionEnter(Collision collision)
 {
     _jukebox.SendMessage("PlayBreak");	//play our sound
     _camera.SendMessage("score",1);
     Destroy(transform.parent.gameObject);
     Destroy(gameObject);
 }
    void OnCollisionEnter(Collision collision)
    {
        AudioSource audio = GetComponent<AudioSource>();

        audio.Play();
            Debug.Log("Bim");
    }
 private void OnCollisionEnter(Collision collision)
 {
     var weapon_backpack = collision.collider.GetComponent<WeaponBackpackController>();
     GameObject nlog = GameObject.FindWithTag("Log");
     string message = "";
     LogScript log = nlog.GetComponent<LogScript>();
     if(weapon_backpack != null) {
         if (pickup_sound != null)
         {
             AudioSource.PlayClipAtPoint(pickup_sound, transform.position);
         }
         var found_ammo = Random.Range(0, max_ammo + 1);
         weapon_backpack.ChangeAmmo(found_ammo);
         var player = GameObject.FindGameObjectWithTag("StartingWeapons");
         string pickupMessage = player.GetComponent<StartingWeapons>().PickupAll();
         Destroy(gameObject);
     }
     var health = collision.collider.GetComponent<HealthController>();
     if (health != null)
     {
         var collected_health = Random.Range(50, 76);
         health.ChangeHealth(collected_health);
         Destroy(gameObject);
     }
     log.PassMessage("You just picked up guns.\nPress r to toggle through\n");
 }
Example #25
0
    public override void OnCollisionEnter(Collision col)
    {
        if (GameManager.Rules.State == GlobalState.DRAG_WHITEBALL)
            return;

        if (col.gameObject.name.Contains("Rail"))
        {
            HOAudioManager.BallhitRail(m_rigidbody.velocity);
            GameManager.Rules.CueBallHitRail();
            GameManager.Rules.BallHitRail();
            GameStatistics.MarkCueballHitRail(1);
        }
        if (col.transform.CompareTag("Ball"))
        {
            HOAudioManager.BallhitBall(m_rigidbody.velocity);
            GameStatistics.MarkCueballHitBall(1);
            PoolBall ball = col.gameObject.GetComponent<PoolBall>();
            GameManager.Rules.WhiteBallHitBall(ball);
            if (ball && ball == m_targetBall)
            {
                m_targetBall.PointAtTarget(m_targetPos);
                m_targetBall = null;
            }
        }
    }
 void OnCollisionEnter(Collision collision)
 {
     if(collision.gameObject.layer == target.layer)
     {
         GameManager.Instance.Endgame();
     }
 }
Example #27
0
	void OnCollisionEnter (Collision collision)
	{
		if(collision.gameObject.tag == "FriendlyFire")
		{
			// Add explosion
			var explosion = GameObject.Instantiate(explosionPrefab);
			explosion.transform.position = collision.gameObject.transform.position;
			AudioSource.PlayClipAtPoint(explosionSound, explosion.transform.position);

      // Remove fireball
      Destroy(collision.gameObject);

			// Subtract health
			int healthLost = getHealthCost(collision.gameObject.name);
			currentHealth -= healthLost;
            Debug.Log(currentHealth);

			// Check for death
			if (currentHealth <= 0) {
				var samuraiExplosion = GameObject.Instantiate(explosionPrefab);
				samuraiExplosion.transform.position = gameObject.transform.position;
				AudioSource.PlayClipAtPoint(deathSound, samuraiExplosion.transform.position);
				Destroy(gameObject);
			}
		}
	}
Example #28
0
	void OnCollisionEnter(Collision collision)
	{
		if(collision.gameObject.tag == "Bullets" ) // bumped bullets
		{
			health -= collision.gameObject.GetComponent<BulletsStats>().damage; // get damage
		}
	}
 void OnCollisionExit(Collision other)
 {
     if (other.gameObject.tag == "Trap")
     {
         traps.Remove(other.gameObject);
     }
 }
Example #30
-1
	public void OnCollisionStay(Collision col)
	{
		if(col.gameObject.transform.position.x < transform.position.x)
			SendMessageUpwards("RotateDoorClock");
		else
			SendMessageUpwards("RotateDoorUnClock");
	}