private void GameCycle() { while (true) { if (menuControl.IsBattle()) { StatusGame?.Invoke("Battle"); if (!battleControl.Start()) { return; } } else { StatusGame?.Invoke("Menu"); if (!menuControl.Start()) { return; } Thread.Sleep(1000); } overlay.UpdateFrame(); overlay.ClearElements(); } }
public bool Is_Game_OVer() { if (Main_Player != null) { if (!Main_Player.GetComponent <Enemy>().isGround) { int count = 0; for (int i = 0; i < player.Length; i++) { if (player[i].GetComponent <Enemy>().isGround) { Debug.Log(player[i].name + " " + "Out"); count++; } } if (count != 1) { isGameOver = true; } else { isGameOver = false; Status = StatusGame.End_Game; } } else { isGameOver = false; // } return(isGameOver); } return(false); }
} // Get game status // Constructor public MineBoard(int iNumRows = 10, int iNumColumns = 10, int iNumMines = 8) { if ( // Wrong entry protection, default values iNumRows < 1 || iNumRows > MAX_ROWS || iNumColumns < 1 || iNumColumns > MAX_COLUMNS || iNumMines < 0 || iNumMines > iNumRows * iNumColumns) { numRows = 10; numColumns = 10; numMines = 8; } else { // If all values are correct, add those to class members numRows = iNumRows; numColumns = iNumColumns; numMines = iNumMines; } /* Debug * Console.WriteLine("Number of rows: " + numRows); * Console.WriteLine("Number of columns: " + numColumns); * Console.WriteLine("Number of mines: " + numMines); */ // Initialization of rest of class members numOpenedFields = 0; status = StatusGame.NotSolved; matrixMines = new int[numRows, numColumns]; openedField = new bool[numRows, numColumns]; // Generate random numbers, set mines Random random = new Random(); for (int i = 0; i < numMines; ++i) { int mina = random.Next(0, numRows * numColumns); /* Debug * Console.WriteLine("Random: " + mina); * Console.WriteLine("row: " + mina / numColumns); * Console.WriteLine("column: " + mina % numColumns); */ // In case of mine repeated on place where mine already exist, set mine on next free field // With this, time to set all mines is shorten while (matrixMines[mina / numColumns, mina % numColumns] == 9) { ++mina; if (mina == numRows * numColumns) { mina = 0; } } matrixMines[mina / numColumns, mina % numColumns] = 9; } }
public void checkEndGameCollectable(Vector2 positionCollectable) { StatusGame status = boardScript.checkEndGame(0, 1); if (status.Equals(StatusGame.VICTORY)) { StartCoroutine(doVictory(positionCollectable)); } }
public void EndGame() { isGameOver = true; isGamePause = true; Status = StatusGame.None; for (int i = 0; i < player.Length; i++) { player[i].GetComponent <Enemy>().Destroy(); } }
public Boolean checkEndGameCommand() { StatusGame status = boardScript.checkEndGame(1, 0); levelManager.setTextCommands(boardScript.getCommandsRemaining()); if (status.Equals(StatusGame.DEFEAT)) { StartCoroutine(doDefeat(false)); return(true); } return(false); }
public void Claim() { if (!Is_End_Game()) { Status = StatusGame.Watching; } else { var a = Instantiate(SpawnEffect.Instance.getEffectName("Status"), null); a.GetComponent <Status>().SetText("THE MATCH ENDED !!!"); } }
public void Start_Game() { WaitForStart.gameObject.SetActive(true); Status = StatusGame.Wait; DestroyAll(); InforMap inforMap = GameObject.Find("Map").GetComponent <InforMap>(); Radius = inforMap.Radius; Ground = inforMap.Ground; Count_Player = DataMananger.Instance.CountPlayer; WaitForStart.GetComponent <WaitForStart>().Start_Waitting(); Reset_Game(); }
public void SetGame(Color startColor, StatusPlayer pl1, StatusPlayer pl2, int depth1, int depth2, Search s1, Search s2, Evaluate e1, Evaluate e2, StatusGame statusGame) { statusApplication = StatusApplication.game; color = startColor; statusPlayer[(int)color] = pl1; statusPlayer[(int)GetOtherColor(color)] = pl2; statusSearch[(int)color] = s1; statusSearch[(int)GetOtherColor(color)] = s2; statusDepth[(int)color] = depth1; statusDepth[(int)GetOtherColor(color)] = depth2; statusEvaluate[(int)color] = e1; statusEvaluate[(int)GetOtherColor(color)] = e2; this.statusGame = statusGame; }
public SkinNotifyGame(StatusGame statusGame) { InitializeComponent(); if (statusGame == StatusGame.Win) { this.btn_Title.BackgroundImage = global::DCN.TicTacToe.UI.Properties.Resources.text_win; this.btn_Star.BackgroundImage = global::DCN.TicTacToe.UI.Properties.Resources.star_win; } else if (statusGame == StatusGame.Lose) { this.btn_Title.BackgroundImage = global::DCN.TicTacToe.UI.Properties.Resources.text_lose; this.btn_Star.BackgroundImage = global::DCN.TicTacToe.UI.Properties.Resources.star_lose; } else if (statusGame == StatusGame.Tie) { this.btn_Title.BackgroundImage = global::DCN.TicTacToe.UI.Properties.Resources.text_tie; this.btn_Star.BackgroundImage = global::DCN.TicTacToe.UI.Properties.Resources.star_tie; } }
private void IsVisibleButtons(StatusGame statusGame) { if (statusGame == StatusGame.StartGame) { _buttonSetBet.Visibility = ViewStates.Visible; _buttonShowCard.Visibility = ViewStates.Invisible; _buttonGetCard.Visibility = ViewStates.Invisible; _buttonDoubleBet.Visibility = ViewStates.Invisible; _buttonContinue.Visibility = ViewStates.Invisible; _info.Text = ""; } else if (statusGame == StatusGame.Play) { _buttonSetBet.Visibility = ViewStates.Invisible; _buttonShowCard.Visibility = ViewStates.Visible; _buttonGetCard.Visibility = ViewStates.Visible; _buttonDoubleBet.Visibility = ViewStates.Visible; _buttonContinue.Visibility = ViewStates.Invisible; _info.Text = ""; } else if (statusGame == StatusGame.Win || statusGame == StatusGame.Losing || statusGame == StatusGame.Draw) { _buttonSetBet.Visibility = ViewStates.Invisible; _buttonShowCard.Visibility = ViewStates.Invisible; _buttonGetCard.Visibility = ViewStates.Invisible; _buttonDoubleBet.Visibility = ViewStates.Invisible; _buttonContinue.Visibility = ViewStates.Visible; _info.Text = statusGame.ToString(); } else //Game Over { _buttonSetBet.Visibility = ViewStates.Invisible; _buttonShowCard.Visibility = ViewStates.Invisible; _buttonGetCard.Visibility = ViewStates.Invisible; _buttonDoubleBet.Visibility = ViewStates.Invisible; _buttonContinue.Visibility = ViewStates.Invisible; _info.Text = statusGame.ToString(); } }
private void GameRequestHandler(GameRequest request) { StatusGame sg = request.BoardGame.GetStatementGame(); this.CountDownInGame.Reset(); this.OtherSideReceiver.CountDownInGame.Reset(); request.BoardGame = request.BoardGame.SwapZvO(); this.OtherSideReceiver.SendMessage(request); if (sg == StatusGame.Win) { SendMsgToClientsOneByOne(new Receiver[] { this, this.OtherSideReceiver }, new MessageBase[] { new GameResponse(request, sg), new GameResponse(request, StatusGame.Lose) } ); this.InGameProperties.WinGame += 1; PropertiesForEndGame(); SendMsgToClients(new Receiver[] { this, this.OtherSideReceiver }, new AcceptPlayRequest()); } else if (sg == StatusGame.Tie) { SendMsgToClientsOneByOne(new Receiver[] { this, this.OtherSideReceiver }, new MessageBase[] { new GameResponse(request, sg), new GameResponse(request, StatusGame.Tie) } ); this.InGameProperties.WinGame += 1; this.OtherSideReceiver.InGameProperties.WinGame += 1; PropertiesForEndGame(); SendMsgToClients(new Receiver[] { this, this.OtherSideReceiver }, new AcceptPlayRequest()); } }
public void NewGame() { StatusGame = StatusGame.Play; score = 0; OnNewGame(); }
public void PreviewGame() { StatusGame = StatusGame.Preview; OnPreview(); }
public bool HumanStep(int x, int y) //true если ход закончен { bool isWay = board[x, y].GetIsWay(); switch (statusGame) { case StatusGame.wait: if (board[x, y].GetColor() == color) { SelectCheckerAndSearchWay(x, y); statusGame = StatusGame.waitStep; } return(false); case StatusGame.waitStep: if (board[x, y].GetIsWay()) { MoveChecker(moves.selectedChecker, x, y); ClearWays(); statusGame = StatusGame.wait; return(true); } if (board[x, y].GetIsLight()) { return(false); } if (board[x, y].GetColor() == color) { ClearWays(); ClearSelected(); SelectCheckerAndSearchWay(x, y); return(false); } ClearWays(); ClearSelected(); statusGame = StatusGame.wait; return(false); case StatusGame.waitEat: if (board[x, y].GetIsLight()) { SelectCheckerAndSearchEat(x, y); statusGame = StatusGame.waitEatSelect; return(false); } ClearWays(); return(false); case StatusGame.waitEatSelect: if (board[x, y].GetIsWay()) { if (MakeEat(moves.selectedChecker, x, y) == true) { ClearWays(); ClearSelectedCanEat(); statusGame = StatusGame.wait; return(true); } else { ClearWays(); ClearSelectedCanEat(); SelectCheckerAndSearchEat(x, y); statusGame = StatusGame.eating; return(false); } } if (board[x, y] == moves.selectedChecker) { return(false); } if (board[x, y].GetIsLight()) { ClearWays(); SelectCheckerAndSearchEat(x, y); return(false); } ClearWays(); statusGame = StatusGame.waitEat; return(false); case StatusGame.eating: if (board[x, y].GetIsWay()) { if (MakeEat(moves.selectedChecker, x, y) == true) { ClearWays(); ClearSelectedCanEat(); statusGame = StatusGame.wait; return(true); } ClearWays(); ClearSelectedCanEat(); SelectCheckerAndSearchEat(x, y); return(false); } return(false); } return(false); }
// Open field, count mines around requested field and open all fields // surrounding requested field if there are no mines around public StatusOpenField OpenField(int row, int column) { // Wrong entry protection if (row < 0 || row >= numRows || column < 0 || column >= numColumns) { return(StatusOpenField.ErrorWrongEntry); } // Open already opened field protection and open field when game over protection // Exit condition for recursive calls if (status == StatusGame.NotSolved && !openedField[row, column]) { int foundMines = 0; openedField[row, column] = true; // Mine opened, Show rest of mines and finish the game if (matrixMines[row, column] == 9) { for (int i = 0; i < numRows; ++i) { for (int j = 0; j < numColumns; ++j) { if (matrixMines[i, j] == 9) { openedField[i, j] = true; } } } status = StatusGame.Lose; return(StatusOpenField.Ok); } // Counting mines around the field // Up left if (row - 1 >= 0 && column - 1 >= 0) { if (matrixMines[row - 1, column - 1] == 9) { ++foundMines; } } // Up if (row - 1 >= 0) { if (matrixMines[row - 1, column] == 9) { ++foundMines; } } // Up right if (row - 1 >= 0 && column + 1 < numColumns) { if (matrixMines[row - 1, column + 1] == 9) { ++foundMines; } } // Right if (column + 1 < numColumns) { if (matrixMines[row, column + 1] == 9) { ++foundMines; } } // Down right if (row + 1 < numRows && column + 1 < numColumns) { if (matrixMines[row + 1, column + 1] == 9) { ++foundMines; } } // Down if (row + 1 < numRows) { if (matrixMines[row + 1, column] == 9) { ++foundMines; } } // Down left if (row + 1 < numRows && column - 1 >= 0) { if (matrixMines[row + 1, column - 1] == 9) { ++foundMines; } } // Left if (column - 1 >= 0) { if (matrixMines[row, column - 1] == 9) { ++foundMines; } } // Mines counted, write mines count in field matrix matrixMines[row, column] = foundMines; ++numOpenedFields; // If all fields are opened, game over if (numOpenedFields == numRows * numColumns - numMines) { for (int i = 0; i < numRows; ++i) { for (int j = 0; j < numColumns; ++j) { if (!openedField[i, j]) { openedField[i, j] = true; } } } status = StatusGame.Win; return(StatusOpenField.Ok); } /* debug * Console.WriteLine("Open field: [{0}, {1}]", row, column); * Console.WriteLine("Number of open fields: " + numOpenedFields); */ // No mines around, open all surrounding fields (recursive calls) if (foundMines == 0) { // Up left if (row - 1 >= 0 && column - 1 >= 0) { OpenField(row - 1, column - 1); } // Up if (row - 1 >= 0) { OpenField(row - 1, column); } // Up right if (row - 1 >= 0 && column + 1 < numColumns) { OpenField(row - 1, column + 1); } // Right if (column + 1 < numColumns) { OpenField(row, column + 1); } // Down right if (row + 1 < numRows && column + 1 < numColumns) { OpenField(row + 1, column + 1); } // Down if (row + 1 < numRows) { OpenField(row + 1, column); } // Down left if (row + 1 < numRows && column - 1 >= 0) { OpenField(row + 1, column - 1); } // Left if (column - 1 >= 0) { OpenField(row, column - 1); } } return(StatusOpenField.Ok); // No error, everything's fine } else // Field has been already opened or game over { if (openedField[row, column]) { return(StatusOpenField.ErrorFieldOpen); } else { return(StatusOpenField.ErrorGameSolved); } } }
private async void conn_Click(object sender, RoutedEventArgs e) { conn.IsEnabled = false; opv.Content = "Спроба підключення."; await Task.Run(() => { if (factory == null) { factory = new DuplexChannelFactory<IService>(new InstanceContext(callback), new NetTcpBinding(), new EndpointAddress(new Uri(@"net.tcp://" + config.IpClient + ":" + config.PortClient + "/IService"))); chanel = factory.CreateChannel(); } try { if (chanel.ClientConnect(ref message)) { var p = chanel.GetPlayer(); CurrentStatusGame = StatusGame.WaitPlayer; //waitPlayer.Visibility = System.Windows.Visibility.Visible; namePlayer1.Content = p[0].Name; this.Dispatcher.Invoke(() => { waitPlayer.Visibility = System.Windows.Visibility.Visible; namePlayer1.Content = p[0].Name; }); //if (p[1] != null) { namePlayer2.Content = p[1].Name; wait.Content = "Ready?"; opv.Content = ""; } if (p[1] != null) { this.Dispatcher.Invoke(() => { namePlayer2.Content = p[1].Name; wait.Content = "Ready?"; opv.Content = ""; }); } } // else opv.Content = "Кімната вже повна."; else this.Dispatcher.Invoke(() => { opv.Content = "Кімната вже повна."; }); } catch (Exception) { //opv.Content = "Звьязок з хостом було втрачено."; this.Dispatcher.Invoke(() => { opv.Content = "Звьязок з хостом було втрачено."; }); factory.Abort(); factory = null; } }); conn.IsEnabled = true; }
public MainWindow() { InitializeComponent(); _x.Visibility = System.Windows.Visibility.Visible; callback.ClientConnected += (s, e) => { if (e._Message.Identify == 1) namePlayer2.Content = e._Message.Name; else namePlayer1.Content = e._Message.Name; start.IsEnabled = true; wait.Content = "Гру можна розпочинати!"; }; callback.ClientStepped += (s, e) => { listAction.Clear(); selectedChecker = allLocation[e.Index].IsChecker; listAction.Add(e.Step); Step_2_(); if (selectedChecker.user == User.Left) InitializeRight(); else InitializeLeft(); }; callback.ClientMessaged += (s, e) => { TextBlock t = new TextBlock() { Text = e._Message.Name + "[" + e._Message.Data.TimeOfDay + "]: " + e._Message }; t.TextWrapping = TextWrapping.Wrap; if (e._Message.Identify != message.Identify) { t.Foreground = Brushes.Blue; t.Margin = new Thickness() { Left = 35, Right = 10, Top = 10 }; boxMessage.Children.Add(t); } else { t.Foreground = Brushes.Green; t.Margin = new Thickness() { Left = 10, Right = 10, Top = 10 }; boxMessage.Children.Add(t); } }; callback.ClientDisconnected += (s, e) => { if (CurrentStatusGame == StatusGame.Play) { serverIsDown.Visibility = System.Windows.Visibility.Visible; chanel.RemoveUser(message); eventPlay.Text = "Гравець покинув гру!"; } else if (CurrentStatusGame == StatusGame.WaitPlayer) { start.IsEnabled = false; if (e._Message.Identify == 1) namePlayer2.Content = "-----_--"; else namePlayer1.Content = "-----_--"; wait.Content = "Очікування граця!"; } }; callback.Run += () => { //InitializeRight(); if (!leftChecker[0].ThisChecker.IsEnabled) { for (byte i = 0; i < rightChecker.Count; i++) { rightChecker[i].ThisChecker.IsEnabled = false; } } player_1.Content = namePlayer1.Content; player_2.Content = namePlayer2.Content; waitPlayer.Visibility = System.Windows.Visibility.Hidden; mainMenu.Visibility = System.Windows.Visibility.Hidden; CurrentStatusGame = StatusGame.Play; }; }
public void SetStatusGame(StatusGame statusGame) { this.statusGame = statusGame; }
public GameInformation(Diller diller, Player player, StatusGame statusGame) { _diller = diller; _player = player; _statusGame = statusGame; }
public void GameOver() { StatusGame = StatusGame.Over; OnGameOver(); }
public bool BotStep() { switch (statusGame) { case StatusGame.wait: statusGame = StatusGame.сalculating; SetArraysForBotStep(); int res = CallBot(w_coords, w_types, w_n, b_coords, b_types, b_n, (int)color, statusDepth[(int)color], (int)statusSearch[(int)color], (int)statusEvaluate[(int)color]); DecipherRes(res); if (botMove.end == 1) { statusGame = StatusGame.gameOver; return(true); } if (botMove.eaten.Count == 0) { ShowBotWay(botMove.way[0].Item1, botMove.way[0].Item2); statusGame = StatusGame.waitStep; } else { botMove.SearchInterm(); ShowBotWay(botMove.interm[0].Item1, botMove.interm[0].Item2); if (botMove.eaten.Count > 1) { statusGame = StatusGame.eating; } else { statusGame = StatusGame.endEating; } } return(false); case StatusGame.waitStep: MoveChecker(botMove.selectedChecker, botMove.way[0].Item1, botMove.way[0].Item2); botMove.Clear(); statusGame = StatusGame.wait; return(true); case StatusGame.eating: MoveChecker(botMove.selectedChecker, botMove.interm[0].Item1, botMove.interm[0].Item2); botMove.interm.Remove(botMove.interm[0]); ShowBotWay(botMove.interm[0].Item1, botMove.interm[0].Item2); if (botMove.interm[0] == botMove.way[0]) { statusGame = StatusGame.endEating; } return(false); case StatusGame.endEating: MoveChecker(botMove.selectedChecker, botMove.way[0].Item1, botMove.way[0].Item2); foreach (Checker ch in botMove.eaten) { DeleteChecker(ch.x, ch.y); } botMove.Clear(); statusGame = StatusGame.wait; return(true); case StatusGame.gameOver: return(true); case StatusGame.сalculating: return(false); } return(false); }
private void FixedUpdate() { if (Application.internetReachability == NetworkReachability.NotReachable) { if (isPlayingGame) { if (connect) { connect = false; Windown.OpenWindow(Windown_Type.End_Game); GamePlayerCtrl.Instance.Event_Over_Game(); Stop_All_Player(); GameMangaer.Instance.Open_Screen(Screen_Type.Screen_Start); var a = Instantiate(SpawnEffect.Instance.getEffectName("Status"), null); a.GetComponent <Status>().SetText("YOU ARE DISCONNECTED INTERNET !!!"); } } } else { connect = true; if (Status == StatusGame.Back_To_Game) { GamePlayerCtrl.Instance.Event_Over_Game(); GameMangaer.Instance.Open_Screen(Screen_Type.Screen_Start); Status = StatusGame.None; } if (Status == StatusGame.Out_Game) { if (Is_End_Game()) { Status = StatusGame.End_Game; Debug.Log("END_GAME"); Windown.CloseWindow(Windown_Type.End_Game); } } if (Status == StatusGame.Play) { if (Is_Game_OVer()) { Status = StatusGame.End_Game; Debug.Log("GameOVer"); //Windown.OpenWindow(Windown_Type.Game_Over); Windown.CloseWindow(Windown_Type.End_Game); } if (Is_End_Game()) { Status = StatusGame.End_Game; Debug.Log("END_GAME"); Windown.CloseWindow(Windown_Type.End_Game); } } if (Status == StatusGame.Watching) { if (isGameOver) { Windown.CloseWindow(Windown_Type.Game_Over); Windown.OpenWindow(Windown_Type.Watching); } Status = StatusGame.Out_Game; } if (Status == StatusGame.End_Game) { Windown.OpenWindow(Windown_Type.End_Game); Status = StatusGame.None; } } }
public StatusGameRequest(StatusGame status) { StatusGame = status; }
private void singl_Click(object sender, RoutedEventArgs e) { temp = true; textSend.IsEnabled = false; //sendMessage.IsEnabled = false; player_1.Content = config.Name; player_2.Content = "noobo_Bot"; CurrentStatusGame = StatusGame.Play; mainMenu.Visibility = System.Windows.Visibility.Hidden; sendMessage.IsEnabled = false; for (byte i = 0; i < leftChecker.Count; i++) { leftChecker[i].ThisChecker.IsEnabled = false; } }
// Use this for initialization void Start() { InitFromRemoteData(); _resourceManager = GetComponent<ResourceManager>(); _resourceManager.Init((int)SizesTextures.Count, 128, 32); //128 наборов текстур. 32 - наименьшей размер текстур // Выяснение размеров игрового поля и инициализация полетной длинны в абстрактном классе префабов if (_quadGameField == null) { _quadGameField = transform.FindChild(DEFAULT_NANE_QUAD_GAME_FIELD); if (_quadGameField == null) DebugF.LogError( "Корректная работа не возможна т.к. поле {0} не инициализировано" + " и в текущем объекте нет Quad'а c именем по умолчанию \"{1}\"", _quadGameField.GetType().GetProperties()[0].Name, DEFAULT_NANE_QUAD_GAME_FIELD); } BehaviourPrefab.HalfFlightLength = _quadGameField.localScale.y/2; // Инициализация статуса игры _currentStatus = new StatusGame(_initialLaunchRate); // Инициализация фабрики _factory = GetComponent<FactoryPrefabs>(); _factory.Init(_quadGameField.localScale.x/2, _resourceManager.textures); // Запуск обновления прошедшего времени InvokeRepeating("UpdateElapsedTime", 0.0f, 1.0f); // Запускаю выдачу игровых объектов InvokeRepeating("RunPrefab", 0.0f, _currentStatus.launchRate); }
public void Back_To_Game() { ManagerAds.Ins.ShowInterstitial(); Status = StatusGame.Back_To_Game; }
private void optoinCencel_Click(object sender, RoutedEventArgs e) { optionWindow.Visibility = System.Windows.Visibility.Hidden; optionSave.IsEnabled = false; CurrentStatusGame = StatusGame.MainMenu; }
private void waitWindowCancel_Click(object sender, RoutedEventArgs e) { try { chanel.RemoveUser(message); } catch (Exception) { } waitPlayer.Visibility = System.Windows.Visibility.Hidden; start.IsEnabled = false; wait.Content = "Очікування гравця!"; CurrentStatusGame = StatusGame.MainMenu; }
private void option_Click(object sender, RoutedEventArgs e) { pClient.Text = config.PortClient; ipClient.Text = config.IpClient; pServer.Text = config.PortServer; ipServer.Text = config.IpServer; name.Text = config.Name; optionWindow.Visibility = System.Windows.Visibility.Visible; CurrentStatusGame = StatusGame.Option; }
public StatusGameRequest() { StatusGame = StatusGame.Continue; }
private void start_Click(object sender, RoutedEventArgs e) { for (byte i = 0; i < leftChecker.Count; i++) { leftChecker[i].ThisChecker.IsEnabled = false; } chanel.Begin(); player_1.Content = namePlayer1.Content; player_2.Content = namePlayer2.Content; waitPlayer.Visibility = System.Windows.Visibility.Hidden; mainMenu.Visibility = System.Windows.Visibility.Hidden; CurrentStatusGame = StatusGame.Play; }
public SkinFrmLogin(StatusGame statusGame) { InitializeComponent(); }
public GameResponse(GameRequest request, StatusGame gameStatus) : base(request) { Game = gameStatus; }