Example #1
0
 public void OnCollisionEnter2D(UnityEngine.Collision2D a)
 {
     if (fn != null)
     {
         fn.invoke(gameObject, a);
     }
 }
		public void OnCollisionEnter2D(Collision2D collision) {
			if (collision.gameObject.GetComponent<Grappleable>() != null) {
				_joint.enabled = true;
				_joint.connectedBody = collision.rigidbody;
				_joint.connectedAnchor = collision.transform.InverseTransformPoint(collision.contacts[0].point);
			}
		}
Example #3
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.Collision2D o;
     o = new UnityEngine.Collision2D();
     pushObject(l, o);
     return(1);
 }
Example #4
0
 protected override void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.CompareTag("World")) {
     ExplodeAt(collision.contacts[0].point);
     Kill();
       }
 }
 private void OnCollisionStay2D(Collision2D collision)
 {
     if (CollisionStay2D != null)
     {
         CollisionStay2D(this, collision);
     }
 }
        void OnCollisionEnter2D(Collision2D col)
        {
            if (infiniteJumps) return;

            numJumps--;
            if(numJumps == 0) StartCoroutine(Fall());
        }
Example #7
0
    public void OnCollisionEnter2D(UnityEngine.Collision2D collision)
    {
        if (collision.gameObject.tag == "Enemy")
        {
            if (weapon.enabled)
            {
                Destroy(collision.gameObject);
            }
            else
            {
                transform.position = GetComponentInParent <Game>().respawnPoint;
            }
        }

        if (collision.gameObject.tag == "powerUp")
        {
            int index = collision.gameObject.GetComponent <Powerup>().Pickup();
            GetComponentInParent <Game>().powerFound[index] = true;
            Destroy(collision.gameObject);
        }

        if (collision.gameObject.tag == "breakableWalls")
        {
            Debug.Log("Hit a breakable wall");
            int BP = collision.gameObject.GetComponent <Tile>().breakingPower;
            if (BP >= 0)
            {
                Debug.Log("Breaks on " + BP + ", powerup is " + (powerUps[BP]));
                if (powerUps[BP])
                {
                    Destroy(collision.gameObject);
                }
            }
        }
    }
Example #8
0
 void OnCollisionStay2D(Collision2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         col.gameObject.GetComponent<CharHealth>().Damage(Attack);
     }
 }
 public void SpawnExplosion(Collision2D other)
 {
     Vector3 direction = other.transform.position - transform.position;
     direction.Normalize();
     Vector3 explosionPos = transform.position + (direction * 0.4f);
     GameType_Astrodillos.instance.Explosion(explosionPos, other.gameObject, 0.25f);
 }
 public void OnCollisionEnter2D(Collision2D collision)
 {
     if (MainScript.SelfType == MainScript.PlayerType.Client)
     {
         MainScript.SelfPlayer.Role.HandleCollision(this, collision);
     }
 }
Example #11
0
    // ---------- トリガーイベント ----------
    /// <summary>
    /// コライダ衝突時イベント
    /// </summary>
    /// <param name="other">衝突対象</param>
    void OnCollisionEnter2D(UnityEngine.Collision2D other)
    {
        switch (other.gameObject.tag)
        {
        // 敵に衝突した場合
        case GameUtil.Const.TAG_NAME_KANI:
        case GameUtil.Const.TAG_NAME_UNI:
        case GameUtil.Const.TAG_NAME_KARASU:
        case GameUtil.Const.TAG_NAME_TAMA:
        case GameUtil.Const.TAG_NAME_HARI:
            if (dimax)
            {
                Destroy(other.gameObject);
            }
            else
            {
                PlayerDead(1.0f);
            }
            break;

        // デリートゾーンの場合
        case GameUtil.Const.TAG_NAME_DELETE_ZONE:
            PlayerDead(1.0f);
            break;

        // 巨バナを手に入れた場合
        case GameUtil.Const.TAG_NAME_KYOBANA:
            Destroy(other.gameObject);
            Dimax();
            break;
        }
    }
