示例#1
0
        /// <summary>
        /// 设置道具详情信息
        /// </summary>
        /// <param name="model"></param>
        private void SetupItemData(ItemModel model)
        {
            m_ItemNameText.text = model.Name;
            m_ItemDesText.text  = model.GetItemDes();
            m_ItemTypeText.text = model.GetItemCategory();

            // 图标
            GameEntry.Resource.LoadAsset(AssetUtility.GetItemSprite(model.Icon), typeof(Sprite),
                                         new LoadAssetCallbacks(LoadAssetSuccessCallback));

            switch (m_ItemInfoType)
            {
            case ItemInfoType.HumanEquipment:
                m_HumanEquipModel = (HumanEquipModel)model;
                SetupHumanEquipmentItemData(m_HumanEquipModel);
                break;

            case ItemInfoType.VehiclenEquipment:
                m_VehicleEquipModel = (VehicleEquipModel)model;
                SetupVehicleEquipmentItemData(m_VehicleEquipModel);
                break;

            case ItemInfoType.Knapsack:
                m_KnapsackModel = (KnapsackModel)model;
                SetupKnapsackItemData(m_KnapsackModel);
                break;
            }
        }
示例#2
0
        /// <summary>
        /// 佩戴人类装备
        /// </summary>
        /// <param name="itemId">道具编号</param>
        /// <returns></returns>
        private void WornHumanEquipment(int itemId)
        {
            // 默认操作主角的装备,如果有打开装备界面,就根据当前显示的角色进行操作
            var playerType = PlayerType.Rebana;

            if (m_CharacterForm != null)
            {
                playerType = m_CharacterForm.GetCurrentPlayerType();
            }

            var model = new HumanEquipModel(itemId)
            {
                OwerPlayerType = playerType
            };

            // 佩戴装备更新属性
            var previousModel = GameEntry.Archive.Data.GetPlayerData(playerType).Equip(model);

            // 原先有装备,则把卸下的装备放到背包里
            if (previousModel != null)
            {
                GameEntry.Controller.Knapsack.AddItem(previousModel.Id, 1, GetItemSourceType.Exchange);
            }

            // 更新角色装备界面UI
            if (m_CharacterForm != null)
            {
                m_CharacterForm.WornHumanEquipment(model);
            }
        }
示例#3
0
 protected override void OnClose(object userData)
 {
     base.OnClose(userData);
     m_KnapsackModel     = null;
     m_HumanEquipModel   = null;
     m_VehicleEquipModel = null;
     m_ItemIcon.enabled  = false;
 }
示例#4
0
        /// <summary>
        /// 脱下指定角色的装备
        /// </summary>
        /// <param name="model"></param>
        public void TakeOffHumanEquipment(HumanEquipModel model)
        {
            foreach (var equipSolt in m_EquipSolts)
            {
                if (equipSolt.PartType == model.PartType)
                {
                    equipSolt.ClearItemBox();
                    break;
                }
            }

            SetupRoleAttribute();
        }
示例#5
0
        /// <summary>
        /// 清空格子里的道具
        /// </summary>
        public void ClearItemBox()
        {
            m_PlaceholderImage.gameObject.SetActive(true);

            var item = GetComponentInChildren <DrawableItemUI>();

            if (item == null)
            {
                return;
            }

            // 如果格子上有道具则销毁
            m_HumanEquipModel = null;
            DestroyImmediate(item.gameObject);
        }
示例#6
0
        /// <summary>
        /// 设置人类装备格子里的道具数据
        /// </summary>
        /// <param name="model">人类装备模型</param>
        public void SetupData(HumanEquipModel model)
        {
            m_HumanEquipModel = model;

            m_PlaceholderImage.gameObject.SetActive(false);

            // 设置道具数据
            var item = GetComponentInChildren <DrawableItemUI>();

            if (item == null)
            {
                return;
            }
            item.SetupData(model.Id);
        }
示例#7
0
        /// <summary>
        /// 脱下装备
        /// </summary>
        /// <param name="model">装备模型</param>
        public void Unequip(HumanEquipModel model)
        {
            if (model == null || model.Id == 0)
            {
                return;
            }

            switch (model.PartType)
            {
            case HumanPartType.Head:
                HeadModel = null;
                break;

            case HumanPartType.Body:
                BodyModel = null;
                break;

            case HumanPartType.Hand:
                HandModel = null;
                break;

            case HumanPartType.Foot:
                FootModel = null;
                break;

            case HumanPartType.Weapon:
                WeaponModel = null;
                break;
            }

            // 更新装备属性和当前属性
            if (model.Attack != 0)
            {
                EquipAttribute.Attack   -= model.Attack;
                CurrentAttribute.Attack -= model.Attack;
            }

            if (model.Defence != 0)
            {
                EquipAttribute.Defence   -= model.Defence;
                CurrentAttribute.Defence -= model.Defence;
            }

            // 更新总属性
            UpdateTotalAttribute();
        }
