示例#1
0
        private void TestInitialize()
        {
            Locator.Provide(new ContentManager("demo-world"));
            Locator.Provide(new TextureManager("demo-world"));

            var cm = Locator.Get <ContentManager>();

            var items = new List <ItemInstance>();

            for (int i = 0; i < 25; i++)
            {
                items.Add(new ItemInstance(cm.GetItem(i + 1), i + 1));
            }
            for (int i = 0; i < 25; i++)
            {
                items.Add(new ItemInstance(cm.GetItem(0)));
            }

            GameState.Instance.InventoryContainerId = 1;
            GameState.Instance.SetContainerItems(GameState.Instance.InventoryContainerId, items);

            MoveItem = (int fromSource, int fromIndex, int toSource, int toIndex) => {
                if (fromSource > 0 && toSource > 0)
                {
                    var temp = MouseDownContainer.Items[fromIndex];
                    GameState.Instance.SetContainerItem(fromSource, MouseUpContainer.Items[toIndex], fromIndex);
                    GameState.Instance.SetContainerItem(toSource, temp, toIndex);
                }
            };
        }
示例#2
0
        public string Move(int gameID, int oldX, int oldY, int oldZ, int newX, int newY)
        {
            var pg       = repository.GetByColumName("GameId", gameID).FirstOrDefault();
            var uiGame   = new SrzJson().desrz(pg);
            var moveItem = new MoveItem(
                uiGame,
                Convert.ToByte(oldX),
                Convert.ToByte(oldY),
                Convert.ToByte(oldZ),
                Convert.ToByte(newX),
                Convert.ToByte(newY)
                );

            uiGame.Move.DumX = 0; uiGame.Move.DumY = 0;
            if (uiGame.Gamer1 == uiGame.Queue)
            {
                uiGame       = moveItem.MoveWhite();
                uiGame.Queue = uiGame.Gamer2;
            }
            else if (uiGame.Gamer2 == uiGame.Queue)
            {
                uiGame       = moveItem.MoveBlack();
                uiGame.Queue = uiGame.Gamer1;
            }
            if (!repository.Update(new SrzJson().srz(uiGame), pg.Id))
            {
                return("");
            }

            return(JsonConvert.SerializeObject(uiGame.Move));
        }
示例#3
0
 public void PickUpItem(MoveItem item)
 {
     if(heldItem != null){
         return;
     }
     heldItem=item;
 }
示例#4
0
        private void MoveItem(NecClient client, MoveItem moveItem, int count)
        {
            if (count <= 0)
            {
                return;
            }

            moveItem.itemCount = (byte)count;
            moveItem.Move(_server, client);
        }
示例#5
0
    private void HandleMoveItem(MoveItem mItem)
    {
        mItem.enabled = true;
        var mRigidbody = mItem.gameObject.AddComponent <Rigidbody2D>();

        mRigidbody.freezeRotation = true;
        mRigidbody.gravityScale   = 1f;
        mItem.Init();
        mItem.StartMove();
    }
示例#6
0
    /// <summary>
    ///
    /// </summary>
    private void SetDestination(MoveItem move)
    {
        // Calculating the destination
        Vector3 destination = move.position;

        if (move.relativeMove)
        {
            destination += startPos;
        }

        // Calculating the rigidbody velocity
        rigid.velocity = (destination - gameObject.transform.position) / move.timeToComplete;
    }
        public HttpResponseMessage MoveItem(MoveItem moveItemRequest)
        {
            // Trace Log
            File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine);
            SuiteWrapper.WriteTraceLog("Called 'MoveItem' with request :" + JsonConvert.SerializeObject(moveItemRequest));
            var    sessionId     = "0";
            string outputMessage = string.Empty;

            if (!SuiteWrapper.ValidateRequest(moveItemRequest, out outputMessage))
            {
                //Trace Log
                SuiteWrapper.WriteTraceLog("Exception while validating request for " + JsonConvert.SerializeObject(moveItemRequest) + " is : " + outputMessage);
                return(Request.CreateResponse(HttpStatusCode.NotAcceptable, outputMessage));;
            }
            try
            {
                sessionId = SuiteWrapper.Login().GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                SuiteWrapper.WriteTraceLog("Exception while generating session id is " + ex.ToString());
                return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, ex.Message.ToString()));
            }

            PushResponseforSingleEntry pushResponseforSingleEntry = new PushResponseforSingleEntry();

            try
            {
                var req = new AddUpdateSingleEntryRequest();
                req.SessionId  = sessionId;
                req.ModuleName = "Itm1_Item";
                req.Entity     = moveItemRequest;
                var response = SuiteWrapper.AddUpdateSingleEntry(req).GetAwaiter().GetResult();
                pushResponseforSingleEntry.Id     = response.Id;
                pushResponseforSingleEntry.Status = "Success";

                SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pushResponseforSingleEntry));
                return(Request.CreateResponse(HttpStatusCode.OK, pushResponseforSingleEntry));
            }
            catch (Exception ex)
            {
                pushResponseforSingleEntry.Id     = null;
                pushResponseforSingleEntry.Status = ex.Message.ToString();

                SuiteWrapper.WriteTraceLog("Exception while pushing data is : " + ex.Message.ToString());
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, pushResponseforSingleEntry));
            }
        }
