Пример #1
0
 // Use this for initialization
 void Awake()
 {
     if (_instance != null) {
         Debug.LogError ("Multiple Game Instances Exist.");
     } else {
         _instance = this;
     }
 }
Пример #2
0
        public void Create(List<UiElement> components, List<UiElement> modalComponents)
        {
            components.Clear();
            modalComponents.Clear();

            var panel = new GamePanel(Consts.SCREEN_WIDTH, Consts.STATUS_BAR_HEIGHT + 1);
            components.Add(panel);

            var textBox = new GameTextBox(new PointF(20, 20)) { Text = "hello, editor!" };
            modalComponents.Add(textBox);
            var checkBox = new GameCheckBox(new PointF(20, 27)) {Caption = "Typical CheckBox"};
            modalComponents.Add(checkBox);

            var newMapBtn = new GameButton(new PointF(5, 1.5f), "New Map");
            newMapBtn.OnClick += () =>
            {
                LayoutManager.GetManager().HasFocus = true;
                textBox.HasFocus = true;
                LayoutManager.GetManager().IsShowingModal = true;
            };
            components.Add(newMapBtn);

            var btnPos = newMapBtn.Position;
            btnPos.X += Consts.BUTTON_WIDTH + 3;
            var loadMapBtn = new GameButton(btnPos, "Load Map");
            loadMapBtn.OnClick += () =>
            {

                LayoutManager.GetManager().IsShowingModal = true;
            };
            components.Add(loadMapBtn);

            btnPos.X += Consts.BUTTON_WIDTH + 3;
            var saveMapBtn = new GameButton(btnPos, "SaveMap") { Enabled = false };
            saveMapBtn.OnClick += () =>
            {
                LayoutManager.GetManager().IsShowingModal = true;
            };
            components.Add(saveMapBtn);

            btnPos.X = Consts.SCREEN_WIDTH - Consts.BUTTON_WIDTH - 1;
            var backToMenuBtn = new GameButton(btnPos, "Return");
            backToMenuBtn.OnClick += () =>
            {
                LayoutManager.GetManager().ScreenType = ScreenType.MainMenu;
                LayoutManager.GetManager().SetComponents(ScreenType.MainMenu);
            };
            components.Add(backToMenuBtn);
        }
 public GameFramework(IGame game, int gameUpdatePeriod)
 {
     this.IsExceptionRaised = false;
     this.game = game;
     this.lastFrameHeight = this.lastFrameWidth = 0;
     this.Initialized = false;
     this.IsFrameworkRunning = false;
     this.FPSCounter = 0;
     this.gameUpdatePeriod = gameUpdatePeriod;
     this.PreviousFPSCounterValue = FPSTarget;
     this.FPSLastUpdate = 0;
     this.gamePanel = null;
     this.IsGameRunning = false;
     this.IsRendererRunning = true;
 }
        public GameStateUpdateWorker(GamePanel gamePanel, GameController gameController) {
            this.WorkerReportsProgress = true;
            this.DoWork += doBackgroundWork;
            this.ProgressChanged += progressChanged;
            this.WorkerSupportsCancellation = true;

            this.gamePanel = gamePanel;
            this.gameController = gameController;

            // Spawnpoints
            int posXSpawn = gamePanel.Width + 100;
            spawnPoints = new Point[3];
            spawnPoints[0] = new Point(posXSpawn, 100);
            spawnPoints[1] = new Point(posXSpawn, 170);
            spawnPoints[2] = new Point(posXSpawn, 240);

            MAX_TORPEDO_Y_POS = gamePanel.Height / 100 * 20;
        }