示例#8
0
 /// <summary>
 /// 实例化一个装备UI
 /// </summary>
 /// <param name="model"></param>
 private void InstantiateItem(HumanEquipModel model)
 {
     foreach (var equipSolt in m_EquipSolts)
     {
         if (equipSolt.PartType == model.PartType)
         {
             // 原先已经有装备UI,则直接替换数据。没有才实例化
             var itemUI = equipSolt.GetComponentInChildren <DrawableItemUI>();
             if (itemUI == null)
             {
                 Log.Debug("实例化 " + model.Name);
                 var itemGo = Instantiate(m_ItemPrefab);
                 itemGo.transform.SetParent(equipSolt.transform, false);
                 itemGo.transform.SetAsFirstSibling();
             }
             Log.Debug("来了");
             equipSolt.SetupData(model);
             break;
         }
     }
 }
示例#9
0
        /// <summary>
        /// 脱掉人类装备
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool TakeOffHumanEquipment(HumanEquipModel model)
        {
            // 先判断背包能不能放的下
            if (!GameEntry.Controller.Knapsack.KnapsackCapacityEnough(model.Id, 1))
            {
                Log.Debug("背包满了 弹出提示框");
                return(false);
            }

            // 卸下身上的装备数据处理
            GameEntry.Archive.Data.GetPlayerData(model.OwerPlayerType).Unequip(model);

            // 卸下身上的装备更新UI
            if (m_CharacterForm != null)
            {
                m_CharacterForm.TakeOffHumanEquipment(model);
            }

            // 卸下的装备放到背包里
            GameEntry.Controller.Knapsack.AddItem(model.Id, 1, GetItemSourceType.Exchange);

            return(true);
        }
示例#10
0
 /// <summary>
 /// 佩戴指定角色的装备
 /// </summary>
 /// <param name="model"></param>
 public void WornHumanEquipment(HumanEquipModel model)
 {
     m_HumanEquipmentView.WornHumanEquipment(model);
 }
示例#11
0
 /// <summary>
 /// 脱下指定角色的装备
 /// </summary>
 /// <param name="model"></param>
 public void TakeOffHumanEquipment(HumanEquipModel model)
 {
     m_HumanEquipmentView.TakeOffHumanEquipment(model);
 }
示例#12
0
 /// <summary>
 /// 设置人类装备界面道具信息
 /// </summary>
 /// <param name="model"></param>
 private void SetupHumanEquipmentItemData(HumanEquipModel model)
 {
     m_FuncButton1.gameObject.SetActive(true);
     m_FuncButton1.GetComponentInChildren <Text>().text = "卸下";
     m_FuncButton2.gameObject.SetActive(false);
 }
示例#13
0
 /// <summary>
 /// 佩戴指定角色的装备
 /// </summary>
 /// <param name="model"></param>
 public void WornHumanEquipment(HumanEquipModel model)
 {
     InstantiateItem(model);
     SetupRoleAttribute();
 }
示例#14
0
        /// <summary>
        /// 穿戴装备 如果原先有装备则会脱掉
        /// </summary>
        /// <param name="model">装备模型</param>
        /// <returns>被替换的原装备</returns>
        public HumanEquipModel Equip(HumanEquipModel model)
        {
            if (model == null || model.Id == 0)
            {
                return(null);
            }

            // 原先装备
            HumanEquipModel previousModel = null;

            switch (model.PartType)
            {
            case HumanPartType.Head:
                previousModel = HeadModel;
                break;

            case HumanPartType.Body:
                previousModel = BodyModel;
                break;

            case HumanPartType.Hand:
                previousModel = HandModel;
                break;

            case HumanPartType.Foot:
                previousModel = FootModel;
                break;

            case HumanPartType.Weapon:
                previousModel = WeaponModel;
                break;
            }

            // 脱下原先装备
            Unequip(previousModel);

            // 佩戴新装备
            switch (model.PartType)
            {
            case HumanPartType.Head:
                HeadModel = model;
                break;

            case HumanPartType.Body:
                BodyModel = model;
                break;

            case HumanPartType.Hand:
                HandModel = model;
                break;

            case HumanPartType.Foot:
                FootModel = model;
                break;

            case HumanPartType.Weapon:
                WeaponModel = model;
                break;
            }

            // 更新装备属性和当前属性
            if (model.Attack != 0)
            {
                EquipAttribute.Attack   += model.Attack;
                CurrentAttribute.Attack += model.Attack;
            }

            if (model.Defence != 0)
            {
                EquipAttribute.Defence   += model.Defence;
                CurrentAttribute.Defence += model.Defence;
            }

            // 更新总属性
            UpdateTotalAttribute();

            // 因为序列化了,所以要判断id
            if (previousModel == null || previousModel.Id == 0)
            {
                return(null);
            }

            return(previousModel);
        }