Example #1
0
        public static void UseItem(string key, FreeData fd, ISkillArgs args)
        {
            if (fd.Player.stateInterface.State.GetCurrentPostureState() == PostureInConfig.Climb)
            {
                return;
            }

            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;
            ItemPosition      ip = GetItemPosition(args, key, fd.freeInventory.GetInventoryManager());

            if (ip != null && ip.key.IsConsume() && FreeItemConfig.GetSing(ip.key) > 0)
            {
                args.TempUse("current", fd);
                args.TempUse("item", ip);
                if (ip.key.CanUse(args))
                {
                    FreeItemConfig.UseAnimation(args.GameContext, fd, ip.key.GetKey());
                    fd.freeInventory.StartUseItem(args, fd, ip, FreeItemConfig.GetSing(ip.key), FreeItemConfig.GetSound(ip.key.GetKey()));
                }
                args.Resume("current");
                args.Resume("item");
            }
            else
            {
                UseItem(ip, fd, fr);
            }
        }
Example #2
0
        public List <ItemPosition> ExportData()
        {
            var items = new List <ItemPosition>();

            foreach (TrackItem item in AllItems)
            {
                var itemPosition = new ItemPosition()
                {
                    FrameWidth     = item.FrameWidth,
                    BackwardOffset = item.BackwardOffset,
                    ForwardOffset  = item.ForwardOffset,
                    Offset         = item.Offset,
                    ItemId         = item.GetTag <StageComponent>().Id,
                    SourceType     = item.SourceType,
                    TrackNumber    = ((((FrameworkElement)item.Parent).TemplatedParent) as Track).TrackNumber,
                    Property       = item.Property,
                };

                items.Add(itemPosition);
            }

            Track_ItemsMaxWidthChanged(null, null);

            return(items);
        }
Example #3
0
        private static void DropPart(string inv, FreeData fd, ServerRoom room)
        {
            int           c3 = fd.freeInventory.GetInventoryManager().GetInventory(inv).posList.Count;
            ItemInventory w3 = fd.freeInventory.GetInventoryManager().GetInventory(inv);

            if (c3 > 0)
            {
                ItemPosition ip = w3.posList[0];

                w3.RemoveItem(room.FreeArgs, ip);

                FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey());

                if (BagCapacityUtil.CanAddToBag(room.FreeArgs, fd, ip))
                {
                    fd.freeInventory.GetInventoryManager().GetDefaultInventory().AddItem(room.FreeArgs, ip.key, true);
                }
                else
                {
                    if (info.cat > 0)
                    {
                        room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity(
                            (ECategory)info.cat,
                            info.id,
                            ip.GetCount(), fd.Player.position.Value);
                    }
                }
            }
        }
Example #4
0
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            FreeData fd = (FreeData)player.freeData.FreeData;

            room.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd);

            string key   = message.Ss[0];
            int    count = message.Ins[0];

            if (key.StartsWith(ChickenConstant.BagDefault))
            {
                ItemPosition ip   = FreeItemManager.GetItemPosition(room.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
                FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());

                if (ip.GetCount() > count)
                {
                    ip.SetCount(ip.GetCount() - count);
                    ip.GetInventory().GetInventoryUI().ReDraw((ISkillArgs)room.FreeArgs, ip.GetInventory(), true);
                }
                else
                {
                    ip.GetInventory().RemoveItem((ISkillArgs)room.FreeArgs, ip);
                }

                room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity(
                    (Assets.XmlConfig.ECategory)info.cat,
                    info.id,
                    count,
                    fd.Player.position.Value);
            }

            room.FreeArgs.Resume(PARA_PLAYER_CURRENT);
        }
Example #5
0
 public bool AddEquipment(ConquerItem Item, ItemPosition Position)
 {
     Item.Position = Position;
     Equipment.ThreadSafeAdd(Position, Item);
     Item.Send(this);
     return(true);
 }