Example #12
0
 private void OnCollisionEnter2D(Collision2D other)
 {
     if (other.collider.tag == Tags.player)
     {
         other.gameObject.GetComponent<Player>().Die();
     }
 }
Example #13
0
        void CreateRicochet(GameObject currentRickochet, Collision2D col, bool isRicochet)
        {
            foreach (ContactPoint2D contact in col.contacts) {
                Debug.DrawRay (contact.point, contact.normal, Color.white);

                Quaternion rotation = Quaternion.LookRotation (contact.normal);
                rotation [0] = 0;
                rotation [1] = 0;
                GameObject projectile = Instantiate (currentRickochet, contact.point, rotation) as GameObject;
                //projectile.transform.eulerAngles = new Vector3(0, 0, projectile.transform.eulerAngles.z);

                Vector3 v = projectile.transform.rotation.eulerAngles;
                projectile.transform.rotation = rotation;
                //Debug.Log("Contact normal: " + contact.normal + " Contact position: " + contact.point + " Rotation: " + rotation);
                if (isRicochet && ricochetSounds.Length != 0) {
                    AudioSource ricochetAudioSource = projectile.AddComponent<AudioSource> ();
                    ricochetAudioSource.clip = ricochetSounds [Random.Range (0, ricochetSounds.Length)];
                    ricochetAudioSource.volume = 0.12f;
                    ricochetAudioSource.maxDistance = 30;
                    ricochetAudioSource.Play ();
                }

                projectile.SetActive (true);
                Destroy (projectile, 1f);
            }
        }
Example #14
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "bullet")
     {
         Destroy(gameObject);
     }
 }
    static void Collision2D_gameObject(JSVCall vc)
    {
        UnityEngine.Collision2D _this = (UnityEngine.Collision2D)vc.csObj;
        var result = _this.gameObject;

        JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
    }
    static void Collision2D_relativeVelocity(JSVCall vc)
    {
        UnityEngine.Collision2D _this = (UnityEngine.Collision2D)vc.csObj;
        var result = _this.relativeVelocity;

        JSApi.setVector2S((int)JSApi.SetType.Rval, result);
    }
Example #17
0
 private void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {
     if (collision.gameObject.tag == "MainCharacter")
     {
         Flowchart.BroadcastFungusMessage("Leave_scene");
     }
 }
// fields

// properties
    static void Collision2D_enabled(JSVCall vc)
    {
        UnityEngine.Collision2D _this = (UnityEngine.Collision2D)vc.csObj;
        var result = _this.enabled;

        JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
    }
Example #19
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (!Data.Paused)
     {
         hit=true;
     }
 }
        public override void OnCollisionStay2D(Collision2D other)
        {
            base.OnCollisionStay2D(other);

            if (other.gameObject.CompareTag(Tag.Elevator))
            {
                fsm.Go<OnElevator>();
            }
            else if (other.gameObject.CompareTag(Tag.Platform))
            {
                float vy = player.rigidbody.velocity.y;
                if (Mathf.Abs(vy) < Mathf.Epsilon)
                {
                    fsm.Go<OnGround>();
                }
            }
            else if (other.gameObject.CompareTag(Tag.Bot))
            {
                Vector3 p1 = player.transform.position;
                Vector3 p2 = other.transform.position;

                Vector3 direction = (p1 - p2).normalized;
                float angle = Vector3.Angle(Vector3.up, direction);

                if (angle <= 30f)
                    return;

                // Die !!!
                player.rigidbody.velocity = Physics2D.gravity;

                fsm.Go<OnFlop>();
            }
        }
Example #21
0
	void OnCollisionEnter2D(Collision2D coll){

			if (coll.gameObject.tag == "Player") {					
			
				coll.gameObject.GetComponent<HealthManager> ().Die ();					
			}
		}
