示例#1
0
 public GameArea(Context context, int aSide,
                 InformationContainer informationContainer) //elmentettem a context és az oldal hosszat, hogy ne kelljen minidg paraméterként megadni
 {
     _parentContext        = context;
     _aSide                = aSide;
     _gombPlace            = new int[aSide, aSide];
     _gameButton           = new GameButton(_parentContext, 0, aSide);
     _informationContainer = informationContainer;
     _saveGameArea         = new SaveGameArea();
     _scoreDatabase        = new ScoreDatabaseController();
 }
示例#2
0
文件: Game.cs 项目: SchmidtPeti/2048
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.game);
            _side          = int.Parse(Intent.GetStringExtra("a_side"));
            _scoreDatabase = new ScoreDatabaseController();
            _textView      = FindViewById <TextView>(Resource.Id.textView1);
            var gameLinearLayout =
                FindViewById <LinearLayout>(Resource.Id
                                            .game_screen); //Ez a legalapbb úgynevett root layout ehhez fogunk majd mindent hozzáadni vertical-is

            _informationContainer =
                new InformationContainer(_textView, int.Parse(Intent.GetStringExtra("a_side")));
            _gameArea = new GameArea(this, int.Parse(Intent.GetStringExtra("a_side")),
                                     _informationContainer); //itt átadtam ennek az activity-t és hogy mekkora legyen a pálya!!!!!!!!!!!!!!!!!!! itt lehet beállitani, hogy hányszor hányas legyen a pálya
            var tableLayout = _gameArea.generate_game_field();

            gameLinearLayout.AddView(tableLayout); //legenáráltam az üres pályát és hozzáadtam a root layout-hoz
            var button = FindViewById <Button>(Resource.Id.new_game);
            var bckBtn = FindViewById <Button>(Resource.Id.button1);

            _lastSceneBtn = FindViewById <Button>(Resource.Id.button2);
            bckBtn.Click += (s, e) =>
            {
                var score = new Score
                {
                    _score = _informationContainer.HighScore,
                    _side  = _side
                };
                _scoreDatabase.set_high_Score(score);
                _gameArea.save_game_Area_();
                var intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
            };
            button.Click         += (s, e) => { _gameArea.New_game(); };
            _lastSceneBtn.Click  += (s, e) => { _gameArea.get_last_scene(); };
            _lastSceneBtn.Enabled = false;
            //  button.SetOnTouchListener(this);//touch sensor érzékelésének hozzáadása a textview-hoz
            set_onclick_for_buttons(tableLayout);
            _saveGame = new SaveGameArea();
            if (_saveGame.GetGame_Area_(int.Parse(Intent.GetStringExtra("a_side"))) != null)
            {
                var getSavedData = _saveGame.GetGame_Area_(int.Parse(Intent.GetStringExtra("a_side")));
                _gameArea.load_saved_game_Area(getSavedData.Places, getSavedData.Values);
            }
            else
            {
                _gameArea.add_new_number(GameButton.get_new_btn()); //az első generálás
                _gameArea.add_new_number(GameButton.get_new_btn());
            }
        }