Пример #1
0
        void CreateGameBoard(nfloat width, nfloat height)
        {
            var cellWidth = 14;
            var numRows   = 40;
            var numCols   = 20;
            var x         = (width / -2f) + (cellWidth / 2f);
            var y         = (height / 2f) - (cellWidth / 2f);

            //loop through rows and columns, create cells
            for (int i = 0; i < numRows; i++)
            {
                for (int j = 0; j < numCols; j++)
                {
                    var cellNode = SKShapeNode.FromRect(new CGSize(width: cellWidth, height: cellWidth));
                    cellNode.StrokeColor = UIColor.Black;
                    cellNode.ZPosition   = 2;
                    cellNode.Position    = new CGPoint(
                        x: Frame.GetMidX() + x,
                        y: Frame.GetMidY() + 40 + y);
                    //add to array of cells -- then add to game board
                    gameArray.Add(new CellObj(cellNode, i, j));
                    gameBG.AddChild(cellNode);
                    //iterate x
                    x += cellWidth;
                }
                //reset x, iterate y
                x  = (width / -2f) + (cellWidth / 2f);
                y -= cellWidth;
            }
        }
Пример #2
0
        public static SKShapeNode MakeDiamond()
        {
            var square = SKShapeNode.FromRect(Settings.Sizes.DiamondSize);

            square.ZRotation = 44.99999999f;
            return(square);
        }
Пример #3
0
        void InitializeGameView()
        {
            currentScore           = new SKLabelNode("ArialRoundedMTBold");
            currentScore.ZPosition = 1;
            currentScore.Position  = new CGPoint(
                x: Frame.GetMidX(),
                y: Frame.GetMidY() + (Frame.Size.Height / -2f) + 60);
            currentScore.FontSize  = 20;
            currentScore.Hidden    = true;
            currentScore.Text      = "Score: 0";
            currentScore.FontColor = UIColor.White;
            AddChild(currentScore);

            var width  = Frame.Size.Width - 94;
            var height = Frame.Size.Height - 106;
            var rect   = new CGRect(
                x: Frame.GetMidX() - width / 2f,
                y: Frame.GetMidY() - height / 2f + 40,
                width: width,
                height: height);

            gameBG           = SKShapeNode.FromRect(rect: rect, cornerRadius: 0.02f);
            gameBG.FillColor = UIColor.DarkGray;
            gameBG.ZPosition = 2;
            gameBG.Hidden    = true;
            AddChild(gameBG);

            CreateGameBoard(width: width, height: height);
        }
Пример #4
0
        public LineBar(GameController controller, CGPoint position, NSColor color)
        {
            this.controller = controller;
            this.position   = position;
            this.color      = color;

            MaxLineWidth  = 300;
            MaxlineHeigth = 10;


            Line           = SKShapeNode.FromRect(new CGSize(MaxLineWidth, MaxlineHeigth));
            Line.FillColor = color;
            Line.Position  = position;
            Line.ZPosition = 1;

            Border             = SKShapeNode.FromRect(new CGSize(MaxLineWidth, MaxlineHeigth));
            Border.StrokeColor = NSColor.Black;
            Border.Position    = position;
            Border.ZPosition   = 1;

            Label = new SKLabelNode
            {
                FontColor = NSColor.White,
                FontName  = "Arial",
                FontSize  = 20,
                Text      = "txt",
                ZPosition = 1
            };

            Label.Position = new CGPoint(
                Line.Position.X, Line.Position.Y + Label.FontSize / 2);

            controller.Scene.AddNodes(Line, Border, Label);
        }
Пример #5
0
        public void UpdateBarData(double data)
        {
            Label.Text = StrTemplate + $" { data } / 100";

            double widthHpAspect = MaxLineWidth / 100;
            double HPBarWidth    = data * widthHpAspect;

            controller.Scene.RemoveChildren(new SKNode[] { Line });
            double HPBarHeight = MaxlineHeigth;

            Line          = SKShapeNode.FromRect(new CGSize(HPBarWidth, HPBarHeight));
            Line.Position =
                new CGPoint(position.X - (MaxLineWidth - HPBarWidth) / 2, position.Y);
            Line.FillColor = color;

            controller.Scene.AddChild(Line);
        }
Пример #6
0
 public static SKShapeNode MakeOval()
 {
     return(SKShapeNode.FromRect(Settings.Sizes.OvalSize, 20));
 }
Пример #7
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);
        }