Наследование: MonoBehaviour
Пример #1
0
 private void OnApplicationQuit()
 {
     if (endGame != null)
     {
         endGame = null;
     }
 }
Пример #2
0
        public void EndGame(bool win)
        {
            OpenMinedCells();

            var endGame = new EndGame();

            var time = view.EndGame();

            endGame.SetTime(time);

            endGame.SetGameResult(win);

            var result = endGame.ShowDialog();

            var lastResult = highScores.GetLastResult(settings.Level);

            if (win && settings.Level != Settings.Levels.Special && (lastResult >= time || lastResult == -1))
            {
                var nameForm = new NameForm();
                var name     = nameForm.GetName();

                WriteToFile(Convert.ToString(time) + '—' + DateTime.Now.ToShortDateString() + '—' +
                            name, $"..\\..\\Resources\\highScores{settings.Level}.txt");
            }

            if (result == DialogResult.Yes)
            {
                SetSettings(Settings.Levels.This);
            }
            else if (result == DialogResult.No)
            {
                Application.Exit();
            }
        }
        private string MakeATurn(int userXint)
        {
            //1. IF reached the top
            if (Settings.YCoordinate[userXint - 1] < 0)
            {
                //The column is full
                return("reload");
            }
            Settings.Board[Settings.YCoordinate[userXint - 1], userXint - 1] = Settings.IsPlayerOne ? CellState.X : CellState.O;
            Settings.NumTurns++;
            //IF win condition was fulfilled
            if (EndGame.GameOver(userXint, Settings))
            {
                GameOver = true;
                return("reload");
            }
            //IF board is full
            if (Settings.NumTurns == Settings.BoardHeight * Settings.BoardWidth)
            {
                FullBoard = true;
                return("reload");
            }
            // IF not change player, save state and let's continue

            Settings.YCoordinate[userXint - 1]--;
            Settings.IsPlayerOne = !Settings.IsPlayerOne;

            RuntimeData.GameSettings = Settings;
            return("OK");
        }
Пример #4
0
    public List <Event> SetEvents()
    {
        List <Event> events = new List <Event>();

        Event pAtack1 = new PirateEncounter1();

        events.Add(pAtack1);

        Event pAtack2 = new PirateEncounter2(pAtack1);

        events.Add(pAtack2);

        Event merchant = new MerchantArrive();

        events.Add(merchant);

        Event refugees = new RefugeesAarrive();

        events.Add(refugees);

        Event endGame = new EndGame();

        events.Add(endGame);

        return(events);
    }
Пример #5
0
 private void ChangeEnemyCount(int enemyCount)
 {
     if (_waves.Count == _currentWaveNumber + 1 && enemyCount == 0) // когда текущая волна последняя и не осталось врагов в волне
     {
         EndGame?.Invoke();                                         // вызываем событие конец игры
     }
 }
        public async Task End_EmptyPayload_ReturnsBadRequest()
        {
            var command  = new EndGame();
            var response = await client.PutAsync($"/games/{Guid.NewGuid()}/end", command.ToContent());

            response.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
        }
Пример #7
0
    void Update()
    {
        if (isWin)
        {
            defaultActionWinlose();
            win();
        }

        if (isLose)
        {
            defaultActionWinlose();
            lose();
        }

        timer -= Time.deltaTime;
        if (timer < 0)
        {
            Debug.Log("TIME");
            object[] allBloks = GameObject.FindGameObjectsWithTag("Block");
            //ExploitBlock
            object[] allBloksExploids = GameObject.FindGameObjectsWithTag("ExploitBlock");
            if (allBloks.Length == 0 && allBloksExploids.Length == 0)
            {
                EndGame.WinLoseAction(true);
            }
            timer = 3f;
        }
    }
Пример #8
0
 void Start()
 {
     _dayTimer = GameObject.Find("Timer").GetComponent <DayTimer>();
     _endGame  = GameObject.Find("HarbourCanvas").GetComponent <EndGame>();
     _col      = gameObject.GetComponent <BoxCollider>();
     ChangeSightSize();
 }
