public bool UpdataShop(int[] objIDs) { mBuyItemList.Clear(); m_ShopIDList.Clear(); foreach (int objID in objIDs) { ItemObject itemObj = ItemMgr.Instance.Get(objID); if (null != itemObj) { //LogManager.Debug("a item is on sell!ID:" + objID); ShopData data = ShopRespository.GetShopDataByItemId(itemObj.protoId); if (data == null) { LogManager.Error("data is null! itemID = ", itemObj.protoId); mBuyItemList.Add(null); m_ShopIDList.Add(-1); continue; } //itemObj.CountUp(data.m_LimitNum); mBuyItemList.Add(itemObj); m_ShopIDList.Add(data.m_ID); } else { LogManager.Error("itemObj is null! ID = ", objID); mBuyItemList.Add(null); m_ShopIDList.Add(-1); continue; } } return(true); }
public void AddStoreId(List <int> storeIdList) { List <int> addList = new List <int> (); foreach (int id in storeIdList) { List <int> allIdOfSameItem = ShopRespository.GetAllIdOfSameItem(id); int limit = ShopRespository.GetLimitNum(id); List <int> idOfSameOrBingerItem = new List <int> (); List <int> idOfSmallerItem = new List <int> (); foreach (int sid in allIdOfSameItem) { if (sid == id) { idOfSameOrBingerItem.Add(sid); } else if (ShopRespository.GetLimitNum(sid) >= limit) { idOfSameOrBingerItem.Add(sid); } else if (ShopRespository.GetLimitNum(sid) < limit) { idOfSmallerItem.Add(sid); } } bool canAdd = true; foreach (int sbid in idOfSameOrBingerItem) { if (AddedStoreId.Contains(sbid)) { canAdd = false; break; } } if (canAdd) { foreach (int smid in idOfSmallerItem) { if (AddedStoreId.Contains(smid)) { AddedStoreId.Remove(smid); break; } } AddedStoreId.Add(id); addList.Add(id); } } if (addList.Count > 0 && UpdateAddedStoreIdListener != null) { UpdateAddedStoreIdListener(); } }
public bool AddNewItemOnSell(int objID, int index) { ItemObject itemObj = ItemMgr.Instance.Get(objID); if (null != itemObj) { LogManager.Info("An item is on sell!ID:", objID); ShopData data = ShopRespository.GetShopDataByItemId(itemObj.protoId); itemObj.IncreaseStackCount(data.m_LimitNum); mBuyItemList[index] = itemObj; m_ShopIDList[index] = data.m_ID; } else { LogManager.Error("itemObj is null! ID = ", objID); return(false); } return(true); }
public void BuyItem(int instanceId, int count) { int shopID = -1; int cost = 0; ItemObject itemObj = ItemAsset.ItemMgr.Instance.Get(instanceId); if (itemObj == null) { UpdateShop(); return; } if (PeGameMgr.IsMulti) { cost = count * Mathf.RoundToInt(ShopRespository.GetPriceBuyItemId(itemObj.protoId) * (1 + ColonyConst.TRADE_POST_CHARGE_RATE)); if (PlayerMoney.current < cost) { PeTipMsg.Register(PELocalization.GetString(Money.Digital? 8000092:8000073), PeTipMsg.EMsgLevel.Warning); return; } _ColonyObj._Network.RPCServer(EPacketType.PT_CL_TRD_BuyItem, instanceId, count); return; } else { foreach (KeyValuePair <int, stShopData> kvp in mShopList) { if (kvp.Value.ItemObjID == instanceId) { shopID = kvp.Key; break; } } if (shopID < 0) { UpdateShop(); return; } ShopData data = ShopRespository.GetShopData(shopID); if (data != null) { cost = Mathf.RoundToInt(data.m_Price * (1 + ColonyConst.TRADE_POST_CHARGE_RATE)) * count; } else { PeTipMsg.Register(PELocalization.GetString(8000496), PeTipMsg.EMsgLevel.Warning); return; } if (!Buy(itemObj, count, data, false)) { return; } } colonyMoney += cost; RemoveBuyItem(itemObj, count); //--to do: updateUi; UpdateBuyDataToUI(); }
public void UpdateShop() { if (PeGameMgr.IsMulti) { UpdateDataToUI(); _ColonyObj._Network.RPCServer(EPacketType.PT_CL_TRD_RequestShop); return; } mBuyItemList.Clear(); bool bPass = true; foreach (int key in mShopList.Keys) { ShopData data = ShopRespository.GetShopData(key); if (data == null) { continue; } bPass = true; if (PeGameMgr.IsStory) { for (int i = 0; i < data.m_LimitMisIDList.Count; i++) { if (data.m_LimitType == 1) { if (MissionManager.Instance.HadCompleteMission(data.m_LimitMisIDList[i])) { break; } } else { if (!MissionManager.Instance.HadCompleteMission(data.m_LimitMisIDList[i])) { bPass = false; break; } } } } if (!bPass) { continue; } if (mShopList[key].CreateTime < 0) { ItemObject itemObj = ItemAsset.ItemMgr.Instance.CreateItem(data.m_ItemID); // single itemObj.stackCount = data.m_LimitNum; mShopList[key].ItemObjID = itemObj.instanceId; mShopList[key].CreateTime = GameTime.Timer.Second; mBuyItemList.Add(itemObj); } else if (GameTime.Timer.Second - mShopList[key].CreateTime > data.m_RefreshTime) { ItemObject itemObj; if (mShopList[key].ItemObjID >= 0) { itemObj = ItemMgr.Instance.Get(mShopList[key].ItemObjID); if (itemObj == null) { itemObj = ItemMgr.Instance.CreateItem(data.m_ItemID); } itemObj.stackCount = data.m_LimitNum; } else { itemObj = ItemMgr.Instance.CreateItem(data.m_ItemID); // single itemObj.stackCount = data.m_LimitNum; } mShopList[key].ItemObjID = itemObj.instanceId; mShopList[key].CreateTime = GameTime.Timer.Second; mBuyItemList.Add(itemObj); } else { if (mShopList[key].ItemObjID < 0) { continue; } else { ItemObject itemObj = ItemMgr.Instance.Get(mShopList[key].ItemObjID); if (itemObj == null) { itemObj = ItemMgr.Instance.CreateItem(data.m_ItemID); } mShopList[key].ItemObjID = itemObj.instanceId; mBuyItemList.Add(itemObj); } } } UpdateDataToUI(); }
public UnitOfWork(CarShopContext context) { _context = context; Cars = new CarRepository(_context); Shops = new ShopRespository(_context); }
public static void LoadAllData() { if (s_localDatabase != null) { return; } #if UNITY_EDITOR System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); #endif s_localDatabase = LoadDb(); SkillSystem.SkData.LoadData(); Pathea.Effect.EffectData.LoadData(); Pathea.Projectile.ProjectileData.LoadData(); Pathea.RequestRelation.LoadData(); Pathea.CampData.LoadData(); Pathea.ThreatData.LoadData(); Pathea.DamageData.LoadData(); HumanSoundData.LoadData(); ItemDropData.LoadData(); PELocalization.LoadData(); NaturalResAsset.NaturalRes.LoadData(); //SkillAsset.EffCastData.LoadData(); //SkillAsset.EffSkill.LoadData(); //SkillAsset.MergeSkill.LoadData(); //AnimData.LoadData(); //AnimSoundData.LoadData(); AiAsset.AiData.LoadData(); SoundAsset.SESoundBuff.LoadData(); SoundAsset.SESoundStory.LoadData(); //CharacterData.LoadCharacterData(); StoryDoodadMap.LoadData(); StoreRepository.LoadData(); NpcMissionDataRepository.LoadData(); //PlayerAttribute.LoadData(); MissionRepository.LoadData(); TalkRespository.LoadData(); //NpcRandomRepository.LoadData(); ShopRespository.LoadData(); WareHouseManager.LoadData(); //HeroTalkRepository.LoadData(); MutiPlayRandRespository.LoadData(); PromptRepository.LoadData(); //MapIconData.LoadDate(); //MapMaskData.LoadDate(); CampPatrolData.LoadDate(); Camp.LoadData(); RepProcessor.LoadData(); CloudManager.LoadData(); //BattleUnitData.LoadData(); TutorialData.LoadData(); //RepairMachineManager.LoadData(); MapMaskData.LoadDate(); MessageData.LoadData(); //lz-2016.07.13 Add it MonsterHandbookData.LoadData(); //lz-2016.07.20 Add it StoryRepository.LoadData(); RMRepository.LoadRandMission(); MisInitRepository.LoadData(); CameraRepository.LoadCameraPlot(); AdRMRepository.LoadData(); VCConfig.InitConfig(); Cutscene.LoadData(); // BuildBrushData.LoadBrush(); BSPattern.LoadBrush(); BSVoxelMatMap.Load(); BSBlockMatMap.Load(); BlockBuilding.LoadBuilding(); LifeFormRule.LoadData(); PlantInfo.LoadData(); MetalScanData.LoadData(); BattleConstData.LoadData(); CustomCharactor.CustomMetaData.LoadData(); SkillTreeInfo.LoadData(); VArtifactUtil.LoadData(); Pathea.ActionRelationData.LoadActionRelation(); //colony CSInfoMgr.LoadData(); ProcessingObjInfo.LoadData(); CSTradeInfoData.LoadData(); CampTradeIdData.LoadData(); AbnormalTypeTreatData.LoadData(); CSMedicineSupport.LoadData(); //RandomItemMgr RandomItemDataMgr.LoadData(); FecesData.LoadData(); //randomdungeon RandomDungeonDataBase.LoadData(); AbnormalData.LoadData(); PEAbnormalNoticeData.LoadData(); RelationInfo.LoadData(); EquipSetData.LoadData(); SuitSetData.LoadData(); CheatData.LoadData(); Pathea.NpcProtoDb.Load(); Pathea.MonsterProtoDb.Load(); Pathea.MonsterRandomDb.Load(); Pathea.MonsterGroupProtoDb.Load(); Pathea.RandomNpcDb.Load(); Pathea.PlayerProtoDb.Load(); Pathea.TowerProtoDb.Load(); Pathea.DoodadProtoDb.Load(); Pathea.AttPlusNPCData.Load(); Pathea.AttPlusBuffDb.Load(); Pathea.NpcTypeDb.Load(); Pathea.NpcRandomTalkDb.Load(); Pathea.NpcThinkDb.LoadData(); Pathea.NpcEatDb.LoadData(); Pathea.NpcRobotDb.Load(); Pathea.NPCScheduleData.Load(); Pathea.NpcVoiceDb.LoadData(); InGameAidData.LoadData(); //lz-2016.08.21 add it MountsSkillDb.LoadData(); #if UNITY_EDITOR sw.Stop(); Debug.Log("Database Loaded : " + sw.ElapsedMilliseconds); sw.Reset(); #else Debug.Log("Database Loaded"); #endif }