Example #6
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr     = (FreeRuleEventArgs)args;
            IGameUnit         player = GetPlayer(args);

            if (StringUtil.IsNullOrEmpty(count) || count.Equals("0"))
            {
                count = "0";
            }
            method = new SelectMethod(FreeUtil.ReplaceVar(exp, args));
            if (player != null)
            {
                FreeData       fd           = (FreeData)player;
                ItemPosition[] currentItems = fd.freeInventory.Select(method);
                fr.TempUse("current", fd);
                int c = FreeUtil.ReplaceInt(count, args);
                for (int i = 0; i < currentItems.Length; i++)
                {
                    ItemPosition ip = currentItems[i];
                    ip.SetCount(c);
                    ip.GetKey().SetCount(c);
                    ip.GetInventory().GetInventoryUI().UpdateItem(fr, ip.GetInventory(), ip);
                }
                fr.Resume("current");
            }
        }
Example #7
0
        bool FindItemPostion(TvItem p_item, ItemPosition p_pos)
        {
            var elem = (UIElement)p_pos.Panel.Children[p_pos.Index];

            if (p_item == p_pos.Taget)
            {
                p_pos.Height = elem.DesiredSize.Height;
                return(true);
            }

            p_pos.Top += elem.DesiredSize.Height;
            p_pos.Index++;
            if (p_item.Children.Count == 0)
            {
                return(false);
            }

            foreach (var child in p_item.Children)
            {
                if (FindItemPostion(child, p_pos))
                {
                    return(true);
                }
            }
            return(false);
        }
        public void AddEquipmentDurability(ItemPosition position, int value)
        {
            if (value >= 0)
            {
                return;
            }

            if (Items.ContainsKey(position))
            {
                Item item = Items[position];
                if (!item.IsEquipment() || !item.IsWeapon())
                {
                    return;
                }
                int nOldDur     = item.Durability;
                int nDurability = Math.Max(0, item.Durability + value);
                item.Durability = (ushort)nDurability;

                if (item.Durability < 100 && item.Durability % 10 == 0)
                {
                    m_pOwner.Send("Your item is damaged, please repair.");
                }
                else if (item.Durability < 200 && item.Durability % 20 == 0)
                {
                    m_pOwner.Send("Your equipment durability is too low.");
                }

                if (nOldDur / 100 != nDurability / 100 || nDurability <= 0)
                {
                    m_pOwner.Send(item.InformationPacket(true));
                }
            }
        }
Example #9
0
        private void HandleDropWeapon(IEventArgs args)
        {
            if ("DropWeapon" == code)
            {
                int      key = FreeUtil.ReplaceInt("{key}", args);
                FreeData fd  = (FreeData)args.GetUnit("current");

                ItemInventory defInv = fd.freeInventory.GetInventoryManager().GetDefaultInventory();
                for (int i = 1; i <= 5; i++)
                {
                    ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory("w" + key + "" + i);
                    if (ii.posList.Count > 0)
                    {
                        ItemPosition ip = ii.posList[0];
                        if (BagCapacityUtil.CanAddToBag(args, fd, ip))
                        {
                            int[] next = defInv.GetNextEmptyPosition(ip.key);
                            ItemInventoryUtil.MovePosition(ip, defInv, next[0], next[1], (ISkillArgs)args);
                        }
                        else
                        {
                            ItemInventory ground = fd.freeInventory.GetInventoryManager().GetInventory("ground");
                            int[]         next   = ground.GetNextEmptyPosition(ip.key);
                            ItemInventoryUtil.MovePosition(ip, ground, next[0], next[1], (ISkillArgs)args);
                        }
                    }
                }

                CarryClipUtil.AddCurrentClipToBag(key, fd, args);
            }
        }
