Esempio n. 1
0
    public void upgrade(UpgradeItem upitem)
    {
        if (upitem.rank >= upitem.rank_max)
        {
            //TODO: Can't improve anymore!
            return;
        }

        if (this.player.gold < upitem.cost)
        {
            //TODO: Not enough gold!
            return;
        }
        else
        {
            this.player.gold -= upitem.cost;
        }


        if (upitem.upgrade_id == "fort_hp")
        {
            this.fort.hp_max += 50;
        }

        if (upitem.upgrade_id == "player_speed")
        {
            this.player.attack_rate /= 2.0f;
        }

        upitem.rank++;
    }
Esempio n. 2
0
    public void onClick_UpgradeItem()
    {
        GameObject  clicker = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject;
        UpgradeItem upitem  = clicker.transform.parent.GetComponent <UpgradeItem>();

        main.upgrade(upitem);
    }
Esempio n. 3
0
        private void UpdateSlots(int slodID)
        {
            DataManager dataManager = ServiceFactory.Instance.Resolve <DataManager>();

            TestExpandItemButton[] buttons = inventoryExpand.GetComponentsInChildren <TestExpandItemButton>();

            // Ignore the 0 position because it is the active slot item
            for (int i = 1; i < 10; i++)
            {
                string upgradeItemID = dataManager.gameData.ShipSlot[slodID, i];

                if (!string.IsNullOrEmpty(upgradeItemID))
                {
                    List <UpgradeItem> upgradeItemList = dataManager.upgradeItemList.itemList;
                    UpgradeItem        upgradeItem     = upgradeItemList.Find(item => item.ItemID == upgradeItemID);
                    Debug.Log(upgradeItem.ItemBonus.ToString());

                    //GameObject upgrade = Instantiate(upgradeItem.ItemPrefab) as GameObject;
                    //buttons[i - 1].gameObject.transform.SetParent(transform.parent, false);
                    //upgrade.GetComponentInChildren<Text>().text = upgradeItem.GetName();
                    buttons[i - 1].GetComponentInChildren <Text>().text = upgradeItem.GetName();
                }
                else
                {
                    buttons[i - 1].GetComponentInChildren <Text>().text = string.Empty;
                }
            }
        }
Esempio n. 4
0
 public override void InitResTable()
 {
     upgradeTabel = new UpgradeItem[MAX_LVL]
     {
         new UpgradeItem(1, 670, new int[4] {
             70, 90, 70, 20
         }),
         new UpgradeItem(2, 870, new int[4] {
             115, 150, 115, 35
         }),
         new UpgradeItem(3, 1110, new int[4] {
             195, 250, 195, 55
         }),
         new UpgradeItem(4, 1390, new int[4] {
             325, 420, 325, 95
         }),
         new UpgradeItem(5, 1710, new int[4] {
             545, 700, 545, 155
         }),
         new UpgradeItem(6, 2090, new int[4] {
             545, 700, 545, 155
         }),
         new UpgradeItem(7, 2520, new int[4] {
             545, 700, 545, 155
         }),
         new UpgradeItem(8, 3030, new int[4] {
             545, 700, 545, 155
         }),
     };
 }
Esempio n. 5
0
    public void SetUpgrade(UpgradeItem upgradeItem)
    {
        foreach (FiringSystem firingSystem in firingSystems)
        {
            if (firingSystem.systemName == upgradeItem.ItemName)
            {
                firingSystem.isActive         = true;
                firingSystem.projectilePrefab = upgradeItem.NextLevelLaserPrefab;

                firingSystem.firePoints.Clear();
                string[] parsedFirePoints = upgradeItem.NextLevelFirePointNames.Split(',');
                foreach (string firePointName in parsedFirePoints)
                {
                    Transform newFirePoints = GameObject.Find(firePointName).transform;
                    if (newFirePoints.childCount > 0)
                    {
                        foreach (Transform newFirePoint in newFirePoints)
                        {
                            firingSystem.firePoints.Add(newFirePoint);
                        }
                    }
                    else
                    {
                        firingSystem.firePoints.Add(newFirePoints);
                    }
                }

                firingSystem.projectileSpeed        = upgradeItem.NextLevelProjectileSpeed;
                firingSystem.projectileFiringPeriod = upgradeItem.NextLevelProjectileFiringPeriod;
            }
        }
    }
