public void InitML() { Brain b = FindObjectOfType <Brain>(); if (b) { PlayerML agent = gameObject.AddComponent <PlayerML>(); agent.GiveBrain(b); isML = true; } }
private void OnCollisionStay(Collision col) { //If a player doesn't hit you ignore it if (!col.gameObject.name.Contains("Player")) { return; } Player otherPlayer = col.gameObject.GetComponent <Player>(); //If the player that hit you is punching teleport you down if (otherPlayer.punching) { PlayerML ml = GetComponent <PlayerML>(); if (blocking) { if (ml) { // ml.reward += 0.8f; } otherPlayer.recoverTime = recoverReset * 3; otherPlayer.animationTime = 0; otherPlayer.punching = false; GetComponent <Rigidbody>().velocity = Vector3.zero; PAM.PlayBlock(); blockParticle.PlayParticle(); } else { if (dead) { return; } deathParticle.PlayParticles(); if (ml) { //ml.reward -= 0.8f; } //Increase the amount of kills the player has col.gameObject.GetComponent <Player>().kills++; transform.position += Vector3.down * 10; ResetCamera(col.gameObject, -1); dead = true; otherPlayer.PAM.PlayHit(); PAM.PlayDeath(); } } }
private void CheckGameOver() { if (gameOver) { return; } //The amount of players alive int aliveCount = 0; winner = null; //Add each player that is alive to the count foreach (GameObject playerObj in players) { if (!playerObj.GetComponent <Player>().dead) { aliveCount++; winner = playerObj; } } //If there is one or less players left end the game if (aliveCount <= 1) { gameOver = true; ConfettiManager.Instance.StartConfetti(); if (winner) { PlayerML winningAgent = winner.GetComponent <PlayerML>(); //if (winningAgent) // winningAgent.reward += 1.0f; } foreach (GameObject playerObj in players) { PlayerML agent = playerObj.GetComponent <PlayerML>(); if (!agent) { return; } else { agent.done = true; } } } }