Пример #1
0
        //public void UpdateStatusBars(){
        //	Player player = Player.mainPlayer;
        //          healthBar.maxValue = player.maxHealth;
        //          healthBar.value = player.health;
        //          manaBar.maxValue = player.maxMana;
        //          manaBar.value = player.mana;
        //          experienceBar.maxValue = player.upgradeExprience;
        //          experienceBar.value = player.experience;
        //          goldText.text = player.totalGold.ToString();
        //          levelText.text = string.Format("等级 Lv.{0}", player.agentLevel);
        //}



        public void UpdatePropertyDisplay(PropertyChange pc)
        {
            Player player = Player.mainPlayer;

            ExploreManager.Instance.expUICtr.UpdatePlayerStatusBar();
            attackText.text              = player.attack.ToString();
            magicAttackText.text         = player.magicAttack.ToString();
            armorText.text               = player.armor.ToString();
            magicResistText.text         = player.magicResist.ToString();
            armorDecreaseText.text       = player.armorDecrease.ToString();
            magicResistDecreaseText.text = player.magicResistDecrease.ToString();
            critText.text            = string.Format("{0}%", (player.crit * 100).ToString("F1"));
            dodgeText.text           = string.Format("{0}%", (player.dodge * 100).ToString("F1"));
            extraGoldText.text       = player.extraGold.ToString();
            extraExperienceText.text = player.extraExperience.ToString();
            healthRecoveryText.text  = player.healthRecovery.ToString();
            magicRecoveryText.text   = player.magicRecovery.ToString();



            ShowEquipmentChangeTint(attackChangeTint, pc.attackChange, 0);
            ShowEquipmentChangeTint(magicAttackChangeTint, pc.magicAttackChange, 1);
            ShowEquipmentChangeTint(armorChangeTint, pc.armorChange, 2);
            ShowEquipmentChangeTint(magicResistChangeTint, pc.magicResistChange, 3);
            ShowEquipmentChangeTint(armorDecreaseChangeTint, pc.armorDecreaseChange, 4);
            ShowEquipmentChangeTint(magicResistDecreaseChangeTint, pc.magicResistDecreaseChange, 5);
            ShowEquipmentChangeTint(critChangeTint, pc.critChange, 6);
            ShowEquipmentChangeTint(dodgeChangeTint, pc.dodgeChange, 7);
            ShowEquipmentChangeTint(extraGoldChangeTint, pc.extraGoldChange, 8);
            ShowEquipmentChangeTint(extraExperienceChangeTint, pc.extraExperienceChange, 9);
            ShowEquipmentChangeTint(healthRecoveryChangeTint, pc.healthRecoveryChange, 10);
            ShowEquipmentChangeTint(magicRecoveryChangeTint, pc.magicRecoveryChange, 11);
        }
Пример #2
0
            public static PropertyChange MergeTwoPropertyChange(PropertyChange arg1, PropertyChange arg2)
            {
                PropertyChange mergedPropertyChange = new PropertyChange();

                mergedPropertyChange.maxHealthChangeFromEq   = arg1.maxHealthChangeFromEq + arg2.maxHealthChangeFromEq;
                mergedPropertyChange.hitChangeFromEq         = arg1.hitChangeFromEq + arg2.hitChangeFromEq;
                mergedPropertyChange.attackChangeFromEq      = arg1.attackChangeFromEq + arg2.attackChangeFromEq;
                mergedPropertyChange.attackSpeedChangeFromEq = arg1.attackSpeedChangeFromEq + arg2.attackSpeedChangeFromEq;
                mergedPropertyChange.manaChangeFromEq        = arg1.manaChangeFromEq + arg2.manaChangeFromEq;
                mergedPropertyChange.armorChangeFromEq       = arg1.armorChangeFromEq + arg2.armorChangeFromEq;
                mergedPropertyChange.magicResistChangeFromEq = arg1.magicResistChangeFromEq + arg2.magicResistChangeFromEq;
                mergedPropertyChange.dodgeChangeFromEq       = arg1.dodgeChangeFromEq + arg2.dodgeChangeFromEq;
                mergedPropertyChange.critChangeFromEq        = arg1.critChangeFromEq + arg2.critChangeFromEq;

                mergedPropertyChange.maxHealthChangeFromOther   = arg1.maxHealthChangeFromOther + arg2.maxHealthChangeFromOther;
                mergedPropertyChange.hitChangeFromOther         = arg1.hitChangeFromOther + arg2.hitChangeFromOther;
                mergedPropertyChange.attackChangeFromOther      = arg1.attackChangeFromOther + arg2.attackChangeFromOther;
                mergedPropertyChange.attackSpeedChangeFromOther = arg1.attackSpeedChangeFromOther + arg2.attackSpeedChangeFromOther;
                mergedPropertyChange.manaChangeFromOther        = arg1.manaChangeFromOther + arg2.manaChangeFromOther;
                mergedPropertyChange.armorChangeFromOther       = arg1.armorChangeFromOther + arg2.armorChangeFromOther;
                mergedPropertyChange.magicResistChangeFromOther = arg1.magicResistChangeFromOther + arg2.magicResistChangeFromOther;
                mergedPropertyChange.dodgeChangeFromOther       = arg1.dodgeChangeFromOther + arg2.dodgeChangeFromOther;
                mergedPropertyChange.critChangeFromOther        = arg1.critChangeFromOther + arg2.critChangeFromOther;

                return(mergedPropertyChange);
            }