Esempio n. 6
0
        public async Task <JsonResult> AddItem([FromBody] ItemViewModel item)
        {
            if (string.IsNullOrEmpty(item.Name))
            {
                return(Json(new { result = false, msg = "名称不能为空" }));
            }
            if (string.IsNullOrEmpty(item.Content))
            {
                return(Json(new { result = false, msg = "更新内容不能为空" }));
            }

            var entity = new UpgradeItem
            {
                Name       = item.Name,
                Content    = item.Content,
                Creater    = "sys",
                CreateTime = DateTimeOffset.Now.DateTime,
                IsValid    = true,
            };

            _upgradeItemRepository.Add(entity);
            if (await UnitOfWork.SaveAsync())
            {
                return(Json(new { result = true, msg = "保存成功" }));
            }
            else
            {
                return(Json(new { result = false, msg = "服务器保存失败" }));
            }
        }
Esempio n. 7
0
        private void btniAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            OpenFileDialog opendlg = new OpenFileDialog();

            opendlg.Multiselect = true;
            opendlg.Title       = "选择更新项目";
            opendlg.Filter      = "所有程序(*.*)|*.*";
            if (opendlg.ShowDialog() == DialogResult.OK)
            {
                foreach (string file in opendlg.FileNames)
                {
                    if (FileUtility.IsDirectory(file))
                    {
                        EnumDirectory(file);
                    }
                    else
                    {
                        UpgradeItem  upItem = new UpgradeItem(file);
                        ListViewItem item   = new ListViewItem(upItem.Name, 1);
                        item.Tag = upItem;
                        lvItems.Items.Add(item);
                    }
                }
                upgradeItemChanged = true;
            }
        }
    private void BuyAction(UpgradeItem item)
    {
        int costs = int.Parse(item.Costs.text);

        if (Inventory.Gold >= costs)
        {
            switch (item.Type)
            {
            case "wood":
                OnChopSpeed();
                break;

            case "stone":
                OnMineSpeed();
                break;

            default:
                OnMoveSpeed();
                break;
            }
            item.Costs.text   = "" + costs * 2;
            item.Percent.text = "+" + 5 * int.Parse(item.Costs.text) + "%";


            Inventory.DecreaseGold(costs);
        }
    }
Esempio n. 9
0
        private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            UpgradeItem item = e.UserState as UpgradeItem;

            downloadSize += item.Size;
            SetProcessBar(0, (int)(downloadSize * 100 / totalSize));
            evtPerDonwload.Set();
        }
Esempio n. 10
0
 /// <summary>
 /// 吃药瓶 (one time)回调
 /// </summary>
 /// <param name="item"></param>
 public void UpgradeItemOneCallBack(UpgradeItem item)
 {
     if (m_UpItem.m_Count <= 0)
     {
         return;
     }
     m_UpItem = item;
     AddExp();
 }
Esempio n. 11
0
 private void DisableItem(UpgradeItem item)
 {
     item.btn.interactable = false;
     item.btn.image.color  = new Color(item.btn.image.color.r, item.btn.image.color.g, item.btn.image.color.b, disabledAlphaValue);
     foreach (TextMeshProUGUI text in item.btn.GetComponentsInChildren <TextMeshProUGUI>())
     {
         text.color = new Color(text.color.r, text.color.g, text.color.b, disabledAlphaValueNormalized);
     }
 }
Esempio n. 12
0
    /// <summary>
    /// 吃药瓶( 持续 )回调
    /// </summary>
    /// <param name="item"></param>
    /// <param name="state"></param>
    public void UpgradeItemCallBack(UpgradeItem item, bool state)
    {
        m_UpItem = item;
        isState  = state;

        if (state)
        {
            Invoke("CallBack", 0.1f);
        }
    }
Esempio n. 13
0
    public void UpdateUI(UpgradeItem item)
    {
        item.ui.price.text  = "Money: " + item.GetPrice();
        item.ui.price.color = (App.Instance.playerVar.money >= item.GetPrice()) ? canBuy : cantBuy;

        item.ui.changeBy.text  = item.ChangeByFormat();
        item.ui.changeBy.color = (item.currentLevel <= item.prices.Length - 1) ? canBuy : cantBuy;

        item.ui.button.interactable = item.ButtonActive();
    }
