Exemple #1
0
        /// <summary>
        /// 初始化背包界面
        /// </summary>
        public void SetUpBagView(bool setVisible)
        {
            this.GetComponent <Canvas> ().enabled = setVisible;

            itemDetail.InitItemDetailHUD(true, HideOperationButtons);
            unlockScrollDetail.InitUnlockScrollDetailHUD(true, null, UnlockItemCallBack, ResolveScrollCallBack);
            craftRecipesDetail.InitCraftingRecipesHUD(true, null, CraftItemCallBack);
            charactersInBag.InitCharactersInBagHUD();


            //获取所有item的图片
//			this.sprites = GameManager.Instance.gameDataCenter.allItemSprites;
            this.player = Player.mainPlayer;



            Agent.PropertyChange propertyChange = player.ResetBattleAgentProperties(false);

            SetUpPlayerStatusPlane(propertyChange);

            SetUpEquipedEquipmentsPlane();

            // 默认初始化 背包一
            SetUpBagItemsPlane(0);
        }
Exemple #2
0
        /// <summary>
        /// 在物品详细信息页点击了装备按钮(装备)
        /// </summary>
        public void OnEquipButtonClick()
        {
            bool[] equipmentSlotUnlockedArray = BuyRecord.Instance.equipmentSlotUnlockedArray;

            for (int i = 0; i < Player.mainPlayer.allEquipedEquipments.Length; i++)
            {
                Equipment equipment = Player.mainPlayer.allEquipedEquipments [i];

                if (equipment.itemId < 0 && equipmentSlotUnlockedArray[i])
                {
                    int oriItemIndexInBag = Player.mainPlayer.GetItemIndexInBag(currentSelectItem);
                    Agent.PropertyChange propertyChange = Player.mainPlayer.EquipEquipment(currentSelectItem as Equipment, i);
                    bagView.SetUpEquipedEquipmentsPlane();
                    bagView.SetUpPlayerStatusPlane(propertyChange);
                    bagView.RemoveBagItemAt(oriItemIndexInBag);

                    AddItemInWait();

                    bagView.QuitItemDetailHUD();
                    bagView.SetUpEquipedEquipmentsPlane();
                    return;
                }
            }

            bagView.SetUpTintHUD("装备栏已满", null);
        }
        protected override void OnUserDrop(PointerEventData eventData)
        {
            GameObject draggedObject = GetDraggedObject(eventData);
            // 获取拖拽物体中的物品信息
            Item draggedItem = GetDraggedItem(eventData);

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

            // 如果是从背包中拖拽出来的物品
            if (draggedObject.GetComponent <ItemInBagDragControl> () != null)
            {
                SetDropResult(eventData, false);
                tintImage.enabled = false;
                return;
            }

            // 如果是从已装备面板拖拽过来的物品
            if (draggedObject.GetComponent <EquipedItemDragControl>() != null)
            {
                if (Player.mainPlayer.CheckBagFull())
                {
                    SetDropResult(eventData, false);
                    tintImage.enabled = false;
                    bagView.SetUpTintHUD("背包已满", null);
                    return;
                }

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

                Equipment equipment = draggedItem as Equipment;

                int equipmentIndexInPanel = GetEquipmentIndexInPanel(equipment);

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

                bagView.SetUpEquipedEquipmentsPlane();

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

            tintImage.enabled = false;
        }
Exemple #4
0
        /// <summary>
        /// 初始化玩家属性界面
        /// </summary>
        public void SetUpPlayerStatusPlane(Agent.PropertyChange propertyChange)
        {
            // 玩家生命条
            healthBar.maxValue = player.maxHealth;
            healthBar.value    = player.health;
            healthText.text    = player.health.ToString() + "/" + player.maxHealth.ToString();

            // 玩家水晶数量
            coinCount.text = player.totalCoins.ToString();

            // 玩家经验条
            playerLevelText.text         = "Lv." + player.agentLevel.ToString();
            playerExperienceBar.maxValue = player.upgradeExprience;
            playerExperienceBar.value    = player.experience;
            playerExperienceText.text    = player.experience.ToString() + "/" + player.upgradeExprience.ToString();


            // 玩家属性面板
            Text playerMaxHealthValue   = playerMaxHealth.Find("PropertyValue").GetComponent <Text>();
            Text playerHitValue         = playerHit.Find("PropertyValue").GetComponent <Text> ();
            Text playerAttackValue      = playerAttack.Find("PropertyValue").GetComponent <Text> ();
            Text playerManaValue        = playerMana.Find("PropertyValue").GetComponent <Text> ();
            Text playerArmorValue       = playerArmor.Find("PropertyValue").GetComponent <Text> ();
            Text playerMagicResistValue = playerMagicResist.Find("PropertyValue").GetComponent <Text> ();
            Text playerDodgeValue       = playerDodge.Find("PropertyValue").GetComponent <Text> ();
            Text playerCritValue        = playerCrit.Find("PropertyValue").GetComponent <Text> ();

            playerMaxHealthValue.text   = player.maxHealth.ToString();
            playerHitValue.text         = player.hit.ToString();
            playerAttackValue.text      = player.attack.ToString();
            playerManaValue.text        = player.mana.ToString();
            playerArmorValue.text       = player.armor.ToString();
            playerMagicResistValue.text = player.magicResist.ToString();
            playerDodgeValue.text       = player.dodge.ToString();
            playerCritValue.text        = player.crit.ToString();


            ShowEquipmentChangeTint(playerMaxHealth, propertyChange.maxHealthChangeFromEq, 0);
            ShowEquipmentChangeTint(playerHit, propertyChange.hitChangeFromEq, 1);
            ShowEquipmentChangeTint(playerAttack, propertyChange.attackChangeFromEq, 2);
            ShowEquipmentChangeTint(playerMana, propertyChange.manaChangeFromEq, 3);
            ShowEquipmentChangeTint(playerArmor, propertyChange.armorChangeFromEq, 4);
            ShowEquipmentChangeTint(playerMagicResist, propertyChange.magicResistChangeFromEq, 5);
            ShowEquipmentChangeTint(playerDodge, propertyChange.dodgeChangeFromEq, 6);
            ShowEquipmentChangeTint(playerCrit, propertyChange.critChangeFromEq, 7);

            ShowConsumablesEffectTint(playerMaxHealth, propertyChange.maxHealthChangeFromOther, 0);
            ShowConsumablesEffectTint(playerHit, propertyChange.hitChangeFromOther, 1);
            ShowConsumablesEffectTint(playerAttack, propertyChange.attackChangeFromOther, 2);
            ShowConsumablesEffectTint(playerMana, propertyChange.manaChangeFromOther, 3);
            ShowConsumablesEffectTint(playerArmor, propertyChange.armorChangeFromOther, 4);
            ShowConsumablesEffectTint(playerMagicResist, propertyChange.magicResistChangeFromOther, 5);
            ShowConsumablesEffectTint(playerDodge, propertyChange.dodgeChangeFromOther, 6);
            ShowConsumablesEffectTint(playerCrit, propertyChange.critChangeFromOther, 7);
        }
Exemple #5
0
        /// <summary>
        /// 在物品详细信息页点击了卸下按钮(装备)
        /// </summary>
        public void OnUnloadButtonClick()
        {
            if (Player.mainPlayer.CheckBagFull())
            {
                bagView.SetUpTintHUD("背包已满", null);
                return;
            }

            for (int i = 0; i < Player.mainPlayer.allEquipedEquipments.Length; i++)
            {
                if (currentSelectItem == Player.mainPlayer.allEquipedEquipments [i])
                {
                    Agent.PropertyChange propertyChange = Player.mainPlayer.UnloadEquipment(currentSelectItem as Equipment, i);
                    bagView.SetUpEquipedEquipmentsPlane();
                    bagView.SetUpPlayerStatusPlane(propertyChange);
                    bagView.AddBagItem(currentSelectItem);
                    bagView.QuitItemDetailHUD();
                    return;
                }
            }
        }
Exemple #6
0
        protected override void OnUserDrop(PointerEventData eventData)
        {
            // 获取拖拽中的物品
            Item itemInBag = GetDraggedItem(eventData);

            bool unlocked = BuyRecord.Instance.equipmentSlotUnlockedArray [equipmentIndexInPanel];

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

            GameObject draggedObject = GetDraggedObject(eventData);

            // 准备换下的装备
            Equipment equipmentPrepareToUnload = GetComponent <ItemDragControl>().item as Equipment;

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


            // 如果是从装备栏中拖拽出来的物品
            if (draggedObject.GetComponent <EquipedItemDragControl>() != null)
            {
//				// 装备标记为拖拽过来的物品的装备标记
//				equipmentPrepareToUnload.equiped = true;
                // 装上背包中拖拽过来的装备标记为已装备
                equipmentPrepareToLoad.equiped = true;

                int unloadEquipmentIndex = equipmentIndexInPanel;

                int loadEquipmentIndex = GetEquipmentIndexInPanel(equipmentPrepareToLoad);

                Debug.LogFormat("装备互换{0}-{1}", unloadEquipmentIndex, loadEquipmentIndex);

                // 互换装备位置(空的格子原来使用空装备占位,也应该进行移动)
                Player.mainPlayer.allEquipedEquipments[unloadEquipmentIndex] = equipmentPrepareToLoad;
                Player.mainPlayer.allEquipedEquipments[loadEquipmentIndex]   = equipmentPrepareToUnload;

                // 对应格子中的装备数据更换
                GetComponent <EquipedItemDragControl>().item = equipmentPrepareToLoad;
                GetDraggedObject(eventData).GetComponent <EquipedItemDragControl> ().item = equipmentPrepareToUnload;

                bagView.SetUpEquipedEquipmentsPlane();

                SetDropResult(eventData, true);

                tintImage.enabled = false;
                return;
            }

            // 如果是从背包中拖拽出来的物品
            if (draggedObject.GetComponent <ItemInBagDragControl>() != null)
            {
                int equipmentIndexInPanel = GetEquipmentIndexInPanel(equipmentPrepareToUnload);

                Agent.PropertyChange propertyChangeFromUnload = new Agent.PropertyChange();

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

                Debug.Log(oriItemIndexInBag);

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

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

                    Debug.Log(equipmentPrepareToUnload.itemName + "UNLOAD");

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

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

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

                bagView.SetUpEquipedEquipmentsPlane();

                bagView.SetUpPlayerStatusPlane(propertyChange);

                // 对应格子中的装备数据更换
                GetComponent <EquipedItemDragControl>().item = equipmentPrepareToLoad;

                Player.mainPlayer.ResetBattleAgentProperties(false);

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

                SetDropResult(eventData, true);

                if (!Player.mainPlayer.CheckBagFull())
                {
                    bagView.GetComponent <BagViewController> ().AddItemInWait();
                }

                tintImage.enabled = false;

                return;
            }

            tintImage.enabled = false;
        }
Exemple #7
0
        /// <summary>
        /// 在物品详细信息页点击了使用按钮(消耗品)
        /// </summary>
        public void OnUseButtonClick()
        {
            Debug.Log("使用了" + currentSelectItem.itemName);

            bool consumblesUsedInExploreScene = false;

            Consumables consumables = currentSelectItem as Consumables;

            Agent.PropertyChange propertyChange = new Agent.PropertyChange();

            switch (consumables.itemName)
            {
            case "药剂":
            case "草药":
            case "蓝莓":
            case "菠菜":
            case "胡萝卜":
            case "樱桃":
            case "南瓜":
            case "蘑菇":
            case "辣椒":

                propertyChange = Player.mainPlayer.UseMedicines(consumables);

                bagView.SetUpPlayerStatusPlane(propertyChange);

                consumblesUsedInExploreScene = false;
                break;

            case "卷轴":

                Player.mainPlayer.RemoveItem(consumables, 1);

                Player.mainPlayer.ResetBattleAgentProperties(true);

                TransformManager.FindTransform("ExploreManager").GetComponent <ExploreManager> ().QuitExploreScene(true);

                consumblesUsedInExploreScene = false;
                break;

            case "锄头":
            case "锯子":
            case "镰刀":
            case "钥匙":
            case "树苗":
            case "火把":
            case "水":
            case "地板":
            case "土块":
            case "开关":
                consumblesUsedInExploreScene = true;
                break;
            }

            bagView.QuitItemDetailHUD();

            if (consumblesUsedInExploreScene)
            {
                OnQuitBagPlaneButtonClick();
                exploreManager.GetComponent <ExploreManager>().clickForConsumablesPos = true;
                exploreManager.GetComponent <ExploreManager>().ShowConsumablesValidPointTintAround(consumables);
            }

            if (!Player.mainPlayer.CheckBagFull())
            {
                AddItemInWait();
            }

            bagView.SetUpCurrentBagItemsPlane();
        }