/// <summary> /// 选择回调 /// </summary> /// <param name="selectView"></param> /// <param name="position"></param> public void ChangeSelectPosition(SelectView selectView, int position) { CreatureCptCharacter character = GetCharacter(); if (character == null) { LogUtil.LogError("没有找到Character组件"); return; } if (selectView == ui_ViewSelectChange_Hair) { CharacterInfoBean characterInfo = listHairInfoData[position]; character.characterSkin.ChangeHair(characterInfo.id); } else if (selectView == ui_ViewSelectChange_Eye) { CharacterInfoBean characterInfo = listEyeInfoData[position]; character.characterSkin.ChangeEye(characterInfo.id); } else if (selectView == ui_ViewSelectChange_Mouth) { CharacterInfoBean characterInfo = listMouthInfoData[position]; character.characterSkin.ChangeMouth(characterInfo.id); } else if (selectView == ui_ViewSelectChange_Clothes) { ItemsInfoBean itemsInfo = listClotehsInfoData[position]; character.characterEquip.ChangeClothes(itemsInfo.id); } }
/// <summary> /// 设置属性 /// </summary> /// <param name="data"></param> public void SetAttributes(ItemsInfoBean data) { CptUtil.RemoveChildsByActive(objAttributeContainer); CreateItemAttributes("ui_ability_life", data.add_life, AttributesTypeEnumTools.GetAttributesName(AttributesTypeEnum.Life), colorForAttribute); CreateItemAttributes("ui_ability_cook", data.add_cook, TextHandler.Instance.manager.GetTextById(1), colorForAttribute); CreateItemAttributes("ui_ability_speed", data.add_speed, AttributesTypeEnumTools.GetAttributesName(AttributesTypeEnum.Speed), colorForAttribute); CreateItemAttributes("ui_ability_account", data.add_account, AttributesTypeEnumTools.GetAttributesName(AttributesTypeEnum.Account), colorForAttribute); CreateItemAttributes("ui_ability_charm", data.add_charm, AttributesTypeEnumTools.GetAttributesName(AttributesTypeEnum.Charm), colorForAttribute); CreateItemAttributes("ui_ability_force", data.add_force, AttributesTypeEnumTools.GetAttributesName(AttributesTypeEnum.Force), colorForAttribute); CreateItemAttributes("ui_ability_lucky", data.add_lucky, AttributesTypeEnumTools.GetAttributesName(AttributesTypeEnum.Lucky), colorForAttribute); if (CheckUtil.StringIsNull(data.effect)) { return; } List <EffectTypeBean> listEffectData = EffectTypeEnumTools.GetListEffectData(data.effect); //获取详情 EffectDetailsEnumTools.GetEffectDetailsForCombat(data.effect_details, out string effectPSName, out int durationForRound); if (listEffectData == null) { return; } foreach (EffectTypeBean itemData in listEffectData) { EffectTypeEnumTools.GetEffectDetails(itemData, null); string describe = itemData.effectDescribe; if (durationForRound != 0) { describe += ("\n" + string.Format(TextHandler.Instance.manager.GetTextById(502), "" + durationForRound)); } CreateItemAttributes(itemData.spIcon, describe); } }
/// <summary> /// 检测是否能被破坏 /// </summary> /// <returns></returns> public bool CheckCanBreak(long breakItemId) { List <BlockBreakTypeEnum> listBreakType = GetBreakType(); for (int i = 0; i < listBreakType.Count; i++) { BlockBreakTypeEnum blockBreakType = listBreakType[i]; if (blockBreakType == BlockBreakTypeEnum.NotBreak) { return(false); } if (blockBreakType == BlockBreakTypeEnum.Normal) { return(true); } else { //如果是空手 if (breakItemId == 0) { } else { ItemsInfoBean useItemInfo = ItemsHandler.Instance.manager.GetItemsInfoById(breakItemId); if (useItemInfo.GetItemsType() == (ItemsTypeEnum)listBreakType[i]) { return(true); } } } } return(false); }
/// <summary> /// 播放使用动画 /// </summary> public virtual void UseForAnim(GameObject user, ItemsBean itemsData) { //播放使用动画 ItemsInfoBean itemsInfo = GetItemsInfo(itemsData.itemId); CreatureCptBase creature = user.GetComponentInChildren <CreatureCptBase>(); if (itemsInfo.anim_use.IsNull()) { //如果没有动画 则播放默认的使用动画 creature.creatureAnim.PlayUse(true); } else { //如果可以转换成int 说明是use的另外一种类型 if (int.TryParse(itemsInfo.anim_use, out int reslut)) { creature.creatureAnim.PlayUse(true, reslut); } else { //如果该道具指定播放指定动画 creature.creatureAnim.PlayAnim(itemsInfo.anim_use); } } }
public void SetContent(ItemsInfoBean data) { string content = "???"; if (data.GetItemsType() == GeneralEnum.Menu && CheckUtil.StringIsNull(data.content)) { MenuInfoBean menuInfo = InnFoodHandler.Instance.manager.GetFoodDataById(data.add_id); if (menuInfo != null) { content = menuInfo.content; } } else { content = data.content; } if (CheckUtil.StringIsNull(content)) { objContent.SetActive(false); } else { objContent.SetActive(true); if (tvContent != null) { tvContent.text = content; } } }
/// <summary> /// 设置手持 /// </summary> /// <param name="handId"></param> public void SetHand(long handId) { ItemsInfoBean itemsInfo = GameItemsHandler.Instance.manager.GetItemsById(handId); Sprite spHand = null; if (itemsInfo != null) { spHand = GameItemsHandler.Instance.manager.GetItemsSpriteByName(itemsInfo.icon_key); } if (spHand == null) { ivHand.color = new Color(1, 1, 1, 0); } else { int scaleY = (int)spHand.rect.height / 32; float scale = (0.5f * scaleY); ivHand.transform.localScale = new Vector3(scale, scale, scale); ivHand.color = new Color(1, 1, 1, 1); } ivHand.sprite = spHand; //设置旋转角度 if (itemsInfo != null && itemsInfo.rotation_angle != 0) { ivHand.transform.localEulerAngles = new Vector3(0, 0, itemsInfo.rotation_angle); } else { ivHand.transform.localEulerAngles = new Vector3(0, 0, 45); } }
/// <summary> /// 设置服装 /// </summary> /// <param name="clothesId"></param> public void SetMask(long maskId) { if (ivMask == null) { return; } ItemsInfoBean itemsInfo = GameItemsHandler.Instance.manager.GetItemsById(maskId); if (itemsInfo == null) { ivMask.color = new Color(1, 1, 1, 0); return; } Sprite spMask = CharacterDressHandler.Instance.manager.GetMaskSpriteByName(itemsInfo.icon_key); if (spMask == null) { ivMask.color = new Color(1, 1, 1, 0); } else { ivMask.color = new Color(1, 1, 1, 1); } ivMask.sprite = spMask; }
/// <summary> /// 获取装备的属性加成 /// </summary> /// <param name="gameItemsManager"></param> /// <returns></returns> public CharacterAttributesBean GetEquipAttributes() { CharacterAttributesBean attributesBean = new CharacterAttributesBean(); ItemsInfoBean maskItem = GameItemsHandler.Instance.manager.GetItemsById(maskId); ItemsInfoBean handItem = GameItemsHandler.Instance.manager.GetItemsById(handId); ItemsInfoBean hatItem = GameItemsHandler.Instance.manager.GetItemsById(hatId); ItemsInfoBean clothesItem = GameItemsHandler.Instance.manager.GetItemsById(clothesId); ItemsInfoBean shoesItem = GameItemsHandler.Instance.manager.GetItemsById(shoesId); if (maskItem != null) { AddAttributes(attributesBean, maskItem); } if (handItem != null) { AddAttributes(attributesBean, handItem); } if (hatItem != null) { AddAttributes(attributesBean, hatItem); } if (clothesItem != null) { AddAttributes(attributesBean, clothesItem); } if (shoesItem != null) { AddAttributes(attributesBean, shoesItem); } return(attributesBean); }
/// <summary> /// 设置鞋子 /// </summary> /// <param name="shoesId"></param> public void SetShoes(long shoesId) { //皇帝的新衣 if (shoesId == 319999) { shoesId = 0; } if (ivShoes == null) { return; } ItemsInfoBean itemsInfo = GameItemsHandler.Instance.manager.GetItemsById(shoesId); if (itemsInfo == null) { ivShoes.color = new Color(1, 1, 1, 0); return; } Sprite spShoes = CharacterDressHandler.Instance.manager.GetShoesSpriteByName(itemsInfo.icon_key); if (spShoes == null) { ivShoes.color = new Color(1, 1, 1, 0); } else { ivShoes.color = new Color(1, 1, 1, 1); } ivShoes.sprite = spShoes; }
/// <summary> /// 在容器中增加新的itemdata /// </summary> /// <param name="arrayContainer"></param> /// <param name="itemId"></param> /// <param name="itemNumber"></param> /// <returns></returns> protected int AddNewItems(ItemsBean[] arrayContainer, long itemId, int itemNumber, string meta) { ItemsInfoBean itemsInfo = ItemsHandler.Instance.manager.GetItemsInfoById(itemId); for (int i = 0; i < arrayContainer.Length; i++) { ItemsBean itemData = arrayContainer[i]; if (itemData == null || itemData.itemId == 0) { ItemsBean newItemData = new ItemsBean(itemId); arrayContainer[i] = newItemData; int subNumber = itemsInfo.max_number; newItemData.meta = meta; //如果增加的数量在该道具的上限之内 if (subNumber >= itemNumber) { newItemData.number += itemNumber; itemNumber = 0; return(itemNumber); } //如果增加的数量在该道具的上限之外 else { newItemData.number = itemsInfo.max_number; itemNumber -= subNumber; } } } return(itemNumber); }
/// <summary> /// 伤害目标 /// </summary> public virtual void DamageTarget(GameObject user, ItemsBean itemsData, Collider[] targetArray) { if (targetArray.IsNull()) { return; } //获取武器伤害 ItemsInfoBean itemsInfo = GetItemsInfo(itemsData.itemId); CreatureCptBase selfCreature = user.GetComponent <CreatureCptBase>(); for (int i = 0; i < targetArray.Length; i++) { Collider itemCollider = targetArray[i]; //获取目标生物 CreatureCptBase creatureCpt = itemCollider.GetComponent <CreatureCptBase>(); if (creatureCpt == null) { continue; } if (creatureCpt == selfCreature) { continue; } creatureCpt.creatureBattle.UnderAttack(user, itemsInfo.atk); } }
/// <summary> /// 设置数据 /// </summary> /// <param name="itemData"></param> /// <param name="storeInfo"></param> public void SetData(ItemBean itemData, StoreInfoBean storeInfo) { this.itemData = itemData; this.storeInfo = storeInfo; Sprite spIcon = null; string name = "???"; if (storeInfo.mark_type == 1) { ItemsInfoBean itemsInfo = GameItemsHandler.Instance.manager.GetItemsById(itemData.itemId); spIcon = GeneralEnumTools.GetGeneralSprite(itemsInfo); if (itemsInfo != null) { name = itemsInfo.name; } } else if (storeInfo.mark_type == 2) { BuildItemBean buildItem = InnBuildHandler.Instance.manager.GetBuildDataById(itemData.itemId); spIcon = BuildItemTypeEnumTools.GetBuildItemSprite(buildItem); if (buildItem != null) { name = buildItem.name; } } SetIcon(spIcon); SetPrice(sellNumber, storeInfo); SetName(name); SetOwn(); SetSellNumber(sellNumber); }
/// <summary> /// 设置弹出框内容 /// </summary> /// <param name="itemsInfo"></param> public void SetPopupData(ItemsInfoBean itemsInfo) { if (infoItemsPopup != null) { infoItemsPopup.SetData(itemsInfo, ivIcon.sprite); } }
protected override void UseForPlayer(Player player, ItemsBean itemData, ItemUseTypeEnum useType) { //检测玩家前方是否有方块 if (player.playerRay.RayToChunkBlock(out RaycastHit hit, out Vector3Int targetBlockPosition)) { ChunkComponent chunkForHit = hit.collider.GetComponentInParent <ChunkComponent>(); if (chunkForHit != null) { //获取位置和方向 player.playerRay.GetHitPositionAndDirection(hit, out Vector3Int targetPosition, out Vector3Int closePosition, out BlockDirectionEnum direction); Vector3Int localPosition = targetPosition - chunkForHit.chunk.chunkData.positionForWorld; //放置位置 Vector3Int upLocalPosition = localPosition + Vector3Int.up; //获取上方方块 Block upBlock = chunkForHit.chunk.chunkData.GetBlockForLocal(upLocalPosition); //如果上方有方块 则无法放置 if (upBlock != null && upBlock.blockType != BlockTypeEnum.None) { return; } ItemsInfoBean itemsInfo = GetItemsInfo(itemData.itemId); CreatureHandler.Instance.CreateCreature(itemsInfo.type_id, targetPosition + Vector3Int.up); } } }
/// <summary> /// 设置数据 /// </summary> public void SetData(long itemId, int itemNumber, string meta) { this.itemId = itemId; this.itemNumber = itemNumber; this.meta = meta; this.itemsInfo = ItemsHandler.Instance.manager.GetItemsInfoById(itemId); RefreshUI(); }
/// <summary> /// 删除数据 /// </summary> /// <param name="itemsInfo"></param> public bool DeleteData(ItemsInfoBean itemsInfo) { if (itemsInfo == null) { return(false); } return(BaseDeleteDataWithLeft("id", "items_id", itemsInfo.id + "")); }
/// <summary> /// 展示UI /// </summary> /// <param name="isCreate"></param> /// <param name="blockInfo"></param> protected void UIForItemItems(bool isCreate, ItemsInfoBean itemsInfo) { if (itemsInfo == null) { return; } GUILayout.BeginHorizontal(); if (isCreate) { if (EditorUI.GUIButton("创建物品", 150)) { itemsInfo.valid = 1; bool isSuccess = serviceForItemsInfo.UpdateData(itemsInfo); if (!isSuccess) { LogUtil.LogError("创建失败"); } } } else { if (EditorUI.GUIButton("更新物品", 150)) { bool isSuccess = serviceForItemsInfo.UpdateData(itemsInfo); if (!isSuccess) { LogUtil.LogError("更新失败"); } } if (EditorUI.GUIButton("删除物品", 150)) { bool isSuccess = serviceForItemsInfo.DeleteData(itemsInfo.id); if (isSuccess) { listQueryData.Remove(itemsInfo); } else { LogUtil.LogError("删除失败"); } } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorUI.GUIText("物品Id", 50); itemsInfo.id = EditorUI.GUIEditorText(itemsInfo.id); EditorUI.GUIText("名字cn", 50); itemsInfo.name_cn = EditorUI.GUIEditorText(itemsInfo.name_cn); EditorUI.GUIText("名字en", 50); itemsInfo.name_en = EditorUI.GUIEditorText(itemsInfo.name_en); EditorUI.GUIText("图标", 50); itemsInfo.icon_key = EditorUI.GUIEditorText(itemsInfo.icon_key, 100); EditorUI.GUIPic("Assets/Texture/Items/" + itemsInfo.icon_key + ".png"); itemsInfo.items_type = (byte)EditorUI.GUIEnum <ItemsTypeEnum>("物品类型", itemsInfo.items_type, 250); GUILayout.EndHorizontal(); }
public static Sprite GetGeneralSprite(ItemsInfoBean itemsInfo, bool isHideDres) { Sprite spIcon = null; switch ((GeneralEnum)itemsInfo.items_type) { case GeneralEnum.Mask: spIcon = CharacterDressHandler.Instance.manager.GetMaskSpriteByName(itemsInfo.icon_key); break; case GeneralEnum.Hat: if (isHideDres) { spIcon = IconDataHandler.Instance.manager.GetIconSpriteByName("unknown_hat_1"); } else { spIcon = CharacterDressHandler.Instance.manager.GetHatSpriteByName(itemsInfo.icon_key); } break; case GeneralEnum.Clothes: if (isHideDres) { spIcon = IconDataHandler.Instance.manager.GetIconSpriteByName("unknown_clothes_1"); } else { spIcon = CharacterDressHandler.Instance.manager.GetClothesSpriteByName(itemsInfo.icon_key); } break; case GeneralEnum.Shoes: if (isHideDres) { spIcon = IconDataHandler.Instance.manager.GetIconSpriteByName("unknown_shoes_1"); } else { spIcon = CharacterDressHandler.Instance.manager.GetShoesSpriteByName(itemsInfo.icon_key); } break; case GeneralEnum.Book: case GeneralEnum.Menu: case GeneralEnum.SkillBook: case GeneralEnum.Read: case GeneralEnum.Gift: case GeneralEnum.Other: spIcon = IconDataHandler.Instance.manager.GetIconSpriteByName(itemsInfo.icon_key); break; default: spIcon = GameItemsHandler.Instance.manager.GetItemsSpriteByName(itemsInfo.icon_key); break; } return(spIcon); }
public void GetItemsInfoSuccess(List <ItemsInfoBean> listData) { this.listDataItems = new Dictionary <long, ItemsInfoBean>(); for (int i = 0; i < listData.Count; i++) { ItemsInfoBean itemData = listData[i]; this.listDataItems.Add(itemData.id, itemData); } }
public override ItemsDetailsBean GetItemsDetailsBean(long itemId) { ItemsInfoBean itemsInfo = GetItemsInfo(itemId); ItemsDetailsToolBean itemsDetailsTool = new ItemsDetailsToolBean(); itemsDetailsTool.life = itemsInfo.life; itemsDetailsTool.lifeMax = itemsInfo.life; return(itemsDetailsTool); }
public void OnCellForItems(ScrollGridCell itemCell) { int index = itemCell.index; ItemBean itemBean = listItemData[index]; ItemsInfoBean itemInfo = GameItemsHandler.Instance.manager.GetItemsById(itemBean.itemId); ItemGameBackpackEquipCpt backpackCpt = itemCell.GetComponent <ItemGameBackpackEquipCpt>(); backpackCpt.SetData(characterData, itemInfo, itemBean); }
public void OnCellForItems(ScrollGridCell itemCell) { ItemBean itemData = listItemData[itemCell.index]; ItemsInfoBean itemsInfo = GameItemsHandler.Instance.manager.GetItemsById(itemData.itemId); ItemGameBackpackPickCpt itemBackpack = itemCell.GetComponent <ItemGameBackpackPickCpt>(); itemBackpack.SetCallBack(this); itemBackpack.SetData(itemsInfo, itemData); itemBackpack.SetSelectionType(itemSelectionType); }
/// <summary> /// 单个数据回调 /// </summary> /// <param name="itemCell"></param> public void OnCellForItem(ScrollGridCell itemCell) { UIViewItemContainer viewItemContainer = itemCell.GetComponent <UIViewItemContainer>(); ItemsInfoBean itemsInfo = listItemsInfo[itemCell.index]; ItemsBean itemsData = new ItemsBean(); itemsData.itemId = itemsInfo.id; itemsData.number = int.MaxValue; viewItemContainer.SetData(UIViewItemContainer.ContainerType.God, itemsData, itemCell.index); }
/// <summary> /// 获取游戏数据 /// </summary> /// <returns></returns> public ItemsInfoBean GetItemsInfoData() { ItemsInfoBean data = serviceItemsInfo.QueryData(); if (data == null) { data = new ItemsInfoBean(); } return(data); }
public void SetData(long itemId) { offsetPivot = new Vector2(0.1f, 0f); this.itemId = itemId; ItemsInfo = ItemsHandler.Instance.manager.GetItemsInfoById(itemId); SetItemIcon(itemId); SetItemName(ItemsInfo.name); SetItemDetails(""); }
public Texture2DArray SetAnimForEquip(string animPro, ItemsInfoBean itemsInfo) { if (itemsInfo == null || itemsInfo.id == 0) { return(null); } Texture2DArray texture2DArray = null; int animLength; string animKey = ""; if (itemsInfo.anim_length != 0) { animKey = itemsInfo.anim_key; animLength = itemsInfo.anim_length; } else { animKey = itemsInfo.icon_key; animLength = 1; } GeneralEnum itemType = itemsInfo.GetItemsType(); switch (itemType) { case GeneralEnum.Mask: texture2DArray = CharacterDressHandler.Instance.manager.GetMaskTextureByName($"{animKey}", animLength); break; case GeneralEnum.Hat: texture2DArray = CharacterDressHandler.Instance.manager.GetHatTextureByName($"{animKey}", animLength); break; case GeneralEnum.Clothes: texture2DArray = CharacterDressHandler.Instance.manager.GetClothesTextureByName($"{animKey}", animLength); break; case GeneralEnum.Shoes: texture2DArray = CharacterDressHandler.Instance.manager.GetShoesTextureByName($"{animKey}", animLength); break; case GeneralEnum.Chef: case GeneralEnum.Waiter: case GeneralEnum.Accoutant: case GeneralEnum.Accost: case GeneralEnum.Beater: texture2DArray = GameItemsHandler.Instance.manager.GetItemsTextureByName($"{animKey}", animLength); break; } srBody.material.SetFloat($"_{animPro}Length", animLength); srBody.material.SetTexture($"_{animPro}Array", texture2DArray); return(texture2DArray); }
/// <summary> /// 添加属性 /// </summary> /// <param name="attributesBean"></param> /// <param name="itemsInfo"></param> private void AddAttributes(CharacterAttributesBean attributesBean, ItemsInfoBean itemsInfo) { attributesBean.life += itemsInfo.add_life; attributesBean.cook += itemsInfo.add_cook; attributesBean.speed += itemsInfo.add_speed; attributesBean.account += itemsInfo.add_account; attributesBean.charm += itemsInfo.add_charm; attributesBean.force += itemsInfo.add_force; attributesBean.lucky += itemsInfo.add_lucky; attributesBean.loyal += itemsInfo.add_loyal; }
/// <summary> /// 更新数据 /// </summary> /// <param name="data"></param> /// <returns></returns> public bool UpdateData(ItemsInfoBean data) { bool deleteState = BaseDeleteDataById(data.id); if (deleteState) { bool insertSuccess = BaseInsertData(tableNameForMain, data); return(insertSuccess); } return(false); }
/// <summary> /// 插入数据 /// </summary> /// <param name="itemsInfo"></param> public void InsertData(ItemsInfoBean itemsInfo) { List <string> listLeftName = new List <string> { "items_id", "content", "name" }; BaseInsertDataWithLeft(itemsInfo, listLeftName); }
/// <summary> /// 获取名字列表 /// </summary> /// <param name="listCharacterInfo"></param> /// <returns></returns> public static List <string> GetNameList(List <ItemsInfoBean> listInfo) { List <string> listName = new List <string>(listInfo.Count); for (int i = 0; i < listInfo.Count; i++) { ItemsInfoBean itemData = listInfo[i]; listName.Add(itemData.name); } return(listName); }