Пример #5
0
        private void GamePanel_MouseDown(object sender, MouseEventArgs e)
        {
            IsGameStarted = true;
            if (!EndOfGame)
            {
                string EndResult = "";
                Point  e1        = new Point(e.X, e.Y);

                if (PvPButton.Checked)
                {
                    int playerIndex = Playerbox.SelectedIndex + 1;

                    Graphics graphics = GamePanel.CreateGraphics();

                    Node node = new Node();
                    int[,] nodeBoard = new int[3, 3];

                    if (Turn % 2 != 0)
                    {
                        drawBoard.DrawFigure(graphics, e1, playerIndex, ref Turn);

                        nodeBoard  = Mechanics.BuildBoard(sectors);                        // Turns the sectors into a board
                        node.Board = nodeBoard;

                        EndOfGame = Mechanics.CheckGameStatusPvAI_PvP(node, Turn, playerIndex, ref EndResult, PvPButton.Checked);                         // Checks if the node has a value. If it does - there is a winner
                    }
                    else
                    {
                        int notPlayer = playerIndex == 1 ? 2 : 1;

                        drawBoard.DrawFigure(graphics, e1, notPlayer, ref Turn);

                        nodeBoard  = Mechanics.BuildBoard(sectors);
                        node.Board = nodeBoard;

                        EndOfGame = Mechanics.CheckGameStatusPvAI_PvP(node, Turn, notPlayer, ref EndResult, PvPButton.Checked);
                    }

                    node.Value = Mechanics.Winner(nodeBoard);         //Looks for a winner

                    Turns.Text = Turn.ToString();                     // Increases turns

                    currentNode = node;
                    graphics.Dispose();
                }
                else                                                    // PvAIButton.Checked
                {
                    int      playerIndex = Playerbox.SelectedIndex + 1; // Gets player's index X/O
                    Graphics graphics    = GamePanel.CreateGraphics();

                    int SectorEdit = 0;

                    if (frezeGame.Active && frezeGame.nextPlayer == "Player" || !frezeGame.Active)
                    {
                        SectorEdit = drawBoard.DrawFigure(graphics, e1, playerIndex, ref Turn);
                    }

                    int[,] nodeBoard = Mechanics.BuildBoard(sectors);

                    if (SectorEdit != -1 || frezeGame.nextPlayer == "AI")                             //AI clicks in a fake spot
                    {
                        Node node = new Node();
                        node.Board            = nodeBoard;
                        node.LastEditedSector = SectorEdit;

                        if (!frezeGame.Active)
                        {
                            Mechanics.GrowTree(node, playerIndex, playerIndex);
                            currentNode = node;
                            EndOfGame   = Mechanics.CheckGameStatusPvAI_PvP(node, Turn, playerIndex, ref EndResult, PvPButton.Checked); // Checks game for a winner
                        }
                        else if (frezeGame.Active && frezeGame.nextPlayer == "Player")                                                  // If we have a turn left and it is our turn
                        {
                            Mechanics.GrowTree(node, playerIndex, playerIndex);
                            currentNode = node;
                            EndOfGame   = Mechanics.CheckGameStatusPvAI_PvP(node, Turn, playerIndex, ref EndResult, PvPButton.Checked);

                            frezeGame.nextPlayer = "NotThePlayer";                  // Will make clicking the board by the player impossible untill the AI has been unFrozen;
                            frezeGame.hasPlayed  = true;                            // Avoids crashing the code by clicking the button without having played
                        }

                        if (!EndOfGame && !frezeGame.Active ||                                 // Won't continue if game has ended
                            !EndOfGame && frezeGame.nextPlayer == "AI")
                        {
                            // AI's turn \\
                            Node minNode = new Node();

                            if (frezeGame.Active)
                            {
                                minNode = currentNode.Children[0];
                            }
                            else
                            {
                                minNode = node.Children[0];
                            }

                            for (int i = 1; i < node.Children.Count; i++)
                            {
                                if (minNode.Value > node.Children[i].Value)
                                {
                                    minNode = node.Children[i];
                                }
                            }

                            Point e2 = new Point();
                            e2.X = sectors[minNode.LastEditedSector].X;
                            e2.Y = sectors[minNode.LastEditedSector].Y;                                     // Gets sector location for painting

                            drawBoard.DrawFigure(graphics, e2, playerIndex == 1 ? 2 : 1, ref Turn);         // Draws AI's choice.

                            EndOfGame = Mechanics.CheckGameStatusPvAI_PvP(minNode, Turn, playerIndex, ref EndResult, PvPButton.Checked);

                            currentNode = minNode;
                        }
                    }

                    graphics.Dispose();
                }

                // After the game has been played, if a result has ben aquired - draws it.
                if (EndOfGame && Turn != 10)
                {
                    Graphics graphics = GamePanel.CreateGraphics();

                    drawBoard.DrawEndResult(graphics, EndResult, sectors);                      //function string-draw

                    graphics.Dispose();
                }
            }
            else
            {
                MessageBox.Show("Game has ended. Please clear the field.");
            }
        }
