Пример #1
0
    public bool AssignHaulableItem(HaulableItem item)
    {
        if (item == null)
        {
            haulableItem = null;
            return(true);
        }

        if (haulableItem != null)
        {
            Debug.LogError("Trying to put a haulableItem where there is one");
            return(false);
        }

        haulableItem = item;
        haulableItem.RegisterOnRemoved(OnHaulableItemRemoved);
        return(true);
    }
    public void OnHaulableItemCreated(HaulableItem item)
    {
        Debug.Log("Item is being created");
        GameObject item_go = new GameObject();

        //Add data and UI to map
        haulableGameObjectMap.Add(item, item_go);

        //Set up general info about the GO
        item_go.name = item.ObjectType + "_" + item.Tile.X + "_" + item.Tile.Y;
        item_go.transform.position = new Vector3(item.Tile.X, item.Tile.Y);
        item_go.transform.SetParent(this.transform, true);

        SpriteRenderer sr = item_go.AddComponent <SpriteRenderer> ();

        sr.sprite           = GetSpriteForHaulableItem(item);
        sr.sortingLayerName = "Fixture";



        //TODO: Implement these
        //item.RegisterOnChanged (OnFixtureChanged);
        item.RegisterOnRemoved(OnHaulableItemRemoved);
    }