Example #10
0
 public static void UseItem(ItemPosition ip, FreeData fd, FreeRuleEventArgs fr)
 {
     if (ip != null)
     {
         fr.TempUse(PARA_ITEM, ip.GetKey());
         if (ip.GetKey().Effect(fr))
         {
             if (!ip.GetKey().IsGoods())
             {
                 if (ip.GetKey().IsUseClose())
                 {
                     CloseInventory(ip.GetInventory(), fr);
                 }
                 ip.GetInventory().UseItem(fr, ip);
                 if (ip.GetCount() <= 0 && ip.GetKey().IsConsume())
                 {
                     RemoveUI(ip, fr);
                 }
             }
         }
         fr.Resume(PARA_ITEM);
         if (!ip.GetKey().IsGoods())
         {
             fd.freeInventory.SetCurrentItem(ip, fr);
         }
         ip.GetKey().GetParameters().AddPara(new IntPara(PARA_ITEM_USE_TIME, fr.GameContext.session.currentTimeObject.CurrentTime));
     }
 }
Example #11
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr     = (FreeRuleEventArgs)args;
            IGameUnit         player = GetPlayer(args);

            if (player != null)
            {
                IParable pa = fr.GetUnit(item);
                if (pa is ItemPosition)
                {
                    ItemPosition  ip    = (ItemPosition)pa;
                    FreeData      fd    = (FreeData)player;
                    ItemInventory toInv = fd.freeInventory.GetInventoryManager().GetInventory(FreeUtil.ReplaceVar(toInventory, args));
                    if (toInv != null)
                    {
                        int toX = 0;
                        int toY = 0;
                        if (string.IsNullOrEmpty(x) && string.IsNullOrEmpty(y))
                        {
                            int[] next = toInv.GetNextEmptyPosition(ip.GetKey());
                            toX = next[0];
                            toY = next[1];
                        }
                        else
                        {
                            toX = FreeUtil.ReplaceInt(x, args);
                            toY = FreeUtil.ReplaceInt(y, args);
                        }
                        ItemInventoryUtil.MovePosition(ip, toInv, toX, toY, fr);
                    }
                }
            }
        }
Example #12
0
        private void ExchangeInv(ISkillArgs args, ItemInventory fromInv, ItemInventory toInv)
        {
            ItemPosition temp = null;

            if (toInv.posList.Count > 0)
            {
                temp = toInv.posList[0];
            }
            toInv.posList.Clear();

            ItemPosition fromIp = null;

            if (fromInv.posList.Count > 0)
            {
                fromIp = fromInv.posList[0];
            }
            fromInv.posList.Clear();

            if (temp != null)
            {
                temp.inventory = fromInv;
                fromInv.posList.Add(temp);
            }

            if (fromIp != null)
            {
                fromIp.inventory = toInv;
                toInv.posList.Add(fromIp);
            }

            fromInv.ReDraw(args);
            toInv.ReDraw(args);
        }
Example #13
0
        // Creates new order from basket data
        public Order CreateOrder(Order newOrder, string userId)
        {
            var bucket = DownloadBucket();

            newOrder.AdditionDate = DateTime.Now;
            newOrder.UserId       = userId;

            db.Orders.Add(newOrder);

            if (newOrder.ItemPosition == null)
            {
                newOrder.ItemPosition = new List <ItemPosition>();
            }

            decimal bucketValue = 0;

            foreach (var bucketElement in bucket)
            {
                var newOrderPosition = new ItemPosition()
                {
                    ItemId     = bucketElement.Item.ItemId,
                    Quantity   = bucketElement.Quantity,
                    OrderValue = bucketElement.Item.ItemPrice
                };

                bucketValue += (bucketElement.Quantity * bucketElement.Item.ItemPrice);
                newOrder.ItemPosition.Add(newOrderPosition);
            }

            newOrder.OrderValue = bucketValue;
            db.SaveChanges();

            return(newOrder);
        }
