Esempio n. 1
0
    void OnUpateItem(GameObject go, int index, int realIndex, List <ItemDataManager.ItemData> dataList, Dictionary <int, PropsItem> dataDic)
    {
        int       index_    = 0;
        int       indexList = Mathf.Abs(realIndex);
        PropsItem Item1     = go.transform.Find("item1").GetComponent <PropsItem>();

        Item1.Init(dataList[indexList * 2]);
        if (!dataDic.ContainsKey(dataList[indexList * 2].id))
        {
            dataDic.Add(dataList[indexList * 2].id, Item1);
        }

        index_ = indexList * 2 + 1;
        int tankCount = dataList.Count;

        if (index_ > (tankCount - 1))
        {
            PropsItem tankItem2 = go.transform.Find("item2").GetComponent <PropsItem>();
            tankItem2.gameObject.SetActive(false);
        }
        else
        {
            PropsItem Item2 = go.transform.Find("item2").GetComponent <PropsItem>();
            Item2.gameObject.SetActive(true);
            Item2.Init(dataList[index_]);
            if (!dataDic.ContainsKey(dataList[index_].id))
            {
                dataDic.Add(dataList[index_].id, Item2);
            }
        }
    }
Esempio n. 2
0
 private void InitUseProps(RPGCharacter Character)
 {
     for (int i = 0; i < Character.Logic.Info.Items.Props.Count; i++)
     {
         PropsItem item = Character.Logic.Info.Items.Props[i];
     }
 }
Esempio n. 3
0
    private void UseItem()
    {
        PropsItem thisItemData = FarmDataManager._Instance.dataManager.GetPropsItemByID(BackpackData.nowItemID);

        UseItemIfTools(thisItemData);
        UseItemIfSeeds(thisItemData);
        UseItemIfFoods(thisItemData);
    }
Esempio n. 4
0
 private void UseItemIfTools(PropsItem thisItemData)
 {
     if (thisItemData.mainType == (int)ItemTypeEnum.MainItemType.tools)
     {
         UseItemIfHoe(thisItemData);
         UseItemIfWateringCan(thisItemData);
     }
 }
Esempio n. 5
0
 private void UseItemIfFoods(PropsItem thisItemData)
 {
     if (thisItemData.mainType == (int)ItemTypeEnum.MainItemType.foods)
     {
         FarmDataManager._Instance.VitalittRegain(thisItemData.para1, thisItemData.para1);//后续要做随机区间就配个para2再改一下这里
         FarmDataManager._Instance.ItemReduce(BackpackData.nowBackpackPage, BackpackData.nowBackpackIndex);
     }
 }
Esempio n. 6
0
 public void lerp(PropsItem curItem, PropsItem nextItem, float percent)
 {
     LayoutTools.MOVE_WINDOW(mProp, MathUtility.lerp(curItem.mOriginPosition, nextItem.mOriginPosition, percent));
     LayoutTools.SCALE_WINDOW(mProp, MathUtility.lerp(curItem.mOriginScale, nextItem.mOriginScale, percent));
     mProp.setDepth((int)MathUtility.lerp(curItem.mOriginPropDepth, nextItem.mOriginPropDepth, percent));
     mBackground.setDepth((int)MathUtility.lerp(curItem.mOriginBackgroundDepth, nextItem.mOriginBackgroundDepth, percent));
     mLabel.setDepth((int)MathUtility.lerp(curItem.mOriginLabelDepth, nextItem.mOriginLabelDepth, percent));
     mIcon.setDepth((int)MathUtility.lerp(curItem.mOriginIconDepth, nextItem.mOriginIconDepth, percent));
 }
Esempio n. 7
0
 private void UseItemIfSeeds(PropsItem thisItemData)
 {
     if (thisItemData.mainType == (int)ItemTypeEnum.MainItemType.seeds)
     {
         if (TileMapController._Instance.CheckSownable(Vector3Int.FloorToInt(gameObject.transform.position)))
         {
             TileMapController._Instance.SowingSeed(Vector3Int.FloorToInt(gameObject.transform.position), thisItemData.para1);
         }
     }
 }
Esempio n. 8
0
    public PropsItem GetPropsItemByID(Int32 id)
    {
        PropsItem t = null;

        p_Props.Dict.TryGetValue(id, out t);
        if (t == null)
        {
            Debug.LogWarning("can't find the id " + id + " in Props");
        }
        return(t);
    }
Esempio n. 9
0
 public override void assignWindow()
 {
     newObject(out mControlHelper, "ControlHelper", 1);
     newObject(out mPropsRoot, "PropsRoot");
     for (int i = 0; i < GameDefine.PACK_ITEM_COUNT; ++i)
     {
         PropsItem item = new PropsItem(this);
         item.assignWindow(mPropsRoot, "Props" + i, i);
         mPropsList.Add(item);
     }
 }
Esempio n. 10
0
        /// <summary>
        /// 初始化控件中道具的信息显示
        /// </summary>
        /// <param name="index"></param>
        /// <param name="Prop"></param>
        public void InitButton(int index, PropsItem Prop)
        {
            PropsDef def = Prop.GetDefinition();

            Elements[index].Show(index, def.Icon, def.CommonProperty.Name, PropsThirdText(def, Prop.Usage), true);
            Elements[index].RegisterClickEvent(() =>
            {
                AddPropToWarehouseAction(Prop);
                PropsItems.RemoveAt(index);
                Hide();
            });
        }
