Esempio n. 1
0
        //called by GameTimer !! replaced by MyGameTimerRef_tickEvent
        //public void BombTickUpdate()
        //{
        //    myTime += myTickIncrement;

        //    Debug.WriteLine("Bomb alive {0} seconds", myTime); //debug the timer
        //    if(myTime >= (effectLifeTime + timeToExplode) && iCanDestroy == true)
        //    {
        //        DestroyBomb();
        //    }
        //    else if(myTime >= timeToExplode)
        //    {
        //        ProcessExplosion();
        //        DrawExplosion();
        //    }

        //}

        //remove the bomb from the level
        private void DestroyBomb()
        {
            foreach (Rectangle exp in explosionTiles)
            {
                curGameGrid.Children.Remove(exp);
            }

            myGameTimerRef.processFrameEvent_TICK -= MyGameTimerRef_tickEvent;
            StaticCollections.RemoveBomb(this);
        }
Esempio n. 2
0
        public GameWindow()
        {
            InitializeComponent();

            GameCanvasInstance = GameCanvas;
            MainGameGrid       = GameBoardGrid;
            gameWindowInstance = this;


            if (gameTimerInstance == null)
            {
                gameTimerInstance = new GameTimer();
            }

            gameTimerInstance.Initialise();

            // The number of players needs to be set before the game board is initialized
            if (MainMenu.GlobalPlayerMainMenu)
            {
                noOfPlayers = 6; playersOnBoard = 6;
            }
            else
            {
                noOfPlayers = 4; playersOnBoard = 4;
            }


            initialiseGameBoardSize();

            gameBoardManager          = new GameBoardManager();
            gameBoardManager.gameGrid = MainGameGrid;
            gameBoardManager.InitializeGameBoard();

            playerControllers = new PlayerController[noOfPlayers];
            playerLives       = new PlayerLivesAndScore[noOfPlayers];
            //playerPositions = new int[noOfPlayers];
            initialisePlayerReferences();

            Debug.WriteLine(GameCanvasInstance.Name);

            StaticCollections _staticColections = new StaticCollections();

            powerupRef             = new Powerup();
            powerupRef.curGameGrid = MainGameGrid;
            powerupRef.InitialisePowerups();
            gameTimerInstance.puRef = powerupRef;


            // End timer
            endTimer          = new DispatcherTimer(DispatcherPriority.Render);
            endTimer.Interval = TimeSpan.FromSeconds(0.5);
            endTimer.Tick    += new EventHandler(timer_Tick);
            endTimer.Start();
        }
Esempio n. 3
0
        public void controller_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var mousewasdownOn = e.Source as FrameworkElement;

            int elementNameC = (int)mousewasdownOn.GetValue(Grid.ColumnProperty);
            int elementNameR = (int)mousewasdownOn.GetValue(Grid.RowProperty);

            if (mousewasdownOn != null && e.ClickCount == 2 && mousewasdownOn == playerTile)
            {
                localBombRelative = mousewasdownOn.TransformToAncestor(localGameGrid).Transform(new Point(lastClickPOS.X, lastClickPOS.Y));
                double localCol = localBombRelative.X;
                double localRow = localBombRelative.Y;


                if (StaticCollections.CheckBombPosition((int)(localCol / tileSize), (int)(localRow / tileSize)) == true)
                {
                    Bomb fireBomb = new Bomb(localGameGrid);
                    fireBomb.managerRef = managerRef;
                    fireBomb.myOwner    = this;

                    localGameGrid.Children.Remove(playerTile);

                    if (playerState == "Superbomb")
                    {
                        bombRadius = bombRadius * 2;
                    }

                    fireBomb.InitialiseBomb((int)(localCol / tileSize), (int)(localRow / tileSize), bombRadius);
                    localGameGrid.Children.Add(playerTile);

                    // Play Bomb Explode Sound (Should also play the tick sound here)
                    //playMusic.playBombExplode(); - move to Bomb.cs

                    //add bomb reference to bomb collection
                    StaticCollections.AddBomb(fireBomb, (int)(localCol / tileSize), (int)(localRow / tileSize));

                    //MessageBox.Show(string.Format("Player state: {0}", playerState));
                    if (playerState == "Superbomb")
                    {
                        bombRadius  = bombRadius / 2;
                        playerState = null;
                        UpdatePlayerStatus("null");
                    }
                }
            }
        }