Пример #6
0
        public void Initialize(int puzzleIndex, int puzzleSize, bool load)
        {
            m_PuzzleStart = DateTime.Now;
            m_PauseSeconds = 0;
            m_bVerifyHintPurchase = true;
            m_bVerifyMegaHintPurchase = true;
            m_iHintCount = 0;
            m_iMegaHintCount = 0;
            m_History = new List<Action>();

            // Create the puzzle
            m_iPuzzleIndex = puzzleIndex;
            m_Puzzle = new Puzzle(puzzleIndex, puzzleSize, 1);
            if( load )
                LoadPuzzle();

            // Initialize the UI
            int buttonPanelWidth = (int)(Constants.ButtonPanel_Width * Game.ScreenWidth);
            int helpPanelHeight = (int)(Constants.HelpPanel_Height * Game.ScreenHeight);
            m_HorizontalCluePanel = new HorizontalCluePanel(this, m_Puzzle.HorizontalClues);
            m_VerticalCluePanel = new VerticalCluePanel(this, m_Puzzle.VerticalClues, Game.ScreenWidth - m_HorizontalCluePanel.Rect.Width);
            m_GamePanel = new GamePanel(this, new Rectangle(buttonPanelWidth, helpPanelHeight, Game.ScreenWidth - (m_HorizontalCluePanel.Rect.Width + buttonPanelWidth), Game.ScreenHeight - (m_VerticalCluePanel.Rect.Height + helpPanelHeight)));
            m_HelpPanel = new HelpPanel(this, new Rectangle(buttonPanelWidth, 0, m_GamePanel.Rect.Width, m_GamePanel.Rect.Top));
            m_ButtonPanel = new ButtonPanel(this, new Rectangle(0, 0, buttonPanelWidth, m_VerticalCluePanel.Rect.Top));

            HappinessNetwork.VipDataArgs vip = NetworkManager.Net.VipData;
            m_ButtonPanel.SetHintCount(vip.Hints - m_iHintCount, vip.Hints);
            m_ButtonPanel.SetMegaHintCount(vip.MegaHints - m_iMegaHintCount, vip.MegaHints);
            m_ButtonPanel.SetUndoCount(m_History.Count, vip.UndoSize);
            m_ButtonPanel.SetCoins(NetworkManager.Net.HardCurrency);

            m_UIPanels = new List<UIPanel>();
            m_UIPanels.Add(m_GamePanel);
            m_UIPanels.Add(m_HorizontalCluePanel);
            m_UIPanels.Add(m_VerticalCluePanel);
            m_UIPanels.Add(m_HelpPanel);
            m_UIPanels.Add(m_ButtonPanel);

            // Init Icons
            InitIcons();

            int gamePanelCenterX = m_GamePanel.Rect.Left + (m_GamePanel.Rect.Width / 6);
            Vector2 clueArrow = new Vector2(m_HorizontalCluePanel.Rect.Left, m_HorizontalCluePanel.Rect.Top + (m_HorizontalCluePanel.ClueHeight >> 1));
            Rectangle bottomTutorialRect = new Rectangle(gamePanelCenterX + Game.Tutorial.ArrowHeight, m_GamePanel.Rect.Bottom + 10, m_GamePanel.Rect.Width - ((m_GamePanel.Rect.Width / 6) + (Game.Tutorial.ArrowHeight >> 1)), 0);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.GameStart, new Vector2(gamePanelCenterX, m_GamePanel.Rect.Bottom), Constants.ArrowUp,
                                                                               bottomTutorialRect, "The object of the game is to figure out which icon belongs in each cell of the puzzle grid area.\nThe puzzle is solved when all of the icons are in the correct places.",
                                                                               TutorialSystem.TutorialPiece.HorizontalClueArea, Rectangle.Empty, true);
            Rectangle clue1Area = new Rectangle(m_HorizontalCluePanel.Rect.Left, m_HorizontalCluePanel.Rect.Top, m_HorizontalCluePanel.Rect.Width, m_HorizontalCluePanel.ClueHeight);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClueArea, clueArrow, 0,
                bottomTutorialRect, "This area is for the horizontal clues.\nHorizontal clues give hints about the icons from left to right or right to left.\n\nTap this first Horizontal Clue.",
                TutorialSystem.TutorialPiece.SpanExplanation, clue1Area);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.SpanExplanation, clueArrow, 0,
                bottomTutorialRect, "The arrow across the top of the clue indicates that this is a span clue.\nA span clue describes a series of 3 neighboring columns. The span can go from left to right or right to left but the center column will always be inbetween the two outer columns.",
                TutorialSystem.TutorialPiece.ClueHelp, Rectangle.Empty, true);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.ClueHelp, new Vector2(m_HelpPanel.Rect.Left, m_HelpPanel.Rect.Bottom), Constants.ArrowDiagonalUpRight,
                bottomTutorialRect, "This area gives a brief description of the currently highlighted clue.\n\nSince this clue is a span type clue, it is showing that in a group of 3 columns {icon:Simpsons[2]} is on one edge of the group and {icon:Superheros[3]} is on the other edge.\nSince there is a NOT icon in the center of this span, in the center column can not have the {icon:Hubble[4]}.",
                TutorialSystem.TutorialPiece.SpanHelp1, Rectangle.Empty, true);

            Rectangle centerGridArea = new Rectangle(m_GamePanel.Rect.Left + m_GamePanel.CellWidth, m_GamePanel.Rect.Top + m_GamePanel.CellHeight, m_GamePanel.CellWidth, m_GamePanel.CellHeight);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.SpanHelp1, m_GamePanel.IconPosition(1, 1, 1), Constants.ArrowDiagonalUpRight,
                bottomTutorialRect, "This is a 3x3 puzzle so the center column of this span has to be the center column of this puzzle.\nWe can eliminate the {icon:Hubble[4]} from the center column.\n\nTap the center grid area.",
                TutorialSystem.TutorialPiece.EliminateRedNebula, centerGridArea);

            Rectangle centerBottomGridArea = new Rectangle(m_GamePanel.Rect.Left + m_GamePanel.CellWidth, m_GamePanel.Rect.Top + (m_GamePanel.CellHeight * 2), m_GamePanel.CellWidth, m_GamePanel.CellHeight);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.BartMan1, m_GamePanel.IconPosition(2, 1, 1), Constants.ArrowDown,
                bottomTutorialRect, "The {icon:Simpsons[2]} has to be on one of the edges of the column group so it can not be in the center column.\n\nTap the bottom grid area of the center column.",
                TutorialSystem.TutorialPiece.BartMan2, centerBottomGridArea);

            Rectangle centerTopGridArea = new Rectangle(m_GamePanel.Rect.Left + m_GamePanel.CellWidth, m_GamePanel.Rect.Top, m_GamePanel.CellWidth, m_GamePanel.CellHeight);
            Vector2 iconBotOffset = new Vector2(m_GamePanel.IconSize >> 1, 0);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.Hulk1, Vector2.Add(m_GamePanel.IconPosition(0, 1, 0), iconBotOffset), Constants.ArrowUp,
                bottomTutorialRect, "The {icon:Superheros[3]} has to be on one of the edges of the column group so it can not be in the center column.\n\nTap the top grid area of the center column.",
                TutorialSystem.TutorialPiece.Hulk2, centerTopGridArea);

            Vector2 clue2Position = new Vector2(m_HorizontalCluePanel.Rect.Left, m_HorizontalCluePanel.Rect.Top + (m_HorizontalCluePanel.ClueHeight) + (m_HorizontalCluePanel.ClueHeight >> 1));
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClue2a, clue2Position, 0,
                bottomTutorialRect, "We have done all we can right now with the first clue.\nLets move on to the next clue.\n\nTap the second horizontal clue.",
                TutorialSystem.TutorialPiece.HorizontalClue2b, new Rectangle(m_HorizontalCluePanel.Rect.Left, m_HorizontalCluePanel.Rect.Top + (m_HorizontalCluePanel.ClueHeight), m_HorizontalCluePanel.Rect.Width, m_HorizontalCluePanel.ClueHeight));

            Vector2 iconTopOffset = new Vector2(m_GamePanel.IconSize >> 1, -m_GamePanel.IconSize);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClue2b, Vector2.Add(m_GamePanel.IconPosition(1, 1, 2), iconTopOffset), Constants.ArrowDown,
                bottomTutorialRect, "This clue is also a span type clue with the {icon:Hubble[2]} in the center column, the {icon:Superheros[2]} on one edge and NOT the {icon:Hubble[3]} on the other edge.\nSince this is a 3x3 puzzle, we know the center of the span is the center column of the puzzle so we now know where the {icon:Hubble[2]} goes.\n\nTap the center grid area.",
                TutorialSystem.TutorialPiece.CrabNebula1, centerGridArea);

            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClue2c, Vector2.Add(m_GamePanel.IconPosition(0, 1, 2), iconTopOffset), Constants.ArrowDown, bottomTutorialRect,
                "We know that the {icon:Superheros[2]} has to be on one of the outer edges, so it cant be in the center column.\n\nTap the top grid area of the center column.", TutorialSystem.TutorialPiece.GreenLantern1, centerTopGridArea);

            Vector2 iconSideOffset = new Vector2(0, -(m_GamePanel.IconSize >> 1));
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClue2d, m_GamePanel.IconPosition(0, 1, 0), 0, bottomTutorialRect,
                "Notice that the {icon:Superheros[4]} is confirmed in the center column now. This is because it was the only posibility left after eliminating the {icon:Superheros[3]} and the {icon:Superheros[2]}.",
                TutorialSystem.TutorialPiece.HorizontalClue3a, Rectangle.Empty, true);

            Vector2 clueHeightOffset = new Vector2(0, m_HorizontalCluePanel.ClueHeight);
            Vector2 clue3Position = Vector2.Add(clue2Position, clueHeightOffset);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClue3a, clue3Position, 0, bottomTutorialRect, "There is nothing else we can do with this clue for now so lets move on to the next clue.\n\nTap the third horizontal clue.\n", TutorialSystem.TutorialPiece.HorizontalClue3b,
                new Rectangle(m_HorizontalCluePanel.Rect.Left, m_HorizontalCluePanel.Rect.Top + (m_HorizontalCluePanel.ClueHeight * 2), m_HorizontalCluePanel.Rect.Width, m_HorizontalCluePanel.ClueHeight));

            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClue3b, m_GamePanel.IconPosition(2, 1, 0), Constants.ArrowDiagonalUpRight, bottomTutorialRect,
                "This is another span type clue. Most of what it is telling us, we already know. It is however telling us that the {icon:Simpsons[3]} is in the center column.\n\nTap the bottom grid area of the center column.",
                TutorialSystem.TutorialPiece.Homer1, centerBottomGridArea);

            Vector2 clue4Position = Vector2.Add(clue3Position, clueHeightOffset);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClue4, clue4Position, 0, bottomTutorialRect, "The fourth clue doesn't have any useful information for us right now since we already know the {icon:Superheros[4]} is in the center column and we dont know where either the {icon:Hubble[4]} or the {icon:Superheros[2]} are.", TutorialSystem.TutorialPiece.HorizontalClue5a, Rectangle.Empty, true);

            Vector2 clue5Position = Vector2.Add(clue4Position, clueHeightOffset);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClue5a, clue5Position, 0, bottomTutorialRect, "Tap the fifth clue to select it.", TutorialSystem.TutorialPiece.HorizontalClue5b,
                new Rectangle(m_HorizontalCluePanel.Rect.Left, m_HorizontalCluePanel.Rect.Top + (m_HorizontalCluePanel.ClueHeight * 4), m_HorizontalCluePanel.Rect.Width, m_HorizontalCluePanel.ClueHeight));

            Rectangle rightTopGridArea = new Rectangle(m_GamePanel.Rect.Right - m_GamePanel.CellWidth, m_GamePanel.Rect.Top, m_GamePanel.CellWidth, m_GamePanel.CellHeight);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClue5b, Vector2.Add(iconSideOffset, m_GamePanel.IconPosition(0, 2, 2)), 0, bottomTutorialRect,
                "This clue tells us that the {icon:Superheros[2]} is in a column somewhere to the right of the {icon:Simpsons[3]}.\nSince we already know where the {icon:Simpsons[3]} is, and there is only one column to the right of it, we know where the {icon:Superheros[2]} is.\n\nTap the top right grid cell.", TutorialSystem.TutorialPiece.GreenLantern4, rightTopGridArea);

            bool online = !NetworkManager.Net.Disabled;

            Vector2 hideClueTarget = new Vector2(m_ButtonPanel.HideClueRect.Right, m_ButtonPanel.HideClueRect.Top + (m_ButtonPanel.HideClueRect.Height >> 1));
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HideClue1, hideClueTarget, Constants.ArrowLeft, bottomTutorialRect,
                "We have learned all we possibly can from this clue since we know where both the {icon:Simpsons[3]} and the {icon:Superheros[2]} are.\nWe can now hide this clue so we can more easily see the relevant clues.\nYou can unhide all the clues anytime you want in the pause menu.\n\nTap the 'HC' button to hide this clue.",
                online ? TutorialSystem.TutorialPiece.Hint1 : TutorialSystem.TutorialPiece.Hint2, m_ButtonPanel.HideClueRect);

            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.Hint1, new Vector2(m_ButtonPanel.HintRect.Right, m_ButtonPanel.HintRect.Top + (m_ButtonPanel.HintRect.Height >> 1)), Constants.ArrowLeft, bottomTutorialRect,
                "If you get stuck on a puzzle you can spend {icon:GoldCoin}2 to get a hint of what to do next.\nThere are a maximum number of hints you can use per puzzle, this number increases with your VIP level.\n\nTap the 'H' button to get a hint.", TutorialSystem.TutorialPiece.Hint2, m_ButtonPanel.HintRect);

            if (online)
            {
                m_MessageBox = new MessageBox("Would you like to spend 2 coins for a hint?", MessageBoxButtons.YesNo, (int)MessageBoxContext.InsufficientFunds_Hint, Game.ScreenWidth, Game.ScreenHeight, "Don't ask again");
                Rectangle hintYes = m_MessageBox.GetButtonRect(0);
                m_MessageBox = null;
                Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.Hint2, m_GamePanel.IconPosition(2, 1, 0), Constants.ArrowDiagonalUpRight, bottomTutorialRect,
                    "When you tap the hint button, you are asked for confirmation before proceding. You can skip this confirmation for the rest of the puzzle by tapping the checkbox. If the box remains unchecked, you will be asked to confirm each hint used in this puzzle.\n\nTap the 'Yes' button to confirm we want a hint.",
                    TutorialSystem.TutorialPiece.Hint3, hintYes);

                Rectangle rightBottomGridArea = new Rectangle(m_GamePanel.Rect.Right - m_GamePanel.CellWidth, m_GamePanel.Rect.Bottom - m_GamePanel.CellHeight, m_GamePanel.CellWidth, m_GamePanel.CellHeight);
                Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.Hint3, Vector2.Add(iconTopOffset, m_GamePanel.IconPosition(2, 2, 2)), Constants.ArrowDown, bottomTutorialRect,
                    "The hint is showing us that this clue should effect the {icon:Simpsons[2]} in the third column.\nThis span clue has the {icon:Superheros[3]} on one edge of the span and the {icon:Simpsons[2]} on the other edge. Since we know the {icon:Superheros[3]} is in the first column, the {icon:Simpsons[2]} belongs in the third column.\n\nTap the bottom right grid cell.",
                    TutorialSystem.TutorialPiece.Bartman5, rightBottomGridArea);
            }
            else
            {
                Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.Hint2, clueArrow, 0, bottomTutorialRect,
                    "Tap the first clue to select it again.",
                    TutorialSystem.TutorialPiece.Hint3, clue1Area);

                Rectangle rightBottomGridArea = new Rectangle(m_GamePanel.Rect.Right - m_GamePanel.CellWidth, m_GamePanel.Rect.Bottom - m_GamePanel.CellHeight, m_GamePanel.CellWidth, m_GamePanel.CellHeight);
                Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.Hint3, Vector2.Add(iconTopOffset, m_GamePanel.IconPosition(2, 2, 2)), Constants.ArrowDown, bottomTutorialRect,
                    "This span clue has the {icon:Superheros[3]} on one edge of the span and the {icon:Simpsons[2]} on the other edge. Since we know the {icon:Superheros[3]} is in the first column, the {icon:Simpsons[2]} belongs in the third column.\n\nTap the bottom right grid cell.",
                    TutorialSystem.TutorialPiece.Bartman5, rightBottomGridArea);
            }

            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.Undo, new Vector2(m_ButtonPanel.UndoRect.Right, m_ButtonPanel.UndoRect.Top + (m_ButtonPanel.UndoRect.Height >> 1)), Constants.ArrowLeft, bottomTutorialRect,
                "If you make a mistake, you can undo previous actions by tapping the 'U' button.\nThere are a limited number of actions that you can undo indicated by the number under the 'U' button. The number on the left is the number of actions currently in the history. The number on the right is the maximum number of actions stored in the history. The maximum increases with your VIP level.",
                TutorialSystem.TutorialPiece.HorizontalClue4b, Rectangle.Empty, true);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClue4b, clue4Position, 0, bottomTutorialRect,
                "There are only two cells left to solve. We need to figure out which cells the {icon:Hubble[4]} and the {icon:Hubble[3]} belong in.\nLets go back to the fourth horizontal clue.\n\nTap the fourth horizontal clue.\n",
                TutorialSystem.TutorialPiece.HorizontalClue4c, new Rectangle(m_HorizontalCluePanel.Rect.Left, m_HorizontalCluePanel.Rect.Top + (m_HorizontalCluePanel.ClueHeight * 3), m_HorizontalCluePanel.Rect.Width, m_HorizontalCluePanel.ClueHeight));

            Rectangle rightCenterGridArea = new Rectangle(m_GamePanel.Rect.Right - m_GamePanel.CellWidth, m_GamePanel.Rect.Top + m_GamePanel.CellHeight, m_GamePanel.CellWidth, m_GamePanel.CellHeight);
            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.HorizontalClue4c, m_GamePanel.IconPosition(1, 2, 1), Constants.ArrowDiagonalUpRight, bottomTutorialRect,
                "This clue is telling us that the {icon:Superheros[4]} has the {icon:Hubble[4]} on one side and NOT the {icon:Superheros[3]} on the other side.\nSince the {icon:Superheros[3]} is in the first column, the {icon:Hubble[4]} can not be in the third column.\n\nTap the middle grid cell in the third column.",
                TutorialSystem.TutorialPiece.RedNebula4, rightCenterGridArea);

            if (!Game.Tutorial.IsPieceSetup(TutorialSystem.TutorialPiece.EndScreen1))
            {
                // Create a dummy end screen here just so that the tutorial data gets setup correctly for later
                EndPuzzleScreen tempEnd = new EndPuzzleScreen(false, 3, 0, Game.ScreenWidth, Game.ScreenHeight, Game);
            }

            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.Puzzle2, new Vector2(-1000, -1000), 0,
                new Rectangle(Game.ScreenWidth - 170, Game.ScreenHeight - 80, 150, 0), "Solve this puzzle", TutorialSystem.TutorialPiece.EndScreen4, new Rectangle(0, 0, Game.ScreenWidth, Game.ScreenHeight));

            Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.Horizontal_NextTo, clue2Position, 0, bottomTutorialRect,
                "This clue is a Next To type clue. It tells us that the {icon:Superheros[5]} is in a column directly next to the column with the {icon:Flowers[2]}.\n\nThis doesn't help you any right now, but it will come in handy as you learn more about the puzzle.", TutorialSystem.TutorialPiece.None, Rectangle.Empty, true);

            Game.Tutorial.TriggerPiece(TutorialSystem.TutorialPiece.GameStart);
        }
