Exemple #1
0
    public override void OnContact()
    {
        PlayerBehavior player = ContactObject.GetComponent <PlayerBehavior> ();

        if (player)
        {
            player.Health -= Value;
            if (_knockback)
            {
                player.DisableMovementControl();
                Rigidbody2D playerRigidbody2D = player.GetComponent <Rigidbody2D> ();
                Vector2     vel             = playerRigidbody2D.velocity;
                float       _knockbackForce = 300f;
                playerRigidbody2D.AddForce(vel.normalized * -_knockbackForce);
                Wait(0.1f, () => {
                    player.EnableMovementControl();
                    if (_volatile)
                    {
                        Destroy(this.gameObject);
                    }
                });
            }

            if (_volatile && !_knockback)
            {
                Destroy(this.gameObject);
            }
        }
    }
Exemple #2
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         GameObject ContactObject;
         ContactObject = collision.gameObject;
         ContactObject.GetComponent <CharacterPreset>().moveSpeed += 0.2f;
     }
 }
Exemple #3
0
    public override void OnContact()
    {
        PlayerBehavior player = ContactObject.GetComponent <PlayerBehavior> ();

        if (player)
        {
            player.Point += Value;
            Destroy(this.gameObject);
        }
    }