本文整理汇总了C#中Spaceship.SetGameManager方法的典型用法代码示例。如果您正苦于以下问题:C# Spaceship.SetGameManager方法的具体用法?C# Spaceship.SetGameManager怎么用?C# Spaceship.SetGameManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spaceship
的用法示例。
在下文中一共展示了Spaceship.SetGameManager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GameStart
IEnumerator GameStart()
{
// Set the proper UI's to display.
mainUI.SetActive(false);
gameUI.SetActive(true);
gameOverUI.SetActive(false);
pauseMenuUI.SetActive(false);
// Set our correct game state.
state = gameState.game;
// Update the score and lives in the beginning of the game, or on restart.
UpdateScore(0);
UpdateLives(0);
UpdateHighscore();
// Spawn the player!
player = Instantiate(spaceshipPrefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
// We use a Spaceship object for easier calling to the player's spaceship.
spaceship = player.GetComponent<Spaceship>();
// Set the GameManager to this object so we can keep a leash on it.
spaceship.SetGameManager(this.gameObject);
// "for" loop that spawns the number of Rocks you set into the scene.
for (int i = 0; i < numStartingRocks; i++)
{
// Cosine and sine always output a value from [-1, 1] inclusive.
// We use that value to generate a random position that is always around the rockSpawnRadius.
float rockPosX = rockSpawnRadius * Mathf.Cos(UnityEngine.Random.Range(0, 360));
float rockPosy = rockSpawnRadius * Mathf.Sin(UnityEngine.Random.Range(0, 360));
// Spawn the Rock prefab!
GameObject rockClone = Instantiate(startingRockPrefab, new Vector3(rockPosX, rockPosy, 0), Quaternion.identity) as GameObject;
// Set the GameManager of this object to the GameManager in the game, so we can control this Rock.
rockClone.GetComponent<Rock>().SetGameManager(this.gameObject);
}
// TODO: ScreenSE and ScreenNW are incorrectly named. Change in the future.
screenSW = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, Camera.main.transform.localPosition.z));
screenNE = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.transform.localPosition.z));
screenSE = new Vector3(screenSW.x, screenNE.y, 0);
screenNW = new Vector3(screenNE.x, screenSW.y, 0);
// Begin the Coroutines that add a large part of the functionality to the game.
StartCoroutine(SaucerSpawn());
StartCoroutine(PowerupSpawn());
// Since Coroutines always need a "yield return" to know when they are done..
yield return null;
}
示例2: GameStart
IEnumerator GameStart()
{
mainUI.SetActive(false);
gameUI.SetActive(true);
gameOverUI.SetActive(false);
pauseMenuUI.SetActive(false);
state = gameState.game;
UpdateLives (0);
player = Instantiate(spaceshipPrefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
spaceship = player.GetComponent<Spaceship>();
spaceship.SetGameManager(this.gameObject);
for (int i = 0; i < numStartingRocks; i++)
{
float rockPosX = rockSpawnRadius * Mathf.Cos(Random.Range(0, 360));
float rockPosy = rockSpawnRadius * Mathf.Sin(Random.Range(0, 360));
GameObject rockClone = Instantiate(startingRockPrefab, new Vector3(rockPosX, rockPosy, 0), Quaternion.identity) as GameObject;
rockClone.GetComponent<Rock>().SetGameManager(this.gameObject);
}
// ScreenSE and ScreenNW are incorrectly named. Change in the future.
screenSW = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, Camera.main.transform.localPosition.z));
screenNE = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.transform.localPosition.z));
screenSE = new Vector3(screenSW.x, screenNE.y, 0);
screenNW = new Vector3(screenNE.x, screenSW.y, 0);
StartCoroutine(SaucerSpawn());
StartCoroutine(PowerupSpawn());
yield return null;
}