protected override void DrawSingleEquipField(SerializedProperty element, Rect rect)
        {
            base.DrawSingleEquipField(element, rect);

            if (playerPrefab.objectReferenceValue != null)
            {
                var obj = playerPrefab.objectReferenceValue as GameObject;
                if (obj != null)
                {
                    if (element.FindPropertyRelative("findDynamic").boolValue == false)
                    {
                        return;
                    }

                    string    path  = element.FindPropertyRelative("equipTransformPath").stringValue;
                    Transform child = null;
                    InventoryUtility.FindChildTransform(obj.transform, path, ref child);
                    if (child == null || path == "")
                    {
                        rect.y += 36;

                        EditorGUI.HelpBox(rect, "Object with path \"" + path + "\" was not found.", MessageType.Error);
                    }
                }
            }
        }
コード例 #2
0
        public static bool CanShow(int eid)
        {
            var partnerData = InventoryUtility.GetPartnerData(eid);
            var presetNames = InventoryUtility.GetAllEquipmentPresetNameContains(eid);

            return(partnerData != null || (presetNames != null && presetNames.Count > 0));
        }
コード例 #3
0
        private void SetPreviewObject(InventoryItemBase item)
        {
            item.gameObject.SetActive(true);
            item.transform.SetParent(itemPreviewParent);
            item.transform.localPosition = Vector3.zero;
            item.transform.localRotation = Quaternion.identity;
            item.transform.localScale    = Vector3.one;
            InventoryUtility.SetLayerRecursive(item.gameObject, itemPreviewLayer); // TODO: Move itemPreviewLayer to settings

            var rigids = item.gameObject.GetComponentsInChildren <Rigidbody>();

            foreach (var rigid in rigids)
            {
                rigid.isKinematic = true;
            }

            var renderer = item.gameObject.GetComponentInChildren <Renderer>();

            if (renderer != null)
            {
                var totalSize = (renderer.bounds.size.x + renderer.bounds.size.y + renderer.bounds.size.z);

                if (itemPreviewCamera.orthographic)
                {
                    itemPreviewCamera.orthographicSize = totalSize * cameraDistanceToScaleRatio;
                }
                else
                {
                    itemPreviewCamera.transform.position = new Vector3(0, 0, -totalSize * cameraDistanceToScaleRatio);
                }
            }
        }
コード例 #4
0
        public void Open()
        {
            selectedItem   = null;
            selectedModule = null;

            gridItems.Clear();

            foreach (Item item in InventoryUtility.InvArmorEquips(Main.LocalPlayer))
            {
                if (item.IsAir)
                {
                    continue;
                }

                if (item.ModItem is ModularItem modularItem)
                {
                    UIModularItem uiModularItem = new UIModularItem(modularItem)
                    {
                        Width  = { Pixels = 48 },
                        Height = { Pixels = 48 }
                    };
                    uiModularItem.OnClick += args =>
                    {
                        args.Handled = true;

                        OpenItem(modularItem);
                    };

                    gridItems.Add(uiModularItem);
                }
            }
        }
コード例 #5
0
        public virtual void RepaintAll()
        {
            if (isActiveAndEnabled == false || defaultStatusRowPrefab == null)
            {
                return;
            }

            if (statsCollection == null)
            {
                return;
            }

            // Get rid of the old
            foreach (Transform child in container)
            {
                Destroy(child.gameObject);
            }

            // Maybe make a pool for the items? See some spikes...
            foreach (var stat in statsCollection)
            {
                // Maybe make a pool for the items? See some spikes...
                if (stat.Value.Count(o => o.definition.showInUI) == 0)
                {
                    continue; // No items to display in this category.
                }
                // stat.Key is category
                // stat.Value is all items in category
                StatCategoryUI cat = null;
                if (statusCategoryPrefab != null)
                {
                    cat = GetNewCategoryUIInstance(stat.Key);
                    cat.Repaint(stat.Key);
                    cat.transform.SetParent(container);
                    InventoryUtility.ResetTransform(cat.transform);
                }

                foreach (var s in stat.Value)
                {
                    if (s.definition.showInUI == false)
                    {
                        continue;
                    }

                    var obj = GetNewStatUIInstance(s);
                    obj.Repaint(s);
                    obj.transform.SetParent(cat != null ? cat.container : container);

                    UIUtility.ResetTransform(obj.transform);
                }
            }
        }
