Ejemplo n.º 1
0
 public static Card GenerateRandomCard()
 {
     return(new Card(
                CardShapes.GetRandom(),
                ShapeCounts.GetRandom(),
                ShapeColors.GetRandom(),
                ShapeFills.GetRandom()
                ));
 }
Ejemplo n.º 2
0
        private SKShapeNode _CreateNode()
        {
            //Creating The Card:
            var rectangle =
                new CGRect(0, 0, Settings.Sizes.CardHeight, Settings.Sizes.CardWidth);
            var card = SKShapeNode.FromRect(rectangle, 5);

            card.FillColor   = Settings.Colors.CardBackgroundColor;
            card.StrokeColor = Settings.Colors.CardStrokeColor;


            //Create the Shape Node:

            //TODO: Check the actual shape enum
            var _totalShapes = ShapeCounts.GetInt(ShapeCount);
            var _fillColor   = ShapeColors.GetColor(ShapeColor);
            var _shapes      = new List <SKShapeNode>(_totalShapes);

            //generate each shape:
            for (int i = 0; i < _totalShapes; i++)
            {
                SKShapeNode _shapeNode = _GetShape();

                _shapeNode.StrokeColor = _fillColor;
                _shapeNode.LineWidth   = 5f;

                switch (ShapeFill)
                {
                case ShapeFill.Full:
                    _shapeNode.FillColor = _fillColor;
                    break;

                case ShapeFill.Half:
                    _shapeNode.FillTexture = SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("stripes", "png"));
                    _shapeNode.FillColor   = card.FillColor;
                    break;

                default:     //None Case
                    _shapeNode.FillColor = card.FillColor;
                    break;
                }



                switch (ShapeCount)   //can this be done less idiomatic?
                {
                case ShapeCount.Two:
                    _shapeNode.Position = Settings.Positions.DoubleShapePosition(i);
                    break;

                case ShapeCount.Three:
                    _shapeNode.Position = Settings.Positions.TripleShapePosition(i);
                    break;

                default:     //case ShapeCount.One:
                    _shapeNode.Position = Settings.Positions.SingleShapePosition;
                    break;
                }

                _shapes.Add(_shapeNode);

                card.AddChild(_shapeNode);
            }

            return(card);
        }