Ejemplo n.º 1
0
    private void UpdateBuildingItemList(BuildingItem[] buildingItems)
    {
        buildingLayoutGroup.DetachChildren();

        foreach (GameObject buildingButton in buildingButtons)
        {
            Destroy(buildingButton);
        }

        buildingButtons = new GameObject[buildingItems.Length];
        int index = 0;

        foreach (BuildingItem buildingItem in buildingItems)
        {
            GameObject buildingButton = Instantiate(buildingItemPrefab, buildingLayoutGroup);
            buildingButtons[index] = buildingButton;
            ++index;

            BuildingMenuItem buildingMenuItem = buildingButton.GetComponent <BuildingMenuItem>();
            buildingMenuItem.image.sprite  = buildingItem.buildingSprite;
            buildingMenuItem.nameText.text = buildingItem.name;
            buildingMenuItem.SetCallBack(() =>
            {
                builder.SetCurrentBuilding(buildingItem.buildingPrefab);
                menuManager.CloseMenu(Menu.MenuName.Building);
                freezer.InteractionUnfreeze();
            });
        }
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        allMenus.Add(this);
        Vector3 pos      = new Vector3(0, 1, 0);
        float   rotation = 0;

        foreach (BuildingMenuItem menuItem in menuItemList)
        {
            BuildingMenuItem newItem = Instantiate(menuItem, Vector3.zero, Quaternion.identity) as BuildingMenuItem;
            newItem.node                    = node;
            newItem.transform.parent        = transform;
            newItem.transform.localPosition = Quaternion.Euler(0, 0, rotation) * pos;
            menuItemInstanceList.Add(newItem);
            rotation += 360f / menuItemList.Length;
        }
        Hide();
    }
Ejemplo n.º 3
0
    public void Spawn(List <BuildingItemData> items)
    {
        DestroySpawned();

        if (items == null || items.Count == 0)
        {
            return;
        }

        foreach (var item in items)
        {
            GameObject go = Instantiate(Prefab, ItemParent);
            spawned.Add(go);
            BuildingMenuItem i = go.GetComponent <BuildingMenuItem>();
            i.Icon     = item.Icon;
            i.BGColour = item.GetColour();
            i.Name     = item.Name;
            i.Count    = item.Count;
            i.Prefab   = item.Prefab;
            i.UpdateVisuals();
        }
    }
Ejemplo n.º 4
0
    public void Start()
    {
        Debug.Assert(freezer, "Freezer doesn't set");
        Debug.Assert(buildingItemList, "Building Item List doesn't set");
        Debug.Assert(builder, "Builder doesn't set");
        Debug.Assert(menuManager, "Menu Manager doesn't set");
        Debug.Assert(buildingLayoutGroup, "Building Layout Group doesn't set");
        Debug.Assert(buildingTypeLayoutGroup, "Building Type Layout Group doesn't set");
        Debug.Assert(buildingItemPrefab, "Building Item Prefab doesn't set");
        Debug.Assert(buildingTypeItemPrefab, "Building Type Item Prefab doesn't set");

        foreach (BuildingItemList.BuildingTypeItemToBuildingItem buildingTypeItemToBuildingItem in
                 buildingItemList.buildingTypeItemToBuildingItems)
        {
            GameObject buildingTypeItem = Instantiate(buildingTypeItemPrefab, buildingTypeLayoutGroup);

            BuildingMenuItem buildingMenuItem = buildingTypeItem.GetComponent <BuildingMenuItem>();
            buildingMenuItem.image.sprite = buildingTypeItemToBuildingItem.buildingTypeItem.buildingSprite;

            buildingMenuItem.SetCallBack(() => UpdateBuildingItemList(buildingTypeItemToBuildingItem.buildingItems));
        }

        UpdateBuildingItemList(buildingItemList.buildingTypeItemToBuildingItems[0].buildingItems);
    }