Example #14
0
    public static ItemIndex ReturnIndexThing(ItemPosition ip)
    {
        Sprite sprite = staticImages[(int)ip].sprite;

        if (sprite == staticSprites[0])
        {
            return(ItemIndex.NOTHING);
        }
        else if (sprite == staticSprites[1])
        {
            return(ItemIndex.hpUpEffect);
        }
        else if (sprite == staticSprites[2])
        {
            return(ItemIndex.jumpEffect);
        }
        else if (sprite == staticSprites[3])
        {
            return(ItemIndex.scoreEffect);
        }
        else
        {
            return(ItemIndex.NOTHING);
        }
    }
        protected override void OnTapped(TappedRoutedEventArgs e)
        {
            base.OnTapped(e);

            if (Data?.position != null)
            {
                Data.position.IsSelected = !Data.position.IsSelected;
            }

            var itemPos = new ItemPosition(Data?.position?.SectionIndex ?? 0, Data?.position?.ItemIndex ?? 0);

            if (Data?.position?.IsSelected ?? false)
            {
                Data?.virtualListView?.SetSelected(itemPos);
            }
            else
            {
                Data?.virtualListView?.SetDeselected(itemPos);
            }

            if (Data?.data is IPositionInfo dataPositionInfo)
            {
                dataPositionInfo.SetPositionInfo(Data.position);
            }

            if (Data != null && Data.position != null)
            {
                Data?.positionalViewSelector?.ViewSelector?.RecycleView(Data.position, Data.data, View);
            }
        }
Example #16
0
 public ItemHotkeyAction(PositionHotKey _enclosing, ItemPosition ip, FreeData fd, string inventory)
     : base()
 {
     this._enclosing = _enclosing;
     this.ip         = ip;
     this.fd         = fd;
     this.inventory  = inventory;
 }
Example #17
0
 public SwinTank(string name, ItemPosition position)
     : base(name, position, ARMOUR, ENERGY, HEALTH, SPEED)
 {
     this.SwimSpeed   = SWIM_SPEED;
     this.IsSwimming  = false;
     this.OxigenLevel = MAX_OXIGEN;
     //TODO: Initialize guns
 }
Example #18
0
 private void RemoveUI(ItemPosition ip, ISkillArgs args)
 {
     //FreeUIDeleteAction del = new FreeUIDeleteAction();
     //del.SetKey(ip.GetUIKey());
     //del.SetScope(1);
     //del.SetPlayer("current");
     //del.Act(args);
 }
Example #19
0
 public StealthTank(string name, ItemPosition position)
     : base(name, position, ARMOUR, ENERGY, HEALTH, SPEED)
 {
     this.IsInvisible          = false;
     this.InvisibilityDuration = INVISIBILITY_DURATION;
     this.Energy = InitialEnergy;
     //TODO: Initialize guns
 }
Example #20
0
        public static float HandleDamage(IEventArgs args, FreeData fd, PlayerDamageInfo damage)
        {
            float readDamage = damage.damage;

            if (damage.type != (int)EUIDeadType.Weapon && damage.type != (int)EUIDeadType.Unarmed)
            {
                return(readDamage);
            }
            if (damage.part == (int)EBodyPart.Head)
            {
                ItemPosition ip = GetHelmet(fd);
                if (ip != null)
                {
                    FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());

                    int percent = 0;
                    if (info.id == 8)
                    {
                        percent = 30;
                    }
                    if (info.id == 9)
                    {
                        percent = 40;
                    }
                    else if (info.id == 10)
                    {
                        percent = 55;
                    }

                    readDamage = ReduceDamage(args, fd, damage, ip, percent, ItemType.Helmet);
                }
            }
            else if (damage.part == (int)EBodyPart.Chest || damage.part == (int)EBodyPart.Stomach || damage.part == (int)EBodyPart.Pelvis)
            {
                ItemPosition ip = GetArmor(fd);
                if (ip != null)
                {
                    FreeItemInfo info    = FreeItemConfig.GetItemInfo(ip.key.GetKey());
                    int          percent = 0;
                    if (info.id == 1)
                    {
                        percent = 30;
                    }
                    if (info.id == 2)
                    {
                        percent = 40;
                    }
                    else if (info.id == 3)
                    {
                        percent = 55;
                    }

                    readDamage = ReduceDamage(args, fd, damage, ip, percent, ItemType.Armor);
                }
            }

            return(readDamage);
        }