Пример #9
0
    //Handles the player clicking a tile.
    public override void handlePlayerAt(int x, int y)
    {
        //Get the staterep location and updating it with the correct value
        latestStateRep[x * 9 + y] = playerIndx == 0 ? 2 : 1;
        //Change the players turn
        currentPlayersTurn = (currentPlayersTurn + 1) % 2;
        //Update the number of moves
        numbMovesPlayed++;
        //Set up the last state
        latestAIState = new HexAIState(playerIndx, null, 0, latestStateRep, numbMovesPlayed);
        //Find out the result of the board
        int result = latestAIState.getWinner();

        //And the end game as such
        if (result >= 0)
        {
            if (result == 2)
            {
                winlose.text = "You drew!";
            }
            else if (result == playerIndx)
            {
                winlose.text = "You won!";
            }
            else
            {
                winlose.text = "You lost!";
            }
            gamePlaying = false;
            EndGame.SetActive(true);
        }
    }
Пример #10
0
        void Start()
        {
            Instance = this;
            if (playerPrefab == null)
            {
                Debug.LogError("<Color=Red><a>Missing</a></Color> playerPrefab Reference. Please set it up in GameObject 'Game Manager'", this);
            }
            else
            {
                Debug.LogFormat("We are Instantiating LocalPlayer from {0}", Application.loadedLevelName);
                // we're in a room. spawn a character for the local player. it gets synced by using PhotonNetwork.Instantiate
                if (PlayerManager.LocalPlayerInstance == null)
                {
                    Debug.LogFormat("We are Instantiating LocalPlayer from {0}", SceneManagerHelper.ActiveSceneName);
                    // we're in a room. spawn a character for the local player. it gets synced by using PhotonNetwork.Instantiate
                    PhotonNetwork.Instantiate(this.playerPrefab.name, new Vector3(0f, 5f, 0f), Quaternion.identity, 0);
                    playerPrefab.GetComponent <FPSController>().enabled = true;
                    playerCam = playerPrefab.transform.Find("Camera").gameObject;
                    playerCam.gameObject.SetActive(true);
                }
                else
                {
                    Debug.LogFormat("Ignoring scene load for {0}", SceneManagerHelper.ActiveSceneName);
                }
            }

            endGameObj = GameObject.FindGameObjectWithTag("EndGame").GetComponent <EndGame>();
        }
Пример #11
0
        // Constructor
        public GameWindow()
        {
            InitializeComponent();

            // Form properties
            StartPosition = FormStartPosition.CenterScreen;
            BackColor     = Color.LightBlue;
            MaximumSize   = new Size(655, 531);
            Size          = new Size(655, 531);

            // Label properties
            scoreText.Text        = "0";
            instructions.Text     = "Press s to start, enter for menu, tab for name input";
            instructions.Font     = new Font(instructions.Font.FontFamily, 14);
            instructions.Location = new Point(100, 200);
            instructions.Visible  = true;

            // Collision event
            collision = new EndGame();
            collision.CollisionOccurrence += new CollisionOccurrenceEventHandler(collision_CollisionOccurrence);

            // Add objects to list
            pictureBoxList.Add((PictureBox)Controls.Find("pipeBottom", true)[0]);
            pictureBoxList.Add((PictureBox)Controls.Find("pipeTop", true)[0]);
            pictureBoxList.Add((PictureBox)Controls.Find("flappyBird", true)[0]);

            pictureBoxList[0].Size = new Size(100, 250);
            pictureBoxList[1].Size = new Size(100, 250);

            pictureBoxList[0].Location = new Point(428, 300);
            pictureBoxList[1].Location = new Point(321, -100);

            // Disable game timer until user input
            gameTimer.Enabled = false;
        }
Пример #12
0
    void Update()
    {
        //foreach (GameObject forBall in GameObject.FindGameObjectsWithTag("Ball")) {

        //Instantiate(respawnPrefab, respawn.transform.position, respawn.transform.rotation) as GameObject;
        //}
        if (GameObject.FindGameObjectsWithTag("Ball").Length == 0 && GameObject.FindGameObjectsWithTag("SmallBall").Length == 0)
        {
            //Говорим прощай жизнь и создаем мячик


            timer -= Time.deltaTime;
            if (timer < 0)
            {
                if (CorrectLife.getLife() > 0)
                {
                    GameObject newBall = Instantiate(createBall) as GameObject;
                    newBall.gameObject.tag = "Ball";
                    newBall.gameObject.GetComponent <BallV2>().isResetBall = true;
                    //Выводим надпись предупреждающую

                    CorrectLife.decLife();
                }
                else
                {
                    //Сообщаем что игра закончена и предлагаем переиграть... т.е. выводим меню
                    EndGame.WinLoseAction(false);
                }

                timer = 0.5f;
            }
        }
    }
 public ReversiBoard(ReversiBoard board, bool isVisualBoard)
 {
     this.gameBoard = new int[8, 8];
     for (int i = 0; i < 8; ++i)
         for (int j = 0; j < 8; ++j)
         {
             this.gameBoard[i, j] = board.gameBoard[i, j];
             this.safeDisc[i, j] = board.safeDisc[i, j];
         }
     this.currentPlayer = board.currentPlayer;
     this.blackCount = board.blackCount;
     this.whiteCount = board.whiteCount;
     this.emptyCount = board.emptyCount;
     GameOver += new EndGame(calculateWinner);
     this.players = board.players;
     this.validMoves = new bool[8, 8];
     if (isVisualBoard)
     {
         this.MoveComplete = board.MoveComplete;
         this.NoLegalMoveAvailable = board.NoLegalMoveAvailable;
         this.GameOver += board.GameOver;
     }
     updateValidMoves(board.previousPlayerHadMoves);
     updateCounters();
 }
