Example #1
0
        public void Bind(StuffItem item, StuffItemInfo info = null)
        {
            this._info   = info ?? ItemNodeUI.GetItemInfo(item);
            this.isTrash = this._info.isTrash;
            this.isNone  = this._info.isNone;
            if (this.isNone)
            {
                this.isTrash = false;
                if (Object.op_Inequality((Object)this._stackCountText, (Object)null))
                {
                    ((Behaviour)this._stackCountText).set_enabled(false);
                }
            }
            ((ReactiveProperty <string>) this._name).set_Value(this._info.Name);
            if (Object.op_Inequality((Object)this._iconImage, (Object)null))
            {
                Resources.ItemIconTables.SetIcon(Resources.ItemIconTables.IconCategory.Item, this._info.IconID, this._iconImage, true);
                if (Object.op_Equality((Object)this._iconImage.get_sprite(), (Object)null))
                {
                    ((Behaviour)this._iconImage).set_enabled(false);
                }
            }
            this._rarelity.set_Value(this._info.Rarelity);
            IntReactiveProperty rate = this._rate;
            int?nullable             = item is MerchantData.VendorItem vendorItem ? new int?(vendorItem.Rate) : new int?();
            int num = !nullable.HasValue ? this._info.Rate : nullable.Value;

            ((ReactiveProperty <int>)rate).set_Value(num);
            this._rarelitySprite.set_Value(this._rarelities.GetElement <Sprite>((int)this._info.Grade));
            this._item = item;
            ((ReactiveProperty <int>) this._stackCount).set_Value(this._item.Count);
        }
 public Actor.SearchInfo GetSearchInfo()
 {
     if (this._searchInfo == null && Singleton <Resources> .IsInstance())
     {
         CommonDefine             commonDefine  = Singleton <Resources> .Instance.CommonDefine;
         Resources.GameInfoTables gameInfo      = Singleton <Resources> .Instance.GameInfo;
         ItemIDKeyPair            driftwoodId   = commonDefine.ItemIDDefine.DriftwoodID;
         StuffItemInfo            stuffItemInfo = gameInfo.GetItem(driftwoodId.categoryID, driftwoodId.itemID);
         if (stuffItemInfo == null)
         {
             return((Actor.SearchInfo)null);
         }
         this._searchInfo = new Actor.SearchInfo()
         {
             IsSuccess = true,
             ItemList  = new List <Actor.ItemSearchInfo>()
             {
                 new Actor.ItemSearchInfo()
                 {
                     categoryID = stuffItemInfo.CategoryID,
                     id         = stuffItemInfo.ID,
                     name       = stuffItemInfo.Name,
                     count      = 1
                 }
             }
         };
     }
     return(this._searchInfo);
 }
Example #3
0
        public virtual Actor.SearchInfo RandomAddItem(
            Dictionary <int, ItemTableElement> itemTable,
            bool containsNone)
        {
            Resources instance = Singleton <Resources> .Instance;

            if (itemTable == null)
            {
                return new Actor.SearchInfo()
                       {
                           IsSuccess = false
                       }
            }
            ;
            Resources.GameInfoTables gameInfo = Singleton <Resources> .Instance.GameInfo;
            int key = this.Lottery(itemTable);
            ItemTableElement itemTableElement;

            if (itemTable.TryGetValue(key, out itemTableElement))
            {
                Actor.SearchInfo searchInfo = new Actor.SearchInfo()
                {
                    IsSuccess = true
                };

                foreach (ItemTableElement.GatherElement element in itemTableElement.Elements)
                {
                    if ((double)Random.get_value() < (double)element.prob)
                    {
                        StuffItemInfo stuffItemInfo = gameInfo.GetItem(element.categoryID, element.itemID);
                        if (stuffItemInfo != null)
                        {
                            int num = Random.Range(element.minCount, element.maxCount + 1);
                            if (num > 0)
                            {
                                searchInfo.ItemList.Add(new Actor.ItemSearchInfo()
                                {
                                    name       = stuffItemInfo.Name,
                                    categoryID = element.categoryID,
                                    id         = element.itemID,
                                    count      = num
                                });
                            }
                        }
                    }
                }
                if (searchInfo.ItemList.IsNullOrEmpty <Actor.ItemSearchInfo>())
                {
                    searchInfo.IsSuccess = false;
                }
                return(searchInfo);
            }
            return(new Actor.SearchInfo()
            {
                IsSuccess = false
            });
        }
Example #4
0
        public virtual TaskStatus OnUpdate()
        {
            foreach (StuffItem stuffItem in this.Agent.AgentData.ItemList)
            {
                StuffItemInfo stuffItemInfo = Singleton <Resources> .Instance.GameInfo.GetItem(stuffItem.CategoryID, stuffItem.ID);

                if (stuffItemInfo != null && stuffItemInfo.EquipableState >= ItemEquipableState.Heroine && this._itemID == stuffItemInfo.ID)
                {
                    return((TaskStatus)2);
                }
            }
            return((TaskStatus)1);
        }
Example #5
0
        public static StuffItemInfo GetItemInfo(StuffItem item)
        {
            if (item == null)
            {
                Debug.LogError((object)"Item none");
                return((StuffItemInfo)null);
            }
            StuffItemInfo stuffItemInfo = Singleton <Resources> .Instance.GameInfo.GetItem(item.CategoryID, item.ID) ?? Singleton <Resources> .Instance.GameInfo.GetItem_System(item.CategoryID, item.ID);

            if (stuffItemInfo == null)
            {
                Debug.LogError((object)string.Format("{0}:{1:00},{2}:{3:00}", (object)"CategoryID", (object)item.CategoryID, (object)"ID", (object)item.ID));
            }
            return(stuffItemInfo);
        }
