/// <summary>
        /// 属性宝石构造函数
        /// </summary>
        /// <param name="pgModel">Pg model.</param>
        /// <param name="itemCount">Item count.</param>
        public PropertyGemstone(PropertyGemstone pgModel, int itemCount)
        {
            itemId          = pgModel.itemId;
            itemName        = pgModel.itemName;
            itemDescription = pgModel.itemDescription;
            spriteName      = pgModel.spriteName;
            itemType        = pgModel.itemType;
            price           = pgModel.price;

            this.itemType  = ItemType.PropertyGemstone;
            this.itemCount = itemCount;

            this.maxHealthGainBase           = pgModel.maxHealthGainBase;
            this.maxManaGainBase             = pgModel.maxManaGainBase;
            this.attackGainBase              = pgModel.attackGainBase;
            this.magicAttackGainBase         = pgModel.magicAttackGainBase;
            this.armorGainBase               = pgModel.armorGainBase;
            this.magicResistGainBase         = pgModel.magicResistGainBase;
            this.armorDecreaseGainBase       = pgModel.armorDecreaseGainBase;
            this.magicResistDecreaseGainBase = pgModel.magicResistDecreaseGainBase;
            this.moveSpeedGainBase           = pgModel.moveSpeedGainBase;
            this.critGainBase               = pgModel.critGainBase;
            this.dodgeGainBase              = pgModel.dodgeGainBase;
            this.critHurtScalerGainBase     = pgModel.critHurtScalerGainBase;
            this.physicalHurtScalerGainBase = pgModel.physicalHurtScalerGainBase;
            this.magicalHurtScalerGainBase  = pgModel.magicalHurtScalerGainBase;
            this.extraGoldGainBase          = pgModel.extraGoldGainBase;
            this.extraExperienceGainBase    = pgModel.extraExperienceGainBase;
            this.healthRecoveryGainBase     = pgModel.healthRecoveryGainBase;
            this.magicRecoveryGainBase      = pgModel.magicRecoveryGainBase;

            this.grade = pgModel.grade;
        }
        public void OnAddGemstoneButtonClick()
        {
            if (Player.mainPlayer.totalGold < 50)
            {
                tintHUD.SetUpSingleTextTintHUD("金币不足");
                return;
            }

            Equipment equipment = equipmentCell.soDragControl.item as Equipment;

            if (equipment == null || equipment.itemId < 0)
            {
                return;
            }

            if (equipment.attachedPropertyGemstones.Count == 2)
            {
                tintHUD.SetUpSingleTextTintHUD("没有可用的宝石槽");
                return;
            }

            PropertyGemstone gemstone = functionalItemCell.soDragControl.item as PropertyGemstone;

            if (equipment == null || gemstone == null || gemstone.itemId == -1)
            {
                return;
            }

            PropertyGemstone newGemstone = new PropertyGemstone(gemstone, 1);

            equipment.AddPropertyGemstone(newGemstone);

            Player.mainPlayer.ResetBattleAgentProperties(false);

            Player.mainPlayer.RemoveItem(gemstone, 1);

            Player.mainPlayer.totalGold -= 50;
            ExploreManager.Instance.expUICtr.UpdatePlayerGold();

            GameManager.Instance.soundManager.PlayAudioClip(CommonData.gemstoneAudioName);

            //equipmentCell.ResetSpecialOperationCell ();

            functionalItemCell.ResetSpecialOperationCell();

            if (addGemstoneCallBack != null)
            {
                addGemstoneCallBack(equipment);
            }
        }
예제 #3
0
        /// <summary>
        /// 移除装备上镶嵌的所有宝石
        /// </summary>
        /// <returns>The property gemstons.</returns>
        public PropertyGemstone[] RemovePropertyGemstons()
        {
            PropertyGemstone[] propertyGemstones = new PropertyGemstone[attachedPropertyGemstones.Count];

            for (int i = 0; i < propertyGemstones.Length; i++)
            {
                PropertyGemstone propertyGemstone = attachedPropertyGemstones[i];
                propertyGemstone.itemCount = 1;
                propertyGemstones[i]       = propertyGemstone;
            }

            attachedPropertyGemstones.Clear();

            return(propertyGemstones);
        }
        public void SetUpAttachedSkillDisplay(List <PropertyGemstone> propertyGemstones)
        {
            for (int i = 0; i < attachedGemstoneIcons.Length; i++)
            {
                Image attachedGemstoneIcon = attachedGemstoneIcons[i];
                if (i < propertyGemstones.Count)
                {
                    PropertyGemstone propertyGemstone = propertyGemstones[i];
                    Sprite           s = GameManager.Instance.gameDataCenter.GetGameItemSprite(propertyGemstone);
                    if (s != null)
                    {
                        attachedGemstoneIcon.sprite  = s;
                        attachedGemstoneIcon.enabled = true;
                    }
                    else
                    {
                        attachedGemstoneIcon.enabled = false;
                    }
                }
                else
                {
                    attachedGemstoneIcon.enabled = false;
                }
            }

            for (int i = 0; i < attachedGemstoneDescriptions.Length; i++)
            {
                Text gemstoneDesc = attachedGemstoneDescriptions[i];

                if (i < propertyGemstones.Count)
                {
                    PropertyGemstone propertyGemstone = propertyGemstones[i];
                    gemstoneDesc.text = propertyGemstone.propertyDescription;
                }
                else
                {
                    gemstoneDesc.text = string.Empty;
                }
            }

            this.gameObject.SetActive(true);
        }