Пример #3
0
        /// <summary>
        /// 在物品详细信息页点击了装备按钮(装备)
        /// </summary>
        public void OnEquipButtonClick()
        {
            // 当前选中的物品为空时,直接返回
            if (currentSelectItem == null)
            {
                return;
            }

            Equipment equipment = currentSelectItem as Equipment;

            // 装备的类【武器,护甲,头盔等】
            int equipmentIndexInPanel = (int)equipment.equipmentType;

            // 获取物品在背包中的序号
            int oriItemIndexInBag = Player.mainPlayer.GetItemIndexInBag(currentSelectItem);

            // 创建一个空的属性变化对象
            PropertyChange propertyChangeFromUnload = new PropertyChange();

            // 如果额外装备槽已解锁,并且想要装上的装备是戒指,并且原有戒指槽已经有装备,则该戒指撞到额外装备槽上
            if (equipment.equipmentType == EquipmentType.Ring && BuyRecord.Instance.extraEquipmentSlotUnlocked && Player.mainPlayer.allEquipedEquipments[5].itemId >= 0 && Player.mainPlayer.allEquipedEquipments[6].itemId < 0)
            {
                equipmentIndexInPanel = 6;
            }

            // 如果已经有同类型的已装备的额物品,则卸下原装备
            if (Player.mainPlayer.allEquipedEquipments [equipmentIndexInPanel].itemId >= 0)
            {
                Equipment equipmentToUnload = Player.mainPlayer.allEquipedEquipments [equipmentIndexInPanel];
                // 卸下原装备的属性变化
                propertyChangeFromUnload = Player.mainPlayer.UnloadEquipment(equipmentToUnload, equipmentIndexInPanel);
                bagView.AddBagItem(equipmentToUnload);
            }

            // 装备物品产生的属性变化
            PropertyChange propertyChangeFromEquip = Player.mainPlayer.EquipEquipment(currentSelectItem as Equipment, equipmentIndexInPanel);

            // 合并两个属性变化获得最终的属性变化
            PropertyChange finalPropertyChange = PropertyChange.MergeTwoPropertyChange(propertyChangeFromUnload, propertyChangeFromEquip);

            // 更新装备面板
            bagView.SetUpEquipedEquipmentsPlane();

            // 更新玩家属性面板
            bagView.SetUpPlayerStatusPlane(finalPropertyChange);

            // 更新背包物品面板
            bagView.UpdateCurrentBagItemsPlane();

            // 更新操作按钮
            bagView.itemDetail.SetUpOperationButtons(false, true, false);

            // 如果玩家正在战斗过程中,则更新技能按钮状态【有可能更换装备后原来魔法不够,更换完成后魔法够用了】
            if (ExploreManager.Instance.battlePlayerCtr.isInFight)
            {
                ExploreManager.Instance.expUICtr.UpdateActiveSkillButtons();
            }
        }
Пример #4
0
        public void OnConfirmForgetButtonClick()
        {
            queryForgetSkillHUD.gameObject.SetActive(false);

            PropertyChange propertyChange = Player.mainPlayer.ForgetSkill(currentSelectedSkill);

            SetUpSkillView();

            skillStatusChangeCallBack(propertyChange);

            skillDetail.ClearSkillDetail();
        }
