コード例 #1
0
ファイル: JellyDouble.cs プロジェクト: lyhyl/WorldOfJelly
 public override JellyObject[] Convert(int[] cid)
 {
     if (cid.Length == 2)
     {
         return(null);
     }
     else
     {
         JellyObject jo = new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[cid[0] == 3 ? 4 : 3].Position);
         return(new JellyObject[1] {
             jo
         });
     }
 }
コード例 #2
0
ファイル: JellyTripleL.cs プロジェクト: lyhyl/WorldOfJelly
        public override JellyObject[] Convert(int[] cid)
        {
            switch (cid.Length)
            {
            case 1:
                int id = cid[0];
                if (id == 4)
                {
                    JellyBox jba, jbb;
                    jba = new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[3].Position);
                    jbb = new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[8].Position);
                    return(new JellyObject[2] {
                        jba, jbb
                    });
                }
                else
                {
                    JellyDouble jd = new JellyDouble(_graphicsDevice, Mass, Size, _color, _nodes[id].Position);
                    return(new JellyObject[1] {
                        jd
                    });
                }

            case 2:
            {
                // 3 - 0011
                // 4 - 0100
                // 8 - 1000
                // |
                // 3 | 4 - 0111
                // 4 | 8 - 1100
                // 3 | 8 - 1011
                // >>
                // 0111 - 01 - 1
                // 1100 - 11 - 3
                // 1011 - 10 - 2
                int         mark = (cid[0] | cid[1]) >> 2;
                JellyObject jo   = null;
                switch (mark)
                {
                case 1:            //cell 8
                    jo = new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[8].Position);
                    break;

                case 2:            //cell 4
                    jo = new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[4].Position);
                    break;

                case 3:            //cell 3
                    jo = new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[3].Position);
                    break;
                }
                return(new JellyObject[1] {
                        jo
                    });
            }

            default:
                return(null);
            }
        }
コード例 #3
0
ファイル: JellyBigBox.cs プロジェクト: lyhyl/WorldOfJelly
        public override JellyObject[] Convert(int[] cid)
        {
            //3,4,8,9
            //11b,100b,1000b,1001b
            switch (cid.Length)
            {
            case 1:
                JellyTripleL jt = null;
                switch (cid[0])
                {
                case 3: jt = new JellyTripleL(_graphicsDevice, Mass, Size, _color, _nodes[0].Position); break;

                case 4: jt = new JellyTripleL(_graphicsDevice, Mass, Size, _color, _nodes[0].Position); break;

                case 8: jt = new JellyTripleL(_graphicsDevice, Mass, Size, _color, _nodes[0].Position); break;

                case 9: jt = new JellyTripleL(_graphicsDevice, Mass, Size, _color, _nodes[0].Position); break;
                }
                return(new JellyObject[1] {
                    jt
                });

            //Sep : 3,9  4,8
            // | : 1010b 1100b | 10 12

            //     3,4      4,9       8,9      3,8
            // | : 0111b 1101b 0001b 1011b | 7 13 1 11
            case 2:
                switch (cid[0] ^ cid[1])
                {
                case 10:
                    return(new JellyObject[2]
                    {
                        new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[3].Position),
                        new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[9].Position)
                    });

                case 12:
                    return(new JellyObject[2]
                    {
                        new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[4].Position),
                        new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[8].Position)
                    });

                case 7:
                    return(new JellyObject[] { new JellyDouble(_graphicsDevice, Mass, Size, _color, _nodes[3].Position, _nodes[4].Position) });

                case 13:
                    return(new JellyObject[] { new JellyDouble(_graphicsDevice, Mass, Size, _color, _nodes[4].Position, _nodes[9].Position) });

                case 1:
                    return(new JellyObject[] { new JellyDouble(_graphicsDevice, Mass, Size, _color, _nodes[8].Position, _nodes[9].Position) });

                case 11:
                    return(new JellyObject[] { new JellyDouble(_graphicsDevice, Mass, Size, _color, _nodes[3].Position, _nodes[8].Position) });
                }
                return(null);   //Should never be here

            //          |           ^
            //!3   1101b   101b     5
            //!4   1011b   10b       2
            //!8   1111b   1110b   14
            //!9   1111b   1111b   15
            case 3:
                JellyBox jb = null;
                switch (cid[0] ^ cid[1] ^ cid[2])
                {
                case 5: jb = new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[3].Position); break;

                case 2: jb = new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[4].Position); break;

                case 14: jb = new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[8].Position); break;

                case 15: jb = new JellyBox(_graphicsDevice, Mass, Size, _color, _nodes[9].Position); break;
                }
                return(new JellyObject[1] {
                    jb
                });

            default:
                return(null);
            }
        }