private void Start()
    {
        _gameModel = ServiceLocator.Instance.Model.GetComponent <ModelGame>();

        _p0 = ServiceLocator.Instance.Character0;
        _p1 = ServiceLocator.Instance.Character1;
    }
Exemplo n.º 2
0
        public void ChangeGame(ModelGame oldGame, ModelGame newGame)
        {
            if (oldGame != null && newGame != null)
            {
                oldGame.Name              = newGame.Name;
                oldGame.IconType          = newGame.IconType;
                oldGame.PathIcon          = newGame.PathIcon;
                oldGame.ItemPath          = newGame.ItemPath;
                oldGame.StartUpParams     = newGame.StartUpParams;
                oldGame.MouseClickCordX   = newGame.MouseClickCordX;
                oldGame.MouseClickCordY   = newGame.MouseClickCordY;
                oldGame.NameProcess       = newGame.NameProcess;
                oldGame.FileMotion        = newGame.FileMotion;
                oldGame.RunKey            = newGame.RunKey;
                oldGame.AdditionalKey     = newGame.AdditionalKey;
                oldGame.TimeOut           = newGame.TimeOut;
                oldGame.StartTime         = newGame.StartTime;
                oldGame.TypeStartFocus    = newGame.TypeStartFocus;
                oldGame.ShiftPressTime    = newGame.ShiftPressTime;
                oldGame.PathToBannerVideo = newGame.PathToBannerVideo;
                context.SaveChanges();

                if (RefreshTableGames != null)
                {
                    RefreshTableGames.Invoke(this, null);
                }
                return;
            }
            throw new Exception("Game not found");
        }
        public GameProcessor(ModelGame game)
        {
            try
            {
                Game          = game;
                NameProcess   = Game.NameProcess;
                MouseHelper.X = (int)Game.MouseClickCordX;
                MouseHelper.Y = (int)Game.MouseClickCordY;
                ProcessStartInfo proc = new ProcessStartInfo();
                // proc.UseShellExecute = true;
                proc.Arguments        = Game.StartUpParams;
                proc.WorkingDirectory = new DirectoryInfo(Game.ItemPath).Parent.FullName.ToString();
                proc.FileName         = new DirectoryInfo(Game.ItemPath).Name;
                proc.Verb             = "runas";

                _currentProcess = new Process()
                {
                    StartInfo = proc
                };
            }
            catch (Exception ex)
            {
                App.SendException(ex);
            }
        }
Exemplo n.º 4
0
        private void btnCreateGame_Click(object sender, EventArgs e)
        {
            string gameName = tbxGameName.Text;
            string password = tbxGamePassword.Text;

            if (String.IsNullOrEmpty(gameName))
            {
                FormMessage fm = new FormMessage("Game name must be specified!");
                fm.Opacity = 0;
                fm.ShowDialog();
                tbxGameName.Focus();
                return;
            }

            if (_selectedIndex >= 0)
            {
                _names.Remove(_names[_selectedIndex]);
            }

            FormGame f = new FormGame(this);

            f.Opacity = 0;
            IModel      m = new ModelGame(gameName, password);
            IController c = new ControllerInternet(m, (IView)f);

            f.GameController = c;
            c.CreateGame();
            f.Show();
        }
Exemplo n.º 5
0
    public override void Awake()
    {
        priority = 1000;
        base.Awake();

        _inputModel = ServiceLocator.Instance.Model.GetComponent <ModelInput>();
        _gameModel  = ServiceLocator.Instance.Model.GetComponent <ModelGame>();
    }
Exemplo n.º 6
0
        public void AddGame(ModelGame game)
        {
            context.Games.Add(game);
            context.SaveChanges();

            if (RefreshTableGames != null)
            {
                RefreshTableGames.Invoke(this, null);
            }
        }
