public void UpdateBoatProgress(float fuelPercentage) { if (gameHasStarted) { float addedProgression = 0; if (fuelPercentage >= _fullProgressBoundary) { addedProgression += _fullSpeedProgress * Time.deltaTime; _paddleWheelSpeed.rotationTime = 4.0f; } else if (fuelPercentage >= _twoThirdsProgressBoundary) { addedProgression += (_fullSpeedProgress * 0.66f) * Time.deltaTime; _paddleWheelSpeed.rotationTime = 7.0f; } else if (fuelPercentage > 0) { addedProgression += (_fullSpeedProgress * 0.33f) * Time.deltaTime; _paddleWheelSpeed.rotationTime = 30.0f; } _boatProgress += addedProgression; UpdateBoatPosition(_boatProgress); if (_boatProgress > 0.5f && !_halfWay) { _halfWay = true; SingletonManager.GetInstance <StormController>().ActivateStorm(); } } }
public void OnEnable() { SingletonManager m = SingletonManager.GetInstance(); if (m != null) { m.GetAudioManager().PlayClip(soundClipName, 1.0f); } }
private void PlayClip() { SingletonManager m = SingletonManager.GetInstance(); if (m != null) { m.GetAudioManager().PlayDialog(dialogClipName); } }
public void OnEnable() { SingletonManager m = SingletonManager.GetInstance(); if (m != null) { m.GetAudioManager().PlayMusic(musicClipName); } }
public void AssignController(int controller) { _controllerNumber = controller; var textureManager = SingletonManager.GetInstance <TextureManager>(); if (textureManager != null) { GetComponent <Renderer>().material = textureManager.GetMaterialFromPlayerNumber(controller); } }
private void StartWinFlow() { SingletonManager.GetInstance <ScoreManager>().InitiateEndOfGame(); Debug.Log("You've finished the game! Congrats!"); _endText.SetActive(true); if (!_resetGameStarted) { bool _resetGameStarted = true; StartCoroutine(LoadFirstScene(10)); } }
private void Start() { _resetGameStarted = false; SingletonManager.GetInstance <ControllerManager>().SpawnPlayers(); if (_boatObjectiveSlider == null) { Debug.LogError("Please fill the serialized \"_boatObjectiveSlider\" variable on the GameModeManager attached to " + gameObject.name); } }
private void OnTriggerEnter(Collider other) { Debug.Log("Collider is" + other.gameObject.name + "_" + other.gameObject.tag); { if (other.tag != "Indestructible" && other.tag != "Boat" && other.tag != "Net" && other.gameObject != gameObjectToIgnore) { SingletonManager.GetInstance <NetTargetManager>().DropOnBoat(other.gameObject); } } }
static int GetInstance(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); LuaFramework.PeriodCallBackManager o = SingletonManager<LuaFramework.PeriodCallBackManager>.GetInstance(); ToLua.PushObject(L, o); return 1; } catch (Exception e) { return LuaDLL.toluaL_exception(L, e); } }
public void ReferenceTestMultipleTypes() { int numberOfThreads = 50; SingletonTestType1 instance1; SingletonTestType2 instance2; SingletonTestType1[] instances1 = new SingletonTestType1[numberOfThreads]; SingletonTestType2[] instances2 = new SingletonTestType2[numberOfThreads]; Thread[] threads = new Thread[numberOfThreads]; instance1 = SingletonManager.GetInstance <SingletonTestType1>(); instance2 = SingletonManager.GetInstance <SingletonTestType2>(); for (int i = 0; i < numberOfThreads; i++) { threads[i] = new Thread((obj) => { int index = (int)obj; instances1[index] = SingletonManager.GetInstance <SingletonTestType1>(); instances2[index] = SingletonManager.GetInstance <SingletonTestType2>(); Assert.IsTrue(instance1 is SingletonTestType1); Assert.IsTrue(instance2 is SingletonTestType2); Assert.IsTrue(instances1[index] is SingletonTestType1); Assert.IsTrue(instances2[index] is SingletonTestType2); Assert.IsTrue(object.ReferenceEquals(instance1, instances1[index])); Assert.IsTrue(object.ReferenceEquals(instance2, instances2[index])); }); } //Start all threads. for (int i = 0; i < numberOfThreads; i++) { threads[i].Start(i); } //Wait for all threads to finish. for (int i = 0; i < numberOfThreads; i++) { threads[i].Join(); } Assert.IsTrue(instance1 is SingletonTestType1); Assert.IsTrue(instance2 is SingletonTestType2); Assert.IsTrue(instances1.All(inst => inst is SingletonTestType1)); Assert.IsTrue(instances2.All(inst => inst is SingletonTestType2)); Assert.IsTrue(instances1.All(inst => object.ReferenceEquals(inst, instance1))); Assert.IsTrue(instances2.All(inst => object.ReferenceEquals(inst, instance2))); }
public void ParameterlessConstructorTest() { SingletonTestTypeNoCtor instance; try { instance = SingletonManager.GetInstance <SingletonTestTypeNoCtor>(); Assert.Fail("ArgumentException not thrown."); } catch (Exception exc) { Assert.IsInstanceOfType(exc, typeof(ArgumentException)); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { other.gameObject.GetComponent <PlayerController>().StartRespawn(); } else if (other.gameObject.GetComponent <Cannon>() != null) { SingletonManager.GetInstance <NetTargetManager>().DropOnBoat(other.gameObject); } else if (other.gameObject.tag != "Indestructible") { Destroy(other.gameObject); } }
public void SpawnTheObject() { Quaternion rot = transform.rotation; Vector3 pos = transform.position; float halfLength = length / 2.0f; //x-axis float halfWidth = width / 2.0f; //z-axis float halfHeight = height / 2.0f; //y-axis switch (whereToSpawn) { case WHERE_TO_SPAWN.TARGET_VECTOR3: rot = spawnRotation; pos = spawnPosition; break; case WHERE_TO_SPAWN.TARGET_TRANSFORM: rot = targetRotationTransform.rotation; pos = targetPositionTransform.position; break; case WHERE_TO_SPAWN.RANDOM_AREA_IN_BOUNDS: if (randomBounds == RANDOM_BOUNDS.SPHERE) { pos = Random.insideUnitSphere * radius; } else { float rndX = Random.Range(-halfLength, halfLength); float rndY = Random.Range(-halfHeight, halfHeight); float rndZ = Random.Range(-halfWidth, halfWidth); pos = new Vector3(rndX, rndY, rndZ); } break; } //now we know pos and rot to spawn SingletonManager m = SingletonManager.GetInstance(); if (m != null) { IPoolManager p = m.GetPoolManager(); if (p != null) { ObjectPool pool = p.GetObjectPool(poolName); if (pool != null) { PooledObject pooled = pool.GetPooledObject(objectName); if (pooled != null) { GameObject objSpawned = pooled.Spawn(pos, rot); if (objSpawned == null) { Debug.LogWarning("The pool \"" + poolName + "\" had no more allocated \"" + objectName + "\" objects able to be spawned."); } } else { Debug.LogError("The SpawnObject tried to spawn the object \"" + objectName + "\" from the pool \"" + poolName + "\" but it didn't exist."); } } else { Debug.LogError("The SpawnObject tried to access the pool \"" + poolName + "\" and it doesn't exist."); } } } }
private void Start() { manager = SingletonManager.GetInstance <GameModeManager>(); _audio = GetComponent <AudioSource>(); }
/// <summary> /// Gets the singleton instance of the specified class type that is managed /// by <see cref="SingletonManager"/>. If no instance exists, then /// one is created using the type's parameterless contructor. /// </summary> /// <returns>Returns the singleton instance of the specified type.</returns> public static T GetInstance() { return(SingletonManager.GetInstance <T>()); }