Пример #1
0
        public void Calculate()
        {
            foreach (var item in GarlandDatabase.Instance.Items)
            {
                if (item.craft == null)
                {
                    continue;
                }

                var ilvl = (int)item.ilvl;
                if (ilvl < MinimumItemLevel || ilvl > MaximumItemLevel)
                {
                    continue;
                }

                var cost = GetCost(item);
                if (cost <= 0)
                {
                    continue;
                }

                if (_itemCostByItemLevel.TryGetValue(ilvl, out var existingCost))
                {
                    if (existingCost.Cost <= cost)
                    {
                        continue;
                    }
                }

                _itemCostByItemLevel[ilvl] = new ItemCost()
                {
                    Cost = cost, Item = item
                };
            }
        }
Пример #2
0
 public Food(string name, ItemCost cost, HungerRecovery hunger, EnergyRecovery energy, string description)
 {
     Name           = name;
     Description    = description;
     Cost           = cost;
     HungerRecovery = hunger;
     EnergyRecovery = energy;
 }
        public static decimal?Fetch <InventoryIDField, CuryInfoIDField>(PXGraph graph, object row, int?vendorID, int?vendorLocationID, DateTime?docDate, string curyID, int?inventoryID, int?subItemID, int?siteID, string uom, bool onlyVendor)
            where InventoryIDField : IBqlField
            where CuryInfoIDField : IBqlField
        {
            ItemCost price = Fetch(graph, vendorID, vendorLocationID, docDate, curyID, inventoryID, subItemID, siteID, uom, onlyVendor);

            return(price.Convert <InventoryIDField, CuryInfoIDField>(graph, row, uom));
        }
Пример #4
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            ItemCost itemCost = await Task.Run(() => itemsService.Get(id));

            await Task.Run(() => itemsService.Delete(itemCost));

            return(RedirectToAction("Index"));
        }
 /// <summary>
 /// Initialization of the upgrade purchase item panel.
 /// </summary>
 void Start()
 {
     // Set the icon of this item.
     transform.GetChild(ItemSpriteIndex).GetComponent <Image>().sprite = ItemIconSprite;
     // Set the name of this item.
     transform.GetChild(ItemNameTextIndex).GetComponent <Text>().text = ItemName;
     // Set the cost of this item.
     transform.GetChild(ItemCostTextIndex).GetComponent <Text>().text = ItemCost.ToString();
 }
 private void OnFormLoad(object sender, EventArgs e)
 {
     if (ExpenseItem?.Length > 0)
     {
         cboSelection.Text    = ExpenseItem;
         txtCost.Text         = ItemCost.ToString();
         cboUnit.Text         = Unit;
         txtUnitQuantity.Text = UnitQuantity.ToString();
     }
 }
Пример #7
0
    private ItemCost GetCost(ConstructionData data)
    {
        Dictionary <string, int> resources = data.GetTotalCost();
        ItemCost cost = new ItemCost();

        cost.wood    = resources.ContainsKey("Wood") ? resources["Wood"] : 0;
        cost.wheat   = resources.ContainsKey("Wheat") ? resources["Wheat"] : 0;
        cost.stone   = resources.ContainsKey("Stone") ? resources["Stone"] : 0;
        cost.iron    = resources.ContainsKey("Iron") ? resources["Iron"] : 0;
        cost.gold    = resources.ContainsKey("Gold") ? resources["Gold"] : 0;
        cost.crystal = resources.ContainsKey("Crystal") ? resources["Crystal"] : 0;
        return(cost);
    }
Пример #8
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Amount,DateCreated,CreatedBy,DateUpdated,UpdatedBy")] ItemCost itemCost)
        {
            itemCost.DateCreated = DateTime.Now;
            itemCost.CreatedBy   = User.Identity.Name;

            if (ModelState.IsValid)
            {
                itemsService.Insert(itemCost);
                return(RedirectToAction("Index"));
            }

            return(View(itemCost));
        }
