Exemple #1
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            // Set windows size for comfort playing
            MyGameView.Window.SetFrame(new CoreGraphics.CGRect(0, 0, 1600, 1000), true, true);

            // Getting GameScene for presenting on the window
            var scene = SKNode.FromFile <MenuScene>("GameScenes/MenuScene");


            // Set the scale mode to scale to fit the window
            scene.ScaleMode = SKSceneScaleMode.ResizeFill;


            // Enable debug information
            MyGameView.ShowsPhysics   = true;
            MyGameView.ShowsFPS       = true;
            MyGameView.ShowsNodeCount = true;

            // SpriteKit applies additional optimizations to improve rendering performance
            MyGameView.IgnoresSiblingOrder = true;


            // Present scene on the window
            MyGameView.PresentScene(scene);
        }
        public override void DidFinishLaunching(NSNotification notification)
        {
            var scene = SKNode.FromFile <GameScene>("GameScene");

            // Set the scale mode to scale to fit the window
            scene.ScaleMode = SKSceneScaleMode.AspectFill;

            MyGameView.PresentScene(scene);

            // SpriteKit applies additional optimizations to improve rendering performance
            MyGameView.IgnoresSiblingOrder = true;

            ProcessName.StringValue = "New Process";
        }
Exemple #3
0
        void Setup()
        {
            // Configure the view.
            GameView.ShowsFPS       = true;
            GameView.ShowsNodeCount = true;
            /* Sprite Kit applies additional optimizations to improve rendering performance */
            GameView.IgnoresSiblingOrder = true;

            // Create and configure the scene.
            var scene = SKNode.FromFile <GameScene>("GameScene");

            scene.ScaleMode = SKSceneScaleMode.AspectFill;

            // Present the scene.
            GameView.PresentScene(scene);
        }
Exemple #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Configure the view.
            var skView = (SKView)View;

            skView.ShowsFPS       = true;
            skView.ShowsNodeCount = true;
            /* Sprite Kit applies additional optimizations to improve rendering performance */
            skView.IgnoresSiblingOrder = true;

            // Create and configure the scene.
            var scene = SKNode.FromFile <GameScene>("GameScene");

            scene.ScaleMode = SKSceneScaleMode.AspectFill;

            // Present the scene.
            skView.PresentScene(scene);
        }
