Exemplo n.º 1
0
        public void ProcessControllerAction(TVControllerAction item)
        {
            if (map.IsGameOver && item == TVControllerAction.Flag)
                item = TVControllerAction.Tap;

            switch (item) {
            case TVControllerAction.Left:
                CurrentX--;
                if (CurrentX < 0)
                    CurrentX = 0;
                break;
            case TVControllerAction.Right:
                CurrentX++;
                if (CurrentX >= map.MapColumns)
                    CurrentX = map.MapColumns - 1;
                break;
            case TVControllerAction.Up:
                CurrentY--;
                if (CurrentY < 0)
                    CurrentY = 0;
                break;
            case TVControllerAction.Down:
                CurrentY++;
                if (CurrentY >= map.MapRows)
                    CurrentY = map.MapRows - 1;
                break;
            case TVControllerAction.Flag:
                var flagResults = map.FlagSpot (CurrentX, CurrentY);

                flagResults.AffectedSpots.ForEach (RedisplaySpot);

                if (flagResults.GameReset) {
                    DisplayMap ();
                }

                MoveCurrentPositionToTop ();
                UpdateLevelDisplay ();

                break;
            case TVControllerAction.Tap:
                var actionDetails = map.ClickOnSpot (CurrentX, CurrentY);

                actionDetails.AffectedSpots.ForEach (RedisplaySpot);

                if (actionDetails.GameOver) {
                    RedisplaySpot (new Spot (CurrentX, CurrentY));

                    // Blow up all the spots
                    MakeExplosionAtPoint (new Spot (CurrentX, CurrentY));

                    var allMines = map.GetAllMinesNear (new Spot (CurrentX, CurrentY));
                    allMines.ForEach (MakeExplosionAtPoint);

                    gameOverNode = new SKLabelNode (displayFontGameOver) {
                        Text = "Game Over",
                            Position = new CGPoint(Scene.Frame.GetMidX(), Scene.Frame. GetMidY()),
                        FontColor = UIColor.Blue,
                        FontSize = displayFontSizeGameOver,
                        VerticalAlignmentMode = SKLabelVerticalAlignmentMode.Center,
                        HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center
                    };
                        float miniBuffer = 3f;
                    gameOverNode2 = new SKLabelNode (displayFontGameOver) {
                        Text = "Game Over",
                            Position = new CGPoint(gameOverNode.Position.X + miniBuffer, gameOverNode.Position.Y - miniBuffer),
                            FontColor = UIColor.FromRGBA(0.0f, 0f, 0f, 0.25f),
                        FontSize = displayFontSizeGameOver,
                        VerticalAlignmentMode = SKLabelVerticalAlignmentMode.Center,
                        HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center
                    };

                    AddChild (gameOverNode2);
                    AddChild (gameOverNode);

                    gameOverNode.RunAction (SKAction.RotateByAngle (
                        (nfloat)(Math.PI / 180) * 720,
                        1.0));
                    gameOverNode2.RunAction (SKAction.RotateByAngle (
                        (nfloat)(Math.PI / 180) * 720,
                        1.0));

                    currentSpot.RunAction(SKAction.RemoveFromParent());
                    currentSpot = null;
                }

                if (actionDetails.GameReset) {
                    DisplayMap ();
                }

                MoveCurrentPositionToTop ();
                UpdateLevelDisplay ();

                break;
            }

            UpdateCurrentSpot();

            currentSpot.RunAction (SKAction.MoveTo (
                GetCellPosition (CurrentX, CurrentY), 0.25
            ));
        }
Exemplo n.º 2
0
 public void FireAction(TVControllerAction item)
 {
     Console.WriteLine ("Remote Control Action: " + item);
     scene.ProcessControllerAction (item);
 }