Пример #5
0
        /// <summary>
        /// 角色卸下装备
        /// </summary>
        /// <param name="equipment">Equipment.</param>
        /// <param name="equipmentIndexInPanel">Equipment index in panel.</param>
        public PropertyChange UnloadEquipment(Equipment equipment, int equipmentIndexInPanel, int indexInBag = -1)
        {
            SoundManager.Instance.PlayAudioClip("UI/sfx_UI_Equipment");

            equipment.equiped = false;

            Debug.LogFormat("卸下装备{0}/{1}", equipmentIndexInPanel, allEquipedEquipments.Length);

            if (equipment.itemId < 0)
            {
                return(new PropertyChange());
            }

            if (indexInBag == -1)
            {
                allItemsInBag.Add(equipment);
            }
            else
            {
                allItemsInBag.Insert(indexInBag, equipment);
            }

            for (int i = 0; i < equipment.attachedSkills.Count; i++)
            {
                TriggeredSkill attachedSkill = equipment.attachedSkills [i];
                attachedTriggeredSkills.Remove(attachedSkill);
                if (!(battleAgentCtr as BattlePlayerController).isInFight)
                {
                    equipment.attachedSkills.Remove(attachedSkill);
                    Destroy(attachedSkill.gameObject);
                    i--;
                }
            }

            Equipment emptyEquipment = new Equipment();

            allEquipedEquipments [equipmentIndexInPanel] = emptyEquipment;

            PropertyChange pc = ResetBattleAgentProperties(false);

            Transform exploreManager = TransformManager.FindTransform("ExploreManager");

            if (exploreManager != null)
            {
                ExploreManager manager = exploreManager.GetComponent <ExploreManager> ();
                manager.UpdatePlayerPropertyCalculator();
                manager.UpdateTriggeredCallBacks();
                manager.UpdatePlayerStatusPlane();
            }


            return(pc);
        }
Пример #6
0
        /// <summary>
        /// 使用技能卷轴
        /// </summary>
        /// <returns>The skill scroll.</returns>
        public PropertyChange UseSkillScroll()
        {
            // 玩家使用技能卷轴学习技能
            PropertyChange propertyChange = Player.mainPlayer.LearnSkill(skillId);

            // 如果在战斗中使用了技能卷轴学习技能,则更新可用技能按钮
            if (ExploreManager.Instance.battlePlayerCtr.isInFight)
            {
                ExploreManager.Instance.expUICtr.UpdateActiveSkillButtons();
            }

            return(propertyChange);
        }
Пример #7
0
        /// <summary>
        /// 初始化玩家属性界面
        /// </summary>
        public void SetUpPlayerStatusPlane(PropertyChange pc)
        {
            // 根据传入的属性变化,更新属性显示面板
            propertyDisplay.UpdatePropertyDisplay(pc);

            // 更新玩家状态面板
            if (ExploreManager.Instance != null)
            {
                ExploreManager.Instance.expUICtr.UpdatePlayerStatusBar();
            }

            playerLevelText.text = string.Format("等级: {0}", player.agentLevel);
        }
Пример #8
0
        /// <summary>
        /// 角色穿上装备
        /// </summary>
        /// <param name="equipment">Equipment.</param>
        /// <param name="equipmentIndexInPanel">Equipment index in panel.</param>
        public PropertyChange EquipEquipment(Equipment equipment, int equipmentIndexInPanel)
        {
            SoundManager.Instance.PlayAudioClip("UI/sfx_UI_Equipment");

            equipment.equiped = true;

            Debug.LogFormat("穿上装备{0}", equipmentIndexInPanel);

            allEquipedEquipments [equipmentIndexInPanel] = equipment;

//			equipmentDragControl.item = equipment;

            if (equipment.attachedSkills.Count == 0)
            {
                for (int i = 0; i < equipment.attachedSkillInfos.Length; i++)
                {
                    TriggeredSkill attachedSkill = SkillGenerator.Instance.GenerateTriggeredSkill(equipment, equipment.attachedSkillInfos [i], triggeredSkillsContainer);
                    equipment.attachedSkills.Add(attachedSkill);
                    attachedTriggeredSkills.Add(attachedSkill);
                    attachedSkill.transform.SetParent(triggeredSkillsContainer);
                }
            }
            else
            {
                for (int i = 0; i < equipment.attachedSkills.Count; i++)
                {
                    TriggeredSkill attachedSkill = equipment.attachedSkills [i];
                    attachedTriggeredSkills.Add(attachedSkill);
                }
            }

            allItemsInBag.Remove(equipment);

            PropertyChange pc = ResetBattleAgentProperties(false);

            Transform exploreManager = TransformManager.FindTransform("ExploreManager");

            if (exploreManager != null)
            {
                ExploreManager manager = exploreManager.GetComponent <ExploreManager> ();
                manager.UpdatePlayerPropertyCalculator();
                manager.UpdateTriggeredCallBacks();
                manager.UpdatePlayerStatusPlane();
            }

            return(pc);
        }