Exemplo n.º 7
0
    public override void Awake()
    {
        priority = 3000;
        base.Awake();

        _gameModel   = ServiceLocator.Instance.Model.GetComponent <ModelGame>();
        _objIntModel = ServiceLocator.Instance.Model.GetComponent <ModelObjectInteraction>();

        _interactiveAssetsTransform = ServiceLocator.Instance.View.Find("InteractiveAssets");
    }
Exemplo n.º 8
0
        private void btnSinglePlayer_Click(object sender, EventArgs e)
        {
            IModel model = new ModelGame();

            fg = new FormGame(this);
            IController ctrl = new ControllerSinglePlayer(model, fg);

            fg.GameController = ctrl;
            fg.Opacity        = 0;
            fg.Show();

            _tSinglePlayer.Enabled = true;
        }
Exemplo n.º 9
0
        private void btnHotseat_Click(object sender, EventArgs e)
        {
            IModel model = new ModelGame();

            fg = new FormGame(this);
            IController ctrl = new ControllerHotseat(model, fg);

            fg.GameController = ctrl;
            fg.Opacity        = 0;

            fg.Show();

            _tHotseat.Enabled = true;
        }
Exemplo n.º 10
0
 public void Register()
 {
     gameModel  = new ModelGame();
     alertModel = new ModelAlert();
     userModel  = new ModelUser();
     roleModel  = new ModelRole();
     guildModel = new ModelGuild();
     chatModel  = new ModelChat();
     cardModel  = new ModelCard();
     mailModel  = new ModelMail();
     fightModel = new ModelFight();
     rankModel  = new ModelRank();
     guideModel = new ModelGuide();
     shareModel = new ModelShare();
 }
Exemplo n.º 11
0
        public void DeleteGame(ModelGame game)
        {
            if (game != null)
            {
                context.Games.Remove(game);
                context.SaveChanges();

                if (RefreshTableGames != null)
                {
                    RefreshTableGames.Invoke(this, null);
                }
                return;
            }
            throw new Exception("Game not found");
        }
Exemplo n.º 12
0
        public MainWindow()
        {
            InitializeComponent();

            model = new ModelGame();

            model.RePaint     += Model_RePaint;
            model.WinComplite += Model_WinComplite;
            model.Init();

            start          = DateTime.Now;
            timer.Tick    += Timer_Tick;
            timer.Interval = TimeSpan.FromMilliseconds(100);
            timer.Start();
        }
Exemplo n.º 13
0
    public override void Awake()
    {
        priority = 2998;
        base.Awake();

        _gameModel     = ServiceLocator.Instance.Model.GetComponent <ModelGame>();
        _objIntModel   = ServiceLocator.Instance.Model.GetComponent <ModelObjectInteraction>();
        _eqptMenuModel = ServiceLocator.Instance.Model.GetComponent <ModelMenuEqpt>();
        _objIntCtrlr   = ServiceLocator.Instance.Controller.GetComponent <ControllerObjectInteraction>();

        _canvas = ServiceLocator.Instance.View.Find("Canvas");

        _p0_MenuParent = _canvas.Find("P0 Menu Parent");
        _p1_MenuParent = _canvas.Find("P1 Menu Parent");

        Debug.Assert(_p0_MenuParent != null);
        Debug.Assert(_p1_MenuParent != null);
    }
Exemplo n.º 14
0
    public override void Awake()
    {
        priority = 2500;
        base.Awake();

        _gameModel   = ServiceLocator.Instance.Model.GetComponent <ModelGame>();
        _inputModel  = ServiceLocator.Instance.Model.GetComponent <ModelInput>();
        _objIntModel = ServiceLocator.Instance.Model.GetComponent <ModelObjectInteraction>();

        _objIntCtrlr   = ServiceLocator.Instance.Controller.GetComponent <ControllerObjectInteraction>();
        _eqptMenuCtrlr = ServiceLocator.Instance.Controller.GetComponent <ControllerMenuEqpt>();

        _p0_Transfrom = ServiceLocator.Instance.Character0;
        _p1_Transform = ServiceLocator.Instance.Character1;

        _p0_RigidBody = _p0_Transfrom.GetComponent <Rigidbody>();
        _p1_RigidBody = _p1_Transform.GetComponent <Rigidbody>();
    }
