public void Finish()
        {
            currentScore.RunAction(SKAction.ScaleTo(0, 0.4), () =>
            {
                currentScore.Hidden = true;
            });

            gameBG.RunAction(SKAction.ScaleTo(0, 0.4), () =>
            {
                gameBG.Hidden   = true;
                gameLogo.Hidden = false;

                gameLogo.RunAction(SKAction.MoveTo(
                                       new CGPoint(
                                           x: Frame.GetMidX(),
                                           y: Frame.GetMidY() + (Frame.Size.Height / 2f) - 200),
                                       0.5), () =>
                {
                    playButton.Hidden = false;
                    playButton.RunAction(SKAction.ScaleTo(1, 0.3));

                    bestScore.RunAction(SKAction.MoveTo(
                                            new CGPoint(
                                                x: gameLogo.Position.X,
                                                y: gameLogo.Position.Y - 50),
                                            0.3));
                });
            });
        }
        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();
        }
        // Show the congratulation screen.
        void ShowCongratulation()
        {
            var gNodes = gameNodes.Value;

            gNodes.Camera.UsesOrthographicProjection = false;

            sceneInterface.Scene.Background.Contents = UIColor.Black;

            gNodes.Confetti.Hidden = false;
            particleRemovalTimer?.Invalidate();
            particleRemovalTimer = NSTimer.CreateScheduledTimer(30, RemoveParticles);

            gNodes.CongratulationsLabel.RemoveFromParent();
            gNodes.CongratulationsLabel.Position = new CGPoint(ContentFrame.Width / 2, ContentFrame.Height / 2);
            gNodes.CongratulationsLabel.XScale   = 0;
            gNodes.CongratulationsLabel.YScale   = 0;
            gNodes.CongratulationsLabel.Alpha    = 0;

            gNodes.CongratulationsLabel.RunAction(SKAction.Group(new SKAction [] {
                SKAction.FadeInWithDuration(0.25),
                SKAction.Sequence(new SKAction [] {
                    SKAction.ScaleTo(0.7f, 0.25),
                    SKAction.ScaleTo(0.8f, 0.2)
                })
            }));

            sceneInterface.OverlayScene.AddChild(gNodes.CongratulationsLabel);
        }
        void ShowEndScreen()
        {
            gameIsComplete = true;

            // Add confettis
            SCNMatrix4 particlePosition = SCNMatrix4.CreateTranslation(0f, 8f, 0f);

            GameView.Scene.AddParticleSystem(confetti, particlePosition);

            // Congratulation title
            SKSpriteNode congrat = SKSpriteNode.FromImageNamed("Images/congratulations.png");

            congrat.Position = new CGPoint(GameView.Bounds.Width / 2, GameView.Bounds.Height / 2);
            SKScene overlay = GameView.OverlayScene;

            congrat.XScale = congrat.YScale = 0;
            congrat.Alpha  = 0;
            congrat.RunAction(SKAction.Group(new [] {
                SKAction.FadeInWithDuration(0.25),
                SKAction.Sequence(new [] {
                    SKAction.ScaleTo(.55f, 0.25),
                    SKAction.ScaleTo(.3f, 0.1),
                })
            }));

            // Panda Image
            SKSpriteNode congratPanda = SKSpriteNode.FromImageNamed("Images/congratulations_pandaMax.png");

            congratPanda.Position    = new CGPoint(GameView.Bounds.Width / 2f, GameView.Bounds.Height / 2f - 90f);
            congratPanda.AnchorPoint = new CGPoint(.5f, 0f);
            congratPanda.XScale      = congratPanda.YScale = 0f;
            congratPanda.Alpha       = 0;

            congratPanda.RunAction(SKAction.Sequence(new [] {
                SKAction.WaitForDuration(.5f),
                SKAction.Sequence(new [] {
                    SKAction.ScaleTo(.5f, 0.25),
                    SKAction.ScaleTo(.4f, 0.1)
                })
            }));

            overlay.AddChild(congratPanda);
            overlay.AddChild(congrat);

            // Stop music
            GameView.Scene.RootNode.RemoveAllAudioPlayers();

            // Play the congrat sound.
            GameView.Scene.RootNode.AddAudioPlayer(SCNAudioPlayer.FromSource(victoryMusic));

            // Animate the camera forever
            DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, 1 * NanoSecondsPerSeond), () => {
                cameraYHandle.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0f, -1f, 0f, 3.0)));
                cameraXHandle.RunAction(SCNAction.RotateTo(-(float)Math.PI / 4f, 0f, 0f, 5.0));
            });
        }
