IEnumerator CreateCanonsRoutine() { canons = new GameObject[numberOfCanons]; GameRing ring = FindObjectOfType <GameRing>(); for (int i = 0; i < canons.Length; i++) { float angle = i * Mathf.PI * 2 / numberOfCanons; Vector3 pos = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0f) * radius; GameObject canon = Instantiate(canonPrefab, this.transform); canon.transform.position = pos; if (lookInside) { canon.transform.up = -(-canon.transform.position + Vector3.zero).normalized; //Look to center } else { canon.transform.up = (-canon.transform.position + Vector3.zero).normalized; //Look to outside } canons[i] = canon; yield return(new WaitForSeconds(0.5f)); } yield return(new WaitForSeconds(1.0f)); for (int i = 0; i < canons.Length; i++) { canons[i].GetComponent <AutoShooter>().Activate(true); } IsReady = true; }
protected virtual void Start() { deadRing = FindObjectOfType <GameRing>(); canShoot = true; timeOfLastShoot = 0f; Restart(); transform.right = (-transform.position + Vector3.zero).normalized; }
private void RepositionPlayers() { if (ring == null) { ring = FindObjectOfType <GameRing>(); } int count = 0; foreach (var item in players) { float angle = count * Mathf.PI * 2 / maxNumberOfPlayers; Vector3 pos = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0f) * ring.Radius; item.Value.transform.position = pos; item.Value.ForceCenterLook(); count++; } }
//Player related methods #region Players public PlayerController CreatePlayer(int deviceID) { //Too many players if (players.Count > MaxNumberOfPlayers) { return(null); } //Get an equidistance point on circle if (ring == null) { ring = FindObjectOfType <GameRing>(); } float angle = players.Count * Mathf.PI * 2 / maxNumberOfPlayers; Vector3 pos = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0f) * ring.Radius; //Instantiate player prefab, store device id + player script in a dictionary GameObject newPlayer = Instantiate(playerPrefab, pos, transform.rotation) as GameObject; PlayerController playerController = newPlayer.GetComponent <PlayerController>(); players.Add(deviceID, playerController); Color color = GetNextColor(); if (color.a < 0.5f) { return(null); } //Set position and color newPlayer.transform.position = pos; playerController.SetColor(color); playerController.SetDeviceId(deviceID); return(playerController); }
static void Main(string[] args) { GameRing championships = new GameRing(); championships.GetNumberOfPlayers(); }
private void Start() { ring = FindObjectOfType <GameRing>(); postProcessVolume.profile = normalProfile; //mainCounter = FindObjectOfType<Counter>(); }