本文整理汇总了C#中Spaceship.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Spaceship.GetComponent方法的具体用法?C# Spaceship.GetComponent怎么用?C# Spaceship.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spaceship
的用法示例。
在下文中一共展示了Spaceship.GetComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Formation
public Formation(Spaceship ship, float range)
{
this.ship = ship;
rig = ship.GetComponent<Rigidbody>();
this.range = range;
actual = Manouver.Rotate;
nextAction = Random.Range(range / 2, 3 * range / 4);
}
示例2: Start
// Use this for initialization
IEnumerator Start()
{
spaceship = GetComponent<Spaceship>();
while(true) {
spaceship.Shot(transform);
spaceship.GetComponent<AudioSource>().Play();
yield return new WaitForSeconds(spaceship.shotDelay);
}
}
示例3: HandleSpawnWait
private static IEnumerator HandleSpawnWait(Spaceship spaceship) {
SpaceshipMatchData matchData = spaceship.GetComponent<SpaceshipMatchData>();
SpaceshipControl controls = spaceship.GetComponent<SpaceshipControl>();
Collider collider = spaceship.GetComponent<Collider>();
matchData.spawnTimeRemaining = normalSpawnWait;
spaceship.isVisible = false;
spaceship.controlsEnabled = false;
// instance.networkView.RPC("SetVisibility", RPCMode.All, false);
// spaceship.spaceshipModelRoot.gameObject.SetActive(instance.isVisible);
// controls.enabled = instance.isVisible;
// collider.enabled = instance.isVisible;
while (matchData.spawnTimeRemaining > 0.0f) {
yield return null;
matchData.spawnTimeRemaining = Mathf.Max(0.0f, matchData.spawnTimeRemaining-Time.deltaTime);
}
spaceship.transform.position = spawnPoints[lastCheckpointID].transform.position;
spaceship.transform.rotation = spawnPoints[lastCheckpointID].transform.rotation;
// instance.networkView.RPC("SetVisibility", RPCMode.All, true);
// spaceship.spaceshipModelRoot.gameObject.SetActive(instance.isVisible);
// controls.enabled = instance.isVisible;
// collider.enabled = instance.isVisible;
SpaceshipHealth healthComponent = spaceship.GetComponent<SpaceshipHealth>();
healthComponent.currentHealth = healthComponent.maxHealth;
spaceship.isVisible = true;
spaceship.controlsEnabled = true;
Debug.Log ("Spawning '" + spaceship + "' at SpawnPoint " + lastCheckpointID + "!");
}
示例4: OnPickup
public override void OnPickup(Spaceship spaceship) {
base.OnPickup(spaceship);
SpaceshipHealth health = spaceship.GetComponent<SpaceshipHealth>();
health.currentHealth = Mathf.Min(health.currentHealth+healthAmount, health.maxHealth);
}