Пример #9
0
        public void OnUpgradeButtonClick()
        {
            bool skillNumEnough = Player.mainPlayer.skillNumLeft >= currentSelectedSkill.upgradeNum;

            if (skillNumEnough)
            {
                PropertyChange propertyChange = Player.mainPlayer.UpgradeSkill(currentSelectedSkill);

                SetUpSkillView();

                skillStatusChangeCallBack(propertyChange);
            }
            else
            {
                tintHUD.SetUpSingleTextTintHUD("剩余技能点不足");
            }
        }
Пример #10
0
        /// <summary>
        /// 合并两个属性变化
        /// </summary>
        /// <returns>The two property change.</returns>
        /// <param name="arg1">Arg1.</param>
        /// <param name="arg2">Arg2.</param>
        public static PropertyChange MergeTwoPropertyChange(PropertyChange arg1, PropertyChange arg2)
        {
            PropertyChange mergedPropertyChange = new PropertyChange();

            mergedPropertyChange.maxHealthChange           = arg1.maxHealthChange + arg2.maxHealthChange;
            mergedPropertyChange.maxManaChange             = arg1.maxManaChange + arg2.maxManaChange;
            mergedPropertyChange.attackChange              = arg1.attackChange + arg2.attackChange;
            mergedPropertyChange.magicAttackChange         = arg1.magicAttackChange + arg2.magicAttackChange;
            mergedPropertyChange.armorChange               = arg1.armorChange + arg2.armorChange;
            mergedPropertyChange.magicResistChange         = arg1.magicResistChange + arg2.magicResistChange;
            mergedPropertyChange.armorDecreaseChange       = arg1.armorDecreaseChange + arg2.armorDecreaseChange;
            mergedPropertyChange.magicResistDecreaseChange = arg1.magicResistDecreaseChange + arg2.magicResistDecreaseChange;
            mergedPropertyChange.dodgeChange               = arg1.dodgeChange + arg2.dodgeChange;
            mergedPropertyChange.critChange            = arg1.critChange + arg2.critChange;
            mergedPropertyChange.healthRecoveryChange  = arg1.healthRecoveryChange + arg2.healthRecoveryChange;
            mergedPropertyChange.magicRecoveryChange   = arg1.magicRecoveryChange + arg2.magicRecoveryChange;
            mergedPropertyChange.extraGoldChange       = arg1.extraGoldChange + arg2.extraGoldChange;
            mergedPropertyChange.extraExperienceChange = arg1.extraExperienceChange = arg2.extraExperienceChange;
            return(mergedPropertyChange);
        }
Пример #11
0
        /// <summary>
        /// 在物品详细信息页点击了卸下按钮(装备)
        /// </summary>
        public void OnUnloadButtonClick()
        {
            // 如果选中的物品为空,直接返回
            if (currentSelectItem == null)
            {
                return;
            }

            // 检查背包是否已经满了,如果满了提示背包已满,并直接返回
            if (Player.mainPlayer.CheckBagFull(currentSelectItem))
            {
                bagView.SetUpSingleTextTintHUD("背包已满");
                return;
            }

            // 卸下装备,
            Equipment equipmentToUnload = currentSelectItem as Equipment;

            int equipmentIndexInPanel = Player.mainPlayer.GetEquipmentIndexInPanel(equipmentToUnload);

            PropertyChange propertyChange = Player.mainPlayer.UnloadEquipment(equipmentToUnload, equipmentIndexInPanel);

            // 更新装备面板
            bagView.SetUpEquipedEquipmentsPlane();

            // 更新状态面板
            bagView.SetUpPlayerStatusPlane(propertyChange);

            // 背包中添加卸载的装备
            bagView.AddBagItem(currentSelectItem);

            // 清除物品详细信息面板
            bagView.ClearItemDetail();

            // 如果玩家正在战斗中,则更新技能按钮的状态
            if (ExploreManager.Instance.battlePlayerCtr.isInFight)
            {
                ExploreManager.Instance.expUICtr.UpdateActiveSkillButtons();
            }
        }
