コード例 #1
0
ファイル: MainApp.cs プロジェクト: wlcwchan/tankGame
        private void label_Click(object sender, EventArgs e, String coordinate, Label label, int x, int y)
        {
            if (!gameFinished)
            {
                bool tankAliveCondition = false;
                isHit = GameUtilities.tankHit(enemyTanks, coordinate);
                gameBoard.updateGrid(coordinate, isHit);
                updateTextBox(isHit ? "Hit" : "Miss");

                if (!isHit && gameBoard.getGrid()[x - 1, y - 1].Equals(GameBoard.MARKER_TANK_HIT))
                {
                    label.Image = Properties.Resources.HIT;
                }
                else
                {
                    label.Image    = isHit? Properties.Resources.HIT : Properties.Resources.MISS;
                    label.AutoSize = true;
                }

                tankDamageCalculation();

                updateTextBox(String.Format("Fortress HP:{0}", fortressHitPoints.getHitpoints().ToString()));

                if (GameUtilities.isTanksDestroyed(enemyTanks, TANK_NUMBER))
                {
                    tankAliveCondition = true;
                }

                if (tankAliveCondition == true || !GameUtilities.isFortressDestroyed(fortressHitPoints.getHitpoints()))
                {
                    endGameProcessing(tankAliveCondition);
                }
            }
        }