Example #22
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Player" || coll.gameObject.tag == "PlayerAttack")
         dead = true;
     if (coll.gameObject.tag == "Enemy" || coll.gameObject.tag == "Health" || coll.gameObject.tag == "Untagged")
         Physics2D.IgnoreCollision(this.gameObject.collider2D, coll.gameObject.collider2D);
 }
Example #23
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.transform.tag == "Obstacle")
     {
         IsColliding = true;
     }
 }
Example #24
0
 void OnCollisionExit2D(Collision2D coll)
 {
     if (coll.transform.tag == "Obstacle")
     {
         IsColliding = false;
     }
 }
        private void OnCollisionEnter2D( Collision2D c )
        {
            // When a collision is detected, we reflect the velocity of the ball, making it bounce off whatever it hit
            // (This might already be handled by Unity, I'm not sure. It seems to work better with this code.)
            rigidbody2D.velocity = Vector3.Reflect( c.relativeVelocity, c.contacts[0].normal );
            switch( c.gameObject.tag ) {
                case "paddle": // If we hit a paddle...
                    if( c.gameObject.audio != null ) // ...and the paddle has a sound...
                    {
                        c.gameObject.audio.volume = PlayerPrefs.GetInt( "Volume", 50 ) / 100.0f;
                        c.gameObject.audio.Play(); // ...play that sound.
                    }
                    if( this.speed < this.maxSpeed ) // If the current speed is less than the maximum speed...
                        this.speed += this.speedIncrement; // ...increase the speed of the ball.

                    // Run awesome screen shake effect. :D
                    Vector2 shakeMagnitude = c.relativeVelocity.normalized * this.screenShakeEffect;
                    StartCoroutine( Shaker.Shake( Camera.main.transform, .25f, shakeMagnitude ) );

                    break;
                case "bounds":
                    // Play a random bound sound if we collide with the roof/floor bounds.
                    int sndIdx = Random.Range( 0, this.boundSounds.Length );
                    audio.clip = this.boundSounds[sndIdx];
                    audio.volume = PlayerPrefs.GetInt( "Volume", 50 ) / 100.0f;
                    audio.Play();
                    break;
            }

            // Make sure the speed doesn't exceed the maximum
            if( this.speed > this.maxSpeed )
                this.speed = this.maxSpeed;
        }
Example #26
0
		void OnCollisionEnter2D (Collision2D col)
		{

			if (col.gameObject.layer == LayerType.Destroyed)
				return;

			particles.Play();

			audiosource.clip = hitSounds[ Random.Range (0 , hitSounds.Length-1) ];
			audiosource.pitch = Random.Range( 1f , 1.5f);
			audiosource.Play();

			Vector3 incomingForce = (col.transform.position - transform.position).normalized * force;

			if (col.rigidbody != null)
				col.rigidbody.AddForce( incomingForce , ForceMode2D.Impulse   );

			bumper.transform.localScale = new Vector3 (1f,1f,1f);

			LeanTween.value (bumper , bumper.transform.localScale , bumper.transform.localScale * 1.2f , animationTime).setEase(bumpAnimation).setOnUpdate ( (Vector3 val) => 
				{
					bumper.transform.localScale = val;
				}
			);


		}
Example #27
0
 public override void OnCollisionExit2D(Collision2D collision)
 {
     if (string.IsNullOrEmpty(tag.Value) || tag.Value.Equals(collision.gameObject.tag)) {
         collidedGameObject.Value = collision.gameObject;
         exitedCollision = true;
     }
 }