Exemple #5
0
        public void InitAgent(SKScene scene, float radius, CGPoint position)
        {
            Position  = position;
            ZPosition = 10f;
            scene.AddChild(this);

            Agent = new GKAgent2D {
                Radius          = radius,
                Position        = new Vector2((float)position.X, (float)position.Y),
                Delegate        = this,
                MaxSpeed        = 100f,
                MaxAcceleration = 50f
            };

            var circleShape = SKShapeNode.FromCircle(radius);

            circleShape.LineWidth = 2.5f;
            circleShape.FillColor = SKColor.Gray;
            circleShape.ZPosition = 1f;
            AddChild(circleShape);

            const float triangleBackSideAngle = (float)((135f / 360f) * (2 * Math.PI));
            var         points = new [] {
                new CGPoint(radius, 0f),                                                                          // Tip
                new CGPoint(radius * Math.Cos(triangleBackSideAngle), radius * Math.Sin(triangleBackSideAngle)),  // Back bottom
                new CGPoint(radius * Math.Cos(triangleBackSideAngle), -radius * Math.Sin(triangleBackSideAngle)), // Back top
                new CGPoint(radius, 0f)                                                                           // Back top
            };

            TriangleShape           = SKShapeNode.FromPoints(ref points [0], (nuint)points.Length);
            TriangleShape.LineWidth = 2.5f;
            TriangleShape.ZPosition = 1f;
            AddChild(TriangleShape);

            Particles            = SKNode.FromFile <SKEmitterNode> ("Trail.sks");
            DefaultParticleRate  = (float)Particles.ParticleBirthRate;
            Particles.Position   = new CGPoint(-radius + 5, 0);
            Particles.TargetNode = scene;
            Particles.ZPosition  = 0f;
            AddChild(Particles);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (DevModeIsOn)
            {
                currentTime = DevLevelTime;
            }

            // Configure the view.
            SKView skView = (SKView)View;

            skView.ShowsFPS       = DevModeIsOn;
            skView.ShowsNodeCount = DevModeIsOn;

            /* Sprite Kit applies additional optimizations to improve rendering performance */
            skView.IgnoresSiblingOrder = true;

            // Create and configure the scene.
            scene           = SKNode.FromFile <GameScene>("GameScene");
            scene.ScaleMode = SKSceneScaleMode.AspectFill;

            // Передаем сцене данные о размере вью
            scene.SetSize(skView.Bounds.Size);

            // Создаем игровой уровень, передаем его сцене
            level = new Level(DevModeIsOn);

            scene.Level = level;

            // инциализируем делегат обработки обмена местами камешков
            scene.SwipeHandler = HandleSwipeAsync;

            // Кнопка "В меню"
            UIButton stopButton = new UIButton
            {
                Frame           = new CoreGraphics.CGRect(30, View.Bounds.Size.Height - 100, 120, 45),
                Font            = CommonFont,
                BackgroundColor = ButtonColor
            };

            stopButton.SetTitle("В МЕНЮ", UIControlState.Normal);

            stopButton.TouchUpInside += (sender, e) =>
            {
                gameTimer.Invalidate();
                UIViewController mainMenu = Storyboard.InstantiateViewController("MainMenu");
                NavigationController.PushViewController(mainMenu, true);
            };

            // Кнопка паузы
            UIButton pauseButton = new UIButton
            {
                Frame           = new CoreGraphics.CGRect(skView.Bounds.Size.Width - 150, View.Bounds.Size.Height - 100, 120, 45),
                Font            = CommonFont,
                BackgroundColor = ButtonColor
            };

            pauseButton.SetTitle("||", UIControlState.Normal);

            pauseButton.TouchUpInside += (sender, e) =>
            {
                pauseLabel.Hidden  = scene.GameIsPaused;
                scene.GameIsPaused = !scene.GameIsPaused;
                scene.SwitchBacgroundZPosition();
            };

            // получаем лучший счет
            highScore = GetHighScore();

            // лэйбл с лучшим счетом
            highScoreLabel = new UILabel
            {
                Frame = new CoreGraphics.CGRect
                        (
                    skView.Bounds.Size.Width / 2 - HighScoreLabelWidth / 2,
                    HighScoreLabelY,
                    HighScoreLabelWidth,
                    CommonLabelHeight
                        ),
                TextAlignment = UITextAlignment.Center,
                Font          = CommonFont,
                Text          = "Лучший счёт: " + highScore,
                TextColor     = UIColor.White
            };

            // лэйбл с таймером
            timerLabel = new UILabel
            {
                Frame = new CoreGraphics.CGRect
                        (
                    skView.Bounds.Size.Width / 2 - CommonLabelWidth / 2,
                    TimerLabelY,
                    CommonLabelWidth,
                    CommonLabelHeight
                        ),
                Font          = CommonFont,
                TextAlignment = UITextAlignment.Center,
                TextColor     = UIColor.White
            };

            // лэйбл с надписью Счет
            UILabel scoreTitle = new UILabel
            {
                Frame = new CoreGraphics.CGRect
                        (
                    skView.Bounds.Size.Width / 2 - CommonLabelWidth / 2,
                    ScoreTitleLabelY,
                    CommonLabelWidth,
                    CommonLabelHeight
                        ),
                TextAlignment = UITextAlignment.Center,
                Font          = CommonFont,
                Text          = "Счёт:",
                TextColor     = UIColor.White
            };

            // лэйбл со счетом
            scoreLabel = new UILabel
            {
                Frame = new CoreGraphics.CGRect
                        (
                    skView.Bounds.Size.Width / 2 - CommonLabelWidth / 2,
                    ScoreLabelY,
                    CommonLabelWidth,
                    CommonLabelHeight
                        ),
                TextAlignment = UITextAlignment.Center,
                Font          = CommonFont,
                Text          = "0",
                TextColor     = UIColor.White
            };

            // лэйбл с надписью Пауза
            pauseLabel = new UILabel
            {
                Hidden = true,
                Frame  = new CoreGraphics.CGRect
                         (
                    skView.Bounds.Size.Width / 2 - CommonLabelWidth / 2,
                    skView.Bounds.Size.Height / 2 - CommonLabelHeight / 2,
                    CommonLabelWidth,
                    CommonLabelHeight
                         ),
                TextAlignment = UITextAlignment.Center,
                Font          = CommonFont,
                Text          = "ПАУЗА",
                TextColor     = UIColor.White
            };

            // добавляем элементы интерфейса на вью
            skView.Add(stopButton);
            skView.Add(pauseButton);
            skView.Add(highScoreLabel);
            skView.Add(timerLabel);
            skView.Add(scoreTitle);
            skView.Add(scoreLabel);
            skView.Add(pauseLabel);

            // Present the scene.
            skView.PresentScene(scene);

            // Начало игры
            BeginGame();
        }
