// NEW SHIT // Used at the start of each round to put the tank into it's default state. public void Reset() { //transform.position = m_SpawnPoint.position; //transform.rotation = m_SpawnPoint.rotation; if (m_PlayerNumber == 1) { transform.position = spawnpoints.spawn1.position; transform.rotation = Quaternion.Euler(0, spawnpoints.spawnAngle1, 0); } if (m_PlayerNumber == 2) { transform.position = spawnpoints.spawn2.position; transform.rotation = Quaternion.Euler(0, spawnpoints.spawnAngle2, 0); } // When the tank is turned off, set it to kinematic so it stops moving. m_Rigidbody.isKinematic = true; // When the tank is turned on, make sure it's not kinematic. m_Rigidbody.isKinematic = false; // Also reset the input values. m_MovementInputValue = 0f; m_TurnInputValue = 0f; Statestics.WriteDataPoint(m_PlayerNumber, StateType.AmountOfMovement, amountOfMovement); amountOfMovement = 0; }
public void TakeDamage(float amount, int playerNumber) { // Reduce current health by the amount of damage done. m_CurrentHealth -= amount; // Change the UI elements appropriately. SetHealthUI(); // If I don't get hit by myself, then measure the time! if (playerNumber != GetComponent <SimpleTankMovement>().m_PlayerNumber) { Statestics.WriteDataPoint(playerNumber, StateType.TimeToHit, Time.time - timestampForHit); timestampForHit = Time.time; Debug.Log("Player " + playerNumber + " hit " + " player " + GetComponent <SimpleTankMovement>().m_PlayerNumber); } // If the current health is at or below zero and it has not yet been registered, call OnDeath. if (m_CurrentHealth <= 0f && !m_Dead) { OnDeath(); // If I died and the it wasn't myself who killed me, measure the time! if (playerNumber != GetComponent <SimpleTankMovement>().m_PlayerNumber) { Statestics.WriteDataPoint(playerNumber, StateType.TimeToKill, Time.time - timestampForKill); Debug.Log("Player " + playerNumber + " killed " + " player " + GetComponent <SimpleTankMovement>().m_PlayerNumber); } } }
private void Update() { if (OneTankLeft()) { if (!healthTank1.m_Dead) { Statestics.WriteDataPoint(1, StateType.Winner, 1); } else if (!healthTank2.m_Dead) { Statestics.WriteDataPoint(2, StateType.Winner, 1); } agentTank1.Done(); agentTank2.Done(); ResetGame(); } }