Example #28
0
 void OnCollisionEnter2D(UnityEngine.Collision2D collisionInfo)
 {
     Debug.Log(transform.localScale.x);
     END = GameObject.FindGameObjectWithTag("EndLevel");
     if (transform.localScale.y > collisionInfo.gameObject.transform.localScale.y && collisionInfo.collider.CompareTag("enemy"))
     {
         if (transform.localScale.x < 0)
         {
             transform.localScale += new Vector3(-.2f, .2f, 1);
             Destroy(collisionInfo.gameObject);
             Debug.Log(collisionInfo.collider);
             Debug.Log(collisionInfo);
         }
         else if (transform.localScale.x > 0)
         {
             transform.localScale += new Vector3(.2f, .2f, 1);
             Destroy(collisionInfo.gameObject);
         }
         //transform.localScale += new Vector3(Math.Abs(1.01f), 1.01f);
         //transform.localScale += new Vector3(1.01f, 1.01f);
         Debug.Log("hit something!");
     }
     //if (collisionInfo.collider.tag == "EndLevel")
     //{
     //    FindObjectOfType<GameManager>().CompleteLevel();
     //    return;
     //}
     if (transform.localScale.y < collisionInfo.gameObject.transform.localScale.y)
     {
         FindObjectOfType <GameManager>().CompleteLevel();
         FindObjectOfType <GameManager>().EndGame();
     }
 }
Example #29
0
    public void OnCollisionEnter2D(UnityEngine.Collision2D collider)
    {
        if (collider.gameObject.tag == "PickUp")
        {
            //  flowchart.ExecuteBlock("Sandwich");
            picking_sand = flowchart.GetBooleanVariable("picking");
            picking      = true;
        }
        if (collider.gameObject.tag == "Dog")
        {
            dogNear   = flowchart.GetBooleanVariable("helpDog");
            isdognear = true;
        }

        if (collider.gameObject.tag == "Bully")
        {
            bulask  = flowchart.GetBooleanVariable("bullyAsk");
            bularea = true;
        }

        if (collider.gameObject.tag == "Key")
        {
            picking_key = true;
        }

        if (collider.gameObject.tag == "Door")
        {
            opening_door = true;
        }

        if (collider.gameObject.tag == "Player")
        {
        }
    }
Example #30
0
 //void Update()
 //{
 //    //for (int i = 0; i < lives.Length; i++)
 //    //{
 //    //    if (i < numOfLives)
 //    //    {
 //    //        lives[i].enabled = true;
 //    //    }
 //    //    else
 //    //    {
 //    //        lives[i].enabled = false;
 //    //    }
 //    //}
 //}
 private void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {
     //if (collision.gameObject.tag == "Enemy")
     //{
     //    Invoke(KnockCoroutine(gameObject.GetComponent<Rigidbody2D>()), 0.2f);
     //}
 }
Example #31
0
 private void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {
     if (collision.collider.CompareTag(_tag))
     {
         _flowMachine.TriggerUnityEvent(_unityEventName);
     }
 }
Example #32
0
 // 공과의 충돌
 void OnCollisionEnter2D(Collision2D coll)
 {
     foreach(ContactPoint2D contact in coll.contacts) {
         if(contact.collider.gameObject.tag == "Ball") {
             float speed = contact.collider.gameObject.GetComponent<Ball>().currentSpeed;
             float barWidth = this.GetComponent<Renderer>().bounds.size.x;
             float percentage = (contact.point.x - transform.position.x) / barWidth / 2;
             // 부착 모드인가?
             /*if(state == State.Attached) {
                 AttachedInfo info = new AttachedInfo();
                 info.velocity = contact.collider.GetComponent<Rigidbody2D>().velocity;
                 contact.collider.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
                 // 딱 닿았을 때의 좌표값과 퍼센트치를 저장해줌
                 info.ball = contact.collider.gameObject;
                 info.ballPosition = contact.collider.transform.position;
                 info.barPosition = tf.position;
                 info.percentage = percentage;
                 attachedBalls.Add(info);
             } else {*/
                 contact.collider.GetComponent<Rigidbody2D>().AddForce(new Vector2(percentage * 5 * (speed * 50), 0));
                 if(contact.collider.GetComponent<Rigidbody2D>().velocity.y < 0)
                     contact.collider.GetComponent<Rigidbody2D>().velocity *= -1;
             //}
             break;
         }
     }
 }
 static public int GetContacts(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.Collision2D      self = (UnityEngine.Collision2D)checkSelf(l);
         UnityEngine.ContactPoint2D[] a1;
         checkArray(l, 2, out a1);
         var ret = self.GetContacts(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Example #34
0
 void OnCollisionEnter2D(Collision2D col)
 {
     Destroy(col.gameObject);
     GameObject boom = Instantiate(Resources.Load<GameObject>("PlasmaExplosion"), col.gameObject.transform.position, col.gameObject.transform.rotation) as GameObject;
     boom.name = "Explosion";
     Destroy(boom, 15f);
 }
 static public int get_relativeVelocity(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.Collision2D self = (UnityEngine.Collision2D)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.relativeVelocity);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.Collision2D o;
         o = new UnityEngine.Collision2D();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Example #37
0
 private void OnCollisionExit2D(UnityEngine.Collision2D collision)
 {
     if (text)
     {
         text.SetActive(false);
     }
 }
 void OnCollisionEnter2D(Collision2D other)
 {
     if (DestroyInColisionEvent)
     {
         CheckCollider(other.gameObject);
     }
 }
 /// <summary>
 /// Explodes when the enemy hits the player.
 /// </summary>
 /// <param name="collision">The collision that the enemy was involved in.</param>
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.collider.tag == "Player")
     {
         Explode();
     }
 }
    // not supported