Пример #7
0
 public void setPanel(GamePanel p)
 {
     if (gamePanel != null) { throw new RowNotInTableException(); }
     gamePanel = p;
 }
Пример #8
0
 /// <summary>
 /// Creates and binds a new GamePanel to the given GameInterface
 /// </summary>
 /// <param name="g"></param>
 public void createGamePanel(GameInterface g)
 {
     GamePanel r = new GamePanel(g);
     r.Size = Size;
     g.setPanel(r);
     Invoke(new Action(() => { Controls.Add(r); }));
 }
Пример #9
0
 private void MyTimer_Tick(object sender, EventArgs e)
 {
     _player.Move();
     GamePanel.Refresh();
 }
Пример #10
0
 // Use this for initialization
 void Start()
 {
     gamePanel = GameObject.Find("Root").GetComponent <GamePanel>();
 }
Пример #11
0
 private void Awake()
 {
     Instance = this;
 }
Пример #12
0
 private void Start()
 {
     _gamePanel = this.GetComponent <GamePanel>();
 }
            public bool ignoreOtherPet;      //屏蔽其它玩家宠物



            public GamePanel(Transform trans)
                : base(trans)
            {
                root      = trans;
                mInstance = this;
            }
Пример #14
0
 void Awake()
 {
     _instance = this;
 }
 public override void Awake()
 {
     actionCode = ActionCode.ShowTimer;
     gamePanel  = GetComponent <GamePanel>();
     base.Awake();
 }
 void Start()
 {
     print("SessionCreatorPanel:Start");
     gamePanel = this.gameObject.GetComponent <GamePanel> ();
 }
 private void Awake()
 {
     base._RequestCode = RequestCode.Game;
     base._ActionCode  = ActionCode.QuitBattle;
     gamePanel         = GetComponent <GamePanel>();
 }