Пример #12
0
        /// <summary>
        /// 确认移除按钮点击响应
        /// </summary>
        public void OnConfirmRemoveButtonClick()
        {
            if (currentSelectItem == null)
            {
                return;
            }

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

            // 确认移除将会把该物品完全移除出背包
            Player.mainPlayer.RemoveItem(currentSelectItem, currentSelectItem.itemCount);

            // 更新当前背包面板
            bagView.UpdateCurrentBagItemsPlane();
            // 更新探索界面的底部bar
            ExploreManager.Instance.expUICtr.UpdateBottomBar();

            PropertyChange propertyChange = new PropertyChange();

            if (currentSelectItem.itemType == ItemType.Equipment)
            {
                Equipment eqp = currentSelectItem as Equipment;
                if (eqp.equiped)
                {
                    propertyChange = Player.mainPlayer.ResetBattleAgentProperties(false);
                    bagView.SetUpEquipedEquipmentsPlane();
                }
            }

            bagView.SetUpPlayerStatusPlane(propertyChange);

            bagView.ClearItemDetail();

            currentSelectItem = null;

            bagView.HideRemoveQueryHUD();
        }
Пример #13
0
        /// <summary>
        /// 初始化背包界面
        /// </summary>
        public void SetUpBagView(bool setVisible)
        {
            // 默认显示背包界面
            panelIndex = 0;

            // 如果初始化后不显示背包界面
            if (!setVisible)
            {
                this.GetComponent <Canvas>().enabled = false;
                return;
            }

            this.player = Player.mainPlayer;

            // 创建一个空的属性变化,这样开背包时就不会显示属性变化了
            PropertyChange propertyChange = new PropertyChange();

            // 以空的属性变化(属性变化都是0)来初始化玩家状态面板
            SetUpPlayerStatusPlane(propertyChange);

            // 初始化装备面板
            SetUpEquipedEquipmentsPlane();

            // 获取物品点击响应回调
            CallBackWithItem shortClickCallback = GetComponent <BagViewController>().OnItemInBagClick;

            // 根据平台初始化背包面板
#if UNITY_IOS
            bagItemsDisplay.InitBagItemsDisplayPlane(shortClickCallback, PurchaseBagCallBack, buyGoldView.SetUpBuyGoldView);
#elif UNITY_ANDROID
            bagItemsDisplay.InitBagItemsDisplayPlane(shortClickCallback, PurchaseBagCallBack, EnterGoldWatchAdOnAndroid);
#elif UNITY_EDITOR
            UnityEditor.BuildTarget buildTarget = UnityEditor.EditorUserBuildSettings.activeBuildTarget;

            switch (buildTarget)
            {
            case UnityEditor.BuildTarget.Android:
                bagItemsDisplay.InitBagItemsDisplayPlane(shortClickCallback, PurchaseBagCallBack, EnterGoldWatchAdOnAndroid);
                break;

            case UnityEditor.BuildTarget.iOS:
                bagItemsDisplay.InitBagItemsDisplayPlane(shortClickCallback, PurchaseBagCallBack, buyGoldView.SetUpBuyGoldView);
                break;
            }
                #endif
            // 初始化技能面板
            skillsView.InitSkillsView(SetUpPlayerStatusPlane);

            // 默认初始化 背包一
            SetUpBagItemsPlane(0);

            // reset物品详细信息面板
            itemDetail.ClearItemDetails();

            // 默认显示的是背包界面,将背包tab button的字体颜色改为选中的颜色
            bagButtonTitle.color   = CommonData.tabBarTitleSelectedColor;
            skillButtonTitle.color = CommonData.tabBarTitleNormalColor;

            // 初始化技能面板
            skillsView.InitSkillsView(SetUpPlayerStatusPlane);
            // 但是不显示技能面板
            skillsView.QuitSkillsView();

            // 默认初始化 背包一
            SetUpBagItemsPlane(0);

            // reset物品详细信息面板
            itemDetail.ClearItemDetails();

            // 默认显示的是背包界面,将背包tab button的字体颜色改为选中的颜色
            bagButtonTitle.color   = CommonData.tabBarTitleSelectedColor;
            skillButtonTitle.color = CommonData.tabBarTitleNormalColor;

            // 显示背包画布
            this.GetComponent <Canvas>().enabled = true;
        }