コード例 #6
0
        private void CreateWapper(ItemCollectionSlotUI prefab, uint index)
        {
            var c = Instantiate <ItemCollectionSlotUI>(prefab);

            c.transform.SetParent(inventoryCollection.container);
            InventoryUtility.ResetTransform(c.transform);

            c.itemCollection = inventoryCollection;
            c.index          = index;
            inventoryCollection.items[index] = c;

            c.Repaint();
        }
コード例 #7
0
        private void Show(int eid)
        {
            var partnerData = InventoryUtility.GetPartnerData(eid);
            var presetNames = InventoryUtility.GetAllEquipmentPresetNameContains(eid);
            var showPreset  = presetNames != null && presetNames.Count > 0;
            var showPartner = partnerData != null;

            _goLeftPlaceholder.SetActive(!showPreset);
            _goScrollView.SetActive(showPreset);
            _goRightPlaceholder.SetActive(!showPartner);
            _goPartnerItem.SetActive(showPartner);
            _partnerCellController.Fill(partnerData);
            UpdatePresetNameList(presetNames);
        }
コード例 #8
0
    protected override void OnSlotEndDrag(GameObject go, ItemSlot slot)
    {
        ItemSlot target = go.GetComponentInParent <ItemSlot>();

        if (Type != OpenType.Preview && target && slot != target && grid.ContainsItem(target))
        {
            slot.Swap(target);
        }
        else if (Type != OpenType.Preview && go.GetComponentInParent <DiscardButton>() == discardButton)
        {
            InventoryUtility.DiscardItem(Handler, slot.Item, discardButton.transform.position);
        }
        else if (WindowsManager.IsWindowOpen <ItemSelectionWindow>(out var selecter) && (target && selecter.ContainsSlot(target) || go == selecter.PlacementArea))
        {
            selecter.Place(slot);
        }
コード例 #9
0
        private void RefreshTips()
        {
            if (_tipsBackground == null)
            {
                return;
            }

            if (Data != null && LTPartnerEquipMainController.instance != null &&
                LTPartnerEquipMainController.instance.CurrentEquipmentViewState == LTPartnerEquipMainController.EquipmentViewState.PresetEditView &&
                _tipsBackground != null)
            {
                bool isEquiped  = InventoryUtility.IsEquipped(Data.Eid);
                bool isInPreset = InventoryUtility.IsInEquipmentPreset(Data.Eid);
                _tipsBackground.gameObject.SetActive(isEquiped || isInPreset);
                _tipsBackground.spriteName = isEquiped ? "Equipment_Di_2" : "Equipment_Di_1";
                _tipsLabel.text            = isEquiped ? EB.Localizer.GetString("ID_EQUIPMENT_PRESET_DRESSED") : EB.Localizer.GetString("ID_EQUIPMENT_PRESET_USED");
            }
            else
            {
                _tipsBackground.gameObject.SetActive(false);
            }
        }
コード例 #10
0
ファイル: DiscardButton.cs プロジェクト: Zetan9565/Project-ZT
    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.button == PointerEventData.InputButton.Left)
        {
#if UNITY_STANDARD
            if (DragableManager.Instance.IsDraging)
            {
                ItemSlotAgent source = DragableManager.Instance.Current as ItemSlotAgent;
                if (source)
                {
                    InventoryUtility.DiscardItem(Window.Handler, source.Item);
                    source.FinishDrag();
                }
            }
            else
            {
                OpenDiscardWindow();
            }
#elif UNITY_ANDROID
            OpenDiscardWindow();
            FloatTipsPanel.ShowText(transform.position, "将物品拖拽到此按钮丢弃,或者点击该按钮进行多选。", 3);
#endif
        }
    }
コード例 #11
0
 private void Awake()
 {
     sharedInstance = this;
 }
