예제 #1
0
        public async Task UpdateMoreThanOneStep()
        {
            using var mocker        = AutoMock.GetStrict();
            await using var handler = mocker.Create <UpdateCountEventHandler>();
            var       stations = Enumerable.Range(100, 4).ToArray();
            const int maxCount = 10000;
            var       state    = TrainInfo.Create(stations, maxCount);

            var wvt = new UpdateCountEvent
            {
                FromStationId = 100,
                ToStationId   = 103
            };
            await handler.HandleEvent(state, wvt, default);

            state.SeatCount.Count.Should().Be(6);
            var leftCount = maxCount - 1;

            state.GetSeatCount(100, 101).Should().Be(leftCount);
            state.GetSeatCount(100, 102).Should().Be(leftCount);
            state.GetSeatCount(100, 103).Should().Be(leftCount);
            state.GetSeatCount(101, 102).Should().Be(leftCount);
            state.GetSeatCount(101, 103).Should().Be(leftCount);
            state.GetSeatCount(102, 103).Should().Be(leftCount);
        }
예제 #2
0
    void UpdateInventory(List <ItemScript> ItemList)
    {
        //Debug.Log("Listened inventory change");

        foreach (ItemScript item in ItemList)
        {
            var found = false;

            for (int j = 0; j < PiecesList.Count; j++)
            {
                if (PiecesList[j].itemName.Equals(item.itemName))
                {
                    UpdateCountEvent?.Invoke((int)item.count, item.itemName);
                    //Debug.Log("Updating piece "+PiecesList[j].itemName+". Increasing count to "+item.count);
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                // Debug.Log("Piece not found. Creating new.");
                CreatePiece(item, this.transform.position + new Vector3(PiecesList.Count * offset, 0, 0));
            }
        }
    }