예제 #1
0
        void StartGame()
        {
            Console.WriteLine("Start game");

            gameLogo.RunAction(SKAction.MoveTo(
                                   new CGPoint(
                                       x: Frame.GetMidX() - 50,
                                       y: Frame.GetMidY() + 600),
                                   0.5),
                               () => gameLogo.Hidden = true);

            bestScore.RunAction(SKAction.MoveTo(
                                    new CGPoint(
                                        x: Frame.GetMidX(),
                                        y: Frame.GetMidY() + (Frame.Size.Height / -2f) + 20),
                                    0.4));

            playButton.RunAction(SKAction.ScaleTo(0, 0.3),
                                 () => playButton.Hidden = true);

            gameBG.SetScale(0);
            currentScore.SetScale(0);
            gameBG.Hidden       = false;
            currentScore.Hidden = false;
            gameBG.RunAction(SKAction.ScaleTo(1, 0.4));
            currentScore.RunAction(SKAction.ScaleTo(1, 0.4));

            game.InitGame();
        }
예제 #2
0
        public async void loadStarter()
        {
            var scoreLoad = new SKLabelNode()
            {
                Text      = "" + (GameObj.ToBeatScore + 1) + " To Win",              //.ToString ();
                Position  = new CGPoint(Size.Width / 2, (Size.Height / 2) - 200),
                FontSize  = 66,
                FontColor = UIColor.White,
                FontName  = "GillSans-Bold",
            };

            scoreLoad.SetScale(0.1f);

            var moveUpAction  = SKAction.MoveTo((new CGPoint(Size.Width / 2, Size.Height / 2)), 1.0);
            var scaleUpAction = SKAction.ScaleBy(9f, 1.0);

            AddChild(scoreLoad);

            scoreLoad.RunAction(moveUpAction);
            scoreLoad.RunAction(scaleUpAction);

            await System.Threading.Tasks.Task.Delay(2000);

            scoreLoad.RemoveFromParent();

            for (int i = 0; i < 3; i++)
            {
                var startGameNode = new SKLabelNode()
                {
                    Text      = "" + (3 - i),
                    Position  = new CGPoint(Size.Width / 2, (Size.Height / 2) - 200),
                    FontSize  = 80,
                    FontColor = UIColor.Red,
                    FontName  = "GillSans-Bold",
                };
                startGameNode.SetScale(0.1f);

                var moveUpAction1  = SKAction.MoveTo((new CGPoint(Size.Width / 2, Size.Height / 2)), 1.0);
                var scaleUpAction1 = SKAction.ScaleBy(9f, 1.0);
                AddChild(startGameNode);

                startGameNode.RunAction(moveUpAction1);
                startGameNode.RunAction(scaleUpAction1);

                await System.Threading.Tasks.Task.Delay(2000);

                startGameNode.RemoveFromParent();
            }
        }