Esempio n. 14
0
        private void generateButton_Click(object sender, RoutedEventArgs e)
        {
            List <UpgradeItem> items    = new List <UpgradeItem>();
            List <string>      fileList = new List <string>();

            foreach (string file in this.fileListBox.Items)
            {
                UpgradeItem item = new UpgradeItem();
                item.PathName = file.Remove(0, this.folderTextBox.Text.Length + 1);
                items.Add(item);
                fileList.Add(file);
            }

            string configFile = System.IO.Path.Combine(this.folderTextBox.Text, "UpgradeConfig.xml");

            SerializerHelper <UpgradeItem[]> .XmlSerialize(configFile, items.ToArray());

            fileList.Add(configFile);

            string folder = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (this.Is64BitOS())
            {
                SevenZipCompressor.SetLibraryPath(System.IO.Path.Combine(folder, "ThirdParty\\7z\\7z64.dll"));
            }
            else
            {
                SevenZipCompressor.SetLibraryPath(System.IO.Path.Combine(folder, "ThirdParty\\7z\\7z.dll"));
            }

            SevenZipCompressor cmp;

            try
            {
                cmp = new SevenZipCompressor();
                cmp.ArchiveFormat    = OutArchiveFormat.Zip;
                cmp.CompressionLevel = CompressionLevel.Normal;
                cmp.CompressionMode  = CompressionMode.Create;
                cmp.FastCompression  = false;

                string targetFolder = this.folderTextBox.Text;
                cmp.TempFolderPath = targetFolder;
                string archiveFile = System.IO.Path.Combine(targetFolder, "AppCenterUpgradePackage.zip");
                if (System.IO.File.Exists(archiveFile))
                {
                    System.IO.File.Delete(archiveFile);
                }

                cmp.CompressFilesEncrypted(archiveFile, "1@3$5^7*", fileList.ToArray());
            }
            catch
            {
            }
        }
Esempio n. 15
0
    private void SpawnItem(Transform parent, NamedEvent itemPoolItem)
    {
        GameObject obj = Instantiate(prefabUpgradeItem, parent);

        obj.transform.localPosition = Vector3.zero;
        UpgradeItem item = obj.GetComponent <UpgradeItem>();

        item.Collected += itemPoolItem.OnInvoked;
        item.Collected += DestroyItems;
        item.SetSprite(itemPoolItem.GetName());
    }
Esempio n. 16
0
 // Start is called before the first frame update
 void Start()
 {
     m_EquipImg = transform.Find("Image").GetComponent <Image>();
     m_Btn      = GetComponent <Button>();
     if (m_Btn != null)
     {
         m_Btn.onClick.AddListener(Btn);
     }
     m_upgradeItem = GameObject.Find("Canvas/UpgradeCanvas/UpgradeItemSlot").GetComponent <UpgradeItem>();
     m_LevelText   = transform.Find("Level").GetComponent <Text>();
 }
Esempio n. 17
0
 public void AddEntry(UpgradeItem item)
 {
     upgrades.Add(item);
     if (item.researched)
     {
         developed.Add(item.upgrade.uuid);
     }
     else
     {
         listSize++;
     }
 }
Esempio n. 18
0
    public void LoadData(UpgradeItem selected_item)
    {
        gameObject.SetActive(true);

        this.selected_item = selected_item;
        //**********************
        //Get the ship Managment
        //**********************
        GameObject player = GameObject.Find("Player_Config");

        if (player == null)
        {
            return;
        }
        ShipManagment ship_managment = player.GetComponent <ShipManagment>();

        if (ship_managment == null)
        {
            return;
        }

        //***********************************
        //Lets get the drop panel of the item
        //***********************************
        Transform panel = gameObject.transform.Find("DropPanel");

        if (panel != null)
        {
            //*************************
            //Lest remove all old items
            //*************************
            foreach (Transform child in panel.transform)
            {
                GameObject.Destroy(child.gameObject);
            }
            if (invetory_upgrade_item_prrefab == null)
            {
                return;
            }
            foreach (Upgrade_Settings e in ship_managment.stored_upgrades)
            {
                GameObject  button = Instantiate(invetory_upgrade_item_prrefab, panel);
                UpgradeItem item   = button.GetComponent <UpgradeItem>();
                if (item != null)
                {
                    item.SetItem(e);
                }
                EventTrigger trigger = item.GetComponent <EventTrigger>();
                UnityFunctions.AddListener(ref trigger, EventTriggerType.PointerClick, onClickListener);
            }
        }
    }
Esempio n. 19
0
    void onClickListener(PointerEventData eventData)
    {
        GameObject  selected = eventData.selectedObject;
        UpgradeItem item     = selected.GetComponent <UpgradeItem>();

        if (item != null)
        {
            selected_item.SetItem(item.item);
        }

        //put your logic here...
        gameObject.SetActive(false);
    }
Esempio n. 20
0
        void Start()
        {
            DataManager dataManager   = ServiceFactory.Instance.Resolve <DataManager>();
            string      upgradeItemID = dataManager.gameData.ShipSlot[slodID, 0];

            if (!string.IsNullOrEmpty(upgradeItemID))
            {
                List <UpgradeItem> upgradeItemList = dataManager.upgradeItemList.itemList;
                UpgradeItem        upgradeItem     = upgradeItemList.Find(i => i.ItemID == upgradeItemID);

                GameObject item = Instantiate(upgradeItem.ItemPrefab) as GameObject;
                item.transform.SetParent(transform.parent, false);
                item.GetComponentInChildren <Text>().text = upgradeItem.GetName();
            }
        }