Пример #9
0
        // GET: ItemCosts/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ItemCost itemCost = await Task.Run(() => itemsService.Get(id.Value));

            if (itemCost == null)
            {
                return(HttpNotFound());
            }
            return(View(itemCost));
        }
Пример #10
0
        // My equivalent of a ToString method.  This will return a string list with each string in the list
        // containing one of the inventory item's attributes, to be used to display an inventory item into
        // a textbox, etc.
        public List <string> ToItemDescription()
        {
            List <string> itemDescription = new List <string>();

            itemDescription.Add("Catalog Item ID: " + CatalogItemId.ToString());
            itemDescription.Add("Item Name: " + ItemName);
            itemDescription.Add("Number In Stock: " + NumberInStock.ToString());
            itemDescription.Add("Item Manufacturer: " + Manufacturer);
            itemDescription.Add("Number of Inscription Lines: " + NumberInscriptionLines.ToString());
            itemDescription.Add("Characters Per Line: " + NumberLineCharacters.ToString());
            itemDescription.Add("Item Cost: " + ItemCost.ToString("C"));
            itemDescription.Add("Retail Price: " + ItemRetailPrice.ToString("C"));
            itemDescription.Add("Inscription Type: " + InscriptionType.ToString());

            return(itemDescription);
        }
Пример #11
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Amount")] ItemCost itemCost)
        {
            if (ModelState.IsValid)
            {
                ItemCost original = await Task.Run(() => itemsService.Get(itemCost.Id));

                if (original != null)
                {
                    original.Name        = itemCost.Name;
                    original.Amount      = itemCost.Amount;
                    original.DateUpdated = DateTime.Now;
                    original.UpdatedBy   = User.Identity.Name;
                }
                return(RedirectToAction("Index"));
            }
            return(View(itemCost));
        }
Пример #12
0
    private ItemCost GetCost(List <string> crafting)
    {
        Dictionary <string, int> resources = new Dictionary <string, int>();

        foreach (string line in crafting)
        {
            char[]   separator = { ' ' };
            string[] s         = line.Split(separator);
            resources.Add(s[0], int.Parse(s[1]));
        }

        ItemCost cost = new ItemCost();

        cost.wood    = resources.ContainsKey("Wood") ? resources["Wood"] : 0;
        cost.wheat   = resources.ContainsKey("Wheat") ? resources["Wheat"] : 0;
        cost.stone   = resources.ContainsKey("Stone") ? resources["Stone"] : 0;
        cost.iron    = resources.ContainsKey("Iron") ? resources["Iron"] : 0;
        cost.gold    = resources.ContainsKey("Gold") ? resources["Gold"] : 0;
        cost.crystal = resources.ContainsKey("Crystal") ? resources["Crystal"] : 0;
        return(cost);
    }
            public decimal Convert <InventoryIDField, CuryInfoIDField>(PXGraph graph, object inventoryRow, object curyRow, string uom)
                where InventoryIDField : IBqlField
                where CuryInfoIDField : IBqlField
            {
                ItemCost price = this;

                if (price == null || price.Cost == 0 || price.Item == null || inventoryRow == null || curyRow == null)
                {
                    return(0);
                }

                decimal result = price.Cost;

                if (ConvertCury)
                {
                    PXCache curyCache = graph.Caches[curyRow.GetType()];
                    PXCurrencyAttribute.CuryConvCury <CuryInfoIDField>(curyCache, curyRow, price.BaseCost, out result, true);
                }

                if (price.UOM != uom && !string.IsNullOrEmpty(uom))
                {
                    if (inventoryRow == null)
                    {
                        return(0);
                    }

                    PXCache invCache = graph.Caches[inventoryRow.GetType()];
                    decimal baseUOM  =
                        price.UOM != price.Item.BaseUnit ?
                        INUnitAttribute.ConvertFromBase <InventoryIDField>(invCache, inventoryRow, price.UOM, result, INPrecision.UNITCOST) :
                        result;

                    result =
                        uom != price.Item.BaseUnit ?
                        INUnitAttribute.ConvertToBase <InventoryIDField>(invCache, inventoryRow, uom, baseUOM, INPrecision.UNITCOST) :
                        baseUOM;
                }

                return(result);
            }
