Beispiel #1
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 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.ConnectBelts(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];

            BeltItemSlotUpdateProcessor myBeltItemSlotUpdateProcessor = new BeltItemSlotUpdateProcessor(beltItems, dummyBeltItemSlotGroup);

            // Act
            myBeltItemSlotUpdateProcessor.UpdateBeltItemSlots();

            // Assert
            Assert.IsNull(dummyBeltItemSlotGroup[0][0].myItem);
            Assert.IsNotNull(dummyBeltItemSlotGroup[0][1].myItem);
        }
    // Start is called before the first frame update
    void Start()
    {
        s = this;

        allBelts = new List <BeltObject>(FindObjectsOfType <BeltObject>());

        allCreators   = new List <MagicItemCreator>(FindObjectsOfType <MagicItemCreator>());
        allDestroyers = new List <MagicItemDestroyer>(FindObjectsOfType <MagicItemDestroyer>());

        foreach (BeltObject belt in allBelts)
        {
            belt.SetPosBasedOnWorlPos();
            belt.GetComponent <BeltGfx>().UpdateGraphics(belt.beltInputs, belt.beltOutputs);
            allBeltsCoords[belt.pos] = belt;
        }

        beltPreProc = new BeltPreProcessor(beltGroups, allBeltItems, GetBeltAtLocation);

        beltItemSlotProc = new BeltItemSlotUpdateProcessor(allBeltItems, beltGroups);

        beltItemGfxProc = new BeltItemGfxUpdateProcessor(allBeltItems);

        print("Belt Count = " + allBelts.Count.ToString());
        allResults.Add("Belt Count = " + allBelts.Count.ToString());

        allResults.Add("Trial Counts: " + "Prepass - " + prePassTrialCount.ToString() + ", Update Slot - " + updateSlotTrialCount.ToString() + ", Update Gfx - " + updateGfxTrialCount.ToString());



        var temp = Time.realtimeSinceStartup;

        TestStartupTime();
        TestBeltSlotUpdateTime();
        TestBeltSlotGfxUpdateTime();

        temp = Time.realtimeSinceStartup - temp;
        print("Total test time: " + (temp).ToString("f6"));
        allResults.Add("Total test time: " + (temp).ToString("f6"));

        int n = 0;

        foreach (string s in allResults)
        {
            print(s);
            if (n < textses.Length)
            {
                textses[n].text = s;
            }
            n++;
        }

        TimingTestRunSaver.WriteTestRunDataToFile(allResults);
    }
Beispiel #4
0
    public void SetupBeltSystem()
    {
        allBelts = new List <BeltObject>(FindObjectsOfType <BeltObject>());

        for (int i = 0; i < allBelts.Count; i++)
        {
            BeltObject belt = allBelts[i];
            belt.SetPosBasedOnWorlPos();
            allBeltsCoords[belt.pos] = belt;
        }

        beltPreProc = new BeltPreProcessor(beltGroups, allBeltItems, GetBeltAtLocation);

        beltPreProc.PrepassBelts(allBelts);

        beltItemSlotProc = new BeltItemSlotUpdateProcessor(itemPool, beltGroups);
    }
Beispiel #5
0
    public void SetupBeltSystem()
    {
        allBelts = new List <BeltObject>(FindObjectsOfType <BeltObject>());

        foreach (BeltObject belt in allBelts)
        {
            belt.SetPosBasedOnWorlPos();
            belt.GetComponent <BeltGfx>().UpdateGraphics(belt.beltInputs, belt.beltOutputs);
        }

        beltProc = new BeltPreProcessor(allBelts, beltGroups, allBeltItemsSlots, beltItemSlotGroups, allBeltItems, GetBeltAtLocation);

        beltProc.PrepassBelts();

        beltItemSlotProc = new BeltItemSlotUpdateProcessor(allBeltItems, beltItemSlotGroups);

        beltItemGfxProc = new BeltItemGfxUpdateProcessor(allBeltItems);
    }