Пример #14
0
 void PopulateLists()
 {
     _player         = GameObject.FindWithTag("Player");
     _endGame        = GameObject.Find("HarbourCanvas").GetComponent <EndGame>();
     _dayTimer       = GameObject.Find("Timer").GetComponent <DayTimer>();
     _dayCycle       = GameObject.Find("MainLight").GetComponent <DayCycle>();
     _rumourScript   = GameObject.Find("TownCanvas").GetComponent <RumourGenerator>();
     _playerControls = _player.GetComponent <PlayerControls_WM>();
     _towns.AddRange(GameObject.FindGameObjectsWithTag("Town"));
     for (int i = 0; i < _towns.Count; i++)
     {
         _buildingScripts.Add(_towns[i].GetComponent <TownManager>());
     }
     _factoryGO.AddRange(GameObject.FindGameObjectsWithTag("Factory"));
     for (int i = 0; i < _factoryGO.Count; i++)
     {
         _factories.Add(_factoryGO[i].GetComponent <Factories>());
     }
     _resourceSpawns.AddRange(GameObject.FindGameObjectsWithTag("ResourceSpawn"));
     for (int i = 0; i < _resourceSpawns.Count; i++)
     {
         _resourceGens.Add(_resourceSpawns[i].GetComponent <ResourceGen>());
     }
     _fowGO.AddRange(GameObject.FindGameObjectsWithTag("FOW"));
     for (int i = 0; i < _fowGO.Count; i++)
     {
         _fow.Add(_fowGO[i].GetComponent <FOW>());
     }
     _spawnGOs.AddRange(GameObject.FindGameObjectsWithTag("Spawn Point"));
     for (int i = 0; i < _spawnGOs.Count; i++)
     {
         _spawns.Add(_spawnGOs[i].GetComponent <SpawnPoint>());
     }
 }
Пример #15
0
 // Update is called once per frame
 void Update()
 {
     if (EndGame.GetEndGame())
     {
         sceneChange.ChangeScene();
     }
 }
Пример #16
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         EndGame.SetEndTimeGame(true);
     }
 }
        public async Task <IActionResult> EndGame([NotEmptyGuid, FromRoute] Guid id, [BindRequired, FromBody] EndGame command)
        {
            command.GameId = id;
            await this.commandBus.Send(command);

            return(Ok());
        }
Пример #18
0
    void Start()
    {
        tiles.Add(tile1);
        tiles.Add(tile2);
        tiles.Add(tile3);
        tiles.Add(tile4);
        tiles.Add(tile5);
        tiles.Add(tile6);
        tiles.Add(tile7);
        tiles.Add(tile8);
        tiles.Add(tile9);
        tiles.Add(tile10);
        tiles.Add(tile11);
        tiles.Add(tile12);
        tiles.Add(tile13);
        tiles.Add(tile14);
        tiles.Add(tile15);
        tiles.Add(tile16);
        tiles.Add(tile17);
        tiles.Add(tile18);
        tiles.Add(tile19);
        tiles.Add(tile20);
        tiles.Add(tile21);
        tiles.Add(tile22);

        tileRots.Add(tileRot1);
        tileRots.Add(tileRot2);
        tileRots.Add(tileRot3);
        tileRots.Add(tileRot4);

        endGame = GameObject.FindGameObjectWithTag("EndGame").GetComponent <EndGame> ();
    }