Exemple #5
0
        // Add Heartbeat Animation to parent node
        private void AddHeartbeat(double tempWait)
        {
            double   wait     = tempWait - 1;
            SKAction sleep    = SKAction.WaitForDuration(wait);
            SKAction sizeUp   = SKAction.ScaleTo(1.2f, 0.1f);
            SKAction sizeDown = SKAction.ScaleTo(0.9f, 0.1f);
            var      sequence = SKAction.Sequence(sleep, sizeUp, sizeDown);

            RunAction(SKAction.RepeatActionForever(sequence));
        }
Exemple #6
0
        /// <summary>
        /// Добававляем его спрайт на нод для камешка, с расчетом размера и позиции
        /// </summary>
        /// <param name="gem">Камешек которому добавляется спрайт.</param>
        private void AttachSpriteTo(Gem gem)
        {
            SKSpriteNode sprite;

            // Если разрушитель - открепляем старый спрайт на этом месте от слоя камешков
            if ((gem.IsALineDestroyer || gem.IsABomb) && Level.GemArray[gem.Row, gem.Column] != null)
            {
                sprite = Level.GemArray[gem.Row, gem.Column].Sprite;

                if (sprite != null && sprite.Parent != null)
                {
                    sprite.RemoveFromParent();
                }
            }

            // подготовка спрайта
            sprite          = SKSpriteNode.FromImageNamed(gem.GetSpriteName());
            sprite.Size     = new CGSize(gemCellWidth, gemCellHeight);
            sprite.Position = GetPositionFromRowAndColumn(gem.Row, gem.Column);
            gemLayer.AddChild(sprite);

            gem.Sprite = sprite;

            // подготовка к анимации
            sprite.Alpha  = 0;
            sprite.XScale = 0.5f;
            sprite.YScale = 0.5f;

            // Анимация появления камешка
            sprite.RunAction(
                SKAction.Sequence(
                    SKAction.WaitForDuration(0.25, 0.5),
                    SKAction.Group(
                        SKAction.FadeInWithDuration(0.25),
                        SKAction.ScaleTo(1.0f, 0.25)
                        )
                    ));

            // если разрушитель - заменяем в массиве камешек
            if (gem.IsALineDestroyer || gem.IsABomb)
            {
                Level.GemArray[gem.Row, gem.Column] = gem;
            }
        }