Exemplo n.º 15
0
    public override void Awake()
    {
        priority = 2999;
        base.Awake();

        _gameModel = ServiceLocator.Instance.Model.GetComponent <ModelGame>();

        _canvas = ServiceLocator.Instance.View.Find("Canvas");

        _menuParent = _canvas.Find("Game Menu Parent");

        _bkgd    = _menuParent.Find("Bkgd");
        _title   = _menuParent.Find("Title");
        _cursor  = _menuParent.Find("Cursor");
        _option1 = _menuParent.Find("Option 1");
        _option2 = _menuParent.Find("Option 2");
        _option3 = _menuParent.Find("Option 3");
        _option4 = _menuParent.Find("Option 4");
    }
Exemplo n.º 16
0
    void Start()
    {
                #if UNITY_IOS
        GameCenterManager.GetInstance().Start();
                #endif
//		LocalStore.Clear ();
//		Debug.Log(Config.OffLineTxt ["cn_14056"]);
//		return;

        //
        ModelManager.inst.Register();
        gameModel = ModelManager.inst.gameModel;
        this.InitConfigXml();
        //非战斗直接进游戏
        if (!FightMain.fightTest)
        {
            this.initQueue.Init(new List <Action> {
                this.InitConfig,
                this.InitRigester,
                this.InitOther,
                this.InitData,
                this.InitLogin
            });
        }
        else
        {
            //直接进入战斗
            this.initQueue.Init(new List <Action> {
                //this.initConfig,
                //this.InitRigester,
                //this.initModel,
                //this.initOther,
                () =>
                {
                    ModelManager.inst.Register();
                    this.initQueue.Next();
                },
                this.InitData,
                FightMain.instance.onStart
            });
        }
    }
Exemplo n.º 17
0
        public void ExecuteCommandMoveButton(string _parameter, Game _game)
        {
            string s = _parameter.ToString();

            string[] _separator  = { "," };
            string[] arrayValues = s.Split(_separator, StringSplitOptions.RemoveEmptyEntries);
            int      columnHuman = Convert.ToInt32(arrayValues[0]);
            int      rowHuman    = Convert.ToInt32(arrayValues[1]);

            if (_game.GameLowestAvailableRowInColumn(columnHuman, rowHuman, _game) > -1)
            {
                rowHuman = _game.GameLowestAvailableRowInColumn(columnHuman, rowHuman, _game);
                if (_game.GameArrayEnabled[columnHuman, rowHuman] == true && _game.IsGameOver == false && _game.IsGameWon == false)
                {
                    ModelGame = ModelGame.GameMoveMake("Human", columnHuman, rowHuman, _game);
                    ModelGame.AiTurn(_game);
                }
            }
            ModelGame = RefreshUiComponents(_game);
        }