Пример #14
0
    private void Update()
    {
        if (privateDragging)
        {
            Vector3 currentPosition = new Vector3(Input.mousePosition.x - posX, Input.mousePosition.y - posY, 0);

            Vector3 worldPosition = UnityEngine.Camera.main.ScreenToWorldPoint(currentPosition);

            //Vector3 floatSnap = new Vector3(5f, 5f , 0);

            //Snap to int grid
            // worldPosition = new Vector3(Mathf.Round(worldPosition.x)/100f * 100, Mathf.Round(worldPosition.y)/100f*100);
            // worldPosition = new Vector3(Mathf.Round(worldPosition.x / floatSnap.x),Mathf.Round(worldPosition.y / floatSnap.y));

            //int intSnap;

            //floatSnap = Mathf.Round(intSnap)/2;

            transform.position = Snap.snap(worldPosition, .5f);

            if (Input.GetMouseButtonUp(0))
            {
                privateDragging = false;

                if (RubbishBin.instance.hovering == true)
                {
                    //do stuff
                    itemScript = GetComponent <ItemCost>();

                    itemScript.Refund();

                    Destroy(gameObject);
                }
            }
            globalDragging = privateDragging;
        }
    }
Пример #15
0
    private void InstanciateShop()
    {
        GameObject shopContainer = new GameObject("shopContainer");

        shopContainer.transform.parent        = transform;
        shopContainer.transform.localPosition = Vector3.zero;
        shopContainer.transform.localRotation = Quaternion.identity;
        shopContainer.transform.localScale    = Vector3.one;
        shopContainer.SetActive(true);

        if (export_csv)
        {
            file_csv += "Arsenal items\n" +
                        "Name;Load;Dammage;Armor;Capacity;Wood;Wheat;Stone;Iron;Gold;Crystal\n";
        }

        // backpack
        Vector3 position = Vector3.zero;

        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = BackpackItem.Type.None.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = new Vector3(-2 * gap, position.y, position.z);
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableBackpack;
            go.AddComponent <BackpackItem>();
            go.SetActive(true);
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            pickable.body.gameObject.SetActive(false);

            if (export_csv)
            {
                file_csv += "\nbackpack items\n";
            }
        }
        foreach (KeyValuePair <BackpackItem.Type, BackpackItem> item in backpackDictionary)
        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = item.Key.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = position;
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableBackpack;
            BackpackItem.Copy(item.Value, go.AddComponent <BackpackItem>());
            go.SetActive(true);

            MeshFilter mf = item.Value.gameObject.GetComponent <MeshFilter>();
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            if (mf)
            {
                pickable.itemMesh.mesh = mf.mesh;
            }
            else
            {
                pickable.itemMesh.gameObject.SetActive(false);
            }
            pickable.body.gameObject.SetActive(false);

            if (createIcons)
            {
                pickable.textmesh.gameObject.SetActive(false);
                pickable.transform.localEulerAngles = new Vector3(0, 15, 0);
                cameraPivot.position = go.transform.position + new Vector3(-0.13f, 0.6f, 1.1f);

                if (item.Key == BackpackItem.Type.AdventureBackpack)
                {
                    pickable.transform.localEulerAngles = new Vector3(0, 90, 0);
                    cameraPivot.position = go.transform.position + new Vector3(0f, 0.7f, 0.9f);
                }

                CreateIcon(iconFolderPath + "/Backpacks/" + go.name + ".png");
            }
            if (export_csv)
            {
                ItemCost cost = GetCost(item.Value.crafting);
                file_csv += item.Key.ToString() + ";" +
                            item.Value.load.ToString() + ";0;0;" + item.Value.capacity.ToString() + ";" +
                            cost.wood.ToString() + ";" + cost.wheat.ToString() + ";" + cost.stone.ToString() + ";" + cost.iron.ToString() + ";" + cost.gold.ToString() + ";" + cost.crystal.ToString() + "\n";
            }
            position.x += gap;
        }

        // shields
        position.x = 0; position.z -= gap; position.y += gapY;
        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = ShieldItem.Type.None.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = new Vector3(-2 * gap, position.y, position.z);
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableShield;
            go.AddComponent <ShieldItem>();
            go.SetActive(true);
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            pickable.body.gameObject.SetActive(false);

            if (export_csv)
            {
                file_csv += "\nshield items\n";
            }
        }
        foreach (KeyValuePair <ShieldItem.Type, ShieldItem> item in shieldDictionary)
        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = item.Key.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = position;
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableShield;
            ShieldItem.Copy(item.Value, go.AddComponent <ShieldItem>());
            go.SetActive(true);

            MeshFilter mf = item.Value.gameObject.GetComponent <MeshFilter>();
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            if (mf)
            {
                pickable.itemMesh.mesh = mf.mesh;
            }
            else
            {
                pickable.itemMesh.gameObject.SetActive(false);
            }
            pickable.body.gameObject.SetActive(false);

            if (createIcons)
            {
                pickable.textmesh.gameObject.SetActive(false);
                pickable.transform.localEulerAngles = new Vector3(0, 30, 0);
                cameraPivot.position = go.transform.position + new Vector3(0f, 0.6f, 1.3f);
                CreateIcon(iconFolderPath + "/Shields/" + go.name + ".png");
            }
            if (export_csv)
            {
                ItemCost cost = GetCost(item.Value.crafting);
                file_csv += item.Key.ToString() + ";" +
                            item.Value.load.ToString() + ";0;" + item.Value.armor.ToString() + ";0;" +
                            cost.wood.ToString() + ";" + cost.wheat.ToString() + ";" + cost.stone.ToString() + ";" + cost.iron.ToString() + ";" + cost.gold.ToString() + ";" + cost.crystal.ToString() + "\n";
            }
            position.x += gap;
        }

        // second hand
        position.x = 0; position.z -= gap; position.y += gapY;
        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = SecondItem.Type.None.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = new Vector3(-2 * gap, position.y, position.z);
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableSecond;
            go.AddComponent <SecondItem>();
            go.SetActive(true);
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            pickable.body.gameObject.SetActive(false);

            if (export_csv)
            {
                file_csv += "\nsecond hand items\n";
            }
        }
        foreach (KeyValuePair <SecondItem.Type, SecondItem> item in secondDictionary)
        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = item.Key.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = position;
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableSecond;
            SecondItem.Copy(item.Value, go.AddComponent <SecondItem>());
            go.SetActive(true);

            MeshFilter mf = item.Value.gameObject.GetComponent <MeshFilter>();
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            if (mf)
            {
                pickable.itemMesh.mesh = mf.mesh;
            }
            else
            {
                pickable.itemMesh.gameObject.SetActive(false);
            }
            pickable.body.gameObject.SetActive(false);

            if (createIcons)
            {
                pickable.textmesh.gameObject.SetActive(false);
                pickable.transform.localEulerAngles = new Vector3(0, 0, -42);
                cameraPivot.position = go.transform.position + new Vector3(0.3f, 0.45f, 1.5f);
                CreateIcon(iconFolderPath + "/SecondHands/" + go.name + ".png");
            }
            if (export_csv)
            {
                ItemCost cost = GetCost(item.Value.crafting);
                file_csv += item.Key.ToString() + ";" +
                            item.Value.load.ToString() + ";" + item.Value.dammage.ToString() + ";0;0;" +
                            cost.wood.ToString() + ";" + cost.wheat.ToString() + ";" + cost.stone.ToString() + ";" + cost.iron.ToString() + ";" + cost.gold.ToString() + ";" + cost.crystal.ToString() + "\n";
            }
            position.x += gap;
        }

        // weapons
        position.x = 0; position.z -= gap; position.y += gapY;
        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = WeaponItem.Type.None.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = new Vector3(-2 * gap, position.y, position.z);
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableWeapon;
            go.AddComponent <WeaponItem>();
            go.SetActive(true);
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            pickable.body.gameObject.SetActive(false);
            if (export_csv)
            {
                file_csv += "\nweapon items\n";
            }
        }
        foreach (KeyValuePair <WeaponItem.Type, WeaponItem> item in weaponDictionary)
        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = item.Key.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = position;
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableWeapon;
            WeaponItem.Copy(item.Value, go.AddComponent <WeaponItem>());
            go.SetActive(true);

            MeshFilter mf = item.Value.gameObject.GetComponent <MeshFilter>();
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            if (mf)
            {
                pickable.itemMesh.mesh = mf.mesh;
            }
            else
            {
                pickable.itemMesh.gameObject.SetActive(false);
            }
            pickable.body.gameObject.SetActive(false);

            if (createIcons)
            {
                pickable.textmesh.gameObject.SetActive(false);
                pickable.transform.localEulerAngles = new Vector3(0, 0, -42);
                cameraPivot.position = go.transform.position + new Vector3(0.3f, 0.6f, 1.5f);

                if (item.Key == WeaponItem.Type.FireSword)
                {
                    pickable.itemMesh.gameObject.transform.Find("swordFireEffect").gameObject.SetActive(true);
                }
                else if (item.Key == WeaponItem.Type.ElectricSword)
                {
                    pickable.itemMesh.gameObject.transform.Find("swordElectricEffect").gameObject.SetActive(true);
                }

                CreateIcon(iconFolderPath + "/Weapons/" + go.name + ".png");
            }
            if (export_csv)
            {
                ItemCost cost = GetCost(item.Value.crafting);
                file_csv += item.Key.ToString() + ";" +
                            item.Value.load.ToString() + ";" + item.Value.dammage.ToString() + ";0;0;" +
                            cost.wood.ToString() + ";" + cost.wheat.ToString() + ";" + cost.stone.ToString() + ";" + cost.iron.ToString() + ";" + cost.gold.ToString() + ";" + cost.crystal.ToString() + "\n";
            }
            position.x += gap;
        }

        // heads
        position.x = 0; position.z -= gap; position.y += gapY;

        if (export_csv)
        {
            file_csv += "\nhead items\n";
        }
        foreach (KeyValuePair <HeadItem.Type, HeadItem> item in headDictionary)
        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = item.Key.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = position;
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableHead;
            HeadItem.Copy(item.Value, go.AddComponent <HeadItem>());
            go.SetActive(true);

            MeshFilter mf = item.Value.gameObject.GetComponent <MeshFilter>();
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            if (mf)
            {
                pickable.itemMesh.mesh = mf.mesh;
            }
            else
            {
                pickable.itemMesh.gameObject.SetActive(false);
            }
            pickable.body.gameObject.SetActive(false);

            if (createIcons)
            {
                pickable.textmesh.gameObject.SetActive(false);
                pickable.transform.localEulerAngles = new Vector3(0, 15, 0);
                cameraPivot.position = go.transform.position + new Vector3(0, 0.6f, 1f);
                CreateIcon(iconFolderPath + "/Heads/" + go.name + ".png");
            }
            if (export_csv)
            {
                ItemCost cost = GetCost(item.Value.crafting);
                file_csv += item.Key.ToString() + ";" +
                            item.Value.load.ToString() + ";0;" + item.Value.armor.ToString() + ";0;" +
                            cost.wood.ToString() + ";" + cost.wheat.ToString() + ";" + cost.stone.ToString() + ";" + cost.iron.ToString() + ";" + cost.gold.ToString() + ";" + cost.crystal.ToString() + "\n";
            }
            position.x += gap;
        }

        // bodies
        position.x = 0; position.z -= gap; position.y += gapY;

        if (export_csv)
        {
            file_csv += "\nbody items\n";
        }
        foreach (KeyValuePair <BodyItem.Type, BodyItem> item in bodyDictionary)
        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = item.Key.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = position;
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableBody;
            BodyItem.Copy(item.Value, go.AddComponent <BodyItem>());
            go.SetActive(true);

            SkinnedMeshRenderer        skin     = item.Value.gameObject.GetComponent <SkinnedMeshRenderer>();
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            pickable.itemMesh.gameObject.SetActive(false);

            if (skin)
            {
                BodySlot.CopySkinnedMesh(skin, pickable.body);
            }
            else
            {
                pickable.body.gameObject.SetActive(false);
            }

            if (createIcons)
            {
                pickable.textmesh.gameObject.SetActive(false);
                pickable.transform.localEulerAngles = new Vector3(0, 15, 0);
                cameraPivot.position = go.transform.position + new Vector3(0, 0.5f, 1.5f);
                CreateIcon(iconFolderPath + "/Bodies/" + go.name + ".png");
            }
            if (export_csv)
            {
                ItemCost cost = GetCost(item.Value.crafting);
                file_csv += item.Key.ToString() + ";" +
                            item.Value.load.ToString() + ";0;" + item.Value.armor.ToString() + ";0;" +
                            cost.wood.ToString() + ";" + cost.wheat.ToString() + ";" + cost.stone.ToString() + ";" + cost.iron.ToString() + ";" + cost.gold.ToString() + ";" + cost.crystal.ToString() + "\n";
            }
            position.x += gap;
        }

        // horses
        position.x = 0; position.z -= 2 * gap; position.y += gapY;
        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = HorseItem.Type.None.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = new Vector3(-2 * gap, position.y, position.z);
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableHorse;
            go.AddComponent <HorseItem>();
            go.SetActive(true);
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            pickable.body.gameObject.SetActive(false);

            if (export_csv)
            {
                file_csv += "\nhorse items\n";
            }
        }
        foreach (KeyValuePair <HorseItem.Type, HorseItem> item in horseDictionary)
        {
            GameObject go = Instantiate(pickablePrefab.gameObject);
            go.name                    = item.Key.ToString();
            go.transform.parent        = shopContainer.transform;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = position;
            go.AddComponent <InteractionType>().type = InteractionType.Type.pickableHorse;
            HorseItem.Copy(item.Value, go.AddComponent <HorseItem>());
            go.SetActive(true);

            SkinnedMeshRenderer        skin     = item.Value.gameObject.GetComponent <SkinnedMeshRenderer>();
            SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();
            pickable.textmesh.text = go.name;
            if (go.name.Length >= 8)
            {
                pickable.textmesh.characterSize *= 0.5f;
            }
            pickable.itemMesh.gameObject.SetActive(false);

            if (skin)
            {
                BodySlot.CopySkinnedMesh(skin, pickable.horse);
            }
            else
            {
                pickable.horse.gameObject.SetActive(false);
            }
            pickable.horse.gameObject.SetActive(true);
            pickable.body.gameObject.SetActive(false);

            if (createIcons)
            {
                pickable.textmesh.gameObject.SetActive(false);
                pickable.transform.localEulerAngles = new Vector3(0, 90, 0);
                cameraPivot.position = go.transform.position + new Vector3(0, 1, 3f);
                CreateIcon(iconFolderPath + "/Horses/" + go.name + ".png");
            }
            if (export_csv)
            {
                file_csv += item.Key.ToString() + ";" + item.Value.load.ToString() + ";0;" + item.Value.armor.ToString() + ";0;0;0;0;0;0;0\n";
            }
            position.x += gap;
        }



        if (export_csv)
        {
            StreamWriter writer = new StreamWriter("Assets/Resources/arsenal.csv", false);
            writer.WriteLine(file_csv);
            writer.Close();
        }
    }