Exemple #7
0
 public static void ConfigureGameScene()
 {
     // Create and configure the scene.
     GameSceneViewer           = SKNode.FromFile <GameScene>("GameScene");
     GameSceneViewer.ScaleMode = SKSceneScaleMode.AspectFill;
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Configure the view.
            var skView = (SKView)View;

            skView.ShowsFPS       = true;
            skView.ShowsNodeCount = true;
            /* Sprite Kit applies additional optimizations to improve rendering performance */
            skView.IgnoresSiblingOrder = true;

            // Create and configure the scene.
            var scene = SKNode.FromFile <GameScene> ("GameScene");

            scene.ScaleMode = SKSceneScaleMode.AspectFill;
            CurrentScene    = scene;

            /*
             * var redbox = new SKSpriteNode (UIColor.Red, new CoreGraphics.CGSize (100, 100));
             * var bluebox = new SKSpriteNode (UIColor.Blue, new CoreGraphics.CGSize (50, 50));
             * var greenbox = new SKSpriteNode (UIColor.Green, new CoreGraphics.CGSize (25, 25));
             *
             * redbox.AnchorPoint = new CoreGraphics.CGPoint (0, 0);
             * redbox.Position = new CoreGraphics.CGPoint (0, 0);
             * redbox.Add (bluebox);
             *
             * bluebox.Add (greenbox);
             * bluebox.Position = CoreGraphics.CGPoint.Empty;
             * bluebox.AnchorPoint = CoreGraphics.CGPoint.Empty;
             *
             * greenbox.Position = CoreGraphics.CGPoint.Empty;
             * greenbox.AnchorPoint = CoreGraphics.CGPoint.Empty;
             *
             * scene.Add (redbox);
             */
            // Present the scene.
            skView.PresentScene(scene);

            inventoryButton = new UIButton(UIButtonType.InfoDark);
            inventoryButton.TranslatesAutoresizingMaskIntoConstraints = false;
            View.AddSubview(inventoryButton);

            inventoryButton.TouchUpInside += (sender, e) => {
                var ivc = new InventoryViewController {
                    Manager = CurrentScene.InvManager
                };
                ivc.ItemActivated += (s, args) => {
                    DismissViewController(false, null);
                    MenuDisplayController.DisplayMenuForItem(args.Item, this, clickHandler);
                };

                PresentViewController(ivc, false, null);
            };

            var viewsDict   = new NSDictionary("inventory", inventoryButton);
            var constraints = NSLayoutConstraint.FromVisualFormat("|-20-[inventory]", NSLayoutFormatOptions.AlignAllTop, null, viewsDict);

            skView.AddConstraints(constraints);

            constraints = NSLayoutConstraint.FromVisualFormat("V:|-20-[inventory]", NSLayoutFormatOptions.AlignAllTop, null, viewsDict);
            skView.AddConstraints(constraints);
        }