public static void RemoveEmbeddedObjectProcess(EmbeddedObject embeddedObject) { //disconnect embeddedObject.Remove(); try { if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "SampleScene") { GameObject.FindObjectOfType <BodyPartSelectorManager>().ResetSelectors(); GameObject.FindObjectOfType <EmbeddedObjectSelectorManager>().ResetSelectors(); } } catch (System.Exception e) { Debug.LogError($"RemoveEmbeddedObjectProcess: {e}"); } UpdateAllBodyPartHeartConnections(); //remove from being child of bodypart if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "SampleScene") { embeddedObject.transform.SetParent(MonoBehaviour.FindObjectOfType <EmbeddedObjectSelectorManager>().transform); } MonoBehaviour.FindObjectOfType <ActionTracker>().surgery_remove_implants += 1; }
public void Enter() { tetrisController = MonoBehaviour.FindObjectOfType <TetrisController>(); gameUIController = MonoBehaviour.FindObjectOfType <InGameUIController>(); tetrisController.Init(); gameUIController.Init(StoreManager.Instance); tetrisController.OnFinished = () => { // TODO: データの保存 SceneManager.LoadScene("Result"); }; // シーン遷移後にステートを変更 SceneManager.activeSceneChanged += OnSceneChanged; gameUIController.OnPaused = () => { }; gameUIController.OnInGamed = () => { }; gameUIController.OnTitled = () => { }; }
/// <summary> /// <description>Adds a topic to the dropdown and creates a button</description> /// </summary> /// <param name="topics">The topics array</param> /// <param name="number">The index in the array</param> private void AddButton(string[] topics, int number) { topicList.Add(topics[number]); var buttonSpawner = MonoBehaviour.FindObjectOfType <TopicButtonSpawner>(); buttonSpawner.NewTopicButton(topics[number]); }
public static IEnumerator ApplyPetrificationCharmCoroutine(BodyPart bodyPart, float seconds, int goldCost) { Clock clock = MonoBehaviour.FindObjectOfType <Clock>(); clock.StartClockUntil(seconds); ButtonActions buttonActions = MonoBehaviour.FindObjectOfType <ButtonActions>(); buttonActions.ActionInProgress(); while (clock.isTimePassing) { yield return(null); } buttonActions.ActionFinished(); if (!clock.actionCancelFlag) { ApplyPetrificationCharmProcess(bodyPart); GameObject.FindObjectOfType <GoldTracker>().goldSpent += goldCost; buttonActions.SelectCharmAction(); } else { clock.actionCancelFlag = false; } }
void Awake() { healthBarController = MonoBehaviour.FindObjectOfType(typeof(HealthBarController)) as HealthBarController; fuelBarController = MonoBehaviour.FindObjectOfType(typeof(FuelBarController)) as FuelBarController; if (debugPlayerController != null) { if (debugPlayerController is IPlayerControllerWithBars) { player = debugPlayerController as IPlayerControllerWithBars; player.HealthChanged += HealthChanged; player.FuelChanged += FuelChanged; } else { Debug.Log("Debug Player Controller needs to conform to IPlayerWithBars"); } return; } PlayerController controller = GetComponent <PlayerController>(); if (controller is IPlayerControllerWithBars) { player = (IPlayerControllerWithBars)controller; player.FuelChanged += FuelChanged; player.HealthChanged += FuelChanged; } else { Debug.LogError("Player Controller class needs to implement IPlayerWithBars" + "interface to communicate with health and fuel bars"); } }
private static IEnumerator AddBloodCoroutine(BodyPart bodyPart, float seconds, int goldCost, int blood) { Clock clock = MonoBehaviour.FindObjectOfType <Clock>(); clock.StartClockUntil(seconds); ButtonActions buttonActions = MonoBehaviour.FindObjectOfType <ButtonActions>(); buttonActions.UpdateMenuButtonsInteractivity(false); buttonActions.ActionInProgress(); while (clock.isTimePassing) { yield return(null); } buttonActions.ActionFinished(); if (!clock.actionCancelFlag) { bodyPart.GetComponent <BodyPart>().blood += blood; MonoBehaviour.FindObjectOfType <ActionTracker>().blood_injected += blood; GameObject.FindObjectOfType <GoldTracker>().goldSpent += goldCost; buttonActions.SelectBloodAction(); } else { clock.actionCancelFlag = false; } }
public HandPhysics(HistoryBuffer buffer) { historyBuffer = buffer; characterController = MonoBehaviour.FindObjectOfType <VR_CharacterController>(); trackingSpace = VR_Manager.instance.TrackingSpace; }
public FlashlightController() { _flashlight = MonoBehaviour.FindObjectOfType <Flashlight>(); _flashlight.Switch(false); _ui = MonoBehaviour.FindObjectOfType <FlashlightUIImage>(); }
protected virtual IEnumerator MovendoScroll_H(UmaOpcao[] umaS, int rowCellCount) { yield return(new WaitForSecondsRealtime(0.01f)); int val = (rowCellCount == -1) ? umaS.Length : Mathf.CeilToInt((float)umaS.Length / rowCellCount); int opc = OpcaoEscolhida / ((rowCellCount == -1) ? 1 : rowCellCount); contadorDeTempo += 0.01f; float destiny = 1 - Mathf.Clamp((float)(val - opc - 1) / Mathf.Max(val - 1, 1), 0, 1); //Debug.Log(OpcaoEscolhida + " : " + rowCellCount + " : " + opc); //Debug.Log(sr.verticalScrollbar.value + " : " + val+" : "+destiny); sr.horizontalScrollbar.value = Mathf.Lerp(sr.horizontalScrollbar.value, destiny, contadorDeTempo / TEMPO_DE_SCROLL); if (sr.horizontalScrollbar.value != destiny) { if (GameController.g) { GameController.g.StartCoroutine(MovendoScroll_H(umaS, rowCellCount)); } else { MonoBehaviour.FindObjectOfType <InitialSceneManager>().StartCoroutine(MovendoScroll_H(umaS, rowCellCount)); } } //GameController.g.StartCoroutine(MovendoScroll(umaS, rowCellCount)); }
public static IEnumerator RemoveOrganCoroutine(Organ organ, float seconds, int goldCost, float bloodLossRateInduced, float damageInduced) { Clock clock = MonoBehaviour.FindObjectOfType <Clock>(); clock.StartClockUntil(seconds); ButtonActions buttonActions = MonoBehaviour.FindObjectOfType <ButtonActions>(); buttonActions.UpdateMenuButtonsInteractivity(false); buttonActions.ActionInProgress(); while (clock.isTimePassing) { RemoveOrganDuring(organ, clock, seconds, bloodLossRateInduced, damageInduced); yield return(null); } buttonActions.ActionFinished(); if (!clock.actionCancelFlag) { RemoveOrganProcess(organ); GameObject.FindObjectOfType <GoldTracker>().goldSpent += goldCost; buttonActions.SelectSurgeryAction(); } }
public AudioElement(List <AudioClip> sounds, List <float> volumes, string id, Transform parentTransform) { if (sounds == null || sounds.Count == 0 || volumes == null || volumes.Count == 0 || sounds.Count != volumes.Count) { return; } element = new GameObject("AudioElement_" + id); if (parentTransform) { element.transform.parent = parentTransform; element.transform.localPosition = new Vector3(0, 0, 0); //element.transform.position = new Vector3(0, 0, 0); } else { // Attach it to the game object list (since we know there should be one present) // Do so to keep the inspector cleaner - this saves making a sounds object GameObjectList list = MonoBehaviour.FindObjectOfType(typeof(GameObjectList)) as GameObjectList; if (list) { element.transform.parent = list.transform; } } Add(sounds, volumes); }
public static IEnumerator DeleteBodyPartCoroutine(BodyPart bodyPart, float seconds, int goldCost) { Clock clock = MonoBehaviour.FindObjectOfType <Clock>(); clock.StartClockUntil(seconds); ButtonActions buttonActions = MonoBehaviour.FindObjectOfType <ButtonActions>(); buttonActions.UpdateMenuButtonsInteractivity(false); buttonActions.ActionInProgress(); while (clock.isTimePassing) { yield return(null); } buttonActions.ActionFinished(); if (!clock.actionCancelFlag) { DeleteBodyPartProcess(bodyPart); GameObject.FindObjectOfType <GoldTracker>().goldSpent += goldCost; if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "SampleScene") { MonoBehaviour.FindObjectOfType <BodyPartStatusManager>().UpdateStatusCollection(); } buttonActions.SelectSurgeryAction(); } }
public static IEnumerator ConnectBodyPartCoroutine(BodyPart bodyPart1, BodyPart bodyPart2, float seconds, int goldCost, float bloodLossRateInduced, float damageInduced) { Clock clock = MonoBehaviour.FindObjectOfType <Clock>(); clock.StartClockUntil(seconds); ButtonActions buttonActions = MonoBehaviour.FindObjectOfType <ButtonActions>(); buttonActions.UpdateMenuButtonsInteractivity(false); buttonActions.ActionInProgress(); while (clock.isTimePassing) { ConnectBodyPartDuring(bodyPart1, bodyPart2, clock, seconds, bloodLossRateInduced, damageInduced); yield return(null); } buttonActions.ActionFinished(); if (!clock.actionCancelFlag) { ConnectBodyPartProcess(bodyPart1, bodyPart2); GameObject.FindObjectOfType <GoldTracker>().goldSpent += goldCost; MonoBehaviour.FindObjectOfType <BodyPartStatusManager>().UpdateStatusCollection(); buttonActions.SelectSurgeryAction(); } }
public static void ImplantOrganProcess(Organ organ, BodyPart bodyPart) { //connect organ.CreateConnection(bodyPart); bodyPart.AddContainedOrgan(organ); try { if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "SampleScene") { GameObject.FindObjectOfType <BodyPartSelectorManager>().ResetSelectors(); GameObject.FindObjectOfType <EmbeddedObjectSelectorManager>().ResetSelectors(); MonoBehaviour.FindObjectOfType <BodyPartStatusManager>().UpdateStatusCollection(); } } catch (System.Exception e) { Debug.LogError($"ImplantOrganProcess: {e}"); } UpdateAllBodyPartHeartConnections(); //make organ child of bodypart organ.transform.SetParent(bodyPart.transform); MonoBehaviour.FindObjectOfType <ActionTracker>().surgery_organtransplant += 1; }
public IEnumerator GameControllerKillerTest() { yield return(TestUtils.WaitUntilSceneIsLoaded("MatchTestScene")); var gameController = MonoBehaviour.FindObjectOfType <GameController>(); var matchManager = MonoBehaviour.FindObjectOfType <MatchManager>(); Time.timeScale = 100.0f; int iterations = 5; while (--iterations > 0) { var settings = MatchSettings.CreateRandomMatchConfig(10, 10, 3, new AIType[] { AIType.Aggressive, AIType.RandomWalker, AIType.RandomWalker }); settings.PlayerConfigs[0].PlayerType = PlayerType.Bot; foreach (var unit in settings.PlayerConfigs[0].Units) { unit.UnitType = 1; } gameController.InitMatch(settings); while (!gameController.GameFinished()) { yield return(gameController.MatchStep()); } foreach (var unit in matchManager.Factions[0].Units) { Assert.IsTrue(unit.IsFullHP); } Assert.IsTrue(matchManager.Factions[1].IsDead); Assert.IsTrue(matchManager.Factions[2].IsDead); } }
public IEnumerator UnitKill() { yield return(TestUtils.WaitUntilSceneIsLoaded("UnitTestScene")); var unitFactory = MonoBehaviour.FindObjectOfType <UnitFactory>(); var iterations = 100; while (--iterations > 0) { var unit1 = unitFactory.CreateUnit(Random.Range(0, 3), 0, new Vector2Int(0, 0)); var unit2 = unitFactory.CreateUnit(Random.Range(0, 3), 1, new Vector2Int(0, 0)); var attacksToKill = Mathf.CeilToInt(((float)unit1.TotalHP) / ((float)unit2.AttackPower)); while (attacksToKill > 0) { yield return(unit1.AttackedBy(unit2, true)); if (attacksToKill == 1) { Assert.IsTrue(unit1.CurrentHP <= unit2.AttackPower); } attacksToKill = attacksToKill - 1; } Object.Destroy(unit1.gameObject); Object.Destroy(unit2.gameObject); } }
public IEnumerator GameControllerRandomWalkerTest() { yield return(TestUtils.WaitUntilSceneIsLoaded("MatchTestScene")); var gameController = MonoBehaviour.FindObjectOfType <GameController>(); var matchManager = MonoBehaviour.FindObjectOfType <MatchManager>(); int iterations = 10; Time.timeScale = 100.0f; while (--iterations > 0) { var settings = MatchSettings.CreateTestMatchConfig(AIType.RandomWalker); settings.PlayerConfigs[0].PlayerType = PlayerType.Bot; gameController.InitMatch(settings); while (!gameController.GameFinished() && gameController.CurrentTurnNumber < 20) { yield return(gameController.MatchStep()); } // All units should be alive and with full HP for (int i = 0; i < matchManager.Factions.Count; i++) { Assert.IsTrue(matchManager.Factions[i].Units.Count == settings.PlayerConfigs[i].Units.Count); foreach (var unit in matchManager.AllUnits()) { Assert.IsTrue(unit.IsFullHP); } } } }
public IEnumerator SpendActionPoints() { yield return(TestUtils.WaitUntilSceneIsLoaded("UnitTestScene")); var unitFactory = MonoBehaviour.FindObjectOfType <UnitFactory>(); var iterations = 100; while (--iterations > 0) { var unit = unitFactory.CreateUnit(Random.Range(0, 3), 0, new Vector2Int(0, 0)); unit.RegenerateAP(); var decrement = Random.Range(1, 5); var neededDecrements = unit.TotalAP / decrement; var module = unit.TotalAP % decrement; while (neededDecrements > 0) { Assert.IsTrue(unit.TryToSpend(decrement)); neededDecrements--; } if (module > 0) { Assert.IsTrue(unit.TryToSpend(module)); } else { Assert.IsFalse(unit.TryToSpend(1)); } Assert.IsTrue(unit.CurrentAP == 0); } }
public void Start() { // try to catch any exception if compatibility issues with KSP occur try { var gaugesObject = (GameObject)MonoBehaviour.FindObjectOfType <LinearControlGauges>().gameObject; var gaugesClass = gaugesObject.GetComponent <LinearControlGauges>(); KSP.UI.Screens.LinearGauge roll = gaugesClass.roll; KSP.UI.Screens.LinearGauge pitch = gaugesClass.pitch; KSP.UI.Screens.LinearGauge yaw = gaugesClass.yaw; // create gauges this.trimRollGauge = CreateGauge("GaugeRollTrimPointer", roll); this.trimPitchGauge = CreateGauge("GaugePitchTrimPointer", pitch); this.trimYawGauge = CreateGauge("GaugeYawTrimPointerw", yaw); } catch (Exception e) { Debug.Log("exception caught in trim indicator init"); disabled = true; throw e; } }
public FlashLightController() { _flashLight = MonoBehaviour.FindObjectOfType <FlashLightModel>(); _flashLightUi = MonoBehaviour.FindObjectOfType <FlashLightUiText>(); _flashLightUIImage = MonoBehaviour.FindObjectOfType <FlashLightUIImage>(); Off(); }
public static IEnumerator ApplyBloodRegenCharmCoroutine(BodyPart bodyPart, float seconds, int goldCost) { Clock clock = MonoBehaviour.FindObjectOfType <Clock>(); clock.StartClockUntil(seconds); ButtonActions buttonActions = MonoBehaviour.FindObjectOfType <ButtonActions>(); buttonActions.ActionInProgress(); while (clock.isTimePassing) { yield return(null); } buttonActions.ActionFinished(); if (!clock.actionCancelFlag) { bodyPart.gameObject.AddComponent <BloodRegenCharm>(); MonoBehaviour.FindObjectOfType <ActionTracker>().charm_petrification += 1; GameObject.FindObjectOfType <GoldTracker>().goldSpent += goldCost; } else { clock.actionCancelFlag = false; } }
// Use this for initialization void Start() { MindMapManager mmmgr = (MindMapManager)MonoBehaviour.FindObjectOfType(typeof(MindMapManager)); _line.SetPosition(0, mmmgr._currentPos); _line.SetPosition(1, this.transform.position); }
public override void Enter() { uIController = MonoBehaviour.FindObjectOfType <ResultUIController>(); // タイトルボタンを押下したらタイトルシーンをロード uIController.OnTitleBtnClicked = () => { SceneManager.LoadScene(SceneName.Title); }; // シーンをロードしたときのイベントを登録 SceneManager.activeSceneChanged += OnActiveSceneChanged; int humanScore = ScoreStore.Instance.GetScore(PlayerType.Human); int aiScore = ScoreStore.Instance.GetScore(PlayerType.Ai); if (humanScore >= aiScore) { uIController.Win(); } else { uIController.Lose(); } }
public static void SpawnBodyPartProcessTemplate(int goldCost, string partName, Func <string, BodyPart> spawnMethod, int menuReset) { spawnMethod(partName); MonoBehaviour.FindObjectOfType <ActionTracker>().spawn_spawned += 1; GameObject.FindObjectOfType <GoldTracker>().goldSpent += goldCost; MonoBehaviour.FindObjectOfType <BodyPartStatusManager>().UpdateStatusCollection(); switch (menuReset) { case 0: MonoBehaviour.FindObjectOfType <ButtonActions>().SelectSpawnOrganActionOptions(); break; case 1: MonoBehaviour.FindObjectOfType <ButtonActions>().SelectSpawnBodyPartActionOptions(); break; case 2: MonoBehaviour.FindObjectOfType <ButtonActions>().SelectSpawnClockworkOrganActionOptions(); break; case 3: MonoBehaviour.FindObjectOfType <ButtonActions>().SelectSpawnClockworkLimbActionOptions(); break; default: break; } }
public static void RemoveOrganProcess(Organ organ) { //disconnect BodyPart organParent = organ.connectedBodyParts[0]; organ.SeverAllConnections(); try { if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "SampleScene") { GameObject.FindObjectOfType <BodyPartSelectorManager>().ResetSelectors(organParent); GameObject.FindObjectOfType <EmbeddedObjectSelectorManager>().ResetSelectors(); MonoBehaviour.FindObjectOfType <BodyPartStatusManager>().UpdateStatusCollection(); } } catch (System.Exception e) { Debug.LogError(e); } UpdateAllBodyPartHeartConnections(); //remove from being child of bodypart organ.transform.SetParent(organ.transform.parent.parent); MonoBehaviour.FindObjectOfType <ActionTracker>().surgery_organremovals += 1; }
// Use this for initialization public void Start() { manager = MonoBehaviour.FindObjectOfType <CharacterManager>(); posAnterior = manager.transform.position; gerenteDeEncontro = new EncounterManager(); proxEncontro = SorteiaPassosParaEncontro(); }
public void InitContainer(GameObject containerObject) { _playerCameraLook = MonoBehaviour.FindObjectOfType <CameraLook>(); _characterMovement = MonoBehaviour.FindObjectOfType <CharacterMovement>(); _playerAttack = MonoBehaviour.FindObjectOfType <PlayerAttack>(); slotGameObject = Resources.Load("InventorySlot") as GameObject; containerGameObject = containerObject; }
private IEnumerator StartGame() { GameLogger.LogMessage("StartGame called", "GameManager"); this.StartCoroutine(this.CheckLoading()); this.levelManager.SetupScene(this.currentLevelNumber, GameManager.customLevel); this.playerInstance = MonoBehaviour.FindObjectOfType <Player>(); yield return(new WaitForEndOfFrame()); }
private void ShowQuestBtn() { if (_questBtn == null) { _questBtn = MonoBehaviour.FindObjectOfType <QuestButton>(); } _questBtn.gameObject.SetActive(true); }
internal void HideQuestBtn() { if (_questBtn == null) { _questBtn = MonoBehaviour.FindObjectOfType <QuestButton>(); } _questBtn.gameObject.SetActive(false); }