Exemplo n.º 1
0
    public void CheckDeath()
    {
        //check what the value of playerdeaths is if the function is called.
        switch (playerDeaths)
        {
        //if the value is player1death when the function is called, give points to the opposing player and make it thier turn
        //and make the value for the switch equal to the opposing player, etc.

        case PlayerDeaths.Player1Death:
            Debug.Log("player 1 has died");
            player2Points++;
            playerTurns = PlayerTurns.Player2Active;

            //if the player has died, it means they have failed to score so that turn will be passed on to the next player
            playerToScore = PlayerScored.Player2Scored;
            break;

        case PlayerDeaths.Player2Death:
            player1Points++;
            Debug.Log("player 2 has died");
            playerTurns   = PlayerTurns.Player1Active;
            playerToScore = PlayerScored.Player1Scored;
            break;
        }

        /* if(playerTurns == PlayerTurns.Player2Active)
         *       {
         *
         *       }
         */
    }
Exemplo n.º 2
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.GetComponent <Hoop>() != null)
            {
                if (!ignoredColliders.Contains(other.gameObject) && other.isTrigger)
                {
#if UNITY_EDITOR
                    Debug.Log("Someone scored!");
#endif

                    PlayerScored?.Invoke(other.GetComponent <Hoop>());
                    DisablePlayerCollider(other);
                }
            }
        }
Exemplo n.º 3
0
    private void Start()
    {
        playerTurns   = PlayerTurns.Player1Active;
        playerToScore = PlayerScored.Player1Scored;



        player1Goalobj = GameObject.FindWithTag("Player1Goal");
        player2Goalobj = GameObject.FindWithTag("Player2Goal");

        CheckPlayer();

        //Ball.GetComponent<Renderer>().material.color = colorOfPlayer;
        //myMat = Ball.GetComponent<Renderer>().material;
        //myMat.color = colorOfPlayer;
    }
Exemplo n.º 4
0
    public void CheckPlayer()
    {
        //check what the value of playerturns is if the function is called, this will be called after checking for the death of the player.
        switch (playerTurns)
        {
        //once the turns have been changed after death, spawn the ball at the opposing side and set that it is player1s turn to die

        //if it is player1s turn spawn them at thier safe zone
        case PlayerTurns.Player1Active:
            //UiManager.Instance.UpdateTurn("It is" + playerTurns + "turn");
            UiManager.Instance.UpdateTurn("It is Player1's turn");

            //turn the goals on and off to stop registering collision when it spawns
            player1Goalobj.SetActive(false);
            player2Goalobj.SetActive(true);

            //make sure on there turn, tell the manager it also thier turn to die, then spawn them at thier starting possition
            Debug.Log("It is player 1's turn");
            playerDeaths = PlayerDeaths.Player1Death;
            //it is this players turn to score
            playerToScore = PlayerScored.Player1Scored;
            //change the players color to indicate clearer whos turn it is
            CheckColor(player1Color);
            // colorOfPlayer = player1Color;
            Ball.transform.position = spawnpoint.position;
            break;

        //if it is player1s turn spawn them at thier safe zone
        case PlayerTurns.Player2Active:
            //UiManager.Instance.UpdateTurn("It is" + playerTurns + "turn");
            UiManager.Instance.UpdateTurn("It is Player2's turn");

            //turn the goals on and off to stop registering collision when it spawns
            player1Goalobj.SetActive(true);
            player2Goalobj.SetActive(false);

            Debug.Log("It is player 2's turn");
            playerDeaths = PlayerDeaths.Player2Death;
            //it is this players turn to score
            playerToScore = PlayerScored.Player2Scored;
            //change the players color to indicate clearer whos turn it is
            CheckColor(player2Color);
            // colorOfPlayer = player2Color;
            Ball.transform.position = spawnpoint2.position;
            break;
        }
    }
Exemplo n.º 5
0
        public void CheckIfCollisionWithPlayer(DrawableObject item)
        {
            Player player = item as Player;

            if (!IsOccupied)
            {
                if (base.CheckIfCollisionWith(item))
                {
                    IsOccupied = true;
                    IsVisible  = false;
                    OccupiedPods++;
                    PlayerScored?.Invoke(player);
                    if (OccupiedPods == CreatedPods)
                    {
                        AllPodsOccupied?.Invoke();
                    }
                }
            }
        }
Exemplo n.º 6
0
 private void OnPlayerScored()
 {
     PlayerScored?.Invoke(this, new EventArgs());
 }
		private async Task MakeShot(string scores)
		{
			try
			{
				this.BusyText = "Wurf wird gespeichert...";
				this.IsBusy = true;

				int points = int.Parse(scores);

				if (_currentGame.GameType == GameType.TeamGame)
					await _controlService.MakeTeamPlayerShot(_currentGame.GameId, _currentGame.PlayerName, this.CurrentShotNumber, points);
				else
					await _controlService.MakePlayerShot(_currentGame.GameId, _currentGame.PlayerName, this.CurrentShotNumber, points);

				var @event = new PlayerScored
				{
					GameId = this.CurrentGame.GameId,
					PlayerName = this.CurrentGame.PlayerName,
					Points = points,
					ShotNumber = this.CurrentShotNumber
				};

				int waitForShotNumber = this.CurrentShotNumber;
				_liveBus.Publish(@event);

				await Task.Delay(1000);

				bool found = false;
				while (!found)
				{
					var gameResult = await _contestDao.FindGameResult(this.CurrentGame.GameId);

					if (gameResult != null)
						found = gameResult.Scores.FirstOrDefault(x => x.ShotNumber.Equals(waitForShotNumber) && x.PlayerName.Equals(this.CurrentGame.PlayerName)) != null;

					if (!found)
						await Task.Delay(500);
				}

				if (_shotNumberToEdit > 0) await Task.Delay(5000);

				this.CurrentGameResult = new NotifyTaskCompletion<GameResult>(
				  this.LoadGameResult(this.CurrentGame.GameId, this.CurrentGame.PlayerName));
				this.OnPropertyChanged("CurrentGameResult");
				this.OnPropertyChanged("IsSinglePlayer");
				(this.NewGameCommand as DelegateCommand).RaiseCanExecuteChanged();

			}
			finally
			{
				this.IsBusy = false;
			}
		}
Exemplo n.º 8
0
		private void OnPlayerScored(PlayerScored e)
		{
			_scores[e.ShotNumber] = e.Points;
			//this.OnPropertyChanged("Scores[]");
			this.OnPropertyChanged("Scores");
			this.OnPropertyChanged("PlayerTotalScore");
			this.OnPropertyChanged("TeamTotalScore");

			RaiseScoreChanged(e.ShotNumber);
		}