コード例 #1
0
ファイル: WeaponScript.cs プロジェクト: Hackadol/ourgame
    public void Attack(float angle, float force, bool reverse)
    {
        var shotTransform = Instantiate(shotPrefab) as Transform;

        // Assign position
        shotTransform.position = transform.position;
        float x = force * (90 - angle) / 90;
        float y = force * angle / 90;

        // The is enemy property
        DrugScript  shot = shotTransform.gameObject.GetComponent <DrugScript>();
        Rigidbody2D rb   = shot.GetComponent <Rigidbody2D>();

        if (rb != null)
        {
            if (!reverse)
            {
                rb.AddForce(new Vector2(x, y));
            }
            else
            {
                rb.AddForce(new Vector2(-x, y));
            }
        }
    }
コード例 #2
0
ファイル: MineScript.cs プロジェクト: Hackadol/ourgame
    private void OnTriggerEnter2D(Collider2D collision)
    {
        DrugScript dr = collision.transform.GetComponent <DrugScript>();

        if (dr != null)
        {
            Destroy(this.gameObject);
        }
    }
コード例 #3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.name == "VirusStopper")
        {
            stop    = true;
            stopPos = this.transform.position;
        }
        DrugScript dr = collision.transform.GetComponent <DrugScript>();

        if (dr != null)
        {
            Destroy(this.gameObject);
        }
    }