Ejemplo n.º 1
0
    public void TetrominoFall(Tetromino tetromino)
    {
        if (!IsAboveTopLine(tetromino))
        {
            EndGame?.Invoke();
        }

        AddTetrominoToGrid(tetromino);

        var completedLineIndexes = FindCompletedLines();

        var deletedLineCount = 0;

        foreach (var lineIndex in completedLineIndexes)
        {
            DeleteCompletedLine(lineIndex);
            MoveUpperLinesDown(lineIndex);
            deletedLineCount++;
        }

        if (deletedLineCount > 0)
        {
            LinesDestroyed?.Invoke(deletedLineCount);
        }
    }
Ejemplo n.º 2
0
 private void ChangeEnemyCount(int enemyCount)
 {
     if (_waves.Count == _currentWaveNumber + 1 && enemyCount == 0) // когда текущая волна последняя и не осталось врагов в волне
     {
         EndGame?.Invoke();                                         // вызываем событие конец игры
     }
 }
Ejemplo n.º 3
0
        public void OnGameEnd(GameResult result)
        {
            if (!IsEndGame)
            {
                EndGame?.Invoke(result);

                IsEndGame = true;
            }
        }
Ejemplo n.º 4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.TryGetComponent <Player>(out Player player))
     {
         _nuberOfPlayerEneter++;
         _monologOfDimon?.Invoke();
         EndGame?.Invoke();
     }
 }
Ejemplo n.º 5
0
    public void OnDataEvent(int socketID, int connectionId, byte[] buffer, NetworkError error)
    {
        DataEvent?.Invoke();

        var JsonText = Encoding.Unicode.GetString(buffer);

        NetworkMessage message = JsonConvert.DeserializeObject <NetworkMessage>(JsonText);

        switch (message.MessageType)
        {
        case DataEvents.ConnectionInfoRequest:     // Get connection info and save in connections pool
            //OnConnectionInfoEvent(hostId, connectionId, message, buffer, error);
            break;

        case DataEvents.PlayRequest:     // if connection response is ok, continue. Else, disconnect from node.
            PlayRequest?.Invoke();
            break;

        case DataEvents.PecasDoJogo:     // if connection response is ok, continue. Else, disconnect from node.
            try
            {
                DominoPecas dominoPecas = JsonConvert.DeserializeObject <DominoPecas>(message.Message.ToString());
                GlobalConfigInfo.blockchain.CreateTransaction(GlobalConfigInfo.CurrentAdversary.connectedNode.nickName, GlobalConfigInfo.ThisNode.nickName, dominoPecas);
                PecasDoJogo?.Invoke(dominoPecas);
            }
            catch (Exception e)
            {
                string exc = e.ToString();
            }
            break;

        case DataEvents.PlayerMove:     // call event to deal with this event and every gameplay script who sould know about network info should do your action
            try
            {
                Peca peca = JsonConvert.DeserializeObject <Peca>(message.Message.ToString());
                GlobalConfigInfo.blockchain.CreateTransaction(GlobalConfigInfo.CurrentAdversary.connectedNode.nickName, GlobalConfigInfo.ThisNode.nickName, peca);
                PecaEvent?.Invoke(peca);
            }
            catch (Exception e)
            {
                string exc = e.ToString();
            }

            //PlayerMove?.Invoke();

            break;

        case DataEvents.EndGame:     // call event to deal with this event and every gameplay script who sould know about network info should do your action
            EndGame?.Invoke();
            break;
        }

        print("|Data event: " +
              "/n|HostId: " + socketID +
              "/n|ConnectionId : " + connectionId +
              "/n|Error: " + error.ToString());
    }
Ejemplo n.º 6
0
 private void IsGameFinished()
 {
     if (SticksCurrent != 0)
     {
         return;
     }
     _gameStatus = GameStatus.Finished;
     EndGame?.Invoke(Current == Player.One ? players[(int)Player.Two] : players[(int)Player.One]);
 }