Пример #19
0
 // Start is called before the first frame update
 void Start()
 {
     myRigidBody2D        = GetComponent <Rigidbody2D>();
     scoreHandlerScript   = ScriptableObject.CreateInstance <ScoreHandler>();
     enemyParticlesObject = GameObject.Find("EnemyParticles");
     endGameScript        = ScriptableObject.CreateInstance <EndGame>();
 }
Пример #20
0
 // Start is called before the first frame update
 void Start()
 {
     circleCollider     = GetComponent <CircleCollider2D>();
     waitForStartScript = ScriptableObject.CreateInstance <WaitForStart>();
     endGameScript      = ScriptableObject.CreateInstance <EndGame>();
     GameObject.FindGameObjectWithTag("Music").GetComponent <MusicHandler>().PlayMusic();
 }
Пример #21
0
 private void SettingsViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "EnableDebugLog")
     {
         EndGame.UpdateLogger();
     }
 }
Пример #22
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);
        }
    }
Пример #23
0
    public void EndOfMatch(EndGame gameState)
    {
        Debug.Log("End of match. Match status: " + gameState);

        Debug.Log("Reseting game.");

        Invoke("ResetGame", resetTime);
    }
Пример #24
0
 public Game(EndGame endGame, UpdateGame updateGame, Client client1, Client client2)
 {
     this.endGame    = endGame;
     this.updateGame = updateGame;
     this.client1    = client1;
     this.client2    = client2;
     startTime       = DateTime.Now;
 }
Пример #25
0
    /// Called when the viewer's trigger is used, between OnGazeEnter and OnGazeExit.
    public void OnGazeTrigger()
    {
        // Call EndTheGame script
        EndGame endgame = FindObjectOfType <EndGame>();
        string  level   = "EndGame";

        endgame.EndTheGame(level, 10.0f);
    }
Пример #26
0
	void Start () 
	{
		dialogueScript 		 = dialogueManager.GetComponent<Dialogue> ();
		entranceScript 		 = gameObject.GetComponent<Entrance>();
		playerMovementScript = gameObject.GetComponent<playerMovement>();
		dancingScript 		 = giraffe.GetComponent<dancing>();
		endGameScript 		 = gameObject.GetComponent<EndGame> ();
	}
Пример #27
0
 // Update is called once per frame
 void Update()
 {
     guiText.text = "LIFE:      " + life;
     if (life < 0)
     {
         EndGame.WinLoseAction(false);
     }
 }
Пример #28
0
        private async Task EndGame(Guid id)
        {
            var command = new EndGame(id);

            command.EndedAt = DateTime.UtcNow.AddMinutes(90);
            var response = await client.PutAsync($"/games/{command.GameId}/end", command.ToContent());

            response.StatusCode.Should().Be((int)HttpStatusCode.OK);
        }
Пример #29
0
 public TicTacToeLogic(PlaceMarker xMarker, PlaceMarker oMarker, EndGame endGame)
 {
     placeXMarker = xMarker;
     placeOMarker = oMarker;
     placeXNext = true;
     boardState = new string[3,3];
     endGameListener = endGame;
     gameOver = false;
 }
Пример #30
0
    /// <summary>
    /// Verify enough players are initialized in the game.
    /// </summary>
    protected void Awake()
    {
        if (players.Count <= 1)
        {
            Debug.LogError("Not enough players.");
        }

        endGame = GetComponent<EndGame>();
    }
Пример #31
0
 // Start is called before the first frame update
 void Start()
 {
     rb          = GetComponent <Rigidbody2D>();
     m_generator = FindObjectOfType <LevelGenerator>();
     if (!endScript)
     {
         endScript = FindObjectOfType <EndGame>();
     }
 }
Пример #32
0
 // Start is called before the first frame update
 void Start()
 {
     tilemap            = GameObject.Find("Tilemap").GetComponent <Tilemap>();
     spawnBulletScript  = ScriptableObject.CreateInstance <SpawnBullet>();
     waitForStartScript = ScriptableObject.CreateInstance <WaitForStart>();
     checkModeScript    = ScriptableObject.CreateInstance <ModeHandler>();
     endGameScript      = ScriptableObject.CreateInstance <EndGame>();
     mouseUp            = false;
 }
Пример #33
0
 void Awake()
 {
     _shake = GetComponent <ObjectShake> ();
     _blastLight.localScale = Vector3.zero;
     _earthquake            = FindObjectOfType <Earthquake> ();
     _theHellFire           = FindObjectOfType <TheHellFire> ();
     _settings = FindObjectOfType <Settings> ();
     _endGame  = FindObjectOfType <EndGame> ();
 }
