本文整理汇总了C#中CarController.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# CarController.GetComponent方法的具体用法?C# CarController.GetComponent怎么用?C# CarController.GetComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CarController
的用法示例。
在下文中一共展示了CarController.GetComponent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsPlayer
bool IsPlayer(CarController car)
{
if (car == null)
return false;
return car.GetComponent<CarUserControlMP>() != null;
}
示例2: CheckpointTriggered
public void CheckpointTriggered(CarController car, int checkPointIndex)
{
PositionData carData = _carPositions[car];
if (!_finished)
{
if (checkPointIndex == 0)
{
if (carData.checkPoint == _checkPointCount-1)
{
carData.checkPoint = checkPointIndex;
carData.lap += 1;
// Mettre à jour le tour le plus avancé :
if (carData.lap > _currentMaxLap) {
_currentMaxLap = carData.lap;
}
if (IsPlayer(car))
{
GetComponent<RaceManager>().Announce("Tour " + (carData.lap + 1).ToString());
// Mec1. Style :
car.GetComponent<StyleManager>().logStyle(100, "Tour complet");
}
if (carData.lap >= _totalLaps)
{
_finished = true;
GetComponent<RaceManager>().EndRace(car.name.ToLower());
if (IsPlayer(car))
{
// Mec1. Style :
car.GetComponent<StyleManager>().logStyle(1000, "Premier !");
}
}
}
}
else if (carData.checkPoint == checkPointIndex-1) //Checkpoints must be hit in order
{
carData.checkPoint = checkPointIndex;
}
}
}
示例3: ResetCar
public IEnumerator ResetCar(CarController car)
{
int count = (int)((float)_resetTimer / 0.16f + 0.5f);
var tracker = car.GetComponent<WaypointProgressTracker>();
car.transform.position = tracker.LastWaypoint.position;
car.transform.rotation = tracker.LastWaypoint.rotation;
do
{
yield return new WaitForSeconds (0.16f);
car.rigidbody.velocity = Vector3.zero;
count--;
} while (count > 0);
car.rigidbody.velocity = Vector3.zero;
car.Reset();
}
示例4: Initialize
public void Initialize(CarController car) {
Debug.Log ("@TODO: Replace this with new engine coefficients.");
// car.Engine.MaxSpeed = maxSpeed;
// car.Engine.MaxAcceleration = maxAcceleration;
car.stopDistance = stopDistance;
car.carColours = new List<Color> (colourOptions);
SpriteRenderer colourizableRenderer = car.GetComponent<SpriteRenderer>();
colourizableRenderer.sprite = colourizableSprite;
foreach (SpriteRenderer renderer in car.GetComponentsInChildren<SpriteRenderer>()) {
if (renderer == colourizableRenderer || renderer.GetComponent<TurnIndicator>() != null) {
continue;
}
else {
renderer.sprite = fixedColourSprite;
break;
}
}
}
示例5: IsPlayer
bool IsPlayer(CarController car)
{
return car.GetComponent<CarUserControlMP>() != null;
}
示例6: Start
private void Start()
{
volumeFadeIn = true;
AudioListener.volume = 0.0f;
// Initialize values
pauseAnimation = false;
pause = false;
started = false;
settings = false;
isDrifting = false;
canContinue = false;
canDrift = true;
canShowExtra = true;
avoiding = false;
pressedExit = false;
tutorial = false;
canAdvanceTutorial = true;
driftTutorial = false;
driftTutorialObjective = false;
driftTutorialDriftDone = false;
checkingGamepad = false;
disabledUI = false;
totalScore = 0;
driftScore = 0;
maxDriftScore = 0;
multiplier = 0;
challengeTextState = 0;
tutorialState = 0;
driftTutorialState = 0;
playerName = "";
previousTimeScale = Time.timeScale;
rigidbodyVelocity = Vector3.zero;
multiplierTemp = multiplierTempInit;
collisionTemp = collisionTempInit;
avoidTemp = avoidTempInit;
initPosition = new Vector3[labelsUI.Length];
dataManager = DataManager.Instance;
carInput = CarInput.Instance;
// Initialize time challenge values
leftTime = leftTimeInit;
timePickupsCount = timePickupRoot.transform.childCount;
currentTimePickup = 0;
timePickups = new GameObject[timePickupsCount];
for(int i = 0; i < timePickups.Length; i++)
{
timePickups[i] = timePickupRoot.transform.GetChild (i).gameObject;
}
for(int i = 0; i < timePickups.Length; i++)
{
timePickups[i].GetComponent<DriftPickup>().DisablePickupForMinimap();
}
timeChallengeUI.SetActive (false);
for(int i = 0; i < freeTutorialLabels.Length; i++)
{
freeTutorialCameras[i].enabled = false;
freeTutorialLabels[i].SetActive (false);
}
for(int i = 0; i < challengeTutorialCameras.Length; i++)
{
challengeTutorialCameras[i].enabled = false;
challengeTutorialLabels[i].SetActive (false);
}
// Get player references
carController = GameObject.FindWithTag ("Player").GetComponent<CarController>();
carEngine = carController.GetComponent<CarEngine>();
carSetup = carController.GetComponent<CarSetup>();
carAudio = carController.GetComponent<CarAudio>();
carRigidbody = carController.GetComponent<Rigidbody>();
introAnimation = GetComponent<CameraIntroAnimation>();
settingsManager = GetComponent<SettingsManager>();
extraTweenText = extraTween.GetComponent<Text>();
challengeLabelTween = challengeLabel.GetComponent<TweenFontSize>();
bloomUI = GameObject.Find ("UICamera").GetComponent<Bloom>();
if(dataManager.isGamepad)
{
#if !UNITY_EDITOR
UnityEngine.Cursor.visible = false;
UnityEngine.Cursor.lockState = CursorLockMode.Locked;
#endif
}
else
{
#if !UNITY_EDITOR
UnityEngine.Cursor.visible = false;
UnityEngine.Cursor.lockState = CursorLockMode.None;
#endif
}
// Load data
maxDriftScore = dataManager.bestDrift;
//.........这里部分代码省略.........
示例7: Start
private void Start()
{
if(GameObject.FindWithTag ("MultiplayerManager"))
{
players = GameObject.FindGameObjectsWithTag("Player");
for(int i = 0; i < players.Length; i++)
{
if(players[i].GetComponent<NetworkIdentity>().isLocalPlayer)
{
carController = players[i].GetComponent<CarController>();
cameras = carController.GetComponent<CameraRig>().cameraTransform;
break;
}
}
}
else
{
carController = GameObject.FindWithTag ("Player").GetComponent<CarController>();
cameras = carController.GetComponent<CameraRig>().cameraTransform;
}
dataManager = DataManager.Instance;
musicSource = audioManager.GetComponents<AudioSource>();
// Initialize values
if(!carController)
{
GameObject.FindWithTag("Player").GetComponent<CarController>();
}
// Setup settings
Invoke ("SetupSettings", 0.01f);
}
示例8: StartGamePlayer
public void StartGamePlayer()
{
// Get player references
players = GameObject.FindGameObjectsWithTag("Player");
for(int i = 0; i < players.Length; i++)
{
if(players[i].GetComponent<NetworkIdentity>().isLocalPlayer)
{
carController = players[i].GetComponent<CarController>();
carEngine = carController.GetComponent<CarEngine>();
carSetup = carController.GetComponent<CarSetup>();
carAudio = carController.GetComponent<CarAudio>();
carRigidbody = carController.GetComponent<Rigidbody>();
carController.enabled = false;
carEngine.enabled = true;
// Disable car audio
carAudio.EnableSources(0.5f);
Debug.Log ("MultiplayerManager: player initialization complete");
break;
}
}
}
示例9: Start
// Use this for initialization
void Start()
{
shieldDome = null;
car = transform.root.GetComponent<CarController>();
carModel = car.GetComponent<Rigidbody>();
explHolder = Helpers.FindOrCreateGameObject("ExplosionHolder");
}