예제 #5
0
        /// <summary>
        /// 在物品详细信息页点击了使用按钮
        /// </summary>
        public void OnUseButtonClick()
        {
            // 如果选中的物品为空,直接返回
            if (currentSelectItem == null)
            {
                return;
            }

            // 标记是否清除物品详细信息【如果物品使用完成后数量为0,从背包中移除了,则清除物品的详细信息】
            bool clearItemDetail = false;

            // 进行特殊操作物品【如点金石点的装备,重铸石重铸的装备等】
            Item specialOperaitonItem = null;

            // 标记是否从背包中移除
            bool totallyRemoved = true;

            // 根据当前选中物品的类型不同,区分不同的使用逻辑
            switch (currentSelectItem.itemType)
            {
            // 消耗品使用逻辑
            case ItemType.Consumables:

                Consumables consumables = currentSelectItem as Consumables;

                PropertyChange propertyChange = consumables.UseConsumables(null);

                if (consumables.itemCount > 0)
                {
                    totallyRemoved = false;
                }


                bagView.SetUpPlayerStatusPlane(propertyChange);

                GameManager.Instance.soundManager.PlayAudioClip(consumables.audioName);

                break;

            // 技能卷轴的使用逻辑
            case ItemType.SkillScroll:

                SkillScroll skillScroll = currentSelectItem as SkillScroll;

                // 检查技能是否已经学满了
                if (Player.mainPlayer.CheckSkillFull())
                {
                    string skillFullHint = string.Format("只能学习{0}个技能", Player.mainPlayer.maxSkillCount);
                    bagView.SetUpSingleTextTintHUD(skillFullHint);
                    return;
                }

                // 检查技能是否已经学习过了
                bool skillHasLearned = Player.mainPlayer.CheckSkillHasLearned(skillScroll.skillId);

                if (skillHasLearned)
                {
                    bagView.SetUpSingleTextTintHUD("不能重复学习技能");
                    return;
                }

                totallyRemoved = true;

                propertyChange = skillScroll.UseSkillScroll();

                GameManager.Instance.soundManager.PlayAudioClip(CommonData.paperAudioName);

                // 由于有被动技能,学习后玩家属性上可能有变化,所以学习技能后也要更新属性面板
                bagView.SetUpPlayerStatusPlane(propertyChange);

                break;

            // 特殊物品的使用逻辑
            case ItemType.SpecialItem:

                SpecialItem specialItem = currentSelectItem as SpecialItem;

                Item itemForSpecialOperation = bagView.itemDetail.soCell.itemInCell;

                specialOperaitonItem = itemForSpecialOperation;

                switch (specialItem.specialItemType)
                {
                case SpecialItemType.ChongZhuShi:
                case SpecialItemType.DianJinFuShi:
                    if (itemForSpecialOperation == null)
                    {
                        return;
                    }
                    break;

                case SpecialItemType.TuiMoJuanZhou:
                    if (itemForSpecialOperation == null)
                    {
                        return;
                    }

                    Equipment equipment = itemForSpecialOperation as Equipment;

                    if (equipment.attachedPropertyGemstones.Count == 0)
                    {
                        bagView.hintHUD.SetUpSingleTextTintHUD("当前装备未镶嵌宝石");
                        return;
                    }

                    int addItemCount = 0;

                    for (int i = 0; i < equipment.attachedPropertyGemstones.Count; i++)
                    {
                        PropertyGemstone propertyGemstone = equipment.attachedPropertyGemstones[i];
                        bool             gemstoneExist    = Player.mainPlayer.CheckItemExistInBag(propertyGemstone);
                        if (!gemstoneExist)
                        {
                            addItemCount++;
                        }
                    }

                    if (specialItem.itemCount == 1)
                    {
                        addItemCount--;
                    }

                    bool bagFull = Player.mainPlayer.allItemsInBag.Count + addItemCount >= Player.mainPlayer.maxBagCount * CommonData.singleBagItemVolume;

                    if (bagFull)
                    {
                        bagView.hintHUD.SetUpSingleTextTintHUD("背包已满");
                        return;
                    }

                    break;

                default:
                    break;
                }

                propertyChange = specialItem.UseSpecialItem(itemForSpecialOperation, bagView.itemDetail.SetUpItemDetail);

                bagView.SetUpEquipedEquipmentsPlane();

                bagView.SetUpPlayerStatusPlane(propertyChange);

                break;
            }

            // 如果玩家正在战斗中,更新技能按钮状态
            if (ExploreManager.Instance.battlePlayerCtr.isInFight)
            {
                ExploreManager.Instance.expUICtr.UpdateActiveSkillButtons();
            }

            // 从背包中移除当前选中的物品,如果该物品完全从背包中移除了,则清空物品详细信息面板
            clearItemDetail = Player.mainPlayer.RemoveItem(currentSelectItem, 1);

            // 更新当前背包
            bagView.UpdateCurrentBagItemsPlane();


            if (clearItemDetail)
            {
                bagView.ClearItemDetail();
            }

            // 进行特殊操作的物品,特殊操作结束后显示被操作物品的信息,并在背包中将该物品的选中框高亮
            if (specialOperaitonItem != null)
            {
                currentSelectItem = specialOperaitonItem;
                bagView.SetUpItemDetail(specialOperaitonItem);
                int specialOperaitonItemIndexInBag = Player.mainPlayer.GetItemIndexInBag(specialOperaitonItem);
                if (specialOperaitonItemIndexInBag >= 0)
                {
                    int itemIndexInCurrentBag = specialOperaitonItemIndexInBag % CommonData.singleBagItemVolume;
                    bagView.bagItemsDisplay.SetSelectionIcon(itemIndexInCurrentBag, true);
                }
            }
            // 非特殊操作的物品,如果使用完之后还没有从背包中完全移除,则显示物品的选中框
            else if (!totallyRemoved)
            {
                int itemIndexInBag = Player.mainPlayer.GetItemIndexInBag(currentSelectItem);
                if (itemIndexInBag >= 0)
                {
                    int itemIndexInCurrentBag = itemIndexInBag % CommonData.singleBagItemVolume;
                    bagView.bagItemsDisplay.SetSelectionIcon(itemIndexInCurrentBag, true);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// 使用特殊物品
        /// </summary>
        /// <returns>属性变化</returns>
        /// <param name="itemForSpecialOperation">进行特殊操作的物品</param>
        /// <param name="refreshItemDetailCallBack">使用完成后更新物品描述的回调</param>
        public PropertyChange UseSpecialItem(Item itemForSpecialOperation, CallBackWithItem refreshItemDetailCallBack)
        {
            PropertyChange propertyChange = new PropertyChange();

            switch (specialItemType)
            {
            case SpecialItemType.TuiMoJuanZhou:
                if (itemForSpecialOperation is Equipment)
                {
                    Equipment equipment = itemForSpecialOperation as Equipment;
                    // 使用退魔卷轴,移除装备上的所有属性宝石
                    PropertyGemstone[] propertyGemstones = equipment.RemovePropertyGemstons();
                    // 属性宝石重新添加进背包
                    for (int i = 0; i < propertyGemstones.Length; i++)
                    {
                        Player.mainPlayer.AddItem(propertyGemstones[i]);
                    }

                    // 刷新装备详细信息
                    if (refreshItemDetailCallBack != null)
                    {
                        refreshItemDetailCallBack(equipment);
                    }
                    // 重算人物属性
                    propertyChange = Player.mainPlayer.ResetBattleAgentProperties(false);
                    GameManager.Instance.soundManager.PlayAudioClip(CommonData.xiaoMoAudioName);
                }
                break;

            case SpecialItemType.ChongZhuShi:
                if (itemForSpecialOperation is Equipment)
                {
                    Equipment equipment = itemForSpecialOperation as Equipment;
                    // 重铸装备
                    equipment.RebuildEquipment();
                    // 刷新装备详细信息页面
                    if (refreshItemDetailCallBack != null)
                    {
                        refreshItemDetailCallBack(equipment);
                    }
                    // 重算人物属性
                    propertyChange = Player.mainPlayer.ResetBattleAgentProperties(false);
                    GameManager.Instance.soundManager.PlayAudioClip(CommonData.chongzhuAudioName);
                }
                break;

            case SpecialItemType.YinShenYuPai:
                int oriFadeStepLeft = ExploreManager.Instance.battlePlayerCtr.fadeStepsLeft;
                // 人物隐身20步
                ExploreManager.Instance.battlePlayerCtr.fadeStepsLeft = Mathf.Max(oriFadeStepLeft, 20);
                GameManager.Instance.soundManager.PlayAudioClip(CommonData.yinShenAudioName);
                // 如果原来人物没有隐身,则播放隐身特效动画
                if (oriFadeStepLeft == 0)
                {
                    ExploreManager.Instance.battlePlayerCtr.SetEffectAnim(CommonData.yinShenEffectName, null, 0, 0);
                }
                break;

            case SpecialItemType.DianJinFuShi:
                if (itemForSpecialOperation is Equipment)
                {
                    Equipment equipment = itemForSpecialOperation as Equipment;
                    // 将装备重铸为金色品质
                    equipment.SetToGoldQuality();
                    // 刷新装备详细信息页面
                    if (refreshItemDetailCallBack != null)
                    {
                        refreshItemDetailCallBack(equipment);
                    }
                    // 重算人物属性
                    propertyChange = Player.mainPlayer.ResetBattleAgentProperties(false);
                    GameManager.Instance.soundManager.PlayAudioClip(CommonData.dianjinAudioName);
                }
                break;

            case SpecialItemType.TieYaoShi:
            case SpecialItemType.TongYaoShi:
            case SpecialItemType.JinYaoShi:
            case SpecialItemType.WanNengYaoShi:
            case SpecialItemType.QiaoZhen:
                break;

            case SpecialItemType.QianDai:
                // 钱袋开出500金币
                Player.mainPlayer.totalGold += 500;
                GameManager.Instance.soundManager.PlayAudioClip(CommonData.goldAudioName);
                break;

            case SpecialItemType.ShenMiYaoJi:
                // 神秘药剂增加2个技能点
                Player.mainPlayer.skillNumLeft += 2;
                GameManager.Instance.soundManager.PlayAudioClip(CommonData.drinkAudioName);
                break;

            case SpecialItemType.ShenMiMianJu:
                // 神秘面具隐身30步
                oriFadeStepLeft = ExploreManager.Instance.battlePlayerCtr.fadeStepsLeft;
                ExploreManager.Instance.battlePlayerCtr.fadeStepsLeft = Mathf.Max(oriFadeStepLeft, 30);
                if (oriFadeStepLeft == 0)
                {
                    ExploreManager.Instance.battlePlayerCtr.SetEffectAnim(CommonData.yinShenEffectName, null, 0, 0);
                }
                GameManager.Instance.soundManager.PlayAudioClip(CommonData.yinShenAudioName);
                break;

            case SpecialItemType.JingYanZhiShu:
                // 经验之书直接升一级
                Player.mainPlayer.agentLevel++;
                ExploreManager.Instance.expUICtr.ShowLevelUpPlane();
                GameManager.Instance.soundManager.PlayAudioClip(CommonData.levelUpAudioName);
                break;

            case SpecialItemType.BaoXiang:
                // 宝箱开出1-3个高级宝石
                int gemstoneCount = Random.Range(1, 4);
                List <PropertyGemstoneModel> allHighGradeGemstones = GameManager.Instance.gameDataCenter.allPropertyGemstoneModels.FindAll(delegate(PropertyGemstoneModel obj)
                {
                    return(obj.grade == GemstoneGrade.High);
                });
                for (int i = 0; i < gemstoneCount; i++)
                {
                    int randomSeed = Random.Range(0, allHighGradeGemstones.Count);
                    PropertyGemstoneModel propertyGemstoneModel = allHighGradeGemstones[randomSeed];
                    PropertyGemstone      propertyGemstone      = new PropertyGemstone(propertyGemstoneModel, 1);
                    Player.mainPlayer.AddItem(propertyGemstone);
                }
                GameManager.Instance.soundManager.PlayAudioClip(CommonData.gemstoneAudioName);

                break;

            case SpecialItemType.CaoYao:
                // 草药回复40%生命
                Player.mainPlayer.health += Mathf.RoundToInt(Player.mainPlayer.maxHealth * 0.4f);
                GameManager.Instance.soundManager.PlayAudioClip(CommonData.eatAudoiName);
                break;

            case SpecialItemType.QuSanChangDi:
            case SpecialItemType.QuSanLingDang:
                // 消灭地图上30%的怪物
                ExploreManager.Instance.newMapGenerator.SomeMonstersToPool(0.3f);
                break;

            case SpecialItemType.HuoBa:
            case SpecialItemType.YouDeng:
                // 环境变亮
                ExploreManager.Instance.newMapGenerator.SetUpExploreMask(1);
                break;

            case SpecialItemType.KaiGuan:
                ExploreManager.Instance.newMapGenerator.AllTrapsOff();
                break;

            case SpecialItemType.SiYeCao:
                // 四叶草提升开宝箱是开出好装备的概率
                Player.mainPlayer.luckInOpenTreasure = 1;
                //GameManager.Instance.persistDataManager.SaveCompletePlayerData();
                GameManager.Instance.soundManager.PlayAudioClip(CommonData.siYeCaoAudioName);
                break;

            case SpecialItemType.XingYunYuMao:
                // 幸运羽毛提升怪物掉落物品的概率
                Player.mainPlayer.luckInMonsterTreasure = 1;
                //GameManager.Instance.persistDataManager.SaveCompletePlayerData();
                GameManager.Instance.soundManager.PlayAudioClip(CommonData.xingYunYuMaoAudioName);
                break;
            }
            return(propertyChange);
        }
예제 #7
0
        /// <summary>
        /// 镶嵌属性宝石
        /// </summary>
        /// <param name="propertyGemstone">Property gemstone.</param>
        public void AddPropertyGemstone(PropertyGemstone propertyGemstone)
        {
            propertyGemstone.GemStonePropertyConfigure();

            attachedPropertyGemstones.Add(propertyGemstone);
        }
예제 #8
0
        /// <summary>
        /// 通过物品id和数量初始化物品
        /// 【0-299】装备
        /// 【300-399】消耗品
        /// 【400-499】属性宝石
        /// 【500-599】技能卷轴
        /// 【600-699】特殊物品
        /// </summary>
        public static Item NewItemWith(int itemId, int itemCount)
        {
            Item newItem = null;

            // 逻辑上相同:寻找数据模型->使用数据模型创建新物品

            if (itemId < 300)
            {
                EquipmentModel equipmentModel = GameManager.Instance.gameDataCenter.allEquipmentModels.Find(delegate(EquipmentModel obj)
                {
                    return(obj.itemId == itemId);
                });

                if (equipmentModel == null)
                {
                    string error = string.Format("未找到id为{0}的物品", itemId);
                    Debug.LogError(error);
                }

                newItem = new Equipment(equipmentModel, itemCount);
            }
            else if (itemId >= 300 && itemId < 400)
            {
                ConsumablesModel cm = GameManager.Instance.gameDataCenter.allConsumablesModels.Find(delegate(ConsumablesModel obj)
                {
                    return(obj.itemId == itemId);
                });

                if (cm == null)
                {
                    string error = string.Format("未找到id为{0}的物品", itemId);
                    Debug.LogError(error);
                }

                newItem = new Consumables(cm, itemCount);
            }
            else if (itemId >= 400 && itemId < 500)
            {
                PropertyGemstoneModel propertyGemstoneModel = GameManager.Instance.gameDataCenter.allPropertyGemstoneModels.Find(delegate(PropertyGemstoneModel obj)
                {
                    return(obj.itemId == itemId);
                });

                if (propertyGemstoneModel == null)
                {
                    string error = string.Format("未找到id为{0}的物品", itemId);
                    Debug.LogError(error);
                }

                newItem = new PropertyGemstone(propertyGemstoneModel, itemCount);
            }
            else if (itemId >= 500 && itemId < 600)
            {
                SkillScrollModel skillScrollModel = GameManager.Instance.gameDataCenter.allSkillScrollModels.Find(delegate(SkillScrollModel obj)
                {
                    return(obj.itemId == itemId);
                });

                if (skillScrollModel == null)
                {
                    string error = string.Format("未找到id为{0}的物品", itemId);
                    Debug.LogError(error);
                }

                newItem = new SkillScroll(skillScrollModel, itemCount);
            }
            else if (itemId >= 600 && itemId < 700)
            {
                SpecialItemModel specialItemModel = GameManager.Instance.gameDataCenter.allSpecialItemModels.Find(delegate(SpecialItemModel obj)
                {
                    return(obj.itemId == itemId);
                });
                if (specialItemModel == null)
                {
                    string error = string.Format("未找到id为{0}的物品", itemId);
                    Debug.LogError(error);
                }
                newItem = new SpecialItem(specialItemModel, itemCount);
            }

            return(newItem);
        }