Пример #14
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);
                }
            }
        }
        protected override void OnUserDrop(PointerEventData eventData)
        {
            // 获取拖拽中的物品
            Item itemInBag = GetDraggedItem(eventData);

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

            bool canEquip = itemInBag.itemType == ItemType.Equipment;

//			if (itemInBag.itemType != ItemType.Equipment) {
//				canEquip = false;
//			} else {
//				Equipment eqp = itemInBag as Equipment;
//				canEquip = Player.mainPlayer.CheckCanEquiped (eqp.equipmentType);
//			}


            // 没有拖拽中的物品或者该装备栏没有解锁或者物品类型不是装备直接返回
            if (!canEquip)
            {
                SetDropResult(eventData, false);
                tintImage.enabled = false;
                return;
            }

            GameObject draggedObject = GetDraggedObject(eventData);

            // 准备装上的装备
            Equipment equipmentPrepareToLoad = itemInBag as Equipment;


            ItemDragControl dragControl = draggedObject.GetComponent <ItemDragControl>();

            if (dragControl == null)
            {
                return;
            }

            if (bagView != null && !(dragControl is SpecialOperationItemDragControl))
            {
                bagView.GetComponent <BagViewController>().currentSelectItem = equipmentPrepareToLoad;
            }

            int indexInPanel = (int)equipmentPrepareToLoad.equipmentType;

            // 如果额外装备槽已解锁,并且想要装上的装备是戒指,并且原有戒指槽已经有装备,则该戒指撞到额外装备槽上
            if (equipmentPrepareToLoad.equipmentType == EquipmentType.Ring && BuyRecord.Instance.extraEquipmentSlotUnlocked && Player.mainPlayer.allEquipedEquipments[5].itemId >= 0 && Player.mainPlayer.allEquipedEquipments[6].itemId < 0)
            {
                indexInPanel = 6;
            }

            // 准备换下的装备
            Equipment equipmentPrepareToUnload = Player.mainPlayer.allEquipedEquipments[indexInPanel];

            // 如果是从装备栏中拖拽出来的物品
            if (dragControl is EquipedItemDragControl)
            {
                SetDropResult(eventData, true);

                tintImage.enabled = false;
                return;
            }

            // 如果是从背包中拖拽出来的物品
            else if (dragControl is ItemInBagDragControl)
            {
                PropertyChange propertyChangeFromUnload = new PropertyChange();

                int oriItemIndexInBag = Player.mainPlayer.GetItemIndexInBag(equipmentPrepareToLoad);

                if (oriItemIndexInBag == -1)
                {
                    Debug.LogError("背包中没有找到该物品");
                }

                if (equipmentPrepareToUnload.itemId >= 0)
                {
                    // 该装备移入背包中
                    propertyChangeFromUnload = Player.mainPlayer.UnloadEquipment(equipmentPrepareToUnload, indexInPanel, oriItemIndexInBag);

                    bagView.AddBagItem(equipmentPrepareToUnload, oriItemIndexInBag, true);
                }

                // 背包中的装备移入已装备列表
                PropertyChange propertyChangeFromLoad = Player.mainPlayer.EquipEquipment(equipmentPrepareToLoad, indexInPanel);

                PropertyChange propertyChange = PropertyChange.MergeTwoPropertyChange(propertyChangeFromLoad, propertyChangeFromUnload);

                bagView.SetUpEquipedEquipmentsPlane();

                bagView.SetUpPlayerStatusPlane(propertyChange);

                // 对应格子中的装备数据更换
                allEquipedItemDragControls[indexInPanel].item = equipmentPrepareToLoad;

                Player.mainPlayer.ResetBattleAgentProperties(false);

                bagView.RemoveBagItemAt(oriItemIndexInBag + (equipmentPrepareToUnload.itemId >= 0 ? 1 : 0));

                SetDropResult(eventData, true);

                bagView.SetUpItemDetail(equipmentPrepareToLoad);

                tintImage.enabled = false;

                return;
            }

            //else if(dragControl is SpecialOperationItemDragControl){
            //	SpecialOperationCell specialOperationCell = dragControl.GetComponent<SpecialOperationCell>();
            //             specialOperationCell.ResetSpecialOperationCell();
            //             SetDropResult(eventData, true);
            //}

            tintImage.enabled = false;
        }