Exemple #7
0
        public void DidBeginContact(SKPhysicsContact contact)
        {
            inprogress = false;

            Console.WriteLine("We Collided!");
            gameended = true;
            void gameOver()
            {
                var textures = Enumerable.Range(1, 4).Select(
                    (i) => SKTexture.FromImageNamed(String.Format("Death-{0}", i))).ToArray();

                deathSpin = SKAction.RepeatAction(SKAction.AnimateWithTextures(textures, .1), 4);
                var shrink = SKAction.ScaleTo(0f, 2f);
                var death  = SKAction.Sequence(deathSpin, shrink);

                playerObject.RunAction(death);

                var playDeath = SKAction.PlaySoundFileNamed("playerDeath", false);

                playerDied.RunAction(playDeath);
                gameSong.RunAction(SKAction.CreateStop());
            }

            void animateOver()
            {
                var grow    = SKAction.ScaleTo(2.0f, 1.5);
                var shrink  = SKAction.ScaleTo(.5f, 1.5);
                var animate = SKAction.RepeatActionForever(SKAction.Sequence(grow, shrink));

                endGame.RunAction(animate);
            }

            playerObject.RemoveAllActions();
            obstacle.RemoveAllActions();
            sidewalk1.RemoveAllActions();
            sidewalk2.RemoveAllActions();
            sidewalk3.RemoveAllActions();
            building1.RemoveAllActions();
            building2.RemoveAllActions();
            building3.RemoveAllActions();
            building4.RemoveAllActions();
            building5.RemoveAllActions();
            building6.RemoveAllActions();
            building7.RemoveAllActions();
            building8.RemoveAllActions();
            building9.RemoveAllActions();
            building10.RemoveAllActions();
            building11.RemoveAllActions();
            building12.RemoveAllActions();
            building13.RemoveAllActions();
            building14.RemoveAllActions();
            road1.RemoveAllActions();
            road2.RemoveAllActions();
            road3.RemoveAllActions();
            road4.RemoveAllActions();
            road5.RemoveAllActions();
            road6.RemoveAllActions();
            obstacle1.RemoveAllActions();
            obstacle2.RemoveAllActions();
            enemy.RemoveAllActions();
            obstacle4.RemoveAllActions();

            scores.Add(score);
            scores.Sort((a, b) => - 1 * a.CompareTo(b)); 


 var sl = scores.Count; 
                 if (sl >= 10)
            {
                
                  {
                    
 sl = 10; 

                }
            }
            

 var plist = NSUserDefaults.StandardUserDefaults; 
                       for (int i = 0; i < sl; i++)

            {
                
                   {
                    
 Console.WriteLine(scores[i]); 
 plist.SetInt(scores[i], String.Format("Score-{0}", i)); 


                }
            }

            score = 0;

            //unsubscribe obstacle objects at the end of the round
            timer.Elapsed  -= sendobstacle;
            timer1.Elapsed -= sendobstacle1;
            timer2.Elapsed -= sendobstacle2;
            timer3.Elapsed -= sendobstacle3;
            timer4.Elapsed -= sendobstacle4;

            gameOver();

            AddChild(endGame);

            animateOver();
        }
Exemple #8
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);
                }
            }
        }
Exemple #9
0
        public void ShowEndScreen()
        {
            // Congratulation title
            var congratulationsNode = SKSpriteNode.FromImageNamed("Overlays/congratulations.png");

            // Max image
            var characterNode = SKSpriteNode.FromImageNamed("Overlays/congratulations_pandaMax.png");

            characterNode.Position    = new CGPoint(0f, -220f);
            characterNode.AnchorPoint = new CGPoint(0.5f, 0f);

            this.congratulationsGroupNode = new SKNode();
            this.congratulationsGroupNode.AddChild(characterNode);
            this.congratulationsGroupNode.AddChild(congratulationsNode);
            this.AddChild(this.congratulationsGroupNode);

            // Layout the overlay
            this.Layout2DOverlay();

            // Animate
            congratulationsNode.Alpha  = 0f;
            congratulationsNode.XScale = 0f;
            congratulationsNode.YScale = 0f;
            congratulationsNode.RunAction(SKAction.Group(new SKAction[] { SKAction.FadeInWithDuration(0.25),
                                                                          SKAction.Sequence(new SKAction[] { SKAction.ScaleTo(1.22f, 0.25),
                                                                                                             SKAction.ScaleTo(1f, 0.1) }) }));

            characterNode.Alpha  = 0f;
            characterNode.XScale = 0f;
            characterNode.YScale = 0f;
            characterNode.RunAction(SKAction.Sequence(new SKAction[] { SKAction.WaitForDuration(0.5),
                                                                       SKAction.Group(new SKAction[] { SKAction.FadeInWithDuration(0.5),
                                                                                                       SKAction.Sequence(new SKAction[] { SKAction.ScaleTo(1.22f, 0.25),
                                                                                                                                          SKAction.ScaleTo(1f, 0.1) }) }) }));
        }