Exemplo n.º 18
0
    public override void Awake()
    {
        priority = 3000;
        base.Awake();

        _gameModel     = ServiceLocator.Instance.Model.GetComponent <ModelGame>();
        _eqptMenuModel = ServiceLocator.Instance.Model.GetComponent <ModelMenuEqpt>();

        _menuParent_p0 = ServiceLocator.Instance.View.Find("Canvas").Find("P0 Menu Parent");
        _menuParent_p1 = ServiceLocator.Instance.View.Find("Canvas").Find("P1 Menu Parent");

        _title_p0 = _menuParent_p0.Find("P0 Title");
        _title_p1 = _menuParent_p1.Find("P1 Title");

        _option1_p0 = _menuParent_p0.Find("P0 Option 1");
        _option1_p1 = _menuParent_p1.Find("P1 Option 1");

        _cursor_p0 = _menuParent_p0.Find("P0 Cursor");
        _cursor_p1 = _menuParent_p1.Find("P1 Cursor");
    }
        private void btnPrzeslijParametry_Click(object sender, EventArgs e)
        {
            gra = new ModelGame();

            gra.MaxWartosc = Convert.ToInt32(txtbMaxWartosc.Text);
            gra.IloscLiczb = Convert.ToInt32(txtbIloscLiczb.Text);

            gra.Gracz1.Name = txtbNickGracz1.Text;
            gra.Gracz2.Name = txtbNickGracz2.Text;

            richtxtbPoleGry.Clear();
            gra.LosujCiag();

            StringBuilder sb = new StringBuilder();

            sb.Append("Wylosowany ciąg: ");
            foreach (var item in gra.TabWylosowaneLiczbyAsReadOnly)
            {
                sb.Append(item + " | ");
            }
            richtxtbPoleGry.Text = sb.ToString();
            labelKomunikat.Text  = $"{gra.Gracz1.Name}: Wybierz podciąg spójny, parzysty. Liczby oddziel spacją.";

            lblPodajWartosci.Visible   = true;
            txtbPodajWartosci.Visible  = true;
            btnWybierzWartosci.Visible = true;
            btnWybierzWartosci.Enabled = false;

            lblNickGracz1.Visible  = false;
            lblNickGracz2.Visible  = false;
            txtbNickGracz1.Visible = false;
            txtbNickGracz2.Visible = false;

            labelMaxWartosc.Visible = false;
            txtbMaxWartosc.Visible  = false;
            labelIloscLiczb.Visible = false;
            txtbIloscLiczb.Visible  = false;

            btnPrzeslijParametry.Visible = false;
        }
Exemplo n.º 20
0
 public override void Initialize()
 {
     objIntCtrlr = ServiceLocator.Instance.Controller.GetComponent <ControllerObjectInteraction>();
     gameModel   = ServiceLocator.Instance.Model.GetComponent <ModelGame>();
     inputModel  = ServiceLocator.Instance.Model.GetComponent <ModelInput>();
 }
Exemplo n.º 21
0
        public VideoControlerPage(ModelGame game) : this()
        {
            try
            {
                InitializeComponent();

                _typeItem    = TypeItem.Game;
                _currentGame = game;
                Start        = StartGame;
                Stop         = StopGame;
                Launch       = LaunchingGame;

                try
                {
                    VideoBanner.VideoCollection = new List <Uri>()
                    {
                        new Uri(game.PathToBannerVideo)
                    };
                }
                catch (Exception ex)
                {
                    App.SendException(ex);
                }

                KeySimulationHelper.CurrentGame = _currentGame;
                KeySimulationHelper.ButtonStart = _currentGame.RunKey.Value;

                Btn_Start.IsEnabled  = false;
                Btn_Stop.IsEnabled   = false;
                Btn_Pause.Visibility = Visibility.Collapsed;
                Btn_Play.Icon        = Char.ConvertFromUtf32(0xE7FC);
                Btn_Play.Text        = "Запустить игру";

                NameVideo.Text = _currentGame.Name;
                KeySimulationHelper.ButtonAdditional = _currentGame.AdditionalKey;
                //visibly timer on
                // GameStartTimer.Visibility = Visibility.Collapsed;
                TimerPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
                TitleTimerOff.Text             = "Обратный отсчет выключения игры";
                _timeOut = _currentGame.TimeOut.Value.TimeOfDay;

                if (_timeOut != null)
                {
                    Hour.Text    = _timeOut.Hours.ToString();
                    Minutes.Text = _timeOut.Minutes.ToString();
                    Second.Text  = _timeOut.Seconds.ToString();
                }
                else
                {
                    TimerPanel.Visibility = Visibility.Hidden;
                }

                _gameProcessor = new GameProcessor(_currentGame);

                // GameStartTimer.Visibility = Visibility.Visible;
                _timeStart = TimeSpan.FromSeconds(game.StartTime.Value);

                _timerStart = new DispatcherTimer
                {
                    Interval = TimeSpan.FromSeconds(1)
                };

                _timerStart.Tick += _timerStartGame_Tick;

                _timerEnd = new DispatcherTimer()
                {
                    Interval = new TimeSpan(0, 0, 1)
                };

                _timerEnd.Tick += _timerStop_Tick;

                // StarGame_Hour.Text = _timeStart.Hours.ToString();
                //  StarGame_Minutes.Text = _timeStart.Minutes.ToString();
                // StarGame_Second.Text = _timeStart.Seconds.ToString();

                if (_gameProcessor.Game.ShiftPressTime != null)
                {
                    _timeShift  = TimeSpan.FromSeconds(_gameProcessor.Game.ShiftPressTime.Value);
                    _timerShift = new DispatcherTimer()
                    {
                        Interval = TimeSpan.FromSeconds(1)
                    };

                    _timerShift.Tick += _timerShift_Tick;
                }

                if (_timeShift != null)
                {
                    //    TimerShift.Visibility = Visibility.Visible;
                    //   ShiftTime_Hour.Text = _timeShift.Value.Hours.ToString();
                    //  ShiftTime_Minutes.Text = _timeShift.Value.Minutes.ToString();
                    //   ShiftTime_Second.Text = _timeShift.Value.Seconds.ToString();
                }

                App.IsVideoMod = false;
                Observer.SetItem(_gameProcessor);
            }
            catch (Exception ex)
            {
                App.SendException(ex);
            }
        }