Esempio n. 21
0
    private void SpawnItem(Transform parent, NamedEvent itemPoolItem)
    {
        GameObject obj = Instantiate(prefabUpgradeItem, parent);

        obj.transform.localPosition = Vector3.zero;
        UpgradeItem item = obj.GetComponent <UpgradeItem>();

        item.Collected += itemPoolItem.OnInvoked;
        item.Collected += DestroyItems;
        string itemName = itemPoolItem.GetName();

        item.SetSprite(itemName);
        item.SetItemName(UtilTranslate.ItemName(itemName));
        item.SetItemProperties(itemPoolItem.GetDescriptionList("\n"));
    }
Esempio n. 22
0
    public void configurePrefab(UpgradeItem _upgrade)
    {
        currentUpgrade = _upgrade;

        if (currentUpgrade != null)
        {
            upgradeIcon.sprite = currentUpgrade.upgradeIcon;

            upgradeName.text = currentUpgrade.upgradeName;
            upgradeDesc.text = currentUpgrade.upgradeDesc;

            lungCost.text   = currentUpgrade.lungCost.ToString();
            liverCost.text  = currentUpgrade.liverCost.ToString();
            kidneyCost.text = currentUpgrade.kidneyCost.ToString();
            heartCost.text  = currentUpgrade.heartCost.ToString();
        }
    }
Esempio n. 23
0
    protected override void Init()
    {
        base.Init();
        instance = this;

        //BtnClose = UnityUtil.FindCtrl<UIButton>(gameObject, "CloseBtn");

        //EventDelegate.Set(BtnClose.onClick, this.OnCloseBtn);

        SprIcon = UnityUtil.FindCtrl <UISprite>(gameObject, "Icon");
        LabName = UnityUtil.FindCtrl <UILabel>(gameObject, "Name");
        LabLv   = UnityUtil.FindCtrl <UILabel>(gameObject, "Lv");

        DerExp = UnityUtil.FindCtrl <UISlider>(gameObject, "ExpBar");

        Globe.allHeroDic.TryGetValue(Globe.selectHero.hero_id, out vo);
        Globe.heroInfoDic.TryGetValue(Globe.selectHero.hero_id, out play);

        GameObject BottleMultList = UnityUtil.FindObjectRecursively(gameObject, "BottleMultList");

        for (int i = 0; i < 6; i++)
        {
            GameObject  go   = UnityUtil.FindObjectRecursively(BottleMultList, "item" + i.ToString());
            UpgradeItem item = new UpgradeItem();
            item.goItem       = go;
            item.SprBg        = go.GetComponent <UISprite>();
            item.SprIcon      = UnityUtil.FindCtrl <UISprite>(go, "MailBtn");
            item.LabCount     = UnityUtil.FindCtrl <UILabel>(go, "Count");
            item.LabExpNumber = UnityUtil.FindCtrl <UILabel>(go, "EXPLabel");

            LisUpgradeItem.Add(item);
        }

        SprIcon.spriteName = vo.icon_name;

        //TODO dele
        HeroData1 data = new HeroData1();

        data.Name   = vo.name;
        data.Lv     = play.Level;
        data.ExpMax = 1000 * play.Level;
        data.ExpNow = play.CurrentExp;
        Open(data);

        isOne = true;
    }
Esempio n. 24
0
    public void buyUpgrade(UpgradeItem _itemToPurchase, UpgradeContainer _uc)
    {
        int lungCost = _itemToPurchase.lungCost, liverCost = _itemToPurchase.liverCost,
            kidneyCost = _itemToPurchase.kidneyCost, heartCost = _itemToPurchase.heartCost;

        GameController gc = GameController.instance;

        if (((gc.getLungAmount() > 0) && (gc.getLungAmount() - lungCost >= 0)) && ((gc.getLiverAmount() > 0) && (gc.getLiverAmount() - liverCost >= 0)) &&
            ((gc.getKidneyAmount() > 0) && (gc.getKidneyAmount() - kidneyCost >= 0)) && ((gc.getHeartAmount() > 0) && (gc.getHeartAmount() - heartCost >= 0)))
        {
            PlayerController pc = GameController.instance.currentPlayer.GetComponent <PlayerController>();

            switch (_itemToPurchase.upgradeName)
            {
            case "Extra Life":
                pc.upgradePlayer(_itemToPurchase.upgradeName);
                break;

            case "Double Shot":
                pc.upgradePlayer(_itemToPurchase.upgradeName);
                _uc.getBuyButton().onClick.RemoveAllListeners();
                _uc.getBuyButton().interactable = false;

                GameController.instance.createUpgradeIcon(_itemToPurchase.upgradeIcon);
                break;

            case "Speed Boost":
                pc.upgradePlayer(_itemToPurchase.upgradeName);
                _uc.getBuyButton().onClick.RemoveAllListeners();
                _uc.getBuyButton().interactable = false;

                GameController.instance.createUpgradeIcon(_itemToPurchase.upgradeIcon);
                break;

            case "Steel Heart":

                break;
            }

            subtractAmounts(lungCost, liverCost, kidneyCost, heartCost);
        }
        else
        {
            //Debug.Log("Not enough organs! Lungs: " + gc.getLungAmount() + ", Liver: " + gc.getLiverAmount() + ", Kidney: " + gc.getKidneyAmount() + ", Heart: " + gc.getHeartAmount());
        }
    }
