public override IEnumerator Action() { if (this.name == "带灯罩的灯") { yield break; } if (!Scene.GetScene().Contains("花架")) { this.description = "灯好高啊..."; } else if (this.state) { this.description = "通电作业不太安全。"; } else { this.description = "这下就可以安装灯罩了。"; if (ItemPack.GetPack().isOn("灯罩")) { ItemPack.GetPack().TakeAway("灯罩"); this.lightOff = this.LightWithShde_off; this.lightOn = this.LightWithShade_on; this.GetComponent <Image>().sprite = this.lightOff; this.name = "带灯罩的灯"; this.description = "完成了!我需要来试下效果。"; } } yield return(null); }
public void CleanUp() { m_PlayerData.Clear(); m_BackPack = new ItemPack(ItemPack.SIZE_BACKPACK, ItemPack.Type.TYPE_BACKPACK); //玩家创建数据缓存 m_CreateMainPlayerCache = new Obj_Init_Data(); }
public override IEnumerator Action() { if (this.name == "带灯罩的灯") { yield break; } if (!Scene.GetScene().Contains("花架")) { this.description = "The light is high..."; } else if (this.state) { this.description = "It is not safe to install with the power on."; } else { this.description = "OK! Now the lampshade can be installed."; if (ItemPack.GetPack().isOn("灯罩")) { ItemPack.GetPack().TakeAway("灯罩"); this.lightOff = this.LightWithShde_off; this.lightOn = this.LightWithShade_on; this.GetComponent <Image>().sprite = this.lightOff; this.name = "带灯罩的灯"; this.description = "Complete! Let's give it a try."; } } yield return(null); }
public static void DropItem(MapHuman human, Item item, int x, int y) { if (NetworkManager.IsClient) { // check what this item is. if (item.Parent == human.ItemsBody) { SendItemMove(ServerCommands.ItemMoveLocation.UnitBody, ServerCommands.ItemMoveLocation.Ground, item.Class.Option.Slot, -1, item.Count, human, x, y); } else if (item.Parent == human.ItemsPack) { SendItemMove(ServerCommands.ItemMoveLocation.UnitPack, ServerCommands.ItemMoveLocation.Ground, item.Index, -1, item.Count, human, x, y); } } else { // check coordinates if (Math.Abs(human.X - x) > 2 || Math.Abs(human.Y - y) > 2) { x = human.X; y = human.Y; } ItemPack pack = new ItemPack(); pack.PutItem(0, new Item(item, item.Count)); MapLogic.Instance.PutSackAt(x, y, pack, false); } }
public void Release(ChainItem item) { ItemPack _pack = null; if (item.GetType() == typeof(CaptionText))//ClickableText是CaptionText的子类,不能用is判断 { _pack = FindPackage(item, m_CaptionTextBuffer); } else if (item is ClickableText) { _pack = FindPackage(item, m_ClickableTextBuffer); } else if (item is StarItem) { _pack = FindPackage(item, m_StarItemBuffer); } if (_pack == null) { Debug.Log("正在释放未知的CaptionText"); } else { RecyclePackage(_pack); } }
public void Win() { Scene.GetScene().BlockOn(); Corner.GetCorner().BlockOn(); Menu.GetMenu().BlockOn(); ItemPack.GetPack().BlockOn(); StartCoroutine(ShowWin()); }
private void RecyclePackage(ItemPack package) { if (package == null) { return; } package.isUseing = false; package.m_Item.Recycle(m_PoolLayout); }
public override void OnItemAction(ItemGrid grid, EventArgs e) { if (ItemPack.GetPack().isOn("铅笔")) { HUD hud = HUD.GetHUD(); hud.BrotherSpeak("难过", "用地毯画魔法阵,你不怕挨揍吗O_O"); hud.Lose(); } }
public override void OnItemAction(ItemGrid grid, EventArgs e) { if (ItemPack.GetPack().isOn("铅笔")) { HUD hud = HUD.GetHUD(); hud.BrotherSpeak("难过", "By accident, I destroy the crucial clues!"); hud.Lose(); } }
public ItemPack(ItemPack other, bool passive, MapUnit parent) { Passive = passive; Parent = parent; for (int i = 0; i < other.ItemList.Count; i++) { ItemList.Add(new Item(other.ItemList[i], other.ItemList[i].Count)); } Money = other.Money; }
public override IEnumerator Action() { ItemPack pack = ItemPack.GetPack(); if (pack.isOn("有电的遥控器")) { pack.TakeAway("有电的遥控器"); screen.SetActive(true); } yield return(null); }
public ClickableText GetClickableText() { ItemPack _pack = GetIdlePackage(m_ClickableTextBuffer); if (_pack == null) { _pack = new ItemPack(ClickableText.GenerateItem(m_OriginalClickableText, m_PoolLayout)); m_ClickableTextBuffer.Add(_pack); } _pack.isUseing = true; return((ClickableText)_pack.m_Item); }
public StarItem GetStarItem() { ItemPack _pack = GetIdlePackage(m_StarItemBuffer); if (_pack == null) { _pack = new ItemPack(StarItem.GenerateItem(m_OriginalStarItem, m_PoolLayout)); m_StarItemBuffer.Add(_pack); } _pack.isUseing = true; return((StarItem)_pack.m_Item); }
protected void Pick() { Debug.Log("正在拾取道具:" + this.name); ItemGrid grid = ItemPack.GetPack().PutIn(this); grid.OnAction += this.OnItemAction; Image image = this.GetComponent <Image>(); if (image) { image.enabled = false; } }
public void Release(ClickableText item) { ItemPack _pack = FindPackage(item, m_ClickableTextBuffer); if (_pack == null) { Debug.Log("正在释放未知的ClickableText"); } else { RecyclePackage(_pack); } }
public bool Process() { if (!MapLogic.Instance.IsLoaded) { return(false); } ItemPack pack = new ItemPack(); pack.Money = Price; MapLogic.Instance.PutSackAt(X, Y, pack, true); return(true); }
public void ProcessPacket(GameHistoryTechRefundPacket packet, NebulaConnection conn) { //only refund if we have contributed if (packet.TechHashedContributed > 0) { //client should have the same research queued, seek currently needed itemIds and re-add points that were contributed ItemPack itemPoints = GameMain.data.mainPlayer.mecha.lab.itemPoints; foreach (KeyValuePair <int, int> item in itemPoints.items) { itemPoints.Alter(item.Key, (int)packet.TechHashedContributed * 3600); } //let the default method give back the items GameMain.mainPlayer.mecha.lab.ManageTakeback(); } }
private ItemPack FindPackage(ChainItem item, List <ItemPack> list) { ItemPack _pack = null; for (int i = 0; i < list.Count; i++) { ItemPack _temp = list[i]; if (_temp.m_Item.Equals(item)) { _pack = _temp; break; } } return(_pack); }
private ItemPack GetIdlePackage(List <ItemPack> list) { ItemPack _pack = null; for (int i = 0; i < list.Count; i++) { ItemPack _temp = list[i]; if (_temp.isUseing == false) { _pack = _temp; break; } } return(_pack); }
protected void InitBaseUnit() { IsAlive = true; IsDying = false; Stats = new UnitStats(); CoreStats = Stats; ItemStats = new UnitStats(); Actions.Clear(); States.Clear(); Actions.Add(new IdleAction(this)); States.Add(new IdleState(this)); VState = UnitVisualState.Idle; DoUpdateView = true; ItemsBody = new ItemPack(false, this); ItemsPack = new ItemPack(false, this); }
public override void OnItemAction(ItemGrid grid, EventArgs e) { if (ItemPack.GetPack().isOn("电池")) { ItemPack.GetPack().TakeAway("电池"); ItemPack.GetPack().TakeAway("没电的遥控器"); PickableProp controllerUseable = new PickableProp(); controllerUseable.name = "有电的遥控器"; controllerUseable.item_desc = "Don't let Grace find the remote controller..."; controllerUseable.icon_off = this.controllerUseable_off; controllerUseable.icon_on = this.controllerUseable_on; ItemPack.GetPack().PutIn(controllerUseable); } }
public void TryPut() { ItemPack pack = ItemPack.GetPack(); for (int i = 0; i < this._putableItem.Length; i++) { string item = this._putableItem[i]; if (!pack.isOn(item)) { continue; } pack.TakeAway(item); this.Put(this._targetProp[i], this._putPos[i]); break; } }
private void ExportData() { ItemPack pack = CreateInstance <ItemPack>(); pack.items = new List <Item>(); foreach (Item i in handler.itemPack.items) { pack.items.Add(i); } string path = "Assets/World Creator Assets/DefaultItems.asset"; AssetDatabase.CreateAsset(pack, path); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); handler.itemPack = pack; handler.GenerateItemList(); }
public ActionResult CreateEditItemPackage(Guid?pkgId) { using (var db = new SCMSEntities()) { ItemPack model = new ItemPack(); if (pkgId.IsNullOrEmpty()) { model.EntityItemPackage = new ItemPackage(); } else { model.EntityItemPackage = db.ItemPackages.FirstOrDefault(p => p.Id == pkgId); ViewBag.Action = "Edit"; } model.Items = new SelectList(itemService.GetItems(countryProg.Id), "Id", "Name"); return(View(model)); } }
public MapSack PutSackAt(int x, int y, ItemPack pack, bool alwayscreate) { if (x < 0 || y < 0 || x >= Width || y >= Height) { return(null); } MapSack existingsack = null; if (alwayscreate) { RemoveSackAt(x, y); } else { existingsack = GetSackAt(x, y); } if (existingsack == null) { existingsack = new MapSack(pack); existingsack.X = x; existingsack.Y = y; existingsack.Tag = TopSackTag++; existingsack.LinkToWorld(); Objects.Add(existingsack); existingsack.UpdateNetVisibility(); } else { for (int i = 0; i < pack.Count; i++) { existingsack.Pack.PutItem(existingsack.Pack.Count, new Item(pack[i], pack[i].Count)); } existingsack.Pack.Money += pack.Money; existingsack.DoUpdateView = true; if (NetworkManager.IsServer) { Server.NotifySack(x, y, existingsack.Pack.Price); } } return(existingsack); }
public void Init(int levelID,bool isElite) { this.LevelID = levelID; this.IsElite = isElite; this.Text = String.Format("{0}({1})的奖励", DBConfigMgr.Instance.MapLevel[levelID].Name,isElite?"精英":"普通"); CB_Type1.Items.Add("没有"); CB_Type2.Items.Add("没有"); CB_Count1.Value = 1; CB_Count2.Value = 2; foreach (AllConfig config in DBConfigMgr.Instance.MapAllRewardTypes.Values) { CB_Type1.Items.Add(config.Name); CB_Type2.Items.Add(config.Name); } Level levelConfig = DBConfigMgr.Instance.MapLevel[levelID]; string[] rewards = levelConfig.ClientShowRewards.Split(';'); if(isElite) rewards = levelConfig.EliteClientShowRewards.Split(';'); // 赋值 TB_Money.Text = isElite?levelConfig.EliteMoneyReward.ToString():levelConfig.MoneyReward.ToString(); TB_EXP.Text = isElite ? levelConfig.EliteGeneralExpReward.ToString() : levelConfig.GeneralExpReward.ToString(); if (rewards.Length > 0) { Reward1 = new ItemPack(rewards[0]); if (rewards.Length > 1) { Reward2 = new ItemPack(rewards[1]); } } if (Reward1 != null && Reward1.Type != 0) { CB_Type1.SelectedItem = DBConfigMgr.Instance.MapAllRewardTypes[Reward1.Type].Name; TB_ID1.Text = Reward1.ID.ToString(); CB_Count1.Value = Reward1.Count; } }
public override void ProcessPacket(GameHistoryTechRefundPacket packet, NebulaConnection conn) { // TODO: TRY TO MERGE THESE BETTER if (IsHost) { //only refund if we have contributed if (packet.TechHashedContributed > 0) { //client should have the same research queued, seek currently needed itemIds and re-add points that were contributed ItemPack itemPoints = GameMain.data.mainPlayer.mecha.lab.itemPoints; foreach (KeyValuePair <int, int> item in itemPoints.items) { itemPoints.Alter(item.Key, (int)packet.TechHashedContributed * 3600); } //let the default method give back the items GameMain.mainPlayer.mecha.lab.ManageTakeback(); } } else { //only refund if we have contributed if (packet.TechHashedContributed > 0) { TechProto techProto = LDB.techs.Select(packet.TechIdContributed); int[] items = techProto.Items; int[] array = techProto.ItemPoints; //client should have the same research queued, seek currently needed itemIds and re-add points that were contributed for (int i = 0; i < array.Length; i++) { int itemId = items[i]; int contributedItems = (int)packet.TechHashedContributed * array[i]; GameMain.data.mainPlayer.mecha.lab.itemPoints.Alter(itemId, contributedItems); } //let the default method give back the items GameMain.mainPlayer.mecha.lab.ManageTakeback(); } } }
public Item(Item original, int count) { for (int i = 0; i < original.ParentUIDs.Count; i++) { ParentUIDs.Add(original.ParentUIDs[i]); } // generate UID (or duplicate old) if (count >= original.Count) { UID = original.UID; // moved old item } else { UID = LocalTopUID++; // new item ParentUIDs.Add(original.UID); } Class = original.Class; Price = original.Price; Count = Math.Min(original.Count, count); Parent = original.Parent; Index = original.Index; InitItem(); MagicEffects.AddRange(original.MagicEffects); if (Class == null) { Debug.LogFormat("Invalid item duplicated (class=<null>)"); return; } UpdateItem(); }
public ActionResult CreateEditItemPackage(ItemPack model, string Action = "") { if (ModelState.IsValid) { if (Action.Equals("Edit")) { if (itemService.EditPackage(model.EntityItemPackage)) { ModelState.Clear(); model.EntityItemPackage = new ItemPackage(); } } else { model.EntityItemPackage.Id = Guid.NewGuid(); if (itemService.AddPackage(model.EntityItemPackage)) { ModelState.Clear(); model.EntityItemPackage = new ItemPackage(); } } } return(RedirectToAction("ListView")); }
public bool Process(ServerClient client) { if (client.State != ClientState.Playing) { return(false); } Player player = MapLogic.Instance.GetNetPlayer(client); if (player == null) { return(false); // huehue, same as "order error" in a2server.exe, except we just boot them } MapUnit unit = MapLogic.Instance.GetUnitByTag(UnitTag); // we can't do anything with units that don't belong to our player. if (unit.Player != player) { return(true); } // right now only body<->pack is supported, no shop or ground items Item item = null; switch (Destination) { case ItemMoveLocation.UnitBody: if (unit == null) { return(true); } item = GetItem(unit); if (!unit.IsItemUsable(item)) { return(true); // can't use } item = TakeItem(unit); if (item == null) { return(true); } unit.PutItemToBody((MapUnit.BodySlot)item.Class.Option.Slot, item); break; case ItemMoveLocation.UnitPack: if (unit == null) { return(true); } item = TakeItem(unit); if (item == null) { return(true); } unit.ItemsPack.PutItem(DestinationIndex, item); break; case ItemMoveLocation.Ground: if (unit == null) { return(true); } item = TakeItem(unit); if (item == null) { return(true); } if (Math.Abs(CellX - unit.X) > 2 || Math.Abs(CellY - unit.Y) > 2) { CellX = unit.X; CellY = unit.Y; } ItemPack pack = new ItemPack(); pack.PutItem(0, new Item(item, item.Count)); MapLogic.Instance.PutSackAt(CellX, CellY, pack, false); break; } Server.NotifyUnitPack(unit); return(true); }
public Shelf(AllodsMap.AlmShop.AlmShopShelf rules) { // basic props PriceMin = rules.PriceMin; PriceMax = rules.PriceMax; MaxItems = rules.MaxItems; MaxSameType = rules.MaxSameItems; // get list of classes supported for the item. var Materials = new List <Templates.TplMaterial>(); var Classes = new List <Templates.TplClass>(); var Types = new List <Templates.TplArmor>(); // ItemClasses = new List <ItemClass>(); SpecialItemClasses = new List <ItemClass>(); // AllowMagic = rules.ItemExtras.HasFlag(AllodsMap.AlmShop.AlmShopItemExtra.Magic); AllowCommon = AllowMagic ? rules.ItemExtras.HasFlag(AllodsMap.AlmShop.AlmShopItemExtra.Common) : true; AllowSpecial = rules.ItemTypes.HasFlag(AllodsMap.AlmShop.AlmShopItemType.Other); // this currently abuses the fact that there is a hardcoded list of materials. // will need to be changed if we extend it. for (int i = 0; i < 15; i++) { uint flag = 1u << i; uint value = (uint)rules.ItemMaterials; if ((flag & value) != 0) { Materials.Add(TemplateLoader.GetMaterialById(i)); } } // same goes for classes. for (int i = 0; i < 7; i++) { uint flag = 1u << i; uint value = ((uint)rules.ItemClasses) >> 15; if ((flag & value) != 0) { Classes.Add(TemplateLoader.GetClassById(i)); } } // types are a bit more complicated, because there is no direct mapping for this. // we use "slot" // note that there is also separation between mage and warrior armor here. // add weapons if (rules.ItemTypes.HasFlag(AllodsMap.AlmShop.AlmShopItemType.Weapon)) { foreach (Templates.TplArmor weapon in TemplateLoader.Templates.Weapons) { if (!CheckArmorShapeAllowed(weapon, rules)) { continue; } if (weapon.SuitableFor == 1) { Types.Add(weapon); } } } if (rules.ItemTypes.HasFlag(AllodsMap.AlmShop.AlmShopItemType.Wands)) { foreach (Templates.TplArmor weapon in TemplateLoader.Templates.Weapons) { if (!CheckArmorShapeAllowed(weapon, rules)) { continue; } if (weapon.SuitableFor == 2) { Types.Add(weapon); } } } // add armor if (rules.ItemTypes.HasFlag(AllodsMap.AlmShop.AlmShopItemType.Armor)) { foreach (Templates.TplArmor armor in TemplateLoader.Templates.Armor) { if (!CheckArmorShapeAllowed(armor, rules)) { continue; } if (armor.SuitableFor == 1) { Types.Add(armor); } } } if (rules.ItemTypes.HasFlag(AllodsMap.AlmShop.AlmShopItemType.ArmorMage)) { foreach (Templates.TplArmor armor in TemplateLoader.Templates.Armor) { if (!CheckArmorShapeAllowed(armor, rules)) { continue; } if (armor.SuitableFor == 2) { Types.Add(armor); } } } // add armor suitable for everyone (e.g. rings) if (rules.ItemTypes.HasFlag(AllodsMap.AlmShop.AlmShopItemType.Armor) || rules.ItemTypes.HasFlag(AllodsMap.AlmShop.AlmShopItemType.ArmorMage)) { foreach (Templates.TplArmor armor in TemplateLoader.Templates.Armor) { if (!CheckArmorShapeAllowed(armor, rules)) { continue; } if (armor.SuitableFor == 3) { Types.Add(armor); } } } // add shields if (rules.ItemTypes.HasFlag(AllodsMap.AlmShop.AlmShopItemType.Shield)) { foreach (Templates.TplArmor shield in TemplateLoader.Templates.Shields) { if (!CheckArmorShapeAllowed(shield, rules)) { continue; } Types.Add(shield); } } // add special (other) // copy the list (we may want to skip some items later) if (rules.ItemTypes.HasFlag(AllodsMap.AlmShop.AlmShopItemType.Other)) { // generate id for scroll. for (ushort i = 6; i <= 0x3F; i++) { ushort itemId = (ushort)(0x0E00 | i); ItemClass cls = ItemClassLoader.GetItemClassById(itemId); if (cls == null) { continue; } if (cls.Price < PriceMin || cls.Price > PriceMax) { continue; } SpecialItemClasses.Add(cls); } } // now that we have all the allowed combinations, let's populate items! // note that not all possible IDs are valid -- we need to check this foreach (Templates.TplArmor armor in Types) { // class id for (int i = 0; i < 7; i++) { // material id for (int j = 0; j < 15; j++) { // check if allowed if ((armor.ClassesAllowed[i] & (1 << j)) == 0) { continue; } ushort itemId = (ushort)((i << 5) | (j << 12) | (armor.Slot << 8) | (armor.Index)); ItemClass cls = ItemClassLoader.GetItemClassById(itemId); if (cls == null) { continue; } if (cls.Price > PriceMax || (!AllowMagic && cls.Price < PriceMin)) { continue; } ItemClasses.Add(cls); } } } Items = new ItemPack(); GenerateItems(); }