Exemplo n.º 22
0
        private Page GetPageByName(string pageName, object param1, object param2 = null)
        {
            switch (pageName)
            {
            case (nameof(StartUpPage)):
            {
                bool p = (bool)param1;
                return(new StartUpPage(p));
            }

            case (nameof(AuthorizePage)):
            {
                bool p = (bool)param1;
                return(new AuthorizePage(p));
            }

            case (nameof(GameAddOrEditDialogPage)):
            {
                ModelGame p = (ModelGame)param1;
                return(new GameAddOrEditDialogPage(p));
            }

            case (nameof(MainSettingPage)):
            {
                bool p = (bool)param1;
                return(new MainSettingPage(p));
            }

            case (nameof(TablesPage)):
            {
                TypeItem p = (TypeItem)param1;
                return(new TablesPage(p));
            }

            case (nameof(VideoAddOrEditDialogPage)):
            {
                if (param2 == null)
                {
                    TypeItem p = (TypeItem)param1;
                    return(new VideoAddOrEditDialogPage(p));
                }
                else
                {
                    TypeItem   p1 = (TypeItem)param1;
                    ModelVideo p2 = (ModelVideo)param2;
                    return(new VideoAddOrEditDialogPage(p1, p2));
                }
            }

            case (nameof(VideoControlerPage)):
            {
                if (param1 is ModelVideo)
                {
                    ModelVideo p = (ModelVideo)param1;
                    return(new VideoControlerPage(p));
                }
                else
                {
                    ModelGame p = (ModelGame)param1;
                    return(new VideoControlerPage(p));
                }
            }

            default: throw new ArgumentException();
            }
        }
