示例#1
0
    private void DropItem(Transform aPosition, GameObject item)
    {
        //GameObject temp = new GameObject(item.name);
        //temp.AddComponent(typeof(SpriteRenderer));
        //temp.GetComponent<SpriteRenderer>().sprite = item.sprite;
        ////temp.GetComponent<SpriteRenderer>().color = Color.red;
        //temp.AddComponent<PolygonCollider2D>();
        //temp.AddComponent<Rigidbody2D>();
        //temp.GetComponent<Rigidbody2D>().gravityScale = 0;
        //temp.GetComponent<Rigidbody2D>().drag = item.Drag;
        //temp.GetComponent<Rigidbody2D>().angularDrag = item.Drag;
        //temp.AddComponent<HingeJoint2D>();
        //temp.AddComponent<ItemController>();
        //temp.GetComponent<ItemController>().SetItem(item, temp.GetComponent<Rigidbody2D>(), temp.GetComponent<HingeJoint2D>());

        GameObject temp = Instantiate(item);


        temp.transform.position = aPosition.position;
        temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y + 20, transform.position.z);
        aPosition.gameObject.GetComponent <DropPoint>().EXPLOSION();
        temp.GetComponent <ItemController>().StartDrop(aPosition);

        myRequestManger.AddItemToRequestManager(temp);
    }