public void BeltItemSlotProcessorCheck()
        {
            // Arrange
            List <List <BeltItemSlot> > dummyBeltItemSlotGroup = new List <List <BeltItemSlot> >();

            dummyBeltItemSlotGroup.Add(new List <BeltItemSlot>());
            dummyBeltItemSlotGroup[0].Add(new BeltItemSlot(Vector3.zero));
            dummyBeltItemSlotGroup[0].Add(new BeltItemSlot(Vector3.zero));
            BeltItemSlot.ConnectBeltItemSlots(dummyBeltItemSlotGroup[0][0], dummyBeltItemSlotGroup[0][1]);

            List <BeltItem> beltItems = new List <BeltItem>();

            beltItems.Add(new GameObject().AddComponent <BeltItem>().GetComponent <BeltItem>());
            dummyBeltItemSlotGroup[0][0].myItem = beltItems[0];
            beltItems[0].mySlot = dummyBeltItemSlotGroup[0][0];

            List <BeltPreProcessor.BeltGroup> dummyBeltGroup = new List <BeltPreProcessor.BeltGroup>();

            BeltPreProcessor.BeltGroup newGroup = new BeltPreProcessor.BeltGroup();
            newGroup.beltItemSlotGroups = dummyBeltItemSlotGroup;
            dummyBeltGroup.Add(newGroup);
            BeltItemSlotUpdateProcessor myBeltItemSlotUpdateProcessor = new BeltItemSlotUpdateProcessor(beltItems, dummyBeltGroup);

            // Act
            myBeltItemSlotUpdateProcessor.UpdateBeltItemSlots();

            // Assert
            Assert.IsNull(dummyBeltItemSlotGroup[0][0].myItem);
            Assert.IsNotNull(dummyBeltItemSlotGroup[0][1].myItem);
        }
Example #2
0
        public void BeltItemSlotProcessorCheck()
        {
            // Arrange
            List <List <BeltItemSlot> > dummyBeltItemSlotGroup = new List <List <BeltItemSlot> >();

            dummyBeltItemSlotGroup.Add(new List <BeltItemSlot>());
            dummyBeltItemSlotGroup[0].Add(new BeltItemSlot(Vector3.zero));
            dummyBeltItemSlotGroup[0].Add(new BeltItemSlot(Vector3.zero));
            BeltItemSlot.ConnectBeltItemSlots(dummyBeltItemSlotGroup[0][0], dummyBeltItemSlotGroup[0][1]);

            ObjectPoolSimple <BeltItem> dummyItemPool = new ObjectPoolSimple <BeltItem>(1, 1);

            dummyItemPool.SetUp();
            dummyBeltItemSlotGroup[0][0].myItem = dummyItemPool.Spawn();


            List <BeltPreProcessor.BeltGroup> dummyBeltGroup = new List <BeltPreProcessor.BeltGroup>();

            BeltPreProcessor.BeltGroup newGroup = new BeltPreProcessor.BeltGroup();
            newGroup.beltItemSlotGroups = dummyBeltItemSlotGroup;
            dummyBeltGroup.Add(newGroup);

            BeltItemSlotUpdateProcessor myBeltItemSlotUpdateProcessor = new BeltItemSlotUpdateProcessor(dummyItemPool, dummyBeltGroup);

            // Act
            myBeltItemSlotUpdateProcessor.UpdateBeltItemSlots();

            // Assert
            Assert.IsNull(dummyBeltItemSlotGroup[0][0].myItem);
            Assert.IsNotNull(dummyBeltItemSlotGroup[0][1].myItem);
        }
    public void UpdateBeltItemSlots()
    {
        for (int i = 0; i < beltItemPool.objectPool.Length; i++)
        {
            beltItemPool.objectPool[i].isProcessedThisLoop = false;
            beltItemPool.objectPool[i].isMarkedThisLoop    = false;
            beltItemPool.objectPool[i].isMovedThisLoop     = false;
        }

        for (int k = 0; k < beltGroups.Count; k++)
        {
            BeltPreProcessor.BeltGroup beltGroup = beltGroups[k];
            for (int m = 0; m < beltGroup.beltItemSlotGroups.Count; m++)
            {
                List <BeltItemSlot> beltItemSlotSection = beltGroup.beltItemSlotGroups[m];
                for (int i = 0; i < beltItemSlotSection.Count; i++)
                {
                    beltItemSlotSection[i].BeltItemSlotUpdate(false);
                }
                for (int i = 0; i < beltItemSlotSection.Count; i++)
                {
                    beltItemSlotSection[i].BeltItemSlotUpdate(true);
                }
            }
        }
        updateOffset++;
        //updateIndex = updateIndex % 12;
    }