public override IEnumerator UsePowerup(GameObject player) { int activatorPosition = gameManager.GetPositionByPlayer(player.GetComponent <Transform>()); int targetPosition = activatorPosition - 1; if (targetPosition == 0) { targetPosition = 2; } Transform targetPlayer = gameManager.GetPlayerByPosition(targetPosition); PlayerStats ps = player.GetComponent <PlayerStats>(); ps.UsedPowerup(); CarController targetCarController = targetPlayer.GetComponent <CarController>(); targetCarController.steeringReversed = true; yield return(new WaitForSeconds(DURATION)); targetCarController.steeringReversed = false; }
private Transform GetPlayerToAttack(Transform ownPlayer) { int ownPosition = gameManager.GetPositionByPlayer(ownPlayer); if (ownPosition == 1) { return(gameManager.GetPlayerByPosition(2)); } else { return(gameManager.GetPlayerByPosition(ownPosition - 1)); } }
public override IEnumerator UsePowerup(GameObject player) { int activatorPosition = gameManager.GetPositionByPlayer(player.GetComponent <Transform>()); PlayerStats aps = player.GetComponent <PlayerStats>(); int targetPosition = activatorPosition - 1; if (targetPosition == 0) { targetPosition = 2; } Transform targetPlayer = gameManager.GetPlayerByPosition(targetPosition); PlayerStats ps = player.GetComponent <PlayerStats>(); ps.UsedPowerup(); CarController targetCarController = targetPlayer.GetComponent <CarController>(); PlayerStats tps = targetPlayer.GetComponent <PlayerStats>(); if (!tps.hasShield) { yield return(new WaitForSeconds(DELAY)); tps.StartReverseSteer(); targetCarController.steeringReversed = true; tps.hasShield = false; } tps.StopShield(); if (aps.hasWhiteBrick) { yield return(new WaitForSeconds(WHITE_BRICK_DURATION)); } else { yield return(new WaitForSeconds(DURATION)); } targetCarController.steeringReversed = false; tps.StopReverseSteer(); }
private void setPlaces() { gameManager_E.secondPlace = gameManager_E.GetPositionByPlayer(gameManager_E.carTransformList[1]); gameManager_E.thirdPlace = gameManager_E.GetPositionByPlayer(gameManager_E.carTransformList[2]); gameManager_E.fourthPlace = gameManager_E.GetPositionByPlayer(gameManager_E.carTransformList[3]); }