예제 #3
0
        public PostGameMenu(CGSize frameSize, IGameUIState gameStateDelegate)
        {
            GameStateDelegate = gameStateDelegate;
            nfloat menuHeight = frameSize.Height * 0.8f;
            var    background = new SKSpriteNode(AppKit.NSColor.Black, new CGSize(frameSize.Width * 0.8f, menuHeight));

            background.ZPosition = -1;
            background.Alpha     = 0.5f;
            background.Position  = new CGPoint(0, -0.2f * menuHeight);

            myLabel          = InGameScene.LabelWithText("Final Score", 65);
            myLabel.Position = new CGPoint(Frame.GetMidX(), Frame.GetMidY());

            Position = new CGPoint(frameSize.Width * 0.5f, frameSize.Height * 0.5f);
            UserInteractionEnabled         = true;
            myLabel.UserInteractionEnabled = true;
            AddChild(myLabel);
            InGameScene.DropShadowOnLabel(myLabel);

            var bananaLocation      = new CGPoint(frameSize.Width * -0.4f, Frame.GetMidY() * -0.4f);
            var coinLocation        = new CGPoint(frameSize.Width * -0.4f, Frame.GetMidY() * -0.6f);
            var totalLocation       = new CGPoint(frameSize.Width * -0.4f, Frame.GetMidY() * -0.8f);
            var bananaScoreLocation = new CGPoint(frameSize.Width * +0.4f, Frame.GetMidY() * -0.4f);
            var coinScoreLocation   = new CGPoint(frameSize.Width * +0.4f, Frame.GetMidY() * -0.6f);
            var totalScoreLocation  = new CGPoint(frameSize.Width * +0.4f, Frame.GetMidY() * -0.8f);

            bananaText          = (SKLabelNode)myLabel.Copy();
            bananaText.Text     = "Bananas";
            bananaText.FontSize = 0.1f * menuHeight;
            bananaText.SetScale(0.8f);
            bananaLocation.X   += bananaText.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f;
            bananaText.Position = new CGPoint(bananaLocation.X, -2000);
            AddChild(bananaText);
            InGameScene.DropShadowOnLabel(bananaText);

            bananaScore            = (SKLabelNode)bananaText.Copy();
            bananaScore.Text       = "000";
            bananaScoreLocation.X -= bananaScore.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f;
            bananaScore.Position   = new CGPoint(bananaScoreLocation.X, -2000);
            AddChild(bananaScore);

            coinText          = (SKLabelNode)bananaText.Copy();
            coinText.Text     = "Large Bananas";
            coinLocation.X   += coinText.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f;
            coinText.Position = new CGPoint(coinLocation.X, -2000f);
            AddChild(coinText);
            InGameScene.DropShadowOnLabel(coinText);

            coinScore            = (SKLabelNode)coinText.Copy();
            coinScore.Text       = "000";
            coinScoreLocation.X -= coinScore.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f;
            coinScore.Position   = new CGPoint(coinScoreLocation.X, -2000f);
            AddChild(coinScore);

            totalText          = (SKLabelNode)bananaText.Copy();
            totalText.Text     = "Total";
            totalLocation.X   += totalText.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f;
            totalText.Position = new CGPoint(totalLocation.X, -2000f);
            AddChild(totalText);
            InGameScene.DropShadowOnLabel(totalText);

            totalScore            = (SKLabelNode)totalText.Copy();
            totalScore.Text       = "000";
            totalScoreLocation.X -= totalScore.CalculateAccumulatedFrame().Width * 0.5f + frameSize.Width * 0.1f;
            totalScore.Position   = new CGPoint(totalScoreLocation.X, -2000f);
            AddChild(totalScore);

            SKAction flyup = SKAction.MoveTo(new CGPoint(frameSize.Width * 0.5f, frameSize.Height - 100), 0.25);

            flyup.TimingMode = SKActionTimingMode.EaseInEaseOut;

            SKAction flyupBananas = SKAction.MoveTo(bananaLocation, 0.25);

            flyupBananas.TimingMode = SKActionTimingMode.EaseInEaseOut;

            SKAction flyupBananasScore = SKAction.MoveTo(bananaScoreLocation, 0.25f);

            flyupBananasScore.TimingMode = SKActionTimingMode.EaseInEaseOut;

            SKAction flyupCoins = SKAction.MoveTo(coinLocation, 0.25);

            flyupCoins.TimingMode = SKActionTimingMode.EaseInEaseOut;

            SKAction flyupCoinsScore = SKAction.MoveTo(coinScoreLocation, 0.25);

            flyupCoinsScore.TimingMode = SKActionTimingMode.EaseInEaseOut;

            SKAction flyupTotal = SKAction.MoveTo(totalLocation, 0.25);

            flyupTotal.TimingMode = SKActionTimingMode.EaseInEaseOut;

            SKAction flyupTotalScore = SKAction.MoveTo(totalScoreLocation, 0.25);

            flyupTotalScore.TimingMode = SKActionTimingMode.EaseInEaseOut;

            int bananasCollected = gameStateDelegate.BananasCollected;
            int coinsCollected   = gameStateDelegate.CoinsCollected;
            int totalCollected   = bananasCollected + (coinsCollected * 100);

            SKAction countUpBananas = SKAction.CustomActionWithDuration(bananasCollected / 100f, ((node, elapsedTime) => {
                if (bananasCollected > 0)
                {
                    SKLabelNode label = (SKLabelNode)node;
                    nint total = (nint)(elapsedTime / (bananasCollected / 100.0f) * bananasCollected);
                    label.Text = total.ToString();

                    if (total % 10 == 0)
                    {
                        GameSimulation.Sim.PlaySound("deposit.caf");
                    }
                }
            }));

            SKAction countUpCoins = SKAction.CustomActionWithDuration(coinsCollected / 100f, ((node, elapsedTime) => {
                if (coinsCollected > 0)
                {
                    SKLabelNode label = (SKLabelNode)node;
                    nint total = (nint)((elapsedTime / (coinsCollected / 100.0f)) * coinsCollected);
                    label.Text = total.ToString();

                    if (total % 10 == 0)
                    {
                        GameSimulation.Sim.PlaySound("deposit.caf");
                    }
                }
            }));

            SKAction countUpTotal = SKAction.CustomActionWithDuration(totalCollected / 500.0f, ((node, elapsedTime) => {
                if (totalCollected > 0)
                {
                    SKLabelNode label = (SKLabelNode)node;
                    nint total = (nint)((elapsedTime / (totalCollected / 500.0f)) * totalCollected);
                    label.Text = total.ToString();

                    if (total % 25 == 0)
                    {
                        GameSimulation.Sim.PlaySound("deposit.caf");
                    }
                }
            }));

            RunAction(flyup, () => {
                bananaText.RunAction(flyupBananas);
                bananaScore.RunAction(flyupBananasScore, () => {
                    bananaScore.RunAction(countUpBananas, () => {
                        bananaScore.Text = bananasCollected.ToString();
                        coinText.RunAction(flyupCoins);
                        coinScore.RunAction(flyupCoinsScore, () => {
                            coinScore.RunAction(countUpCoins, () => {
                                coinScore.Text = coinsCollected.ToString();
                                totalText.RunAction(flyupTotal);
                                totalScore.RunAction(flyupTotalScore, () => {
                                    totalScore.RunAction(countUpTotal, () => {
                                        totalScore.Text = totalCollected.ToString();
                                    });
                                });
                            });
                        });
                    });
                });
            });
        }
