コード例 #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (canDamage)
     {
         collision.BroadcastMessage("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
     }
 }
コード例 #2
0
    void onTriggerEnterEvent(Collider2D col)
    {
        if (col.tag == "WolfPickup")
        {
            hasWolfForm = true;
            audio.PlayOneShot(pickupSound);
            Destroy(col.gameObject);
        }
        else if (col.tag == "HammerPickup")
        {
            hasHammer = true;
            SceneManager.LoadScene(2);
            audio.PlayOneShot(pickupSound);
            Destroy(col.gameObject);
        }
        else if (col.tag == "KeyPickup")
        {
            hasKey = true;
            audio.PlayOneShot(pickupSound);
            Destroy(col.gameObject);
        }
        else if (col.tag == "HealthPickup")
        {
            health += 25;
            audio.PlayOneShot(pickupSound);
            Destroy(col.gameObject);
        }


        if (col.tag == "Door" && hasKey)
        {
            col.BroadcastMessage("OpenDoor", SendMessageOptions.DontRequireReceiver);
            hasKey = false;
        }
    }
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Enemy")
     {
         float baseDamage = heavyMeleeAbilityStats.GetDamage();
         collision.BroadcastMessage("TakeDamage", baseDamage * currentDamageScale);
     }
 }
コード例 #4
0
 void OnTriggerEnter2D(Collider2D ent)
 {
     if (ent.tag == "Player")
     {
         print("broadcasting to player");
         ent.BroadcastMessage("Die", "Crushed");
     }
 }
コード例 #5
0
 private void OnTriggerEnter2D(Collider2D _Collision)
 {
     if (_Collision.CompareTag("Player") && _HealingAmmount > 0)
     {
         _Collision.BroadcastMessage("Heal", _HealingAmmount);
         Die();
     }
 }
コード例 #6
0
ファイル: ImmunePowerup.cs プロジェクト: akarina7/DM
 private void OnTriggerEnter2D(Collider2D _Collision)
 {
     if (_Collision.CompareTag("Player") && _ImmuneDuration > 0)
     {
         _Collision.BroadcastMessage("StartInvincibility", _ImmuneDuration);
         Die();
     }
 }
    //private void OnTriggerStay2D(Collider2D collision)
    //{
    //	if (enableHeal){
    //		if (collision.tag == "Player"){
    //			collision.BroadcastMessage("RestoreHealthBy", amountPerHeal);
    //		}
    //	}
    //	enableHeal = false;
    //}

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            collision.BroadcastMessage("RestoreHealthBy", amountPerHeal);
        }
        collider2D.enabled = false;
    }
コード例 #8
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Bit Receptor")
     {
         other.BroadcastMessage("beginPulse");
         End_Journey();
     }
 }
コード例 #9
0
ファイル: Projectile.cs プロジェクト: brunothg/BabyQuinn
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject != emmitedFrom)
     {
         Debug.Log("Hit Target - Damage");
         collision.BroadcastMessage("OnProjectileDamage", this, SendMessageOptions.DontRequireReceiver);
         Destroy(this.gameObject);
     }
 }
コード例 #10
0
ファイル: DamageTrigger.cs プロジェクト: tonyli99/GGJ2020
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (!collision.CompareTag(tagToDamage))
     {
         return;
     }
     //Debug.Log(name + " damaged " + collision, collision);
     collision.BroadcastMessage("TakeDamage", attackDamage);
 }
コード例 #11
0
ファイル: Killable.cs プロジェクト: tvezzani/DuckRunner
 private void OnTriggerEnter2D(Collider2D col)
 {
     if (col.tag == "Coin")
     {
         col.BroadcastMessage("Kill");
     }
     else if (lives > 0 && col.tag != "Wolf")
     {
         if (extraLives[lives - 1] != null)
         {
             extraLives[lives - 1].killed = true;
         }
         else if (extraLives[lives - 2] != null)
         {
             extraLives[lives - 2].killed = true;
         }
         else if (extraLives[lives - 3] != null)
         {
             extraLives[lives - 3].killed = true;
         }
         lives -= 1;
         col.BroadcastMessage("Kill");
     }
     else
     {
         GameObject d = Instantiate(deadObject);
         d.transform.position = transform.position;
         if (isMainPlayer)
         {
             GameController.lose = true;
         }
         else
         {
             StaticContainer.ducklingsSurvived -= 1;
         }
         if (_parent != null)
         {
             _parent.lives -= 1;
         }
         Destroy(gameObject);
     }
 }
コード例 #12
0
ファイル: Portal.cs プロジェクト: lukebandy/Reloop
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.transform.CompareTag("Player") || collision.transform.CompareTag("Ghost"))
     {
         if (!audioSource.isPlaying)
         {
             audioSource.Play();
         }
         collision.BroadcastMessage("Freeze");
         FindObjectOfType <LevelLoader>().LoadLevel(SceneManager.GetActiveScene().buildIndex + 1);
     }
 }
コード例 #13
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (tag != "Whiff")
     {
         if (other.tag == "Whiff")
         {
             other.GetComponentInParent <PlayerStateMachine>().BroadcastMessage("GetHit", punch);
         }
         else if (other.CompareTag(GetComponentInParent <PlayerStateMachine>().tag) == false && other.tag != tag)
         {
             other.BroadcastMessage("GetHit", punch);                 // send data about what attack just hit the player.
             transform.parent.GetComponentInChildren <SpriteRenderer>().sortingOrder = 1;
         }
     }
 }
コード例 #14
0
ファイル: Enemy.cs プロジェクト: dylannorthrup/space-shooter
    private void OnTriggerEnter2D(Collider2D other)
    {
        // If this is an EnemyLaser, ignore it
        if (other.CompareTag("EnemyLaser"))
        {
            return;
        }

        // If the other item is a player
        if (other.CompareTag("Player"))
        {
            // Damage player
            Player player = other.transform.GetComponent <Player>();
            if (player != null)
            {
                player.Damage();
            }

            //// Start our dying process
            StartDying();
        }

        // If the other item is a laser, start dying and tell the
        // laser to start dying as well.
        if (other.CompareTag("Laser"))
        {
            StartDying();
            // Get reference to player and invoke AddToScore(score)
            Player p = GameObject.Find("Player").GetComponent <Player>();
            if (p != null)
            {
                p.AddToScore(_myScore);
            }

            // Tell the laser to start dying
            other.BroadcastMessage("StartDying");
        }
    }
コード例 #15
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     collision.BroadcastMessage("ReachedMiddlePoint", SendMessageOptions.DontRequireReceiver);
 }
コード例 #16
0
ファイル: walkingTargetScript.cs プロジェクト: WT26/Steampunk
 void OnTriggerEnter2D(Collider2D other)
 {
     other.BroadcastMessage("targetReached");
 }
コード例 #17
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     collision.BroadcastMessage(message, SendMessageOptions.DontRequireReceiver);
 }