Пример #1
0
    List <BeltGroup> GetNearbyBeltGroups(BeltObject belt)
    {
        List <BeltGroup> nearbyBeltGroups = new List <BeltGroup>();

        for (int i = 0; i < 4; i++)
        {
            if (belt.beltInputs[i] || belt.beltOutputs[i])
            {
                BeltObject neighborBelt = GetBeltAtLocation(belt.pos + IndexToXY(i));
                if (BeltObject.CanConnectBelts(belt, neighborBelt))
                {
                    nearbyBeltGroups.Add(allBeltGroups[neighborBelt.beltGroup]);
                }
            }
        }

        return(nearbyBeltGroups);
    }
Пример #2
0
        public void BeltCanConnectBeltsTest()
        {
            //Arrange
            GameObject belt1_obj = new GameObject();
            BeltObject belt1     = belt1_obj.AddComponent <BeltObject>();

            belt1.beltOutputs[1] = true;
            GameObject belt2_obj = new GameObject();
            BeltObject belt2     = belt2_obj.AddComponent <BeltObject>();

            belt2.pos.x         = 1;
            belt2.beltInputs[3] = true;
            GameObject belt3_obj = new GameObject();
            BeltObject belt3     = belt3_obj.AddComponent <BeltObject>();

            belt3.pos.x         = 2;
            belt3.beltInputs[3] = true;

            //Assert
            Assert.IsTrue(BeltObject.CanConnectBelts(belt1, belt2));
            Assert.IsFalse(BeltObject.CanConnectBelts(belt1, belt3));
        }