示例#1
0
        public static void PutOnFirstPlace(IThing thing, ref IBag bag)
        {
            int  x = -1, y = -1;
            byte rot = 0;

            for (; rot < 4; rot++)
            {
                for (int i = 0; i < bag.Height; i++)
                {
                    for (int j = 0; j < bag.Width; j++)
                    {
                        if (bag.CanPutThing(new LocalThing(thing, j, i, rot)))
                        {
                            x = j;
                            y = i;
                            break;
                        }
                    }
                    if (x != -1)
                    {
                        break;
                    }
                }
                if (x != -1)
                {
                    break;
                }
            }

            LocalThing lthing = new LocalThing(thing, x, y, rot);

            if (x != -1)
            {
                bag.PutThing(lthing);
            }
        }