Exemplo n.º 23
0
        private void Btn_Save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (TBox_Name.Text == string.Empty ||
                    TB_OpenFileGame.Text == string.Empty ||
                    TBox_NameProcess.Text == string.Empty ||
                    TB_OpenFileMoution.Text == string.Empty
                    )
                {
                    throw new Exception();
                }

                ModelGame newGame = new ModelGame
                {
                    Name              = TBox_Name.Text,
                    PathIcon          = TB_OpenFileIcon.Text,
                    ItemPath          = TB_OpenFileGame.Text,
                    StartUpParams     = TBox_Params.Text,
                    NameProcess       = TBox_NameProcess.Text,
                    FileMotion        = TB_OpenFileMoution.Text,
                    AdditionalKey     = _additionalKeyPressed,
                    StartTime         = Convert.ToInt32(TBox_TimeShift.Text),
                    MouseClickCordX   = Convert.ToInt32(TB_xMousClick.Text),
                    MouseClickCordY   = Convert.ToInt32(TB_yMousClick.Text),
                    TypeStartFocus    = (TypeStartFocus)CB_TypeStart.SelectedIndex,
                    PathToBannerVideo = TB_OpenFileVideoBanner.Text
                };

                IconType?iconType = null;

                if (RBtn_Image.IsChecked == true)
                {
                    iconType = IconType.Image;
                }
                else if (RBtn_Video.IsChecked == true)
                {
                    iconType = IconType.Video;
                }
                newGame.IconType = (IconType)iconType;

                Key?startUpButtpn = null;

                if (RBEnter.IsChecked == true)
                {
                    startUpButtpn = Key.Enter;
                }
                else if (RBSpace.IsChecked == true)
                {
                    startUpButtpn = Key.Space;
                }
                newGame.RunKey = (Key)startUpButtpn;

                if (TP_TimeOut.SelectedTime != null)
                {
                    DateTime?nowDate = new DateTime(2000, 12, 12, 0, 0, 0);
                    nowDate        += TP_TimeOut.SelectedTime;
                    newGame.TimeOut = nowDate;
                }

                if (TS_ShiftClick.IsChecked.Value)
                {
                    newGame.ShiftPressTime = int.Parse(TB_ShiftClick.Text);
                }
                else
                {
                    newGame.ShiftPressTime = null;
                }


                if (isAddOrEdit)
                {
                    _rep.ChangeGame(_oldGame, newGame);
                }
                else
                {
                    _rep.AddGame(newGame);
                }



                App.Frame.Navigate(new TablesPage(_typeItem));
            }
            catch (FormatException)
            {
                ValidationMessage.Text = "Время в сек.нажатия клавиши Shift или Моусклика введенно некоректно";
            }
            catch (Exception ex)
            {
                ValidationMessage.Text = "Вы не заполнили всех полей!";
            }
        }