Esempio n. 25
0
        private void EnumDirectory(string path)
        {
            List <string> files = FileUtility.SearchDirectory(path, "*.*");

            foreach (string file in files)
            {
                if (FileUtility.IsDirectory(file))
                {
                    EnumDirectory(file);
                }
                else
                {
                    UpgradeItem  upItem = new UpgradeItem(file);
                    ListViewItem item   = new ListViewItem(upItem.Name, 1);
                    item.Tag = upItem;
                    lvItems.Items.Add(item);
                }
            }
        }
            public static UpgradeItem Load(List <string> values)
            {
                UpgradeItem item = new UpgradeItem();

                item.iconGraphic = new Graphics(ref values, 23);
                ItemInfo.LoadGeneralSettings1((ItemInfo)item, values);

                int currentPlace = 31;

                for (int i = 0; i < 15; i++)
                {
                    Upgrade child = new Upgrade();
                    child.inputID  = CSVReader.GetInt(values[currentPlace + 0]);
                    child.outputID = CSVReader.GetInt(values[currentPlace + 1]);
                    currentPlace  += 2;
                    item.upgrades.Add(child);
                }

                return(item);
            }
 public override void InitResTable()
 {
     upgradeTabel = new UpgradeItem[5]
     {
         new UpgradeItem(1, 150, new int[4] {
             100, 80, 30, 60
         }),
         new UpgradeItem(2, 310, new int[4] {
             165, 135, 50, 100
         }),
         new UpgradeItem(3, 560, new int[4] {
             280, 225, 85, 165
         }),
         new UpgradeItem(4, 960, new int[4] {
             465, 375, 140, 280
         }),
         new UpgradeItem(5, 1600, new int[4] {
             780, 630, 235, 465
         }),
     };
 }
 public override void InitResTable()
 {
     upgradeTabel = new UpgradeItem[5]
     {
         new UpgradeItem(1, 50, new int[4] {
             70, 90, 70, 20
         }),
         new UpgradeItem(2, 120, new int[4] {
             115, 150, 115, 35
         }),
         new UpgradeItem(3, 300, new int[4] {
             195, 250, 195, 55
         }),
         new UpgradeItem(4, 550, new int[4] {
             325, 420, 325, 95
         }),
         new UpgradeItem(5, 940, new int[4] {
             545, 700, 545, 155
         }),
     };
 }
Esempio n. 29
0
 public override void InitResTable()
 {
     upgradeTabel = new UpgradeItem[5]
     {
         new UpgradeItem(1, 90, new int[4] {
             40, 100, 50, 60
         }),
         new UpgradeItem(2, 210, new int[4] {
             65, 165, 85, 100
         }),
         new UpgradeItem(3, 400, new int[4] {
             110, 280, 140, 165
         }),
         new UpgradeItem(4, 700, new int[4] {
             185, 465, 235, 280
         }),
         new UpgradeItem(5, 1190, new int[4] {
             310, 780, 390, 465
         }),
     };
 }
Esempio n. 30
0
        public async Task <JsonResult> Edit(UpgradeItem item)
        {
            var entity = await _upgradeItemRepository.GetByIdAsync(item.Id);

            if (entity.IsNull())
            {
                return(Json(new { result = false, msg = "后台未找到对应数据" }));
            }
            entity.Name    = item.Name;
            entity.Content = item.Content;
            entity.IsValid = item.IsValid;
            _upgradeItemRepository.Update(entity);
            if (await UnitOfWork.SaveAsync())
            {
                return(Json(new { result = true }));
            }
            else
            {
                return(Json(new { result = false, msg = "修改失败" }));
            }
        }