public void ActivatePowerUp(PowerUpHolder powerUp) { switch (powerUp.GetPowerUpType()) { case PowerUpType.Heart: { break; } case PowerUpType.Gold: { break; } case PowerUpType.Emerald: { break; } default: { break; } } }
void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } //DontDestroyOnLoad(gameObject); }
public GameObject SpawnPrefab(Vector3 position) { GameObject go = Instantiate(prefab, position, prefab.transform.rotation); PowerUpHolder pp = go.GetComponent <PowerUpHolder>(); if (pp == null) { pp = go.AddComponent <PowerUpHolder>(); pp.powerUp = this; } else { pp.powerUp = this; } return(go); }
/// <summary> /// <para>Update the Power Ups images on UI</para> /// </summary> /// <param name="_slot1">Power Up on Slot 1</param> /// <param name="_slot2">Power Up on Slot 2</param> public void UpdatePowerUpUI(PowerUpHolder _slot1, PowerUpHolder _slot2) { if (_slot1.powerUp != null) { switch (_slot1.powerUp.powerUp) { case EPowerUps.SUPER_SPEED: slot1Image.sprite = superSpeedSprite; break; case EPowerUps.SUPER_SLAM: slot1Image.sprite = superSlamSprite; break; case EPowerUps.BACK_OFF: slot1Image.sprite = backoffSprite; break; } } else { slot1Image.sprite = emptyPowerUpSprite; } if (_slot2.powerUp != null) { switch (_slot2.powerUp.powerUp) { case EPowerUps.SUPER_SPEED: slot2Image.sprite = superSpeedSprite; break; case EPowerUps.SUPER_SLAM: slot2Image.sprite = superSlamSprite; break; case EPowerUps.BACK_OFF: slot2Image.sprite = backoffSprite; break; } } else { slot2Image.sprite = emptyPowerUpSprite; } }
private IEnumerator PowerUpDrawCoroutine() { float powerUpIntervalTime = 0.0f; while (true) { if (GameState == GameStates.InGame) { powerUpIntervalTime += Time.deltaTime; if (powerUpIntervalTime > PowerUpProbability.CheckInterval) { powerUpIntervalTime = 0.0f; bool spawnPowerUp = PowerUpProbability.GetProbability(GameTime) > Random.Range(0, 100); if (spawnPowerUp == true) { Vector3 spawnPosition = EnemySpawner.GetSpawnPosition(); spawnPosition.y = Mathf.Max(PlayerManager.PlayerSpawnPoint.y + 2f, spawnPosition.y); Vector3 movementDirection = spawnPosition.x > 0 ? Vector3.left : Vector3.right; PowerUpHolder powerUpHolder = Instantiate(PowerUpHolderPrefab, spawnPosition, Quaternion.identity); powerUpHolder.SetMovementDirection(movementDirection); powerUpHolder.SetPowerUp(AvailablePowerUps.PickRandomElement()); powerUpHolder.OnHit += GivePowerUpToPlayer; Destroy(powerUpHolder, 10f); } } } yield return(new WaitForEndOfFrame()); } }