Пример #18
0
        public static void Main(string[] args)
        {
            GamePanel panel         = new GamePanel();
            Snake     snake         = new Snake();
            Punkt     punkt         = new Punkt();
            DateTime  tijd          = DateTime.Now;
            DateTime  tijd2         = DateTime.Now;
            Boolean   buttonPressed = false;
            Boolean   gameOver      = false;

            initializeMap(panel, snake, punkt);

            while (true)
            {
                // Jeśli gameOver
                // czyści konsolę
                // czeka na input gracza
                // gdy znajdzie input
                // resetuje pozycję węża
                // oraz punktację
                if (gameOver)
                {
                    Console.WriteLine("Game Over!!");
                    Console.ReadKey();
                    gameOver = false;
                    snake    = new Snake();
                    punkt.NowaPunktacja();
                }

                // Odświeża grę
                // Wypisuje zdibyte punkty oraz prędkość węża
                tijd          = DateTime.Now;
                buttonPressed = false;
                initializeMap(panel, snake, punkt);
                refreshScreen(panel);
                Console.WriteLine("Zdobyte Punkty {0}", punkt.IleRazyPowstal);
                Console.WriteLine("Prędkość Węża {0}", snake.PokazywanSzybkosc);

                while (true)
                {
                    tijd2 = DateTime.Now;
                    if (tijd2.Subtract(tijd).TotalMilliseconds > snake.Speed)
                    {
                        break;
                    }

                    // Sprawdza ktory klawisz jest wcisniety
                    // i czy klawisz nie jest przeciwny do kierunku ruchu
                    // węża
                    if (Console.KeyAvailable)
                    {
                        ConsoleKeyInfo pressedKey = Console.ReadKey(true);

                        if (pressedKey.Key.Equals(ConsoleKey.UpArrow) &&
                            snake.direction != Snake.Directions.Down && buttonPressed == false)
                        {
                            snake.direction = Snake.Directions.Up;
                            buttonPressed   = true;
                        }

                        if (pressedKey.Key.Equals(ConsoleKey.DownArrow) &&
                            snake.direction != Snake.Directions.Up && buttonPressed == false)
                        {
                            snake.direction = Snake.Directions.Down;
                            buttonPressed   = true;
                        }

                        if (pressedKey.Key.Equals(ConsoleKey.LeftArrow) &&
                            snake.direction != Snake.Directions.Right && buttonPressed == false)
                        {
                            snake.direction = Snake.Directions.Left;
                            buttonPressed   = true;
                        }

                        if (pressedKey.Key.Equals(ConsoleKey.RightArrow) &&
                            snake.direction != Snake.Directions.Left && buttonPressed == false)
                        {
                            snake.direction = Snake.Directions.Right;
                            buttonPressed   = true;
                        }
                    }
                }

                // Gdy wąż może się bezpiecznie poruszyć
                // rusza węża
                // a jeśli koliduje z czymś (patrz isSafeMove())
                // GameOver
                if (snake.isSafeMove(panel))
                {
                    snake.move();
                    // Sprawdza czy zdobyl punkt
                    Point pun = snake.getHeadPosition();
                    // Zmienia predkosc, rosnie, rysuje kolejny punkt gdy zdobyl punkt
                    if (pun.X == punkt.xx && pun.Y == punkt.xy)
                    {
                        snake.OgonRosnij = true;
                        punkt.RysujeKolejnyPunkt();
                        snake.Speed             /= (float )1.1;
                        snake.PokazywanSzybkosc *= (float)1.1;
                    }
                }
                else
                {
                    gameOver = true;
                }
            }
        }
