// When a correct answer is chosen by button press. Plays audio, increments score, increments progress, destroys barrel, and checks success conditions. void HandleCorrectAnswer(BarrelManager barrel) { _audioPlayer.PlayOneShot(_correctSound, correctSoundVolume); score += scoreModifier; correctBarrelCount++; Destroy(barrel.gameObject); if (correctBarrelCount >= barrelsRequired) { SuccessConditionMet(); } }
public override void OnInspectorGUI() { _so.Update(); EditorGUILayout.PropertyField(_propRadius); EditorGUILayout.PropertyField(_propDamage); EditorGUILayout.PropertyField(_propColor); if (_so.ApplyModifiedProperties()) { BarrelManager.TryApplyAllColors(); } }
public static void StopTheTank() { TankManager.Sensor.Stop(); Console.Write("Tread Manager: "); TreadsManager.Stop(); Console.Write("Barrel Manager: "); BarrelManager.Stop(); Console.Write("Sides Manager: "); PanelsManager.Stop(); Console.WriteLine("Closing uDMX"); DmxControl.Dispose(); }
// When an incorrect answer is chosen by button press or bottom of screen being reached. Plays audio, destroys barrel, decreases lives, and checks fail conditions. void HandleIncorrectAnswer(BarrelManager barrel) { Instantiate(_explosionPrefab).transform.position = barrel.transform.position; _audioPlayer.PlayOneShot(_incorrectSound, incorrectSoundVolume); Debug.Log("Handle In: " + lives); lives -= 1; if (lives < 1) { FailConditionMet(); lives = 0; } score -= scoreModifier; Destroy(barrel.gameObject); }
IEnumerator Explode() { barrelsInRadius = GameObject.FindGameObjectsWithTag("Barrel"); SoundManager.Instance.Play(explosionSound, SceneManager.Instance.camera.transform, 0.2f); rend.material = invisible; explosion.GetComponent <ParticleSystem>().Play(); foreach (GameObject barrel in barrelsInRadius) { float distance = Vector3.Distance(myTransform.position, barrel.transform.position); if (barrel != this && (distance <= explosionRadius)) { BarrelManager bm = barrel.GetComponent <BarrelManager>(); if (bm.damaged == false) { bm.damaged = true; bm.SetHealth(2); bm.LightFuse(); } } } foreach (GameObject enemy in EnemySpawnManager.Instance.enemies) { if (enemy == null) { continue; } if (Vector3.Distance(myTransform.position, enemy.transform.position) <= explosionRadius) { enemy.GetComponent <Breakable>().Damage(mobDamage); } } if (Vector3.Distance(myTransform.position, SceneManager.Instance.playerTransform.position) <= explosionRadius) { Debug.Log("Explosion hit player!"); SceneManager.Instance.DamagePlayer(playerDamage); } yield return(new WaitForSeconds(explosionDuration)); Destroy(gameObject); }
// Handles a button click public void ButtonClicked(string type) { // Debug.Log (type); if (gameOver) { return; } if (barrels.Count == 0) { return; } BarrelManager nextBarrel = barrels.Dequeue(); if (nextBarrel.correctAnswer == type) { HandleCorrectAnswer(nextBarrel); } else { HandleIncorrectAnswer(nextBarrel); } }
// Determines if a barrel has reached the bottom of the screen void CalculateBarrelCrash() { if (barrels.Count == 0) { return; } BarrelManager nextBarrel = barrels.Peek(); if (nextBarrel.gameObject.transform.position.y <= -_mainCamera.orthographicSize * 0.87f) { do { barrels.Dequeue(); HandleIncorrectAnswer(nextBarrel); if (barrels.Count == 0) { break; } nextBarrel = barrels.Peek(); } while(nextBarrel.gameObject.transform.position.y <= -_mainCamera.orthographicSize); } }
static void changeIdleTimer_Elapsed(object sender, ElapsedEventArgs e) { TreadsManager.NextIdleEffect(); BarrelManager.NextIdleEffect(); PanelsManager.NextIdleEffect(); }
private void Awake() { Instance = this; }
public void InitGame() { GameObject.Find("LoadingScreen").transform.GetChild(0).gameObject.SetActive(true); if (PhotonNetwork.IsMasterClient) { isWereWolf = new bool[playersNameList.Count]; int randomIndex = UnityEngine.Random.Range(0, playersNameList.Count); isWereWolf[randomIndex] = true; photonView.RPC("RPC_ChooseWereWolf", RpcTarget.AllBufferedViaServer, isWereWolf); PhotonNetwork.CurrentRoom.IsOpen = false; } if (fov == null) { fov = FindObjectOfType <FieldOfView>(); } if (barrelManager == null) { barrelManager = FindObjectOfType <BarrelManager>(); } if (camera == null) { camera = FindObjectOfType <CameraController>(); } if (votingArea == null) { votingArea = FindObjectOfType <VotingArea>(); } if (chat == null) { chat = FindObjectOfType <ChatUI>(); } if (shop == null) { shop = FindObjectOfType <Shop>(); } if (gameTimeUI == null) { gameTimeUI = FindObjectOfType <GameTimeUI>(); } if (playerItemsUI == null) { playerItemsUI = FindObjectOfType <playerItemsUI>(); } timer = dayTime; gamePhase = GamePhases.Day; barrelManager.canStartGeneration = true; barrelManager.GenerateBarrels(); shop.canGenerateNewRecipe = true; if (shop.canGenerateNewRecipe) { if (PhotonNetwork.IsMasterClient) { shop.canGetReward = true; shop.GenerateNewRecipe(); } } if (PhotonNetwork.IsMasterClient) { photonView.RPC("RPC_test", RpcTarget.AllBufferedViaServer); } StartCoroutine(delayedList()); }
// Creates a barrel from xml file and difficulty void CreateBarrel() { GameObject newBarrel = Instantiate(_barrelPrefab); BarrelManager newBarrelScript = newBarrel.GetComponent <BarrelManager> (); // Initialize barrel physical state float xPos = Random.Range(-_mainCamera.orthographicSize * Screen.width / Screen.height + newBarrel.transform.localScale.x / 2, _mainCamera.orthographicSize * Screen.width / Screen.height - newBarrel.transform.localScale.x / 2); newBarrel.transform.position = new Vector3(xPos, _mainCamera.orthographicSize + newBarrel.transform.localScale.y / 2, barrelIndex * 0.0001f); // Initialize barrel script state (Choose barrel hint and correct answer here) int preferredDifficulty = Mathf.FloorToInt(SettingsManager.manager.currentStage + 1f); Barrel barrelData = HintHelper.manager.GetRandomBarrelFromDifficulty(preferredDifficulty, 1, allowedFertilizers); if (barrelData == null) { Destroy(newBarrel); return; } bool success = false; if (success == false && !string.IsNullOrEmpty(barrelData.imagePath)) { Sprite imageHint = HintHelper.manager.LoadSpriteByName(barrelData.imagePath); if (imageHint != null) { newBarrelScript.SetHintImage(imageHint); newBarrelScript.ImageHint(); success = true; } } if (success == false && !string.IsNullOrEmpty(barrelData.hintText)) { newBarrelScript.SetHintText(barrelData.hintText); newBarrelScript.TextHint(); success = true; } if (success == false) { Destroy(newBarrel); return; } //newBarrelScript.SetHintText ("- A: " + SettingsManager.manager.fertilizerTypeNames [selectedType]); //newBarrelScript.TextHint (); newBarrelScript.correctAnswer = barrelData.fertilizerType; // Show barrel newBarrel.SetActive(true); barrels.Enqueue(newBarrelScript); barrelIndex++; }