示例#8
0
        public bool Equip(Layer layer, uint objId)
        {
            if (!Enum.IsDefined(typeof(Layer), layer))
            {
                return(false);
            }

            if (!MoveItem.DragItem(objId, 1))
            {
                return(false);
            }

            Thread.Sleep(20);

            return(WearItem(layer, objId));
        }
示例#9
0
        public bool Equipt(Layer layer, ushort objType)
        {
            uint obj = Search.FindType(objType, Search.Backpack);

            if (obj == 0 || !Enum.IsDefined(typeof(Layer), layer))
            {
                return(false);
            }

            if (!MoveItem.DragItem(obj, 1))
            {
                return(false);
            }

            return(WearItem(layer, obj));
        }
示例#10
0
        public bool Unequip(Layer layer)
        {
            if (!Enum.IsDefined(typeof(Layer), layer))
            {
                return(false);
            }
            uint objId = ObjAtLayerEx(layer, CharStat.Self);

            if (objId != 0)
            {
                return(MoveItem.MoveItem(objId, 1, Search.Backpack, 0, 0, 0));
            }
            else
            {
                return(false);
            }
        }
示例#11
0
        protected override OpResult _Store(MoveItem _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "MoveItem object cannot be created as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_UpdateQuery(_obj));
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj));
            }

            ExecuteNonQuery(GetQuery_InsertQuery(_obj));
            _obj.FromDb = true;

            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