Esempio n. 11
0
 private void UseItemIfWateringCan(PropsItem thisItemData)
 {
     if (thisItemData.subType == (int)ItemTypeEnum.ToolsType.wateringCan)
     {
         if (FarmDataManager._Instance.VitalityConsume(thisItemData.para1, thisItemData.para2))
         {
             if (TileMapController._Instance.CheckWaterable(Vector3Int.FloorToInt(gameObject.transform.position)))
             {
                 TileMapController._Instance.WateringLand(Vector3Int.FloorToInt(gameObject.transform.position));
             }
         }
     }
 }
Esempio n. 12
0
 public bool UnEquipProp(int Index)
 {
     if (passiveItems.Count > Index)
     {
         PropsItem item = props[Index];
         props.Add(item);
         passiveItems.RemoveAt(Index);
         return(true);
     }
     else
     {
         Debug.Log("该处没有装备");
         return(false);
     }
 }
Esempio n. 13
0
    IEnumerator CreateUnit(UIGrid grid, List <ItemDataManager.ItemData> unitData, Dictionary <int, PropsItem> dataDic)
    {
        yield return(new WaitForSeconds(0.01f));

        if (grid != null)
        {
            grid.DestoryAllChildren();
        }

        int tankCount = unitData.Count;
        int itemCount = 0;

        if (tankCount % 2 == 0)
        {
            itemCount = tankCount / 2;
        }
        else
        {
            itemCount = tankCount / 2 + 1;
        }
        for (int i = 0; i < itemCount; i++)
        {
            if (grid.gameObject != null)
            {
                int        index_   = 0;
                GameObject tankItem = (GameObject)Resources.Load(AppConfig.FOLDER_PROFAB_UI + "warehouse/props_items");
                GameObject item     = NGUITools.AddChild(grid.gameObject, tankItem);
                item.name = "0" + i;
                PropsItem tankItem1 = item.transform.Find("item1").GetComponent <PropsItem>();
                tankItem1.Init(unitData[i * 2]);
                dataDic.Add(unitData[i * 2].id, tankItem1);
                PropsItem tankItem2 = item.transform.Find("item2").GetComponent <PropsItem>();

                index_ = i * 2 + 1;
                if (index_ > (tankCount - 1))
                {
                    NGUITools.Destroy(tankItem2.gameObject);
                }
                else
                {
                    tankItem2.Init(unitData[index_]);
                    dataDic.Add(unitData[index_].id, tankItem2);
                }
            }
        }
        grid.repositionNow = true;
        grid.Reposition();
    }
Esempio n. 14
0
 public bool AddProp(PropsItem Item)     //获得装备
 {
     if (props.Count == MAX_PROPS_COUNT) //装备已满返回false
     {
         Debug.Log("物品已达上限");
         props.Add(Item);
         RPG.UI.SendItemToWarehouse Sender = UIController.Instance.GetUI <RPG.UI.SendItemToWarehouse>();
         Sender.Show(props);
         return(false);
     }
     else
     {
         props.Add(Item);
         return(true);
     }
 }
Esempio n. 15
0
 public bool AddProp(PropsItem Item, int InsertIndex)      //添加装备到指定顺序
 {
     if (Weapons.Count == ConstTable.CONST_MAX_ITEM_COUNT) //若装备已满,返回FALSE
     {
         Debug.Log("物品已达上限");
         return(false);
     }
     if (InsertIndex >= Weapons.Count)
     {
         props.Add(Item);
     }
     else
     {
         props.Insert(InsertIndex, Item);
     }
     return(true);
 }
Esempio n. 16
0
    protected void updateItem(float controlValue)
    {
        // 变化时需要随时更新当前值
        mCurOffsetValue = controlValue;
        int count = mPropsList.Count;

        for (int i = 0; i < count; ++i)
        {
            PropsItem item  = mPropsList[i];
            float     value = controlValue + item.mControlValueOffset;
            // 确保值在0-1范围内,并且不能等于1
            while (value >= 1.0f)
            {
                value -= 1.0f;
            }
            int   index   = (int)(value * count);
            float percent = (value - (float)index / count) / (1.0f / count);
            mPropsList[i].lerp(mPropsList[index], mPropsList[(index + 1) % count], percent);
        }
    }
Esempio n. 17
0
    public bool EquipProp(int Index)
    {
        if (passiveItems.Count == MAX_PASSIVEITEM_COUNT)
        {
            Debug.Log("慢了,无法在进行装备被动物品");
            return(false);
        }
        PropsItem item = props[Index];

        if (item.GetDefinition().EquipItem)
        {
            passiveItems.Add(item);
            props.RemoveAt(Index);
        }
        else
        {
            Debug.Log("无法装备的物品");
            return(false);
        }

        return(true);
    }
Esempio n. 18
0
 public void RemoveProp(PropsItem Prop)
 {
     Props.Remove(Prop);
 }
Esempio n. 19
0
 public void AddProp(PropsItem Prop)
 {
     Props.Add(Prop);
 }