#else
        // ReSharper disable once UnusedMember.Local
        private void OnCollisionEnter2D(Collision2D coll) {
            if (!_isValid) {
                return;
            }

            KillableToAlert.CollisionEnter2D(coll);
        }
Example #41
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Player")
     {
         explode();
         destroy_all();
     }
 }
Example #42
0
 private void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {//when player attach NPC it will targeting the block in flowchart to start the dialog
     if (collision.gameObject.CompareTag("player"))
     {
         Block targetBlock = talkFlowchart.FindBlock(onCollosionEnter);
         talkFlowchart.ExecuteBlock(targetBlock);
     }
 }
Example #43
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (Managers.GameManager.IsRunning)
     {
         if (coll.gameObject.tag == "Player")
             UnityEngine.SceneManagement.SceneManager.LoadScene(level);
     }
 }
Example #44
0
 void OnCollisionEnter2D(UnityEngine.Collision2D hit)
 {
     if (hit.gameObject.tag == "gold")
     {
         PlayerPrefs.SetInt("money", PlayerPrefs.GetInt("money") + 50);
         Destroy(money);
     }
 }
Example #45
0
 public override void OnCollisionEnter2D(Collision2D col)
 {
     base.OnCollisionEnter2D(col);
     if (col.gameObject.tag == TagManager.deadly)
     {
         Kill();
     }
 }
 void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {
     if (collision.gameObject.tag != "projectile" && collision.gameObject.tag != "Playerprojectile")
     {
         StartCoroutine(deathanim());;
         Debug.Log("collision");
     }
 }
 public void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {
     if (collision.gameObject.CompareTag("Ground") ||
         collision.gameObject.CompareTag("Player"))
     {
         isGrounded = true;
     }
 }
    //void Give

    //{
    //    if (findPlayer)
    //    {
    //        if (GameObject.FindGameObjectWithTag("Player"))
    //        {
    //            GetComponent<Player>().TakeDamage(damage);

    //        }
    //    }
    //}

    private void OnCollisionStay2D(UnityEngine.Collision2D collision)
    {
        if (collision.gameObject.tag == "Player")//or tag
        {
            gameObject.transform.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Static;
            TimerAttack.playerTouched = true;
        }
    }
Example #49
0
        void OnCollisionEnter2D(Collision2D coll)
        {
            HandleHit(coll.collider.gameObject);

            if (OnCollisionPrefab != null)
                Instantiate(OnCollisionPrefab, new Vector3(coll.contacts[0].point.x, coll.contacts[0].point.y, transform.position.z), transform.rotation);
            Destroy(gameObject);
        }