Пример #19
0
 public void Setup(GamePanel gamePanel, DialogPanel dialogPanel)
 {
     game   = gamePanel;
     dialog = dialogPanel;
 }
Пример #20
0
 void Awake()
 {
     _instance = this;
 }
Пример #21
0
 public GameWindow()
 {
     InitializeComponent();
     Graphics = GamePanel.CreateGraphics();
     Pen      = new Pen(Color.Red, 3);
 }
Пример #22
0
    /// <summary>
    /// 创建对象完成
    /// </summary>
    /// <param name="go"></param>
    private void OnCreateOK(GameObject go)
    {
        gameObj = go;

        //面板脚本
        panel = go.AddComponent<GamePanel>();

        //元件事件
        panel.m_Select1.onClick.AddListener(OnOpenButton1);
        panel.m_Select2.onClick.AddListener(OnOpenButton2);
        panel.m_Select3.onClick.AddListener(OnOpenButton3);
        panel.m_Quit.onClick.AddListener(OnQuit);

        //玩家初始化
        PlayerInit();

        // 加载资源,包名,prefable名
        Debug.LogWarning("OnCreateOK---->>>>" + go.name);
    }
Пример #23
0
 private void Start()
 {
     PlayerAttackDec = GameObject.FindGameObjectWithTag("Player").GetComponent <AttackDetectionTwo>();
     gamePanel       = GameObject.Find("Canvas").transform.GetChild(0).GetComponent <GamePanel>();
 }
        /// <summary>
        /// Ја стартува играта испратена како параметар. 
        /// Играта мора да го имплементира интерфејсот IGame.
        /// </summary>
        public void StartGame(GamePanel panel)
        {
            if (IsFrameworkRunning)
            {
                throw new SystemException("The game is already running!");
            }

            this.gamePanel = panel;
            gamePanel.GameFramework = this;
            this.InitializeFramework();

            this.IsFrameworkRunning = true;
            this.lastFrameWidth = gamePanel.Width;
            this.lastFrameHeight = gamePanel.Height;

            gamePanel.Invalidate();

            try
            {
                this.IsGameRunning = true;
                game.GameUpdatePeriod = gameUpdatePeriod;
                this.GameMainLoop();
            }
            catch (Exception e)
            {
                IsExceptionRaised = true;
                MessageBox.Show(string.Format("Се случи критична грешка\nДетали за грешката:"
                    + "\nException: {0}\nMessage: {4}\nStack trace: {1}\nSource: {2}\nTarget site: {3}\n",
                    e.GetType().FullName, e.StackTrace, e.Source, e.TargetSite, e.Message), "Грешка",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.IsGameRunning = false;
                this.IsFrameworkRunning = false;
            }
        }
Пример #25
0
 public void EnableInputFor(HumanPlayer p)
 {
     GamePanel.EnableInputFor(p);
 }
Пример #26
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    protected new void Awake()
    {
        base.Awake();

        Application.targetFrameRate = 60;

        if (instance == null) {
            instance = this;
        }

        spawner = GetComponent<Spawner>();
        player = FindObjectOfType( typeof (Player) ) as Player;
        gamePanel = FindObjectOfType (typeof(GamePanel)) as GamePanel;
        if ( gamePanel == null ) {
            Debug.LogError ( "Can't find GamePanel in the scene" );
        }
        challengeMng = FindObjectOfType (typeof(ChallengeMng)) as ChallengeMng;
        spawner.Init();
    }
Пример #27
0
 public abstract bool Passed(UnlockEvent unlockEvent, GamePanel panel);