Example #6
0
        protected override void OnCompletedStateTask()
        {
            AgentActor agent     = this.Agent;
            int        desireKey = Desire.GetDesireKey(Desire.Type.Cook);

            agent.SetDesire(desireKey, 0.0f);
            if (this._createItem == null)
            {
                return;
            }
            StuffItemInfo info = Singleton <Resources> .Instance.GameInfo.GetItem(this._createItem.item.CategoryID, this._createItem.item.ID);

            MapUIContainer.AddItemLog((Actor)agent, info, this._createItem.info.CreateSum, false);
            this._createItem = (CraftUI.CreateItem)null;
        }
Example #7
0
        protected override void OnCompletedStateTask()
        {
            AgentActor agent     = this.Agent;
            int        desireKey = Desire.GetDesireKey(Desire.Type.Hunt);

            agent.SetDesire(desireKey, 0.0f);
            Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = agent.AgentData.SearchActionLockTable;

            AIProject.SaveData.Environment.SearchActionInfo searchActionInfo;
            if (!searchActionLockTable.TryGetValue(agent.CurrentPoint.RegisterID, out searchActionInfo))
            {
                searchActionInfo = new AIProject.SaveData.Environment.SearchActionInfo();
            }
            ++searchActionInfo.Count;
            searchActionLockTable[agent.CurrentPoint.RegisterID] = searchActionInfo;
            ActionPoint currentPoint = this.Agent.CurrentPoint;
            Dictionary <int, ItemTableElement> itemTableInArea = Singleton <Resources> .Instance.GameInfo.GetItemTableInArea(currentPoint.IDList.IsNullOrEmpty <int>()?currentPoint.ID : currentPoint.IDList.GetElement <int>(0));

            if (itemTableInArea != null)
            {
                ;
            }
            Actor.SearchInfo searchInfo = agent.RandomAddItem(itemTableInArea, false);
            if (!searchInfo.IsSuccess)
            {
                return;
            }
            foreach (Actor.ItemSearchInfo itemSearchInfo in searchInfo.ItemList)
            {
                StuffItem stuffItem = new StuffItem(itemSearchInfo.categoryID, itemSearchInfo.id, itemSearchInfo.count);
                agent.AgentData.ItemList.AddItem(stuffItem);
                StuffItemInfo info = Singleton <Resources> .Instance.GameInfo.GetItem(itemSearchInfo.categoryID, itemSearchInfo.id);

                MapUIContainer.AddItemLog((Actor)agent, info, itemSearchInfo.count, false);
            }
        }
Example #8
0
 public virtual bool CanAddItem(StuffItemInfo item)
 {
     return(true);
 }
Example #9
0
        private void OnUpdate()
        {
            List <AIProject.SaveData.Environment.PlantInfo> source;

            if (!Singleton <Game> .Instance.Environment.FarmlandTable.TryGetValue(this.HarvestID, out source))
            {
                return;
            }
            AIProject.SaveData.Environment.PlantInfo element = source.GetElement <AIProject.SaveData.Environment.PlantInfo>(this.SectionID);
            if (element == null)
            {
                if (this._plantInfo == null)
                {
                    return;
                }
                this._plantInfo = (AIProject.SaveData.Environment.PlantInfo)null;
                if (!Object.op_Inequality((Object)this._plantItem, (Object)null))
                {
                    return;
                }
                Object.Destroy((Object)((Component)this._plantItem).get_gameObject());
                this._plantItem = (PlantItem)null;
            }
            else
            {
                if (this._plantInfo != element)
                {
                    this._plantInfo = element;
                    StuffItemInfo seedInfo = Singleton <Resources> .Instance.GameInfo.FindItemInfo(element.nameHash);

                    AssetBundleInfo assetBundleInfo;
                    if (Singleton <Resources> .Instance.Map.PlantItemList.TryGetValue(Singleton <Resources> .Instance.Map.PlantIvyFilterList.Find((Predicate <ItemInfo>)(x => x.CategoryID == seedInfo.CategoryID && x.ItemID == seedInfo.ID)).ObjID, out assetBundleInfo))
                    {
                        GameObject gameObject = CommonLib.LoadAsset <GameObject>((string)assetBundleInfo.assetbundle, (string)assetBundleInfo.asset, false, (string)assetBundleInfo.manifest);
                        MapScene.AddAssetBundlePath((string)assetBundleInfo.assetbundle, (string)assetBundleInfo.manifest);
                        if (Object.op_Inequality((Object)gameObject, (Object)null))
                        {
                            if (Object.op_Inequality((Object)this._plantItem, (Object)null))
                            {
                                Object.Destroy((Object)((Component)this._plantItem).get_gameObject());
                                this._plantItem = (PlantItem)null;
                            }
                            this._plantItem = (PlantItem)((GameObject)Object.Instantiate <GameObject>((M0)gameObject, ((Component)this).get_transform(), false)).GetComponent <PlantItem>();
                            this._plantItem.ChangeState(0);
                        }
                    }
                }
                if (!Object.op_Inequality((Object)this._plantItem, (Object)null))
                {
                    return;
                }
                float num = element.timer / (float)element.timeLimit;
                if ((double)num < 0.5)
                {
                    this._plantItem.ChangeState(0);
                }
                else if ((double)num < 1.0)
                {
                    this._plantItem.ChangeState(1);
                }
                else
                {
                    this._plantItem.ChangeState(2);
                }
            }
        }