コード例 #12
0
        public virtual void Repaint(InventoryItemBase item)
        {
            SetText(itemName, item.name, true);
            SetText(itemDescription, item.description, true);
            SetText(itemAmount, item.currentStackSize + "X", true);
            SetText(itemRarity, item.rarity.name, true);
            if (useItemRarityColor && itemRarity != null)
            {
                itemRarity.color = item.rarity.color;
            }

            SetText(itemCategory, item.category.name);
            SetText(itemCooldownTime, item.cooldownTime.ToString(), true);

            DestroyChildren(propertyContainer);
            foreach (var stat in item.stats)
            {
                var row = Instantiate <StatRowUI>(propertyRowPrefab);
                row.transform.SetParent(propertyContainer);
                InventoryUtility.ResetTransform(row.transform);
                row.text.text = string.Format("{0} {1}", stat.value, stat.stat.name);

                if (stat.floatValue < 0f)
                {
                    // - sign is added auto.
                    row.text.text  = row.text.text.Remove(0, 1);
                    row.text.text  = "- " + row.text.text;
                    row.text.color = propertyNegativeColor;
                }
                else if (stat.floatValue > 0f)
                {
                    if (stat.actionEffect == StatDecorator.ActionEffect.Decrease)
                    {
                        row.text.text  = "- " + row.text.text;
                        row.text.color = propertyNegativeColor;
                    }
                    else
                    {
                        row.text.text  = "+ " + row.text.text;
                        row.text.color = proprertyPositiveColor;
                    }
                }
            }


            DestroyChildren(usageRequirementPropertiesContainer);
            foreach (var stat in item.usageRequirement)
            {
                var row = Instantiate <UsageRequirementRowUI>(usageRequirementPropertyRowPrefab);
                row.transform.SetParent(usageRequirementPropertiesContainer);
                InventoryUtility.ResetTransform(row.transform);
                row.text.text = string.Format("{0} {1}", stat.value, stat.stat.name);

                if (stat.CanUse(PlayerManager.instance.currentPlayer.inventoryPlayer))
                {
                    row.text.color = usageRequirementPositiveColor;
                }
                else
                {
                    row.text.color = usageRequirementNegativeColor;
                }
            }

            SetText(itemWeight, item.weight.ToString(), true);
            SetText(itemRequiredLevel, item.requiredLevel.ToString(), true);
            if (itemIcon != null)
            {
                itemIcon.sprite = item.icon;
            }

            if (isDroppable != null)
            {
                isDroppable.gameObject.SetActive(item.isDroppable == false);
            }

            if (isSellable != null)
            {
                isSellable.gameObject.SetActive(item.isSellable == false);
            }

            if (isStorable != null)
            {
                isStorable.gameObject.SetActive(item.isStorable == false);
            }

            SetText(buyPrice, item.buyPrice.ToString());
            SetText(sellPrice, item.sellPrice.ToString());
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: vinayakushakola/CSharp
        static void Main(string[] args)
        {
            Console.WriteLine("\n........Welcome To Object Oriented Programs........\n");
            bool flag = true;

            while (flag)
            {
                try
                {
                    Console.WriteLine("\n");
                    Console.WriteLine("\t1. Inventory Data Management");
                    Console.WriteLine("\t2. Inventory Management Program");
                    Console.WriteLine("\t3. Address Book");
                    Console.WriteLine("\t4. Stock Account Management");
                    Console.WriteLine("\t5. Deck Of Cards");
                    Console.WriteLine("\t6. Deck Of Cards Using Queue");
                    Console.WriteLine("\t7. Clinique Management");
                    Console.WriteLine("\t8. Commercial Data Processing");
                    Console.WriteLine("\t9. Exit");
                    Console.Write("Enter Your Choice: ");
                    int choice = Convert.ToInt32(Console.ReadLine());
                    switch (choice)
                    {
                    case 1:
                        InventoryUtility.InventoryMain();
                        break;

                    case 2:
                        InventoryManagement.InventoryManager();
                        break;

                    case 3:
                        AddressBookProgram.AddressBook();
                        break;

                    case 4:
                        StockReportProgram.StockReport();
                        break;

                    case 5:
                        DeckOfCardsProgram.DeckOfCards();
                        break;

                    case 6:
                        DeckOfCardsQueueProgram.DeckOfCardsQueue();
                        break;

                    case 7:
                        CliniqueManagementProgram.CliniqueManagement();
                        break;

                    case 8:
                        StockAccountReportProgram.StockReport();;
                        break;

                    case 9:
                        flag = false;
                        break;

                    default:
                        Console.WriteLine("Wrong choice!");
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
        }
コード例 #14
0
        internal void UpdateCache()
        {
            TotalPowerNetConsumption = PowerConsumptionByGroup.Values.Sum();
            TotalPowerStorage        = BlockCountByType
                                       .Select(x => MyTuple.Create(MyDefinitionManager.Static.GetCubeBlockDefinition(x.Key), x.Value))
                                       .Where(x => x.Item1 is MyBatteryBlockDefinition)
                                       .Sum(x => ((MyBatteryBlockDefinition)x.Item1).MaxStoredPower * x.Item2);
            TotalInventoryCapacity = BlockCountByType
                                     .Select(x => x.Value * InventoryUtility.GetInventoryVolume(x.Key))
                                     .Sum();

            m_productionCache.Clear();
            m_gasStorageCache.Clear();
            foreach (var kv in BlockCountByType)
            {
                var def        = MyDefinitionManager.Static.GetCubeBlockDefinition(kv.Key);
                var gasTankDef = def as MyGasTankDefinition;
                if (gasTankDef != null)
                {
                    m_gasStorageCache.AddValue(gasTankDef.StoredGasId, gasTankDef.Capacity * kv.Value);
                    continue;
                }
                var oxyDef = def as MyOxygenGeneratorDefinition;
                if (oxyDef != null)
                {
                    if (oxyDef.ProducedGases == null)
                    {
                        continue;
                    }
                    foreach (var recipe in oxyDef.ProducedGases)
                    {
                        m_productionCache.AddValue(recipe.Id, recipe.IceToGasRatio * oxyDef.IceConsumptionPerSecond * kv.Value);
                    }
                    continue;
                }

                var oxyFarmDef = def as MyOxygenFarmDefinition;
                if (oxyFarmDef != null)
                {
                    m_productionCache.AddValue(oxyFarmDef.ProducedGas, oxyFarmDef.MaxGasOutput * Utilities.SunMovementMultiplier * (oxyFarmDef.IsTwoSided ? 1 : 0.5f) * kv.Value);
                    continue;
                }

                var prodDef = def as MyProductionBlockDefinition;
                if (prodDef == null)
                {
                    continue;
                }
                var speedMult = 1.0;
                var asmDef    = def as MyAssemblerDefinition;
                if (asmDef != null)
                {
                    speedMult = asmDef.AssemblySpeed;
                }
                var refineDef = def as MyRefineryDefinition;
                if (refineDef != null)
                {
                    speedMult = refineDef.RefineSpeed;
                }
                foreach (var bpc in prodDef.BlueprintClasses)
                {
                    foreach (var bp in bpc)
                    {
                        foreach (var result in bp.Results)
                        {
                            m_productionCache.AddValue(result.Id, speedMult * (1 / bp.BaseProductionTimeInSeconds) * (double)result.Amount * kv.Value);
                        }
                        foreach (var preq in bp.Prerequisites)
                        {
                            if (preq.Id.TypeId != typeof(MyObjectBuilder_Ore))
                            {
                                continue;
                            }
                            m_productionCache.AddValue(preq.Id, speedMult * (1 / bp.BaseProductionTimeInSeconds) * (double)preq.Amount * kv.Value);
                        }
                    }
                }
            }

            var reqResources = 0D;

            foreach (var kv in BlockCountByType)
            {
                reqResources += BlueprintIndex.Instance.GetRawResourcesFor(kv.Key) * kv.Value;
            }
            TotalRawResources = reqResources;
        }
コード例 #15
0
 private void UMACharacterUpdated(UMAData data)
 {
     InventoryUtility.SetLayerRecursive(gameObject, InventorySettingsManager.instance.settings.localPlayerLayer);
 }