示例#12
0
        public bool Disarm()
        {
            bool lh = true;
            bool rh = true;

            uint objId = ObjAtLayerEx(Layer.LHand, CharStat.Self);

            if (objId != 0)
            {
                lh = MoveItem.MoveItem(objId, 1, Search.Backpack, 0xff, 0xff, 0);
            }

            objId = ObjAtLayerEx(Layer.RHand, CharStat.Self);
            if (objId != 0)
            {
                rh = MoveItem.MoveItem(objId, 1, Search.Backpack, 0xff, 0xff, 0);
            }

            return(lh && rh);
        }
        public override void Handle(NecClient client, NecPacket packet)
        {
            byte
                toStoreType =
                packet.Data
                .ReadByte();         // [0 = adventure bag. 1 = character equipment], [then unknown byte], [then slot], [then unknown]
            byte  toBagId       = packet.Data.ReadByte();
            short fromSlot      = packet.Data.ReadInt16();
            byte  fromStoreType = packet.Data.ReadByte();
            byte  fromBagId     = packet.Data.ReadByte();
            short toSlot        = packet.Data.ReadInt16();

            Logger.Debug($"fromStoreType byte [{fromStoreType}]");
            Logger.Debug($"fromBagId byte [{fromBagId}]");
            Logger.Debug($"fromSlot byte [{fromSlot}]");
            Logger.Debug($"toStoreType byte [{toStoreType}]");
            Logger.Debug($"toBagId byte [{toBagId}]");
            Logger.Debug($"toSlot [{toSlot}]");

            int itemCount = packet.Data.ReadByte(); //last byte is stack count?

            Logger.Debug($"itemCount [{itemCount}]");
            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0); //error check. 0 to work

            /*
             *  ITEMUSE	GENERIC	Unable to use this item right now
             *  ITEMUSE	-201	Store location is incorrect
             *  ITEMUSE	-204	Item amount is incorrect
             *  ITEMUSE	-205	The target to use this item is incorrect
             *  ITEMUSE	-206	Unable to use due to delay time
             *  ITEMUSE	-207	No space available in inventory
             *  ITEMUSE	-208	Unable to use this item since it is cursed
             *  ITEMUSE	-209	Unable to use this item since it is broken
             *  ITEMUSE	-210	You do not meet the requirements to equip this item
             *  ITEMUSE	-211	Unable to use this item
             *  ITEMUSE	-212	You are not in the right status to use this item
             *  ITEMUSE	-230	Unable to use since it is on cool down.
             *  ITEMUSE	-2601	You've already received this scrap
             *  ITEMUSE	-2708	Cannot be used outside of town
             *  ITEMUSE	-3001	Unable to move items when you have a shop open
             *
             */

            Router.Send(client, (ushort)AreaPacketId.recv_item_move_r, res, ServerType.Area);

            InventoryItem fromInvItem = client.Character.GetInventoryItem(fromStoreType, fromBagId, fromSlot);
            InventoryItem toInvItem   = client.Character.GetInventoryItem(toStoreType, toBagId, toSlot);

            if (toInvItem != null && (fromInvItem.StorageItem != toInvItem.StorageItem))
            {
                RecvNormalSystemMessage unlikeItems = new RecvNormalSystemMessage("You can only stack like items!");
                _server.Router.Send(unlikeItems, client);
                return;
            }

            if (toInvItem != null && (toInvItem.StorageCount >= 255))
            {
                RecvNormalSystemMessage unlikeItems =
                    new RecvNormalSystemMessage("The move would place too many items in destination slot!");
                _server.Router.Send(unlikeItems, client);
                return;
            }

            if (fromInvItem.StorageCount > 1)
            {
                if (client.Character.currentEvent != null)
                {
                    Logger.Error(
                        $"Trying to start new event with another outstanding event active! Outstanding event type [{client.Character.currentEvent.EventType}]");
                    client.Character.currentEvent = null;
                }

                MoveItem moveItem = _server.Instances.CreateInstance <MoveItem>();
                moveItem.toStoreType          = toStoreType;
                moveItem.toBagId              = toBagId;
                moveItem.toSlot               = toSlot;
                moveItem.fromStoreType        = fromStoreType;
                moveItem.fromBagId            = moveItem.fromBagId;
                moveItem.fromSlot             = fromSlot;
                moveItem.itemCount            = (byte)itemCount;
                moveItem.item                 = fromInvItem.StorageItem;
                client.Character.currentEvent = moveItem;
                RecvEventStart eventStart = new RecvEventStart(0, 0);
                Router.Send(eventStart, client);
                RecvEventRequestInt getCount = new RecvEventRequestInt("Select number to move.", 1,
                                                                       fromInvItem.StorageCount, fromInvItem.StorageCount);
                Router.Send(getCount, client);
            }
            else
            {
                if (toInvItem == null)
                {
                    fromInvItem.StorageType = toStoreType;
                    fromInvItem.StorageId   = toBagId;
                    fromInvItem.StorageSlot = toSlot;
                    client.Character.UpdateInventoryItem(fromInvItem);
                    RecvItemUpdatePlace changePlace =
                        new RecvItemUpdatePlace(fromInvItem.InstanceId, toStoreType, toBagId, toSlot);
                    _server.Router.Send(changePlace, client);
                    client.Character.UpdateInventoryItem(fromInvItem);
                }
                else
                {
                    toInvItem.StorageCount += 1;
                    RecvItemUpdateNum updateNum = new RecvItemUpdateNum(toInvItem.InstanceId, toInvItem.StorageCount);
                    _server.Router.Send(updateNum, client);
                    RecvItemRemove removeitem = new RecvItemRemove(fromInvItem.InstanceId);
                    _server.Router.Send(removeitem, client);
                    client.Character.UpdateInventoryItem(toInvItem);
                    client.Character.RemoveInventoryItem(fromInvItem);
                }
            }

            //SendItemPlace(client);
            //SendItemPlaceChange(client);
        }
示例#14
0
 public void DropItem(MoveItem item)
 {
     if(item == heldItem){
         heldItem = null;
     }
 }
示例#15
0
        public int? WinLocation(IPlayer player)
        {
            var moveItems = new MoveItem[3];
            foreach (var condition in WinConditions)
            {
                int x, y;
                IndexToCoords(condition[0], out x, out y);
                moveItems[0] = new MoveItem(condition[0],BoardPositions[y][x]);
                IndexToCoords(condition[1], out x, out y);
                moveItems[1] = new MoveItem(condition[1],BoardPositions[y][x]);
                IndexToCoords(condition[2], out x, out y);
                moveItems[2] = new MoveItem(condition[2],BoardPositions[y][x]);

                if (moveItems.Count(m => m.Player == player) == 2 && moveItems.Count(m=>m.Player == null) == 1)
                {
                    var move = moveItems.First(m => m.Player == null);
                    return move.Move;
                }
            }

            return null;
        }
示例#16
0
 private void label4_MouseDown(object sender, MouseEventArgs e)
 {
     MoveItem.MouseDown(this);
 }
示例#17
0
 private void panel1_MouseDown(object sender, MouseEventArgs e)
 {
     MoveItem.MouseDown(this);
 }
