Exemplo n.º 1
0
        protected Shape GenerateRandomTier3Shape(int [] cases, int index)
        {
            Shape Temp = null;

            //generates a shape based on "cases" unique, random set of values
            switch (cases[index])
            {
            case 0: Temp = new KiteShape();
                break;

            case 1: Temp = new HookShape();
                break;

            case 2: Temp = new TonfuShape();
                break;

            case 3: Temp = new HardDiagonalShape();
                break;
            }

            return(Temp);
        }
Exemplo n.º 2
0
        public static Shape ConvertToShape(string s)
        {
            Shape  shape = null;
            string name  = "";

            string[] ss = new string[0];        //array of all the data parts
            int      numBlocks;                 //counting variables
            bool     extraData = false;         //Grab extra data from the string for shape shifting shape

            try
            {
                //Get name
                ss = s.Split('[');
                for (int i = 0; i < ss.Length; i++)
                {
                    ss[i] = ss[i].Trim('[', ']');
                }

                //Set up initial shape design
                name = ss[0];
                switch (name)
                {
                case "IShape":
                    shape = new IShape();
                    break;

                case "JShape":
                    shape = new JShape();
                    break;

                case "LShape":
                    shape = new LShape();
                    break;

                case "OShape":
                    shape = new OShape();
                    break;

                case "SShape":
                    shape = new SShape();
                    break;

                case "TShape":
                    shape = new TShape();
                    break;

                case "ZShape":
                    shape = new ZShape();
                    break;

                case "Corner Shape":
                    shape = new CornerShape();
                    break;

                case "Easy Diagonal Shape":
                    shape = new EasyDiagonalShape();
                    break;

                case "Hockey Stick Shape":
                    shape = new HockeyStickShape();
                    break;

                case "Oklahoma Shape":
                    shape = new OklahomaShape();
                    break;

                case "Reverse Hockey Stick Shape":
                    shape = new ReverseHockeyStickShape();
                    break;

                case "Bucket Shape":
                    shape = new BucketShape();
                    break;

                case "Lobster Claw Shape":
                    shape = new LobsterClawShape();
                    break;

                case "Plus Shape":
                    shape = new PlusShape();
                    break;

                case "Stair Shape":
                    shape = new StairShape();
                    break;

                case "VShape":
                    shape = new VShape();
                    break;

                case "Hard Diagonal Shape":
                    shape = new HardDiagonalShape();
                    break;

                case "Hook Shape":
                    shape = new HookShape();
                    break;

                case "Kite Shape":
                    shape = new KiteShape();
                    break;

                case "Tonfu Shape":
                    shape = new TonfuShape();
                    break;

                case "Shape Shifting Shape":
                    shape     = new ShapeShiftingShape();
                    extraData = true;
                    break;

                default:
                    shape = new OShape();
                    break;
                }

                //Set up blocks
                numBlocks = int.Parse(ss[1]);
                for (int i = 0; i < numBlocks; i++)
                {
                    int blockIndex = int.Parse(ss[2 + i]);
                    shape.blocks[i].blockColor = BlockColors.AllBlocks[blockIndex];
                }

                //If shapeshifting shape, get state relative positions of the different forms
                if (extraData)
                {
                    shape.stateRelativePositions.Clear();
                    int index = 2 + numBlocks;
                    for (int i = 0; i < 4; i++)
                    {
                        shape.stateRelativePositions.Add(new List <Vector2>());
                        int numFormBlocks = int.Parse(ss[index]);
                        index++;
                        for (int j = 0; j < numFormBlocks; j++)
                        {
                            int x = int.Parse(ss[index]);
                            int y = int.Parse(ss[index + 1]);
                            index += 2;

                            shape.stateRelativePositions[i].Add(new Vector2(x, y));
                        }
                    }
                }
            }
            catch
            {
                Console.WriteLine("String could not be converted to shape: {0}", s);
            }

            return(shape);
        }