예제 #4
0
        public async void AnalyzeTouch()
        {
            var touchDiff  = LastTouch.Y - FirstTouch.Y;
            var touchDiffX = LastTouch.X - FirstTouch.X;

            if (touchDiff > 66)
            {
                var sprite = new SKSpriteNode("dart_blue")
                {
                    Position = new CGPoint(
                        FirstTouch.X, -5f)
                };


                //dart_blue
//				var sprite1 = new SKSpriteNode ("knife1") {
//					Position = new CGPoint(
//						FirstTouch.X,-5f )
//				};



                sprite.SetScale(1.5f);
                AddChild(sprite);

                var finaldest = new CGPoint();
                var action    = SKAction.MoveTo(finaldest, 0.3);

                if (touchDiff < 150)
                {
                    finaldest = new CGPoint(LastTouch.X + (touchDiffX * 0.5f), LastTouch.Y + (touchDiff * 0.3f));
                    action    = SKAction.MoveTo(finaldest, 0.3);                //FollowPath (np, 3.0);
                }
                else
                {
                    finaldest = new CGPoint(LastTouch.X + (touchDiffX * 0.5f),
                                            LastTouch.Y + (touchDiff * 0.6f));

                    action = SKAction.MoveTo(finaldest, 0.2);
                }

                nfloat rotatingAngle = touchDiffX / 333;

                Console.WriteLine("touchDiff:::" + touchDiffX);
                Console.WriteLine("toRadians:::" + rotatingAngle);

                //to radians
                var RotAction = SKAction.RotateToAngle(-rotatingAngle, 0);

                //to small size
                var scaleAction = SKAction.ScaleTo(0.8f, 0.1555);

                sprite.RunAction(action);
                sprite.RunAction(RotAction);
                sprite.RunAction(scaleAction);

                SpriteCount++;

                //COLLISION
                if (PhotoNode.ContainsPoint(finaldest))
                {
                    CurrentScore++;
                    System.Diagnostics.Debug.WriteLine("POINTS:    " + CurrentScore);
                    System.Diagnostics.Debug.WriteLine("collideddddddd::::::::::::::::::::::");

                    await System.Threading.Tasks.Task.Delay(200);

                    await System.Threading.Tasks.Task.Delay(200);

                    var displayScoreNode = new SKLabelNode();

                    displayScoreNode.Text      = "" + CurrentScore;                    //.ToString ();
                    displayScoreNode.Position  = new CGPoint(Size.Width / 2, (Size.Height / 2) - 200);
                    displayScoreNode.FontSize  = 80;
                    displayScoreNode.FontColor = UIColor.Red;
                    displayScoreNode.FontName  = "GillSans-Bold";
                    displayScoreNode.SetScale(0.1f);

                    var moveUpAction  = SKAction.MoveTo((new CGPoint(Size.Width / 2, Size.Height / 2)), 0.5);
                    var scaleUpAction = SKAction.ScaleBy(9f, 0.5);
                    AddChild(displayScoreNode);

                    displayScoreNode.RunAction(moveUpAction);
                    displayScoreNode.RunAction(scaleUpAction);

                    await System.Threading.Tasks.Task.Delay(1000);

                    displayScoreNode.RemoveFromParent();
                }
                else
                {
                    await System.Threading.Tasks.Task.Delay(300);

                    SystemSound.Vibrate.PlaySystemSound();                     //.PlayAlertSound();
                    SystemSound.Vibrate.Close();
                }

                //REMOVE SLOW DART
                if (touchDiff < 100)
                {
                    await System.Threading.Tasks.Task.Delay(200);

                    sprite.RemoveFromParent();
                    SpriteCount--;
                }

                if (touchDiff > 120 && (!PhotoFrameNode.ContainsPoint(finaldest)))
                {
                    await System.Threading.Tasks.Task.Delay(300);

                    SystemSound.Vibrate.PlaySystemSound();                     //.PlayAlertSound();
                    SystemSound.Vibrate.Close();
                    await System.Threading.Tasks.Task.Delay(200);
                }
            }
        }