Example #21
0
        private static void RemoveUI(ItemPosition ip, ISkillArgs args)
        {
            FreeUIDeleteAction del = new FreeUIDeleteAction();

            del.SetKey(ip.GetUIKey());
            del.SetScope(1);
            del.SetPlayer(PARA_PLAYER_CURRENT);
            del.Act(args);
        }
Example #22
0
        public static void MovePosition(ItemPosition ip, ItemInventory toIn, int x, int y, ISkillArgs args)
        {
            ItemInventory     fromIn = ip.GetInventory();
            IInventoryUI      fromUI = fromIn.GetInventoryUI();
            IInventoryUI      toUI   = toIn.GetInventoryUI();
            FreeRuleEventArgs fr     = (FreeRuleEventArgs)args;

            Move(fromIn, toIn, ip, x, y, args, fr, fromUI, toUI);
        }
Example #23
0
 public TimeXact(ItemPosition position, DateTime checkin, bool completed = false, Account account = null, string desc = null, string note = null)
 {
     Position  = position ?? new ItemPosition();
     Checkin   = checkin;
     Completed = completed;
     Account   = account;
     Desc      = desc ?? String.Empty;
     Note      = note ?? String.Empty;
 }
Example #24
0
 private static void RemoveUI(ItemPosition ip, ISkillArgs args)
 {
     //FreeUIDeleteAction del = new FreeUIDeleteAction();
     //del.SetKey(ip.GetUIKey());
     //del.SetScope(1);
     //del.SetPlayer(PARA_PLAYER_CURRENT);
     //del.Act(args);
     //ip.GetInventory().GetInventoryUI().DeleteItem(args, ip.GetInventory(), ip);
 }
Example #25
0
		public virtual void SetCurrentItem(ItemPosition currentItem, ISkillArgs args)
		{
			this.currentItem = currentItem;
			string cat = ((FreeGameItem)currentItem.GetKey()).GetCat();
			if (cat != null)
			{
				this.lastUseItem[cat] = currentItem;
			}
		}
Example #26
0
        public static void UpdateGamePlayData(FreeData fd, ItemPosition ip, ItemType itemType)
        {
            GamePlayComponent gamePlay = fd.Player.gamePlay;

            if (ip == null)
            {
                if (itemType == ItemType.Armor)
                {
                    gamePlay.MaxArmor = 0;
                    gamePlay.CurArmor = 0;
                }
                if (itemType == ItemType.Helmet)
                {
                    gamePlay.MaxHelmet = 0;
                    gamePlay.CurHelmet = 0;
                }
            }
            else
            {
                FreeItemInfo itemInfo = FreeItemConfig.GetItemInfo(ip.key.GetKey());
                switch (itemType)
                {
                case ItemType.Armor:
                    gamePlay.CurArmor = Math.Max(0, ip.GetCount());
                    if (itemInfo.id == 1)
                    {
                        gamePlay.MaxArmor = 200;
                    }
                    else if (itemInfo.id == 2)
                    {
                        gamePlay.MaxArmor = 220;
                    }
                    else if (itemInfo.id == 3)
                    {
                        gamePlay.MaxArmor = 250;
                    }
                    break;

                case ItemType.Helmet:
                    gamePlay.CurHelmet = Math.Max(0, ip.GetCount());
                    if (itemInfo.id == 8)
                    {
                        gamePlay.MaxHelmet = 80;
                    }
                    else if (itemInfo.id == 9)
                    {
                        gamePlay.MaxHelmet = 150;
                    }
                    else if (itemInfo.id == 10)
                    {
                        gamePlay.MaxHelmet = 230;
                    }
                    break;
                }
            }
        }
Example #27
0
 public bool TryGetEquipment(ItemPosition Position, out ConquerItem Item)
 {
     Item = default(ConquerItem);
     if (Equipment.ContainsKey(Position))
     {
         Item = Equipment[Position];
         return(true);
     }
     return(false);
 }
