public static void Load() { _tickables = null; _removables = null; _addables = null; loadNewBehaviour = new Time(); loadNewBehaviour = player = newPlayer; loadNewBehaviour = new PlayerUI(); loadNewBehaviour = new PowerupUI(); gameScroller = new GameScroller(); gameXLocation = 0; currentLevel.load(); //FieldPartContainer.generateFieldParts(); game.gameTimer.Start(); Console.WriteLine("load"); foreach (IBehaviour b in tickables) { b.onLoad(); } }
public IEnumerator HandlePowerup() { soundController.PlayPowerupSound(); Powerup pu = null; int i = 0; do { i = Random.Range(0, powerups.Length); pu = powerups[i]; } while (remainingEscapeCards >= 1 && i == 1); GameObject prefabInst = Instantiate(powerupUIPrefab); prefabInst.transform.SetParent(uiController.canvas.transform, false); RectTransform rectTransform = prefabInst.GetComponent <RectTransform>(); PowerupUI powerupUI = prefabInst.GetComponent <PowerupUI>(); powerupUI.ApplyPowerup(pu); pu.Activate(this); yield return(new WaitForSeconds(5.5f)); Destroy(prefabInst); CheckPlayerTurnStatus(); }
void Start() { // get secondary controller secondaryController = gameObject.GetComponent <SecondaryController>(); powerupUI = gameObject.GetComponent <PowerupUI>(); // try to find the player try { playerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>(); } catch (System.NullReferenceException) { playerController = null; } // set default cursor for browsers that don't pick up Unity's custom cursor CursorManager.instance.SetDefaultCursor(); // initialize game variables hazardSpeed = 1; paused = false; gameOver = false; restart = false; // initialize UI variables gameOverOverlay.SetActive(false); if (DatabaseManager.instance.player1Name != "" && DatabaseManager.instance.player2Name != "") { player1NameText.text = DatabaseManager.instance.player1Name; player2NameText.text = DatabaseManager.instance.player2Name; } finalScoreText.text = ""; finalWaveText.text = ""; for (int i = 0; i < topScoresRanksText.Length; ++i) { topScoresRanksText[i].text = ""; topScoresNamesText[i].text = ""; topScoresScoresText[i].text = ""; surroundingScoresRanksText[i].text = ""; surroundingScoresNamesText[i].text = ""; surroundingScoresScoresText[i].text = ""; } // end for // initialize score values score = 0; wave = 0; scoreSpecial = 0; baseTargetSpecial = targetSpecial; UpdateScore(); UpdateWave(); specialBar.rectTransform.anchorMax = new Vector2(scoreSpecial / targetSpecial, 1); // start spawning hazards StartCoroutine(SpawnWaves()); }
void Start() { // Find the Game Controller GameObject gameControllerObject = GameObject.FindWithTag("GameController"); if (gameControllerObject != null) { //gameController = gameControllerObject.GetComponent<GameController>(); powerupUI = gameControllerObject.GetComponent <PowerupUI>(); } //if (gameController == null) //{ // Debug.Log("Cannot find 'GameController' Script"); //} if (powerupUI == null) { Debug.Log("Cannot find 'PowerupUI' Script"); } // Find the Secondary Controller GameObject secondaryControllerObject = GameObject.FindWithTag("SecondaryController"); if (secondaryControllerObject != null) { secondaryController = secondaryControllerObject.GetComponent <SecondaryController>(); } if (secondaryController == null) { Debug.Log("Cannot find 'SecondaryController' Script"); } // get objects rb = GetComponent <Rigidbody>(); //audioSource = GetComponent<AudioSource>(); collider = GetComponent <MeshCollider>(); camera = GameObject.FindWithTag("MainCamera").GetComponent <Camera>(); // set up power up data fireRatePower = false; shield = GameObject.FindWithTag("Shield"); shotSpawn = new int[] { 0 }; turretFireRate = fireRate; turret = GameObject.FindWithTag("Turret"); if (!startShield) { shield.SetActive(false); } else { collider.enabled = false; } }
void Start() { info = GetComponent <PowerupInfo> (); ui = GetComponent <PowerupUI> (); getPowerup = GetComponent <GetPowerup> (); uiImage = ui.powerupUI.GetComponent <PowerupUIImage> (); quickdrawObj.SetActive(false); CheckForNextPowerup(); }
IEnumerator BlinkAllSprites() { itemsBlinking = true; List <Image> images = new List <Image> (); for (int i = 1; i < powerupSprites.Count; i++) { PowerupUI p = powerupSprites [i]; if (p != null) { images.Add(p.GetComponent <Image> ()); } } while (!stopBlink) { foreach (Image i in images) { if (i == null) { continue; } Color color = i.color; color.a = Mathf.PingPong(Time.time / 2f, 0.7f) + 0.3f; i.color = color; } yield return(new WaitForSeconds(0.2f)); } foreach (Image i in images) { if (i == null) { continue; } Color color = i.color; color.a = 1f; i.color = color; } stopBlink = false; itemsBlinking = false; yield return(null); }
void Start() { // Find the Game Controller GameObject gameControllerObject = GameObject.FindWithTag("GameController"); if (gameControllerObject != null) { gameController = gameControllerObject.GetComponent <GameController>(); powerupUI = gameControllerObject.GetComponent <PowerupUI>(); } if (gameController == null) { Debug.Log("Cannot find 'GameController' Script"); } if (powerupUI == null) { Debug.Log("Cannot find 'PowerupUI' Script"); } // get components rb = GetComponent <Rigidbody2D>(); collider = GetComponent <PolygonCollider2D>(); portThrusterAnimator = portThruster.GetComponent <Animator>(); starboardThrusterAnimator = starboardThruster.GetComponent <Animator>(); // set up power up data shield.SetActive(false); fireRatePower = false; shotSpawnsActive.Add((int)Side.Bow); speedUpPower = false; turret.SetActive(false); turretFireRate = fireRate; turretShotSpawnActive = 0; turretCursor = false; // set shield state if (startShield) { StartPowerup(1); } // set debug data debugPlayer = gameController.debug; }
IEnumerator movePowerup(int newIndex) { Vector3 newPosition = harvestBox.transform.position + new Vector3(newIndex * (distanceBetweenPowerups), 0); Vector3 oldPosition = harvestBox.transform.position + new Vector3((newIndex - 1) * (distanceBetweenPowerups), 0); float elapsed = 0; while (powerupSprites [newIndex].transform.position != newPosition) { powerupSprites [newIndex].transform.position = Vector3.Lerp(oldPosition, newPosition, elapsed); elapsed += 0.1f; yield return(new WaitForSeconds(0.1f)); } //careful for race conditions? animationInProgress--; if (animationInProgress == 0) { trashCan.GetComponent <Image> ().color = Color.clear; } if (newIndex == 3) { DestroyImmediate(powerupSprites [newIndex].gameObject); powerupSprites.RemoveAt(newIndex); } else if (newIndex == 2) { PowerupUI newp = powerupSprites [newIndex]; itemBox2.color = newp.getColor(); if (GameManager.IsPOTD(newp.letter)) { text2.text = newp.count.ToString(); } else if (GameManager.IsPassive(newp.letter)) { text2.text = "P"; } else { text2.text = "--"; } } else if (newIndex == 1) { PowerupUI newp = powerupSprites [newIndex]; itemBox1.color = newp.getColor(); if (GameManager.IsPOTD(newp.letter)) { text1.text = newp.count.ToString(); } else if (GameManager.IsPassive(newp.letter)) { text1.text = "P"; } else { text1.text = "--"; } } yield return(null); }
void Start() { Init(); powerupUI = GetComponent <PowerupUI> (); }