Ejemplo n.º 7
0
 public void Update()
 {
     if (ShouldGameEnd())
     {
         EndGame?.Invoke();
     }
     UpdateBullets();
     UpdateTargets();
     bulletsToRemove.Clear();
 }
 public void EndConversationSimple()
 {
     if (day.var != 2)
     {
         EndDay.Invoke();
     }
     else
     {
         EndGame.Invoke();
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Check is end of game
 /// </summary>
 /// <returns>true if it's end, false if not</returns>
 public static bool CheckEndOfGame()
 {
     if (GameDataHandler.BlackCheckers.Count == 0)
     {
         Clear();
         EndGame?.Invoke(Color.White);
         return(true);
     }
     if (GameDataHandler.WhiteCheckers.Count == 0)
     {
         Clear();
         EndGame?.Invoke(Color.Black);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Stops the game.
        /// </summary>
        protected void StopGame(bool endedByTime)
        {
            _gameTimer.Paused = true;

            _gameData.GainedPoints += (int)Math.Floor(_gameTimer.TimeLeft * _config.UnusedTimeGameBonus);

            if (endedByTime)
            {
                _gameData.TimeSpent = _config.TimePerGame;
            }

            _gameTimer.Stop();
            _taskTimer.Stop();
            HideComponents();
            DisableComponents();

            EndGame?.Invoke(this, new GameDataEventArgs {
                GameData = _gameData
            });
        }
Ejemplo n.º 11
0
        private void TimeLineControl_CheckingAnswerResult(bool isAnswerValid)
        {
            if (counter == numberOfQuestion)
            {
                Dispatcher.Invoke(DispatcherPriority.Render, (Action)(() => { }));
                Thread.Sleep(500);
                Dispatcher.Invoke(DispatcherPriority.Render, (Action)(() => { }));

                EndGame?.Invoke(counter, gamesControlLife.CurrentAmountOfLife, numberOfQuestion, Life.MAXLifeAmount);
            }
            else if (isAnswerValid || gamesControlLife.CurrentAmountOfLife > 0)
            {
                UpdateQuestion(questionList[GetRandom()]);
            }
            else
            {
                Dispatcher.Invoke(DispatcherPriority.Render, (Action)(() => { }));
                Thread.Sleep(500);
                Dispatcher.Invoke(DispatcherPriority.Render, (Action)(() => { }));

                EndGame?.Invoke(counter, gamesControlLife.CurrentAmountOfLife, numberOfQuestion, Life.MAXLifeAmount);
            }
        }
Ejemplo n.º 12
0
 protected virtual void OnEndGame(object sender, Player p) => EndGame?.Invoke(sender, p);
Ejemplo n.º 13
0
        public Repository()
        {
            //Сингтоны движка и сессии
            Engine      = GameEngine.getInstance();
            Engine.Buy += (user) =>
            {
                return(BuyRepo?.Invoke(user)); //Надеюсь, меня не исключат за это говно;
            };
            Engine.BuybackFromPrison += (user) =>
            {
                return(BuybackFromPrisonRepo?.Invoke(user));
            };
            Engine.GetUsersProperties += (user) =>
            {
                GetUsersPropertiesRepo?.Invoke(user);
            };
            Engine.JailRelease += (user) =>
            {
                JailReleaseRepo?.Invoke(user);
            };
            Engine.SetPrison += (user) =>
            {
                SetPrisonRepo?.Invoke(user);
            };
            Engine.Dice += (user, a, b) =>
            {
                DiceRepo?.Invoke(user, a, b);
            };
            Engine.CurrentCell += (user, position) =>
            {
                CurrentCellRepo?.Invoke(user, position);
            };
            Engine.GetCardPick += (user, card) =>
            {
                GetCardPickRepo?.Invoke(user, card);
            };
            Engine.NoEnoughMoney += (user) =>
            {
                NoEnoughMoneyRepo?.Invoke(user);
            };
            Engine.Transaction += (user, priviouse_m, current_m) =>
            {
                TransactionRepo?.Invoke(user, priviouse_m, current_m);
            };
            Engine.SetHouse += (user) =>
            {
                return(ByeHouseRepo?.Invoke(user));
            };
            Engine.RemoveFromGame += (user) =>
            {
                Session.Users.Remove(user);
                if (Session.Users.Count == 1)
                {
                    if (Session.Users.Last() != null)
                    {
                        EndGame?.Invoke(Session.Users.Last());
                    }
                }
            };

            Session = Session.getInstance();
        }
Ejemplo n.º 14
0
 private void OnFinishGroupsMove()
 {
     // Finish the game
     EndGame?.Invoke(GameData.CurrentScore);
 }
Ejemplo n.º 15
0
 public void EndGameRaiseEvent()
 {
     EndGame?.Invoke();
 }
Ejemplo n.º 16
0
 public static void EndGameAction()
 {
     EndGame?.Invoke();
 }
 public void SendEndGame()
 {
     EndGame?.Invoke();
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Occurs when the game end
 /// </summary>
 protected virtual void OnEndGame()
 {
     PauseGame();
     EndGame?.Invoke(this, new EventArgs());
 }
 public static void CallEndGame()
 {
     EndGame?.Invoke();
 }
Ejemplo n.º 20
0
 private void EndScreen_reset(object sender, PropertyChangedEventArgs e)
 {
     EndGame?.Invoke(null, null);
 }
Ejemplo n.º 21
0
 protected virtual void OnEndGame(PlayerType type)
 {
     EndGame?.Invoke(type);
 }
Ejemplo n.º 22
0
 /// <summary>
 ///     Event handler. Called by button2 for click events.
 /// </summary>
 /// <param name="sender"> Source of the event. </param>
 /// <param name="e">      Event information. </param>
 private void button2_Click(object sender, EventArgs e)
 {
     EndGame?.Invoke(this, e);
 }