Esempio n. 1
0
    public void Instantiate()
    {
        if (Input.GetMouseButton(1))
        {
            Remove();
            return;
        }
        Item item = new Item();

        item.ID   = character.ID;
        item.name = character.name;
        item.type = ItemType.Other;
        item.obj  = Instantiate(itemObj);

        cursor.SetCurrent(item);
    }
Esempio n. 2
0
 public void SetCursorItem()
 {
     cursor.SetCurrent(itemIndex);
 }
Esempio n. 3
0
    void Start()
    {
        for (int i = 0; i < itemHandler.itemPack.items.Count; i++)
        {
            var buttonObj = Instantiate(betterBarButtonPrefab, betterBarContents, false);
            var x         = i;
            buttonObj.AddComponent <Button>().onClick.AddListener(new UnityAction(() => {
                currentActiveButton = x;
                cursor.SetCurrent(x);
            }));
            var img = buttonObj.GetComponent <Image>();
            images.Add(img);
            if (itemHandler.itemPack.items[i].assetID != "")
            {
                if (ResourceManager.Instance.resourceExists(itemHandler.itemPack.items[i].assetID) &&
                    ResourceManager.GetAsset <Object>(itemHandler.itemPack.items[i].assetID) as EntityBlueprint)
                {
                    var print = ResourceManager.GetAsset <EntityBlueprint>(itemHandler.itemPack.items[i].assetID);
                    buttonObj.transform.Find("MaskObj").Find("StandardImage").gameObject.SetActive(false);
                    var scaler = buttonObj.transform.Find("MaskObj").Find("EntityDisplay").transform;

                    switch (print.intendedType)
                    {
                    case EntityBlueprint.IntendedType.AirCarrier:
                    case EntityBlueprint.IntendedType.GroundCarrier:
                    case EntityBlueprint.IntendedType.Yard:
                    case EntityBlueprint.IntendedType.Trader:
                    case EntityBlueprint.IntendedType.WeaponStation:
                    case EntityBlueprint.IntendedType.CoreUpgrader:
                    case EntityBlueprint.IntendedType.DroneWorkshop:
                        scaler.localScale = new Vector3(0.15f, 0.15f, 1);
                        break;

                    default:
                        scaler.localScale = new Vector3(0.3f, 0.3f, 1);
                        break;
                    }

                    var sdh = buttonObj.GetComponentInChildren <SelectionDisplayHandler>();
                    sdh.AssignDisplay(print, print.intendedType == EntityBlueprint.IntendedType.Drone ? DroneUtilities.GetDefaultData(print.customDroneType) : null);
                }
                else
                {
                    var obj = itemHandler.itemPack.items[i].obj;
                    SetStandardImage(obj, buttonObj, 0.5f);
                }
            }
            else
            {
                var obj = itemHandler.itemPack.items[i].obj;
                SetStandardImage(obj, buttonObj, 0.5f);
            }
        }

        for (int i = 0; i < globalButtons.Count; i++)
        {
            AddOptionButton(i, globalButtons);
        }

        for (int i = 0; i < extraButtons.Count; i++)
        {
            AddOptionButton(i, extraButtons);
        }
        UpdateActiveButtons();
    }