예제 #5
0
		public PostGameMenu (CGSize frameSize, IGameUIState gameStateDelegate)
		{
			GameStateDelegate = gameStateDelegate;
			nfloat menuHeight = frameSize.Height * 0.8f;
			var background = new SKSpriteNode (AppKit.NSColor.Black, new CGSize (frameSize.Width * 0.8f, menuHeight));

			background.ZPosition = -1;
			background.Alpha = 0.5f;
			background.Position = new CGPoint (0, -0.2f * menuHeight);

			myLabel = InGameScene.LabelWithText ("Final Score", 65);
			myLabel.Position = new CGPoint (Frame.GetMidX (), Frame.GetMidY ());

			Position = new CGPoint (frameSize.Width * 0.5f, frameSize.Height * 0.5f);
			UserInteractionEnabled = true;
			myLabel.UserInteractionEnabled = true;
			AddChild (myLabel);
			InGameScene.DropShadowOnLabel (myLabel);

			var bananaLocation = new CGPoint (frameSize.Width * -0.4f, Frame.GetMidY () * -0.4f);
			var	coinLocation = new CGPoint (frameSize.Width * -0.4f, Frame.GetMidY () * -0.6f);
			var totalLocation = new CGPoint (frameSize.Width * -0.4f, Frame.GetMidY () * -0.8f);
			var bananaScoreLocation = new CGPoint (frameSize.Width * +0.4f, Frame.GetMidY () * -0.4f);
			var coinScoreLocation = new CGPoint (frameSize.Width * +0.4f, Frame.GetMidY () * -0.6f);
			var totalScoreLocation = new CGPoint (frameSize.Width * +0.4f, Frame.GetMidY () * -0.8f);

			bananaText = (SKLabelNode)myLabel.Copy ();
			bananaText.Text = "Bananas";
			bananaText.FontSize = 0.1f * menuHeight;
			bananaText.SetScale (0.8f);
			bananaLocation.X += bananaText.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f;
			bananaText.Position = new CGPoint (bananaLocation.X, -2000);
			AddChild (bananaText);
			InGameScene.DropShadowOnLabel (bananaText);

			bananaScore = (SKLabelNode)bananaText.Copy ();
			bananaScore.Text = "000";
			bananaScoreLocation.X -= bananaScore.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f;
			bananaScore.Position = new CGPoint (bananaScoreLocation.X, -2000);
			AddChild (bananaScore);

			coinText = (SKLabelNode)bananaText.Copy ();
			coinText.Text = "Large Bananas";
			coinLocation.X += coinText.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f;
			coinText.Position = new CGPoint (coinLocation.X, -2000f);
			AddChild (coinText);
			InGameScene.DropShadowOnLabel (coinText);

			coinScore = (SKLabelNode)coinText.Copy ();
			coinScore.Text = "000";
			coinScoreLocation.X -= coinScore.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f;
			coinScore.Position = new CGPoint (coinScoreLocation.X, -2000f);
			AddChild (coinScore);

			totalText = (SKLabelNode)bananaText.Copy ();
			totalText.Text = "Total";
			totalLocation.X += totalText.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f;
			totalText.Position = new CGPoint (totalLocation.X, -2000f);
			AddChild (totalText);
			InGameScene.DropShadowOnLabel (totalText);

			totalScore = (SKLabelNode)totalText.Copy ();
			totalScore.Text = "000";
			totalScoreLocation.X -= totalScore.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f;
			totalScore.Position = new CGPoint (totalScoreLocation.X, -2000f);
			AddChild (totalScore);

			SKAction flyup = SKAction.MoveTo (new CGPoint (frameSize.Width * 0.5f, frameSize.Height - 100), 0.25);
			flyup.TimingMode = SKActionTimingMode.EaseInEaseOut;

			SKAction flyupBananas = SKAction.MoveTo (bananaLocation, 0.25);
			flyupBananas.TimingMode = SKActionTimingMode.EaseInEaseOut;

			SKAction flyupBananasScore = SKAction.MoveTo (bananaScoreLocation, 0.25f);
			flyupBananasScore.TimingMode = SKActionTimingMode.EaseInEaseOut;

			SKAction flyupCoins = SKAction.MoveTo (coinLocation, 0.25);
			flyupCoins.TimingMode = SKActionTimingMode.EaseInEaseOut;

			SKAction flyupCoinsScore = SKAction.MoveTo (coinScoreLocation, 0.25);
			flyupCoinsScore.TimingMode = SKActionTimingMode.EaseInEaseOut;

			SKAction flyupTotal = SKAction.MoveTo (totalLocation, 0.25);
			flyupTotal.TimingMode = SKActionTimingMode.EaseInEaseOut;

			SKAction flyupTotalScore = SKAction.MoveTo (totalScoreLocation, 0.25);
			flyupTotalScore.TimingMode = SKActionTimingMode.EaseInEaseOut;

			int bananasCollected = gameStateDelegate.BananasCollected;
			int coinsCollected = gameStateDelegate.CoinsCollected;
			int totalCollected = bananasCollected + (coinsCollected * 100);

			SKAction countUpBananas = SKAction.CustomActionWithDuration (bananasCollected / 100f, ((node, elapsedTime) => {
				if (bananasCollected > 0) {
					SKLabelNode label = (SKLabelNode)node;
					nint total = (nint)(elapsedTime / (bananasCollected / 100.0f) * bananasCollected);
					label.Text = total.ToString ();
						
					if (total % 10 == 0)
						GameSimulation.Sim.PlaySound ("deposit.caf");
				}
			}));

			SKAction countUpCoins = SKAction.CustomActionWithDuration (coinsCollected / 100f, ((node, elapsedTime) => {
				if (coinsCollected > 0) {
					SKLabelNode label = (SKLabelNode)node;
					nint total = (nint)((elapsedTime / (coinsCollected / 100.0f)) * coinsCollected);
					label.Text = total.ToString ();

					if (total % 10 == 0)
						GameSimulation.Sim.PlaySound ("deposit.caf");
				}
			}));

			SKAction countUpTotal = SKAction.CustomActionWithDuration (totalCollected / 500.0f, ((node, elapsedTime) => {
				if (totalCollected > 0) {
					SKLabelNode label = (SKLabelNode)node;
					nint total = (nint)((elapsedTime / (totalCollected / 500.0f)) * totalCollected);
					label.Text = total.ToString ();

					if (total % 25 == 0)
						GameSimulation.Sim.PlaySound ("deposit.caf");
				}
			}));

			RunAction (flyup, () => {
				bananaText.RunAction (flyupBananas);
				bananaScore.RunAction (flyupBananasScore, () => {
					bananaScore.RunAction (countUpBananas, () => {
						bananaScore.Text = bananasCollected.ToString ();
						coinText.RunAction (flyupCoins);
						coinScore.RunAction (flyupCoinsScore, () => {
							coinScore.RunAction (countUpCoins, () => {
								coinScore.Text = coinsCollected.ToString ();
								totalText.RunAction (flyupTotal);
								totalScore.RunAction (flyupTotalScore, () => {
									totalScore.RunAction (countUpTotal, () => {
										totalScore.Text = totalCollected.ToString ();
									});
								});
							});
						});
					});
				});
			});
		}