Пример #16
0
        protected override void OnUserDrop(PointerEventData eventData)
        {
            GameObject draggedObject = GetDraggedObject(eventData);
            // 获取拖拽物体中的物品信息
            Item draggedItem = GetDraggedItem(eventData);

            // 如果拖拽游戏图中没有物品
            if (draggedItem == null || draggedItem.itemId < 0)
            {
                SetDropResult(eventData, false);
                tintImage.enabled = false;
                return;
            }

            ItemDragControl dragControl = draggedObject.GetComponent <ItemDragControl> ();

            if (bagView != null && !(dragControl is SpecialOperationItemDragControl))
            {
                bagView.GetComponent <BagViewController>().currentSelectItem = draggedItem;
            }

            // 如果是从背包中拖拽出来的物品
            if (dragControl is ItemInBagDragControl)
            {
                SetDropResult(eventData, false);
                tintImage.enabled = false;
                return;
            }

            // 如果是从已装备面板拖拽过来的物品
            if (dragControl is EquipedItemDragControl)
            {
                if (Player.mainPlayer.CheckBagFull(draggedItem))
                {
                    SetDropResult(eventData, false);
                    tintImage.enabled = false;
                    bagView.SetUpSingleTextTintHUD("背包已满,请先整理背包");
                    return;
                }

//				EquipedItemDragControl equipmentDragControl = draggedObject.GetComponent<EquipedItemDragControl> ();

                Equipment equipment = draggedItem as Equipment;

                int equipmentIndexInPanel = Player.mainPlayer.GetEquipmentIndexInPanel(equipment);

                PropertyChange propertyChange = Player.mainPlayer.UnloadEquipment(equipment, equipmentIndexInPanel);

                bagView.SetUpEquipedEquipmentsPlane();

                if (equipment.itemId >= 0)
                {
                    bagView.AddBagItem(draggedItem);
                    bagView.SetUpEquipedEquipmentsPlane();
                    bagView.SetUpPlayerStatusPlane(propertyChange);
                    SetDropResult(eventData, true);
                    bagView.ClearItemDetail();
                }
                else
                {
                    SetDropResult(eventData, false);
                }
            }

            // 如果是从特殊操作面板拖拽过来的物品
            if (dragControl is SpecialOperationItemDragControl)
            {
                SpecialOperationCell specialOperationCell = dragControl.GetComponent <SpecialOperationCell>();

                specialOperationCell.ResetSpecialOperationCell();
                SetDropResult(eventData, true);

                //bagView.GetComponent<BagViewController>().itemForSpecialOperation = null;
            }



            tintImage.enabled = false;
        }
