Beispiel #1
0
        public async void loadHater(UIImage hater)
        {
//			if (GameObj.finalImage != null) {
//				await System.Threading.Tasks.Task.Delay (2000);
            //RemoveAllChildren ();

            if (currentSelected == 1)
            {
                GameObj.finalImage = hater;
                _image1            = hater;
                _img1.RemoveFromParent();
                _img1          = new SKSpriteNode(SKTexture.FromImage(hater));        //Frage (xy.hater));//(UIColor.DarkGray,new CGSize(200f,200f));
                _img1.Size     = new CGSize(100f, 100f);
                _img1.Position = new CGPoint(52, Size.Height / 1.3f);

                _pushPin.RemoveFromParent();
                movePin(_img1.Position);
//				_img2.Position = new CGPoint (Size.Width / 2, Size.Height / 1.3f);

                AddChild(_img1);
                AddChild(_pushPin);
            }
            else if (currentSelected == 2)
            {
                _img2.RemoveFromParent();
                _img2          = new SKSpriteNode(SKTexture.FromImage(hater));        //Frage (xy.hater));//(UIColor.DarkGray,new CGSize(200f,200f));
                _img2.Size     = new CGSize(100f, 100f);
                _img2.Position = new CGPoint(Size.Width / 2, Size.Height / 1.3f);


                AddChild(_img2);
                _image2            = hater;
                GameObj.finalImage = hater;

                _pushPin.RemoveFromParent();
                movePin(_img2.Position);
                AddChild(_pushPin);
            }
            else if (currentSelected == 3)
            {
                _img3.RemoveFromParent();
                _img3      = new SKSpriteNode(SKTexture.FromImage(hater));            //Frage (xy.hater));//(UIColor.DarkGray,new CGSize(200f,200f));
                _img3.Size = new CGSize(100f, 100f);

                _img3.Position = new CGPoint(Size.Width - 52, Size.Height / 1.3f);


                AddChild(_img3);
                _image3            = hater;
                GameObj.finalImage = hater;


                _pushPin.RemoveFromParent();
                movePin(_img3.Position);
                AddChild(_pushPin);
            }
        }
Beispiel #2
0
 public void FinishActionPlacement()
 {
     if (_check != null)
     {
         _check.RemoveFromParent();
         _check = null;
     }
 }
 public void Action(SKScene sceen, CGPoint location)
 {
     node.Position = location;
     sceen.AddChild(node);
     // 繰り返しの場合
     //SKAction* forever = [SKAction repeatActionForever: walk];
     //[walker runAction:forever];
     node.RunAction(action, () =>
     {
         node.RemoveFromParent();
     });
 }
Beispiel #4
0
        /// <summary>
        /// Подсвечивание выбранного камешка заменой текстуры в спрайте
        /// </summary>
        /// <param name="gem">Камешек на подстветку.</param>
        private void ShowSelectionIndicator(Gem gem)
        {
            // Открепляем спрайт от родителя, если он есть
            if (selectedSprite.Parent != null)
            {
                selectedSprite.RemoveFromParent();
            }

            SKSpriteNode sprite  = gem.Sprite;
            SKTexture    texture = SKTexture.FromImageNamed(gem.GetSelectedSpriteName());

            selectedSprite.Size = new CGSize(gemCellWidth, gemCellHeight);
            selectedSprite.RunAction(SKAction.SetTexture(texture));

            // "Подсветка" добавляется в качестве потомка к основному спрайту камешка
            sprite.AddChild(selectedSprite);
            selectedSprite.Alpha = 1.0f;
        }
Beispiel #5
0
        public void FinishScanAction()
        {
            if (_scanText1 != null)
            {
                _scanText1.RemoveFromParent();
                _scanText1 = null;
            }
            if (_scanText2 != null)
            {
                _scanText2.RemoveFromParent();
                _scanText2 = null;
            }
            if (_phone != null)
            {
                _phone.RemoveAllActions();
                _phone.RemoveFromParent();
                _phone = null;
            }

            ScanActionShowing  = false;
            ScanActionFinished = true;
        }