Exemplo n.º 24
0
        private void Rozgrywka()
        {
            ModelGame gra = new ModelGame();
            int       iloscLiczb;
            int       maxWartosc;

            Console.WriteLine("Witaj w grze.\nPodaj nick gracza nr 1: ");
            gra.Gracz1.Name = Console.ReadLine();
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("Podaj nick gracza nr 2: ");
            gra.Gracz2.Name = Console.ReadLine();
            Console.WriteLine("----------------------------------------------------------------");

            while (!(gra.CzyWybranoPoprawnaIloscLiczbDoWylosowania))
            {
                Console.WriteLine("Podaj ilość liczb do wylosowania. Minimum 3 liczby.");
                while (!(Int32.TryParse(Console.ReadLine(), out iloscLiczb)))
                {
                    Console.WriteLine("Niepoprawna wartość! Wpisz liczbę o wartości minimum 3.");
                }
                gra.WybierzIloscLiczbDoWylosowania(iloscLiczb);
                Console.WriteLine("----------------------------------------------------------------");
            }

            while (!(gra.CzyWybranoPoprawnaMaxWartoscDoWylosowania))
            {
                Console.WriteLine("Podaj max wartość losowanej liczby. Minimum liczba 2.");
                while (!(Int32.TryParse(Console.ReadLine(), out maxWartosc)))
                {
                    Console.WriteLine("Niepoprawna wartość! Wpisz liczbę o wartości minimum 2.");
                }
                gra.WybierzMaxWartoscLosowanejLiczby(maxWartosc);
                Console.WriteLine("----------------------------------------------------------------");
            }

            gra.LosujCiag();

            Console.WriteLine("Wylosowany ciąg: ");
            foreach (var item in gra.TabWylosowaneLiczbyAsReadOnly)
            {
                Console.WriteLine(item);
            }

            do
            {
                Console.WriteLine("----------------------------------------------------------------");
                Console.WriteLine("{0}: Wybierz podciąg spójny, parzysty. Liczby oddziel spacją.", gra.Gracz1.Name);
                string liczbyGracz1 = "";
                gra.Gracz1.PodciagCheck = false; //przechowuje info o poprawności formatu danych
                while (!gra.Gracz1.PodciagCheck)
                {
                    liczbyGracz1 = Console.ReadLine();
                    if (int.TryParse(liczbyGracz1.Replace(" ", string.Empty), out int result)) //jeśli po usunięciu przerw w stringu, da się sparsować na inta to znaczy, że wpisano same liczby. Clever :D
                    {
                        gra.Gracz1.PodciagCheck = true;                                        //same liczby, zwróć true, info o poprawnych danych
                    }
                    else
                    {
                        Console.WriteLine("----------------------------------------------------------------");
                        Console.WriteLine("Nieprawidłowy format danych. Wpisz tylko liczby całkowite oddzielone spacją.");
                    }
                }

                gra.Gracz1.WybierzLiczby(liczbyGracz1);
                Console.WriteLine("----------------------------------------------------------------");
                Console.WriteLine("Wybrano liczby: " + liczbyGracz1);
                Console.WriteLine("----------------------------------------------------------------");
                gra.SprawdzCzyWybranoPoprawneLiczby(gra.Gracz1);
                gra.WyrzucWybraneLiczby(gra.Gracz1);
                Console.WriteLine("Aktualna postać ciągu: ");

                foreach (var item in gra.TabWylosowaneLiczbyAsReadOnly) //zredukowany ciąg
                {
                    Console.WriteLine(item + " ");
                }
                Console.WriteLine("----------------------------------------------------------------");

                if (!(gra.SprawdzCzyMoznaKontynuowac(gra.Gracz1)))
                {
                    gra.Wygrany = gra.Gracz1.Name;
                }


                if (gra.CzySaJeszczeRuchy && gra.CzyWybranoPoprawneLiczbyDoWyrzucenia)
                {
                    Console.WriteLine("{0}: Wybierz podciąg spójny, parzysty. Liczby oddziel spacją.", gra.Gracz2.Name);
                    string liczbyGracz2 = "";
                    int    result1      = 0;
                    gra.Gracz2.PodciagCheck = false;
                    while (!gra.Gracz2.PodciagCheck)
                    {
                        liczbyGracz2 = Console.ReadLine();
                        if (int.TryParse(liczbyGracz2.Replace(" ", string.Empty), out result1))
                        {
                            gra.Gracz2.PodciagCheck = true;
                        }
                        else
                        {
                            Console.WriteLine("----------------------------------------------------------------");
                            Console.WriteLine("Nieprawidłowy format danych. Wpisz tylko liczby całkowite oddzielone spacją.");
                        }
                    }

                    gra.Gracz2.WybierzLiczby(liczbyGracz2);
                    Console.WriteLine("----------------------------------------------------------------");
                    Console.WriteLine("Wybrano liczby: " + liczbyGracz2);
                    Console.WriteLine("----------------------------------------------------------------");
                    gra.SprawdzCzyWybranoPoprawneLiczby(gra.Gracz2);
                    gra.WyrzucWybraneLiczby(gra.Gracz2);
                    Console.WriteLine("Aktualne wartości ciągu do wyboru: ");
                    foreach (var item in gra.TabWylosowaneLiczbyAsReadOnly)
                    {
                        Console.WriteLine(item + " ");
                    }
                    Console.WriteLine("----------------------------------------------------------------");
                    if (!(gra.SprawdzCzyMoznaKontynuowac(gra.Gracz2)))
                    {
                        gra.Wygrany = gra.Gracz2.Name;
                    }
                }
            } while (gra.CzyWybranoPoprawneLiczbyDoWyrzucenia && gra.CzySaJeszczeRuchy);

            if (gra.CzyWybranoPoprawneLiczbyDoWyrzucenia == false)
            { //wyrzuca błąd kiedy wartości są błędne np. nieparzyste, niespójne, w ogóle nie istnieją
                gra.Wygrany             = "Przegrałeś! \nWybrany podciąg nie spełnia warunków: parzystości, spójności lub nie istnieje.";
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("KONIEC GRY: " + gra.Wygrany.ToUpper());
                Console.ResetColor();
                Console.WriteLine();
                Console.WriteLine("Czy chcesz zagrać ponownie T/N?");
                string repeat = "";
                repeat = Console.ReadLine();
                if (repeat.ToUpper() == "T")
                {
                    Console.Clear();
                    Run();
                }
            }

            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("KONIEC GRY, WYGRYWA: " + gra.Wygrany.ToUpper());
                Console.ResetColor();
                Console.WriteLine();
                Console.WriteLine("Czy chcesz zagrać ponownie T/N?");
                string repeat = "";
                repeat = Console.ReadLine();
                if (repeat.ToUpper() == "T")
                {
                    Console.Clear();
                    Run();
                }
            }
        }
