示例#1
0
    public void OnTriggerEnter2D(Collider2D collider)
    {
        PlayerMoveControler player = collider.GetComponent <PlayerMoveControler>();

        player.Hit(-2, new Vector2(0.0f, 0.0f));

        int        i            = Random.Range(0, Weapons.Length);
        BaseWeapon weaponToGrab = Weapons[i];

        if (weaponToGrab.id == player.weapon.id)
        {
            if (i == Weapons.Length - 1)
            {
                weaponToGrab = Weapons[(i - 1)];
            }
            else
            {
                weaponToGrab = Weapons[(i + 1)];
            }
        }

        player.SetWeapon(weaponToGrab);
        SoundManager.instance.PlaySound(soundToPlay);
        GameObject.Destroy(gameObject, 0.1f);
    }
示例#2
0
    public void OnCollisionEnter2D(Collision2D collision)
    {
        if (isAlive == false)
        {
            return;
        }

        PlayerMoveControler player = collision.collider.GetComponent <PlayerMoveControler>();

        if (player != null)
        {
            player.Hit(1, Vector2.zero);
        }
    }