Пример #17
0
        /// <summary>
        /// 使用消耗品
        /// </summary>
        /// <returns>返回角色属性变化</returns>
        /// <param name="battleAgentController">Battle agent controller.</param>
        public PropertyChange UseConsumables(BattleAgentController battleAgentController)
        {
            Player player = Player.mainPlayer;

            PropertyChange propertyChange = new PropertyChange();

            // 如果提升最大生命值
            if (maxHealthGain > 0)
            {
                int maxHealthRecord = player.maxHealth;
                player.maxHealth         += maxHealthGain;
                player.originalMaxHealth += maxHealthGain;
                // 按照最大生命值的提升比例同时提升实际生命值
                player.health = Mathf.RoundToInt((player.health * (float)player.maxHealth / maxHealthRecord));
                propertyChange.maxHealthChange = maxHealthGain;
            }

            // 如果提升最大魔法值
            if (maxManaGain > 0)
            {
                int maxManaRecord = player.maxMana;
                player.maxMana         += maxManaGain;
                player.originalMaxMana += maxManaGain;
                // 按照最大魔法值的提升比例同时提升实际魔法值
                player.mana = Mathf.RoundToInt(player.mana * (float)player.maxMana / maxManaRecord);
                propertyChange.maxManaChange = maxManaGain;
            }

            // 如果提升实际生命值
            if (healthGain > 0)
            {
                if (battleAgentController != null)
                {
                    battleAgentController.AddHealthGainAndShow(healthGain + player.healthRecovery);
                    battleAgentController.SetEffectAnim(CommonData.healthHealEffecttName);
                }
                else
                {
                    player.health += healthGain + player.healthRecovery;
                }
            }

            // 如果提升实际魔法值
            if (manaGain > 0)
            {
                if (battleAgentController != null)
                {
                    battleAgentController.AddManaGainAndShow(manaGain + player.magicRecovery);
                    battleAgentController.SetEffectAnim(CommonData.magicHealEffectName);
                }
                else
                {
                    player.mana += manaGain + player.magicRecovery;
                }
            }
            else if (manaGain < 0)
            {
                player.mana += manaGain;
            }

            // 如果提升实际经验值
            if (experienceGain > 0)
            {
                player.experience += experienceGain;
                bool isLevelUp = Player.mainPlayer.LevelUpIfExperienceEnough();
                if (isLevelUp)
                {
                    ExploreManager.Instance.battlePlayerCtr.SetEffectAnim(CommonData.levelUpEffectName);
                    GameManager.Instance.soundManager.PlayAudioClip(CommonData.levelUpAudioName);
                    ExploreManager.Instance.expUICtr.ShowLevelUpPlane();
                }
            }

            // 提升物理攻击力
            if (attackGain > 0)
            {
                player.attack              += attackGain;
                player.originalAttack      += attackGain;
                propertyChange.attackChange = attackGain;
            }

            // 提升魔法攻击力
            if (magicAttackGain > 0)
            {
                player.magicAttack              += magicAttackGain;
                player.originalMagicAttack      += magicAttackGain;
                propertyChange.magicAttackChange = magicAttackGain;
            }

            // 提升护甲
            if (armorGain > 0)
            {
                player.armor              += armorGain;
                player.originalArmor      += armorGain;
                propertyChange.armorChange = armorGain;
            }

            // 提升抗性
            if (magicResistGain > 0)
            {
                player.magicResist              += magicResistGain;
                player.originalMagicResist      += magicResistGain;
                propertyChange.magicResistChange = magicResistGain;
            }

            // 提升护甲穿透
            if (armorDecreaseGain > 0)
            {
                player.armorDecrease              += armorDecreaseGain;
                player.originalArmorDecrease      += armorDecreaseGain;
                propertyChange.armorDecreaseChange = armorDecreaseGain;
            }

            // 提升抗性穿透
            if (magicResistDecreaseGain > 0)
            {
                player.magicResistDecrease              += magicResistDecreaseGain;
                player.originalMagicResistDecrease      += magicResistDecreaseGain;
                propertyChange.magicResistDecreaseChange = magicResistDecreaseGain;
            }

            // 提升移动速度
            if (moveSpeedGain > 0)
            {
                player.moveSpeed         += moveSpeedGain;
                player.originalMoveSpeed += moveSpeedGain;
            }

            // 提升暴击
            if (critGain > 0)
            {
                float myCritGain = (float)critGain / 100;
                player.crit              += myCritGain;
                player.originalCrit      += myCritGain;
                propertyChange.critChange = myCritGain;
            }

            // 提升闪避
            if (dodgeGain > 0)
            {
                float myDodgeGain = (float)dodgeGain / 100;
                player.dodge              += myDodgeGain;
                player.originalDodge      += myDodgeGain;
                propertyChange.dodgeChange = myDodgeGain;
            }

            // 提升暴击伤害倍率
            if (critHurtScalerGain > 0)
            {
                float myCritHurtScalerGain = (float)critHurtScalerGain / 100;
                player.critHurtScaler         += myCritHurtScalerGain;
                player.originalCritHurtScaler += myCritHurtScalerGain;
            }

            // 提升物理伤害系数
            if (physicalHurtScalerGain > 0)
            {
                float myPhysicalHurtScalerGain = (float)physicalHurtScalerGain / 100;
                player.physicalHurtScaler         += myPhysicalHurtScalerGain;
                player.originalPhysicalHurtScaler += myPhysicalHurtScalerGain;
            }

            // 提升魔法伤害系数
            if (magicalHurtScalerGain > 0)
            {
                float myMagicalHurtScalerGain = (float)magicalHurtScalerGain / 100;
                player.magicalHurtScaler         += myMagicalHurtScalerGain;
                player.originalMagicalHurtScaler += myMagicalHurtScalerGain;
            }

            // 提升额外金币
            if (extraGoldGain > 0)
            {
                player.extraGold              += extraGoldGain;
                player.originalExtraGold      += extraGoldGain;
                propertyChange.extraGoldChange = extraGoldGain;
            }

            // 提升额外经验
            if (extraExperienceGain > 0)
            {
                player.extraExperience              += extraExperienceGain;
                player.originalExtraExperience      += extraExperienceGain;
                propertyChange.extraExperienceChange = extraExperienceGain;
            }

            // 提升生命回复
            if (healthRecoveryGain > 0)
            {
                player.healthRecovery              += healthRecoveryGain;
                player.originalHealthRecovery      += healthRecoveryGain;
                propertyChange.healthRecoveryChange = healthRecoveryGain;
            }

            // 提升魔法回复
            if (magicRecoveryGain > 0)
            {
                player.magicRecovery              += magicRecoveryGain;
                player.originalMagicRecovery      += magicRecoveryGain;
                propertyChange.magicRecoveryChange = magicRecoveryGain;
            }



            return(propertyChange);
        }
Пример #18
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);
        }