Example #28
0
 public Tank(string name, ItemPosition position, int armour, int energy, int health, int speed)
     : base(name, position)
 {
     this.Mode          = TankModeEnum.Attack;
     this.InitialEnergy = energy;
     this.Armour        = armour;
     this.Energy        = this.InitialEnergy;
     this.Health        = health;
     this.Speed         = speed;
 }
Example #29
0
        private void AwakeBotUserInterface_Load(object sender, EventArgs e)
        {
            // Remove the annoying double border from buttons when focus is occured
            btnItemPosition.GotFocus            += (s, ev) => { ((Button)s).NotifyDefault(false); };
            btnAwakeScrollPosition.GotFocus     += (s, ev) => { ((Button)s).NotifyDefault(false); };
            btnReversionScrollPosition.GotFocus += (s, ev) => { ((Button)s).NotifyDefault(false); };
            btnSelectInventory.GotFocus         += (s, ev) => { ((Button)s).NotifyDefault(false); };

            btnItemPosition.MouseUp += (s, ev) =>
            {
                if (TrySetAwakePosition((Control)s))
                {
                    ItemPosition         = Cursor.Position;
                    lblItemPosition.Text = ItemPosition.ToString();
                }
            };

            btnAwakeScrollPosition.MouseUp += (s, ev) =>
            {
                if (TrySetAwakePosition((Control)s))
                {
                    AwakeScrollPosition   = Cursor.Position;
                    lblAwakePosition.Text = AwakeScrollPosition.ToString();
                }
            };

            btnReversionScrollPosition.MouseUp += (s, ev) =>
            {
                if (TrySetAwakePosition((Control)s))
                {
                    ReversionPosition         = Cursor.Position;
                    lblReversionPosition.Text = ReversionPosition.ToString();
                }
            };

            if (!Directory.Exists(ConfigDirectory))
            {
                Directory.CreateDirectory(ConfigDirectory);
            }

            string[] files = Directory.GetFiles(ConfigDirectory, "*.xml");

            if (files.Length <= 0)
            {
                GeneralUtils.DisplayError("No server config files found");
            }

            foreach (var file in files)
            {
                string fileName = file.Substring(file.LastIndexOf('\\') + 1);
                fileName = fileName.Substring(0, fileName.LastIndexOf('.'));
                cbConfigs.Items.Add(fileName);
            }
        }
 public virtual void DeleteItem(ISkillArgs args, ItemInventory inventory, ItemPosition ip)
 {
     if (delete == null)
     {
         delete = new FreeUIDeleteAction();
     }
     delete.SetKey(ip.GetUIKey());
     delete.SetScope(1);
     delete.SetPlayer("current");
     delete.Act(args);
 }
Example #31
0
 public void Unequip(ConquerItem Item, ItemPosition Position)
 {
     Item.Position = Position;
     Item.Unequip(this);
     Equipment.ThreadSafeRemove(Position);
 }
Example #32
0
    private ArrayList GetItemList(FS2RoleDataInfo roleInfo, ItemPosition type)
    {
        //LabelTitle.Text += string.Format("[{0}]物品信息", roleInfo.RoleName);

        ArrayList itemList = new ArrayList();

        foreach (FS2ItemDataInfo itemInfo in roleInfo.ItemList)
        {
            if(itemInfo.Local.Equals((byte)type))
            {
                itemList.Add(itemInfo);                
            }
        }
        //if (renderRoleSate) RenderRoleState((FS2ItemDataInfo[])itemInBody.ToArray(typeof(FS2ItemDataInfo)));
        return itemList;
    }
Example #33
0
 public bool TryGetEquipment(ItemPosition Position, out ConquerItem Item)
 {
     Item = default(ConquerItem);
     if (Equipment.ContainsKey(Position))
     {
         Item = Equipment[Position];
         return true;
     }
     return false;
 }
Example #34
0
 public bool AddEquipment(ConquerItem Item, ItemPosition Position)
 {
     Item.Position = Position;
     Equipment.ThreadSafeAdd(Position, Item);
     Item.Send(this);
     return true;
 }