コード例 #1
0
ファイル: Player.cs プロジェクト: manfredhq/itchio
    private void OnTriggerEnter2D(Collider2D collision)
    {
        IBonus bonus = collision.gameObject.GetComponent <IBonus>();

        if (bonus != null)
        {
            bonus.makeAction(this);
            Destroy(collision.gameObject);
        }
        IWeapon weapon = collision.gameObject.GetComponent <IWeapon>();

        if (weapon != null)
        {
            GameObject newWeapon = Instantiate(collision.gameObject, new Vector3(10000, 10000, -1000), Quaternion.identity);
            newWeapon.GetComponent <SpriteRenderer>().sprite = null;
            newWeapon.AddComponent <NoDestroy>();
            GetComponent <Shooting>().weapon = newWeapon;
        }
        Destroy(collision.gameObject);
    }