示例#18
0
        private void moveUpDown(int itemIndex, MoveItem moveItem)
        {
            ListViewItem item = listViewGroupsAndProviders.Items[itemIndex];
            ListViewGroup itemGroup = item.Group;
            int itemIndexInGroup = itemGroup.Items.IndexOf(item);
            //List<SettingsProvider> providersInGroupAll = (listViewGroupsAndProviders.Groups[0].Items[0].Tag as SettingsGroup).Providers;
            //List<SettingsProvider> providersInGroupAllEnabled = (listViewGroupsAndProviders.Groups[0].Items[1].Tag as SettingsGroup).Providers;

            int newItemIndex = -1;
            int newItemIndexInGroup = -1;
            bool condition = false;
            if (moveItem == MoveItem.Up) {
                newItemIndex = itemIndex - 1;
                newItemIndexInGroup = itemIndexInGroup - 1;
                condition = (newItemIndex >= 1);
            }
            else if (moveItem == MoveItem.Down) {
                newItemIndex = itemIndex + 1;
                newItemIndexInGroup = itemIndexInGroup + 1;
                condition = (newItemIndex < listViewGroupsAndProviders.Items.Count);
            }

            if (condition) {
                listViewGroupsAndProviders.BeginUpdate();
                listViewGroupsAndProviders.SelectedIndexChanged -= listViewGroupsAndProviders_SelectedIndexChanged;
                try {
                    //listViewGroupsAndProviders.Items.RemoveAt(itemIndex);
                    //itemGroup.Items.Remove(item);
                    //itemGroup.Items.RemoveAt(itemIndexInGroup);

                    //listViewGroupsAndProviders.Items.Insert(newItemIndex, item);
                    //itemGroup.Items.Insert(itemIndexInGroup, item);
                    //itemGroup.Items.Add(item);

                    //MoveInGroup(item, item.Group, newItemIndexInGroup);

                    switch (itemType(item)) {
                        case ListViewItemType.Group:
                            Settings.SettingsManager.Properties.GeneralSettings.Groups.RemoveAt(itemIndexInGroup - 2);
                            Settings.SettingsManager.Properties.GeneralSettings.Groups.Insert(newItemIndexInGroup - 2, item.Tag as SettingsGroup);
                            break;
                        case ListViewItemType.Provider:
                            Settings.SettingsManager.Properties.GeneralSettings.Providers.RemoveAt(itemIndexInGroup);
                            Settings.SettingsManager.Properties.GeneralSettings.Providers.Insert(newItemIndexInGroup, item.Tag as SettingsProvider);
                            break;
                    }

                    listViewGroupsAndProviders.Items.Clear();
                    listViewGroupsAndProviders.Groups[0].Items.Clear();
                    listViewGroupsAndProviders.Groups[1].Items.Clear();
                    fillProviderGroupsFromSettings();
                    setSubItemsForGroups();
                    fillProvidersFromSettings();
                }
                finally {
                    listViewGroupsAndProviders.SelectedIndexChanged += new System.EventHandler(listViewGroupsAndProviders_SelectedIndexChanged);
                    listViewGroupsAndProviders.Items[newItemIndex].Selected = false;
                    listViewGroupsAndProviders.Items[newItemIndex].Selected = true;
                    listViewGroupsAndProviders.Items[newItemIndex].Focused = true;
                    listViewGroupsAndProviders.EndUpdate();
                    //if (newItemIndex >= 0 && newItemIndex < listViewGroupsAndProviders.Items.Count) {
                    //    listViewGroupsAndProviders.EnsureVisible(newItemIndex);
                    //}
                    //listViewGroupsAndProviders.Select();
                    //listViewGroupsAndProviders.Items[newItemIndex].EnsureVisible();
                    doEnsureVisible(listViewGroupsAndProviders, listViewGroupsAndProviders.Items[newItemIndex]);
                }
            }
            listViewGroupsAndProviders.Select();
        }
示例#19
0
 private bool _checkIsEmptyItem(MoveItem moveItem)
 {
     return(moveItem == null);
 }
示例#20
0
        private DbInsertStatement GetQuery_InsertQuery(MoveItem _obj)
        {
            Dictionary <string, DbFieldEntry> fields = GetFields(_obj);

            return(DbMgr.CreateInsertClause("MoveItems", fields));
        }
示例#21
0
 private DbUpdateStatement GetQuery_UpdateQuery(MoveItem _obj)
 {
     return(DbMgr.CreateUpdateClause("MoveItems", GetFields(_obj), "MoveItemID", _obj.MoveItemID));
 }
示例#22
0
 public RecvItemUpdatePlaceChange(int instanceId, MoveItem moveItem)
     : base((ushort)AreaPacketId.recv_item_update_place_change, ServerType.Area)
 {
     _instanceId = instanceId;
     _moveItem   = moveItem;
 }
示例#23
0
 private void label6_MouseDown(object sender, MouseEventArgs e)
 {
     btnCancel.BackColor = Color.White;
     MoveItem.MouseDown(this);
 }