Пример #34
0
 private void IsGameFinished()
 {
     if (SticksCurrent != 0)
     {
         return;
     }
     _gameStatus = GameStatus.Finished;
     EndGame?.Invoke(Current == Player.One ? players[(int)Player.Two] : players[(int)Player.One]);
 }
Пример #35
0
        public void Handle(EndGame command)
        {
            _running = false;

            var message = new GameEnded();

            foreach (IListenForGameEnded listener in _gamEndedListeners)
            {
                listener.Handle(message);
            }
        }
Пример #36
0
 void Awake()
 {
     if (!instance)
     {
         instance = this;
         GameObject.DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
 public ReversiBoard(int currentPlayer)
 {
     if (currentPlayer != 0 && currentPlayer != 1) throw new ArgumentOutOfRangeException();
     this.gameBoard = new int[8, 8];
     this.gameBoard[4, 4] = ReversiBoard.White;
     this.gameBoard[3, 4] = ReversiBoard.Black;
     this.gameBoard[4, 3] = ReversiBoard.Black;
     this.gameBoard[3, 3] = ReversiBoard.White;
     this.players = new ReversiPlayer[2];
     this.players[0] = new ReversiPlayer(1);
     this.players[1] = new ReversiPlayer(-1);
     this.currentPlayer = currentPlayer;
     this.blackCount = 2;
     this.whiteCount = 2;
     this.emptyCount = 60;
     updateValidMoves(true);
     GameOver += new EndGame(calculateWinner);
 }
        public CheckersWindow()
        {
            this.InitializeComponent();
            board = new CheckersBoard(0, x);
            board.GameMaxLength = 150;
            lastMove = new CheckersMove(null, false, 1);
            moveList.Tag = new List<CheckersMove>();
            myRepaint = new Repaint(this.repaint);
            CheckersPlayer player = new CheckersPlayer(ComputerPlayer);
            alg = new Algorithms(player);
            int blackWhite = 1;
            for (int row = 0; row < 8; ++row)
            {
                for (int col = 0; col < 8; ++col)
                {

                    if (blackWhite % 2 == 0)
                    {
                        BlackSquare square = new BlackSquare();
                        square.SetValue(Grid.ColumnProperty, col);
                        square.SetValue(Grid.RowProperty, row);
                        square.Tag = new System.Windows.Point(row, col);
                        square.DragEnter += new DragEventHandler(square_DragEnter);
                        square.Drop += new DragEventHandler(square_Drop);
                        square.MouseLeftButtonDown += new MouseButtonEventHandler(square_MouseLeftButtonDown);
                        UIBoard.Children.Add(square);
                        blackSquares.Add(square);

                    }
                    else
                    {
                        WhiteSquare square = new WhiteSquare();
                        square.SetValue(Grid.ColumnProperty, col);
                        square.SetValue(Grid.RowProperty, row);
                        UIBoard.Children.Add(square);

                    }
                    blackWhite++;
                }
                blackWhite++;
            }
            StringBuilder stringBuilder = new StringBuilder("Current Player is:\n");
            stringBuilder.Append(board.GetCurrentPlayer().GetPlayerID().ToString() == "-1" ? "Black" : "White");
            currentPlayerLabel.Content = stringBuilder.ToString();
            repaint(null);
            board.GameOver += new CheckersBoard.EndGame(board_GameOver);
            if (board.GetCurrentPlayer().GetPlayerID() == alg.ComputerPlayerID)
            {
                computerThread = new Thread(this.computerMove);
                computerThread.Start();
            }
            this.visualGameOver = new EndGame(this.theGameIsOver);
        }
Пример #39
0
 void Start()
 {
     explosionPrefab = Explosion;
     info = GetComponent<WaitingScreen>();
     info.enabled = false;
     pause = GetComponent<MenuKeysController>();
     pause.enabled = false;
     hud = GetComponent<GameHUD>();
     hud.enabled = false;
     end = GetComponent<EndGame>();
     end.enabled = false;
     alpha = GetComponent<AlphaBackground>();
     alpha.enabled = false;
 }
Пример #40
0
 private void endGame(EndGame.OnEndGame eventData)
 {
     Debug.Log("Ending the game");
     PlayerPrefs.SetInt("gameStatus", eventData.gameStatus ? 1 : 0);
     Application.LoadLevel("EndGameScene");
 }