Example #50
0
		void OnCollisionStay2D( Collision2D coll ) {
			DrawDebugStar( coll.contacts[0].point, SizeMlt / 30f, Color.blue );
			Debug.DrawLine( coll.contacts[0].point, coll.contacts[0].point + coll.contacts[0].normal * SizeMlt, Color.green );
			Debug.DrawLine( coll.contacts[0].point, coll.contacts[0].point + coll.relativeVelocity * SizeMlt, Color.red );
			var projection = coll.contacts[0].normal * ( coll.contacts[0].normal.x * coll.relativeVelocity.x + coll.contacts[0].normal.y * coll.relativeVelocity.y );
			Debug.DrawLine( coll.contacts[0].point, coll.contacts[0].point + projection * SizeMlt, Color.yellow );
			Debug.DrawLine( coll.contacts[0].point, coll.contacts[0].point + GetComponent<Rigidbody2D>().velocity * SizeMlt, new Color( 1, 130f / 255f, 148f / 255f ) );
		}
Example #51
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (Managers.GameManager.IsRunning)
     {
         if (coll.gameObject.tag == "Enemy")
             Physics2D.IgnoreCollision(gameObject.GetComponent<Collider2D>(), coll.gameObject.GetComponent<Collider2D>());
     }
 }
Example #52
0
 private void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {
     if (collision.gameObject.tag.Equals("Enemy"))
     {
         Destroy(gameObject);
         collision.gameObject.GetComponent <EnemyControl>().DecreaseHealth(damage);
         //Destroy(collision.gameObject);//destroy enemy
     }
 }
Example #53
0
 private void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {
     if (collision.collider.gameObject.CompareTag("Player"))
     {
         bomb.Play();
         Invoke("DieMessage", 0.0f);
         Invoke("Restart", delay);
     }
 }
Example #54
0
 public void OnCollisionStay2D(UnityEngine.Collision2D collision)
 {
     if (collision.gameObject.tag == "Plant")
     {
         attackingPlant = true;
         FindObjectOfType <AudioManager>().Play("ZombieBite1");
         collision.gameObject.GetComponent <ItemObjectScript>().takeDamage(1);
     }
 }
Example #55
0
 public void OnCollisionExit2D(UnityEngine.Collision2D collision)
 {
     //Check if exiting plant
     if (collision.gameObject.tag == "Plant")
     {
         //No longer attacking plant
         attackingPlant = false;
     }
 }
Example #56
0
    void OnCollisionEnter2D(UnityEngine.Collision2D other)
    {
        if (!contactTypes.Contains(ContactType.collision2d))
        {
            return;
        }

        DamageOtherObjectIfAppropriate(other.gameObject);
    }
Example #57
0
 void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {
     if (collision.collider.gameObject.CompareTag("Wall")) // for example wall is called Wall
     {
         //Debug.Log("collided with " + collision.collider.gameObject.name);
         movement = -movement;
         rb.AddForce(movement * maxSpeed);
     }
 }
 private void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {
     if (collision.gameObject.tag == "Sword")
     {
         gameObject.GetComponent <WeaponSwitcher>().weaponHolding = gameObject.GetComponent <WeaponSwitcher>().weaponList[0];
         flow.ExecuteBlock("Regular Sword");
         Destroy(collision.gameObject);
     }
 }
Example #59
0
 private void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {
     Debug.Log("Something entered my collider");
     if (collision.gameObject.GetComponent <Bomb>() != null && !isActivated)
     {
         transform.position = new Vector3(transform.position.x, transform.position.y - 0.2f, transform.position.z);
         isActivated        = true;
     }
 }
Example #60
0
 private void OnCollisionEnter2D(UnityEngine.Collision2D collision)
 {
     //Debug.Log("Va cham");
     if (collision.gameObject.tag == "ground")
     {
         //Debug.Log("Destroy");
         Destroy(gameObject, 1f);
     }
 }