Exemplo n.º 25
0
 public Kontroler()
 {
     widok = new Widok(this);
     gra   = new ModelGame();
 }
Exemplo n.º 26
0
        public GameAddOrEditDialog(TypeItem typeItem, ModelGame game) : this(typeItem)
        {
            _oldGame                    = game;
            isAddOrEdit                 = true;
            TBox_Name.Text              = _oldGame.Name;
            TB_OpenFileIcon.Text        = _oldGame.PathIcon;
            TB_OpenFileGame.Text        = _oldGame.ItemPath;
            TBox_Params.Text            = _oldGame.StartUpParams;
            TBox_NameProcess.Text       = _oldGame.NameProcess;
            TB_OpenFileMoution.Text     = _oldGame.FileMotion;
            _additionalKeyPressed       = _oldGame.AdditionalKey;
            TBox_AddingKey.Text         = _additionalKeyPressed.ToString();
            TBox_TimeShift.Text         = _oldGame.StartTime.ToString();
            TB_xMousClick.Text          = _oldGame.MouseClickCordX.ToString();
            TB_yMousClick.Text          = _oldGame.MouseClickCordY.ToString();
            CB_TypeStart.SelectedIndex  = (int)_oldGame.TypeStartFocus;
            TB_OpenFileVideoBanner.Text = _oldGame.PathToBannerVideo;

            if (_oldGame.ShiftPressTime == null)
            {
                TB_ShiftClick.Text      = "";
                TS_ShiftClick.IsChecked = false;
            }
            else
            {
                TB_ShiftClick.Text      = _oldGame.ShiftPressTime.Value.ToString();
                TS_ShiftClick.IsChecked = true;
            }

            IconType?iconType = _oldGame.IconType;

            if (iconType == IconType.Image)
            {
                RBtn_Image.IsChecked = true;
            }
            else if (iconType == IconType.Video)
            {
                RBtn_Video.IsChecked = true;
            }

            Key?startUpButtpn = _oldGame.RunKey;

            if (startUpButtpn == Key.Enter)
            {
                RBEnter.IsChecked = true;
            }
            else if (startUpButtpn == Key.Space)
            {
                RBSpace.IsChecked = true;
            }

            if (_oldGame.TimeOut != null)
            {
                selectedTime            = _oldGame.TimeOut.Value.TimeOfDay;
                TP_TimeOut.SelectedTime = selectedTime;
            }
            else
            {
                TP_TimeOut.SelectedTime = new TimeSpan(0, 0, 30);
            }
        }