Beispiel #6
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            // Called when a touch begins

            // control player motion
            base.TouchesBegan(touches, evt);
            var touch       = (UITouch)touches.AnyObject;
            var touchedNode = GetNodeAtPoint(touch.LocationInNode(this));


            Console.WriteLine(touch.LocationInNode(this));
            Console.WriteLine(gameTitle.Position);
            Console.WriteLine(touchedNode);

            //starts game on title tap
            if (touchedNode.Name == "stumblingMan")
            {
                Console.WriteLine("it worked");
                AddChild(gameSong);
                startScreen.RemoveFromParent();
                gameTitle.RemoveFromParent();
                AddChild(playerObject);
                AddChild(pauseButton);

                startGame();
            }
            else if (touchedNode == helpButton)
            {
                if (tappedHelp == false)
                {
                    tappedHelp = true;
                    AddChild(instructions);
                }
                else
                {
                    tappedHelp = false;
                    instructions.RemoveFromParent();
                }
            }
            else if (touchedNode.Name == "gameOver")
            {
                obstacle.Position  = new CGPoint(Frame.Width / 2, Frame.Bottom + obhalf + 5);
                enemy.Position     = new CGPoint(Frame.Width / 2, Frame.Bottom + obhalf + 5);
                obstacle1.Position = new CGPoint(obstacle1.Frame.X + obstacle1.Frame.Width / 2, Frame.Bottom + obhalf + 1);
                obstacle2.Position = new CGPoint(obstacle2.Frame.X + obstacle2.Frame.Width / 2, Frame.Bottom + obhalf + 1);
                obstacle4.Position = new CGPoint(obstacle4.Frame.X + obstacle4.Frame.Width / 2, Frame.Bottom + obhalf + 1);

                playerObject.Paused = true;
                playerObject.RemoveAllActions();
                speed = 0;
                endGame.RemoveFromParent();
                gameSong.RunAction(SKAction.CreatePlay());
                startGame();
            }
            else if (touchedNode == pauseButton)
            {
                gamePause();
            }

            else if (!gameended)
            {
                playerMove(touch);
            }

            void gamePause()
            {
                if (pauseTouched == false)
                {
                    Console.WriteLine("UNSstartpause");

                    // all obstacles must unsubscribe at the begining of a pause
                    if (inprogress)
                    {
                        timer.Elapsed  -= sendobstacle;
                        timer1.Elapsed -= sendobstacle1;
                        timer2.Elapsed -= sendobstacle2;
                        timer3.Elapsed -= sendobstacle3;
                        timer4.Elapsed -= sendobstacle4;
                    }

                    pauseTouched = true;
                    AddChild(pauseOverlay);
                    AddChild(highScores);

                    for (int i = 0; i < 10; i++)
                    {
                        if (i >= 1)
                        {
                            scorelist[i].Text     = String.Format("Score: {0}", scores[i]);
                            scorelist[i].Position = new CGPoint(Frame.Width / 2, scorelist[i - 1].Position.Y - (scorelist[i - 1].Frame.Height / 2) - 42);
                        }
                        else
                        {
                            scorelist[i].Text     = String.Format("Score: {0}", scores[i]);
                            scorelist[i].Position = new CGPoint(Frame.Width / 2, highScores.Position.Y - (highScores.Frame.Height / 2) - 42);
                        }
                        AddChild(scorelist[i]);
                    }
                    Scene.Paused = true;
                }
                else
                {
                    Console.WriteLine("SUBendpause");

                    //all obstacle timers must subscribe at the end of a pause
                    if (inprogress)
                    {
                        timer.Elapsed  += sendobstacle;
                        timer1.Elapsed += sendobstacle1;
                        timer2.Elapsed += sendobstacle2;
                        timer3.Elapsed += sendobstacle3;
                        timer4.Elapsed += sendobstacle4;
                    }

                    pauseOverlay.RemoveFromParent();
                    highScores.RemoveFromParent();
                    for (int i = 0; i < 10; i++)
                    {
                        scorelist[i].RemoveFromParent();
                    }
                    pauseTouched = false;
                    Scene.Paused = false;
                }
            }

            // detects left and right screen taps, moves player accordingly
            void playerMove(UITouch location)
            {
                if (touch.LocationInNode(this).X >= playerObject.Frame.Right)
                {
                    if (DIR)
                    {
                        Console.WriteLine("clickright + moveright" + speed);
                        playerObject.RunAction(SKAction.RepeatActionForever(SKAction.MoveBy(difficulty, 0, 2.0f)));
                        speed = speed + difficulty;
                    }
                    else
                    {
                        Console.WriteLine("clickright + moveleft" + speed);
                        playerObject.RunAction(SKAction.RepeatActionForever(SKAction.MoveBy(difficulty - speed, 0, 2.0f)));
                        speed = difficulty;
                        DIR   = true;
                    }
                }
                if (touch.LocationInNode(this).X < playerObject.Frame.Left)
                {
                    if (!DIR)
                    {
                        Console.WriteLine("clickleft + moveleft" + speed);
                        playerObject.RunAction(SKAction.RepeatActionForever(SKAction.MoveBy(-difficulty, 0, 2.0f)));
                        speed = speed - difficulty;
                    }
                    else
                    {
                        Console.WriteLine("clickleft + moveleft" + speed);
                        playerObject.RunAction(SKAction.RepeatActionForever(SKAction.MoveBy(-difficulty - speed, 0, 2.0f)));
                        speed = -difficulty;
                        DIR   = false;
                    }
                }
            }

            void startGame()
            {
                //setting the game is in progress to true
                playerObject.PhysicsBody.AllowsRotation = false;
                obstacle.PhysicsBody.AllowsRotation     = false;
                enemy.PhysicsBody.AllowsRotation        = false;
                obstacle1.PhysicsBody.AllowsRotation    = false;
                obstacle2.PhysicsBody.AllowsRotation    = false;
                obstacle4.PhysicsBody.AllowsRotation    = false;

                inprogress          = true;
                gameended           = false;
                playerObject.Paused = false;

                #region for timers

                timer          = new System.Timers.Timer();
                timer.Interval = 1000;
                Console.WriteLine("SUB");
                timer.Elapsed  += sendobstacle;
                timer.AutoReset = true;
                timer.Enabled   = true;

                timer1          = new System.Timers.Timer();
                timer1.Interval = 2000;
                Console.WriteLine("SUB");
                timer1.Elapsed  += sendobstacle1;
                timer1.AutoReset = true;
                timer1.Enabled   = true;

                timer2          = new System.Timers.Timer();
                timer2.Interval = 4000;
                Console.WriteLine("SUB");
                timer2.Elapsed  += sendobstacle2;
                timer2.AutoReset = true;
                timer2.Enabled   = true;

                timer3          = new System.Timers.Timer();
                timer3.Interval = 1150;
                Console.WriteLine("SUB");
                timer3.Elapsed  += sendobstacle3;
                timer3.AutoReset = true;
                timer3.Enabled   = true;

                timer4          = new System.Timers.Timer();
                timer4.Interval = 1250;
                Console.WriteLine("SUB");
                timer4.Elapsed  += sendobstacle4;
                timer4.AutoReset = true;
                timer4.Enabled   = true;

                #endregion


                startScreen.RunAction(SKAction.CreatePause());
                Scroll(sidewalk1);
                Scroll(sidewalk2);
                Scroll(sidewalk3);

                playerObject.XScale   = 2.0f;
                playerObject.YScale   = 2.0f;
                playerObject.Position = new CGPoint(Frame.Width / 2, Frame.Height / 4);
                Scroll(road1);
                Scroll(road2);
                Scroll(road3);
                Scroll(road4);
                Scroll(road5);
                Scroll(road6);

                Scroll(building1);
                Scroll(building2);
                Scroll(building3);
                Scroll(building4);
                Scroll(building5);
                Scroll(building6);
                Scroll(building7);
                Scroll(building8);
                Scroll(building9);
                Scroll(building10);
                Scroll(building11);
                Scroll(building12);
                Scroll(building13);
                Scroll(building14);


                animatePlayer();

                playerObject.RunAction(SKAction.RepeatActionForever(SKAction.MoveBy(0.001f, 0, 2.0f)));
                DIR = true;
            }
        }
Beispiel #7
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);
                }
            }
        }