Пример #16
0
 public bool Delete(ItemCost itemCost)
 {
     return(repository.Remove(itemCost));
 }
Пример #17
0
 public bool Exists(ItemCost itemCost)
 {
     return(repository.GetAll(x => x.Name.Trim().Equals(itemCost.Name.Trim(), StringComparison.InvariantCultureIgnoreCase) && x.Amount == itemCost.Amount).Any());
 }
Пример #18
0
    void Start()
    {
        eventsystem = (EventSystem)FindObjectOfType(typeof(EventSystem));

        tpsController.activated = !activated;
        rtsController.activated = activated;
        constructionUI.gameObject.SetActive(activated);
        lastActivated      = activated;
        RenderSettings.fog = !activated;

        lastIcon = constructionUI.selectedIcon;

        previewMeshFilter = preview.AddComponent <MeshFilter>();
        MeshRenderer mr = preview.AddComponent <MeshRenderer>();

        mr.sharedMaterial      = previewMaterial;
        currentPreviewMaterial = mr.material;

        multiPreviewPrefab.SetActive(false);
        multiPreviewFilters.Add(multiPreviewPrefab.GetComponent <MeshFilter>());
        mr = multiPreviewPrefab.GetComponent <MeshRenderer>();
        mr.sharedMaterial = previewMaterial;
        multiPreviewRenderers.Add(mr);

        for (int i = 0; i < maximumMultiplacement - 1; i++)
        {
            GameObject go = Instantiate(multiPreviewPrefab);
            go.name                    = multiPreviewPrefab.name;
            go.transform.parent        = multiPreviewContainer;
            go.transform.localPosition = Vector3.zero;
            go.SetActive(false);

            multiPreviewFilters.Add(go.GetComponent <MeshFilter>());
            mr = go.GetComponent <MeshRenderer>();
            mr.sharedMaterial = previewMaterial;
            multiPreviewRenderers.Add(mr);
        }

        if (export_csv)
        {
            file_csv += "Constructions data\n" +
                        "Name;Wood;Wheat;Stone;Iron;Gold;Crystal\n";
        }
        foreach (ConstructionData cd in buildingList)
        {
            knownBuildings.Add(cd.name, cd);

            if (export_csv)
            {
                ItemCost cost = GetCost(cd);
                file_csv += cd.name + ";" +
                            cost.wood.ToString() + ";" + cost.wheat.ToString() + ";" + cost.stone.ToString() + ";" + cost.iron.ToString() + ";" + cost.gold.ToString() + ";" + cost.crystal.ToString() + "\n";
            }
        }
        if (export_csv)
        {
            StreamWriter writer = new StreamWriter("Assets/Resources/constructions.csv", false);
            writer.WriteLine(file_csv);
            writer.Close();
        }

        ResetState();
    }
Пример #19
0
 public void SetTarget(ItemCost _target)
 {
     target = _target;
     UpdateUI();
 }
Пример #20
0
 public ItemCost Insert(ItemCost ItemCost)
 {
     return(repository.Add(ItemCost));
 }
Пример #21
0
 public bool Update(ItemCost ItemCost)
 {
     ItemCost.DateUpdated = DateTime.Now;
     repository.Update(ItemCost);
     return(true);
 }
Пример #22
0
    public void SetPrice(ItemCost itemCost)
    {
        itemSpriteImage.sprite = itemCost.item.Info.Icon;

        this.itemCost = itemCost;
    }
Пример #23
0
 public Food(string name, ItemCost cost, int hungerRecovery, int energyRecovery, string description)
     : this(name, cost, new HungerRecovery(hungerRecovery), new EnergyRecovery(energyRecovery), description)
 {
 }