void Start() { if (highlighter == null) { highlighter = gameObject.GetComponent <HighlighterHelper> (); } }
void Start() { rig = gameObject.GetComponent <Rigidbody> (); if (rig == null) { rig = gameObject.AddComponent <Rigidbody> (); rig.useGravity = true; rig.isKinematic = false; } if (highlighter == null) { highlighter = gameObject.GetComponent <HighlighterHelper> (); } if (state == SnapTargetState.Locked) { clearPhysic(); } else { } }
private void OnDisable() { if (Initialized && fsmEditor != null) { fsmEditor.OnDisable(); } HighlighterHelper.Reset(GetType()); instance = null; }
private static void OpenWindow <T>(string id = "Window") where T : EditorWindow { if (FsmEditorSettings.PingOpenEditorWindows) { var window = Resources.FindObjectsOfTypeAll <T>(); if (window.Length > 0) { HighlighterHelper.PingHighlight(typeof(T), id); } } GetWindow <T>(); }
public void TestSingleIntersection() { var minusSections = new List <Section>(); var plusSections = new List <Section>(); minusSections.Add(new Section(0, 101, 1)); minusSections.Add(new Section(200, 1010, 1)); plusSections.Add(new Section(1011, 1031, 1)); minusSections.Add(new Section(1200, 1310, 1)); var intersections = HighlighterHelper.GetIntersections(minusSections, plusSections); intersections.Count.ShouldBe(1); intersections.First().Item1.ShouldBe(minusSections[1]); intersections.First().Item2.ShouldBe(plusSections[0]); }
public void CanCombineWithBothNextAndPreviousSection() { var s1 = new Section(10, 20, 2); var s3 = new Section(80, 100, 2); var sections = new List <Section> { s1, s3 }; var s2 = new Section(22, 79, 1); HighlighterHelper.AddToSection(sections, s2); sections.Count.ShouldBe(1); sections[0].Start.ShouldBe(s1.Start); sections[0].End.ShouldBe(s3.End); sections[0].DelimiterLength.ShouldBe(s3.DelimiterLength); }
public void GiveALineNotInAnyExistingSection_ANewSectionAdded() { var s1 = new Section(10, 20, 2); var s3 = new Section(80, 100, 2); var sections = new List <Section> { s1, s3 }; var s2 = new Section(23, 78, 1); HighlighterHelper.AddToSection(sections, s2); sections.Count.ShouldBe(3); sections[0].ShouldBe(s1); sections[1].ShouldBe(s2); sections[2].ShouldBe(s3); }
// Use this for initialization void Start() { if (GetComponent <SnapTarget> () != null) { snap = GetComponent <SnapTarget> (); } if (GetComponent <HighlighterHelper> () != null) { hl = GetComponent <HighlighterHelper> (); } audioSource = GetComponent <AudioSource> (); audioSource.loop = false; audioSource.volume = volume; audioSource.spatialBlend = 0.0f; }
/// <summary> /// Open a window and optionally "ping" it if it's already open. /// </summary> public static void OpenWindow <T>(string id = "Window") where T : EditorWindow { // Sometimes it's confusing in Unity when you open a window // that's already open but you get no feedback and can't find it. // We fix this by "pinging" the window if it's already open. if (FsmEditorSettings.PingOpenEditorWindows) { var window = Resources.FindObjectsOfTypeAll <T>(); if (window.Length > 0) { HighlighterHelper.PingHighlight(typeof(T), id); } } GetWindow <T>(); }
public void TestNoIntersection() { var minusSections = new List <Section>(); var plusSections = new List <Section>(); minusSections.Add(new Section(0, 101, 1)); minusSections.Add(new Section(200, 1010, 1)); plusSections.Add(new Section(1012, 1031, 1)); minusSections.Add(new Section(1200, 1310, 1)); minusSections.Add(new Section(1320, 1380, 1)); minusSections.Add(new Section(1400, 1410, 1)); plusSections.Add(new Section(1413, 1490, 1)); minusSections.Add(new Section(1499, 1510, 1)); plusSections.Add(new Section(1522, 1590, 1)); var intersections = HighlighterHelper.GetIntersections(minusSections, plusSections); intersections.Count.ShouldBe(0); }
public void TestFirstPlusIsNotInAnyIntersection() { var minusSections = new List <Section>(); var plusSections = new List <Section>(); minusSections.Add(new Section(0, 101, 1)); minusSections.Add(new Section(200, 1010, 1)); plusSections.Add(new Section(1013, 1031, 1)); minusSections.Add(new Section(1200, 1310, 1)); minusSections.Add(new Section(1320, 1380, 1)); minusSections.Add(new Section(1400, 1410, 1)); plusSections.Add(new Section(1411, 1490, 1)); minusSections.Add(new Section(1499, 1510, 1)); plusSections.Add(new Section(1522, 1590, 1)); var intersections = HighlighterHelper.GetIntersections(minusSections, plusSections); intersections.Count.ShouldBe(1); intersections[0].Item1.ShouldBe(minusSections[4]); intersections[0].Item2.ShouldBe(plusSections[1]); }
public override void OnInspectorGUI() { GUILayout.BeginVertical(); try { fsmInspector.OnGUI(); } catch (Exception e) { if (e is ExitGUIException) { throw; } //TODO: detect if stuck in loop here // E.g., set a "triedToRecover" flag that is cleared when OnGUI succeeds. // If triedToRecover is true here it means we failed twice! fsmInspector.Reset(); Repaint(); GUIUtility.ExitGUI(); } GUILayout.EndVertical(); if (Event.current.type == EventType.Repaint) { if (inspectorWindow == null) { inspectorWindow = EditorHacks.GetUnityInspectorWindow(); } HighlighterHelper.Init(inspectorWindow); HighlighterHelper.FromGUILayout("PlayMakerFSM_" + fsmComponent.GetInstanceID()); HighlighterHelper.OnGUI(); } }
public void TestIntersectionWithDifferentDelimiters() { var minusSections = new List <Section>(); var plusSections = new List <Section>(); minusSections.Add(new Section(0, 101, 1)); minusSections.Add(new Section(200, 1010, 1)); plusSections.Add(new Section(1011, 1031, 1)); minusSections.Add(new Section(1200, 1310, 1)); minusSections.Add(new Section(1320, 1380, 1)); minusSections.Add(new Section(1400, 1410, 2)); plusSections.Add(new Section(1412, 1490, 1)); minusSections.Add(new Section(1499, 1510, 1)); plusSections.Add(new Section(1522, 1590, 1)); var intersections = HighlighterHelper.GetIntersections(minusSections, plusSections); intersections.Count.ShouldBe(2); intersections.First().Item1.ShouldBe(minusSections[1]); intersections.First().Item2.ShouldBe(plusSections[0]); intersections[1].Item1.ShouldBe(minusSections[4]); intersections[1].Item2.ShouldBe(plusSections[1]); }
private void updateStep() { if (stepIndex < 0 || stepIndex >= steps.Length) { return; } StepInfo info = steps [stepIndex]; GameObject[] items = info.items; AudioClip[] audios = info.audios; // pick up the tire iron if (stepIndex == 0) { if (items[0].GetComponent <SnapTarget>().state == SnapTargetState.Locked) { items[0].GetComponent <SnapTarget>().unlockTarget(); } if (items[1].GetComponent <SnapBase>().state == SnapBaseState.Closed) { return; } lightOffAll(items); } // remove the lug nuts else if (stepIndex >= 1 && stepIndex <= 5) { TwistTarget2 lugNut = items[0].GetComponent <TwistTarget2>(); if (lugNut.progress != 0) { return; } items[0].GetComponent <SnapTarget>().highlighter.lightOff(); items[0].GetComponent <TwistTarget2>().SetDisable(); } // put the jack to the correct position else if (stepIndex == 6) { if (items[0].GetComponent <SnapTarget>().state == SnapTargetState.Locked) { items[0].GetComponent <SnapTarget>().unlockTarget(); } if (items[1].GetComponent <SnapBase>().state == SnapBaseState.Closed) { return; } lightOffAll(items); } // put the jack to the correct position else if (stepIndex == 7) { if (items [0].GetComponent <SnapTarget> ().state != SnapTargetState.Closed) { return; } lightOffAll(items); } // pick up the jack hook else if (stepIndex == 8) { if (items [0].GetComponent <SnapTarget> ().state == SnapTargetState.Locked) { items [0].GetComponent <SnapTarget> ().unlockTarget(); } if (items [1].GetComponent <SnapBase> ().state == SnapBaseState.Closed) { return; } lightOffAll(items); } else if (stepIndex == 9) { for (int i = 2; i < items.Length; i++) { if (items [i].GetComponent <SnapTarget> ().state != SnapTargetState.Locked) { items [i].GetComponent <SnapTarget> ().lockTarget(); items [i].GetComponent <SnapTarget> ().highlighter.lightOff(); } } if (items [0].GetComponent <JackHook> ().state != JackHookState.Connecting) { items [1].GetComponent <HighlighterHelper> ().lightOn(Color.green); return; } // lock the jack once the jack hook is connected. items [0].GetComponent <JackHook> ().SetEnable(); steps [0].items [0].GetComponent <SnapTarget> ().lockTarget(); if (items [1].GetComponent <JackHookBase> ().getProgress() < 1.0f) { return; } items [0].GetComponent <JackHook> ().SetDisable(); lightOffAll(items); } // remove the lug nuts else if (stepIndex >= 10 && stepIndex <= 14) { SnapTarget lugNut = items [0].GetComponent <SnapTarget> (); if (lugNut.state == SnapTargetState.Locked) { lugNut.unlockTarget(); } if (lugNut.state != SnapTargetState.Open) { return; } lugNut.highlighter.lightOff(); } else if (stepIndex == 15) { SnapTarget flatTire = items [0].GetComponent <SnapTarget> (); if (flatTire.state == SnapTargetState.Locked) { flatTire.unlockTarget(); } if (flatTire.state != SnapTargetState.Open) { return; } flatTire.highlighter.lightOff(); } // get the spare tire from the truck else if (stepIndex == 16) { // hide the tool tray over the spare tire items [2].SetActive(false); if (items [0].GetComponent <SnapTarget> ().state == SnapTargetState.Locked) { items [0].GetComponent <SnapTarget> ().unlockTarget(); } if (items [1].GetComponent <SnapBase> ().state == SnapBaseState.Closed) { return; } lightOffAll(items); } // put the spare tire onto the hub else if (stepIndex == 17) { if (items [1].GetComponent <SnapBase> ().state != SnapBaseState.Closed) { return; } lightOffAll(items); } // put back the lug nuts and tighten them else if (stepIndex >= 18 && stepIndex <= 22) { SnapBase stud = items [0].GetComponent <SnapBase> (); if (stud.targetObj != null && curObj == null) { curObj = stud.targetObj; if (curObj.GetComponent <TwistTarget2> () != null) { curObj.GetComponent <TwistTarget2> ().SetEnable(); } // please put on tighten the lugNut with Tire Iron if (audios.Length > 1) { playAudioEffect(audios [1]); } } if (stud.state == SnapBaseState.Closed) { HighlighterHelper[] hl = stud.GetComponentsInChildren <HighlighterHelper> (); if (hl.Length > 0) { hl [0].lightOff(); } } if (stud.state == SnapBaseState.Closed && curObj != null && curObj.GetComponent <TwistTarget2> ().progress >= curObj.GetComponent <TwistTarget2> ().max2) { curObj = null; // go to next Step } else { return; } lightOffAll(items); } // jack down the car else if (stepIndex == 23) { items [0].GetComponent <JackHook> ().SetEnable(); if (items [1].GetComponent <JackHookBase> ().getProgress() > 0.0f) { return; } lightOffAll(items); if (audios.Length > 1) { playAudioEffect(audios [1]); } } // put the flat tire to the truck else if (stepIndex == 24) { items [2].SetActive(false); if (items [1].GetComponent <SnapBase> ().state != SnapBaseState.Closed) { return; } items [0].GetComponent <SnapTarget> ().lockTarget(); items [2].SetActive(true); lightOffAll(items); } // disconnect the jack hook and put it back to the trunk else if (stepIndex == 25) { // disable the jaskhook base; items [1].SetActive(false); items [0].GetComponent <JackHook> ().SetState(JackHookState.Open); if (items [2].GetComponent <SnapBase> ().state != SnapBaseState.Closed) { return; } // unlock the jack steps [0].items [0].GetComponent <SnapTarget> ().unlockTarget(); lightOffAll(items); } // remove the jack and put it back to the trunk else if (stepIndex == 26) { if (items [1].GetComponent <SnapBase> ().state != SnapBaseState.Closed) { return; } lightOffAll(items); } // put the tire iron to the tooltray else if (stepIndex == 27) { if (items [1].GetComponent <SnapBase> ().state != SnapBaseState.Closed) { return; } lightOffAll(items); } else if (stepIndex == 28) { HighlighterHelper car = items [0].GetComponent <HighlighterHelper> (); car.lightOn(); print("Completed!!!!!"); completed = true; timer.index = 3; } info.delay -= Time.deltaTime; if (info.delay > 0) { return; } stepIndex = info.nextStepIndex; enableStep(); }
private void Update() { if (Input.GetKeyDown(KeyCode.F9)) { if (PhotoModeCamera.instance != null) { PhotoModeCamera.instance.Destroy(); } else { UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("PhotoMode")); PhotoModeCamera.instance.StopTime = true; } } if (Input.GetKeyDown(KeyCode.F8)) { if (PhotoModeCamera.instance != null) { StageScript.Instance.AllowInput = true; PhotoModeCamera.instance.Destroy(); } else { StageScript.Instance.AllowInput = false; UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("PhotoMode")); PhotoModeCamera.instance.StopTime = false; } } if (Input.GetKeyDown(KeyCode.F10)) { GameObject gameObject = new GameObject(); MegaGrab megaGrab = gameObject.AddComponent <MegaGrab>(); megaGrab.SrcCamera = Camera.main; megaGrab.SaveName = "Capture"; megaGrab.ResUpscale = 2; megaGrab.AASamples = 4; megaGrab.Quality = 1f; megaGrab.Path = Environment.CurrentDirectory; megaGrab.OutputFormat = IMGFormat.Tga; megaGrab.GrabWidthWillBe = 1920; megaGrab.GrabHeightWillBe = 1080; megaGrab.GrabKey = KeyCode.None; megaGrab.DoScreenGrab(); Debug.Log("Done Screenshot"); UnityEngine.Object.Destroy(gameObject, 0.1f); } if (Input.inputString.Length > 0) { this.lastInput += Input.inputString.ToLower(); if (this.lastInput.Length > 10) { this.lastInput = this.lastInput.Remove(0, this.lastInput.Length - 10); } if (this.lastInput.EndsWith("ravpic")) { this.Ravpic(); } else if (this.lastInput.EndsWith("movie")) { this.Ravpic(); this.Noise(); this.Outline(); this.StopTapes(); this.Music(); } else if (this.lastInput.EndsWith("shazam")) { StageScript.Instance.EndStage(StageScript.EndStageReasons.SurvivorsWon); } else if (this.lastInput.EndsWith("iddqd")) { ((SurvivorController)StageScript.Instance.LocalCharacter).Data.Die(); } else if (this.lastInput.EndsWith("showtapes")) { foreach (GoalInstance goalInstance in StageScript.Instance.Goals) { if (goalInstance != null && !goalInstance.IsCleared) { HighlighterHelper componentInChildren = goalInstance.GetComponentInChildren <HighlighterHelper>(); if (componentInChildren != null) { componentInChildren.ConstantOn(Color.white, 30f); } } } } else if (this.lastInput.EndsWith("sane")) { ((SurvivorController)StageScript.Instance.LocalCharacter).Data.Sanity.MaxOut(); } else if (this.lastInput.EndsWith("terror")) { ((SurvivorController)StageScript.Instance.LocalCharacter).Data.Sanity.Progress = 0f; } else if (this.lastInput.EndsWith("outline")) { this.Outline(); } else if (this.lastInput.EndsWith("asylum")) { foreach (SurvivorController survivorController in StageScript.Instance.Survivors) { if (!survivorController.IsRemote && !survivorController.IsLocal) { survivorController.Data.Sanity.Value = 0f; } } } else if (this.lastInput.EndsWith("stoptapes")) { this.StopTapes(); } else if (this.lastInput.EndsWith("nomonster")) { StageScript.Instance.Monster.gameObject.SetActive(false); } else if (this.lastInput.EndsWith("flash")) { StageScript.Instance.Monster.Data.StartFlashed(null); } else if (this.lastInput.EndsWith("debug")) { GameObject original = Resources.Load <GameObject>("UI/HUD/Debug"); GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(original); gameObject2.transform.parent = PanelManager.Instance.transform; gameObject2.transform.Reset(); } else if (this.lastInput.EndsWith("powerup")) { if (StageScript.Instance.LocalCharacter.IsSurvivor) { SurvivorController survivorController2 = StageScript.Instance.LocalCharacter as SurvivorController; survivorController2.ResetPowers(); } else { MonsterController monsterController = StageScript.Instance.LocalCharacter as MonsterController; monsterController.Data.ResetPowers(); } } else if (this.lastInput.EndsWith("catch")) { if (StageScript.Instance.LocalCharacter.IsSurvivor) { SurvivorController survivorController3 = StageScript.Instance.LocalCharacter as SurvivorController; StageScript.Instance.Monster.transform.position = survivorController3.transform.position - survivorController3.transform.forward * 1.2f * 0.9f; } else { SurvivorController survivorController4 = StageScript.Instance.Survivors[0]; StageScript.Instance.Monster.transform.position = survivorController4.transform.position - survivorController4.transform.forward * 1.2f * 0.9f; } } else if (this.lastInput.EndsWith("getbot")) { SurvivorController survivorController5 = null; foreach (SurvivorController survivorController6 in StageScript.Instance.Survivors) { if (survivorController6.Movement.IsBot && survivorController6.Data.IsAlive) { survivorController5 = survivorController6; break; } } if (survivorController5 != null) { StageScript.Instance.Monster.transform.position = survivorController5.transform.position - survivorController5.transform.forward * 1.2f * 0.9f; } } else if (this.lastInput.EndsWith("noise")) { this.Noise(); } else if (this.lastInput.EndsWith("nototems")) { foreach (Totem totem in StageScript.Instance.Totems) { totem.gameObject.SetActive(false); } foreach (TotemSpawn totemSpawn in StageScript.Instance.TotemSpawnPreviews) { totemSpawn.gameObject.SetActive(false); } } else if (this.lastInput.EndsWith("battery")) { SurvivorController survivorController7 = StageScript.Instance.LocalCharacter as SurvivorController; survivorController7.Data.BatteryLife.MaxOut(); survivorController7.Data.FlashlightBattery.SetValue(100000f); } else if (this.lastInput.EndsWith("lowbat")) { SurvivorController survivorController8 = StageScript.Instance.LocalCharacter as SurvivorController; survivorController8.Data.BatteryLife.Progress = 0.15f; survivorController8.Data.FlashlightBattery.SetValue(100000f); } else if (this.lastInput.EndsWith("front")) { if (StageScript.Instance.LocalCharacter.IsSurvivor) { SurvivorController survivorController9 = StageScript.Instance.LocalCharacter as SurvivorController; StageScript.Instance.Monster.transform.position = survivorController9.transform.position + survivorController9.transform.forward * 18f + new Vector3(0f, 1.5f, 0f); } else { SurvivorController survivorController10 = StageScript.Instance.Survivors[0]; StageScript.Instance.Monster.transform.position = survivorController10.transform.position - survivorController10.transform.forward * 18f + new Vector3(0f, 1.5f, 0f); } } else if (this.lastInput.EndsWith("reunite")) { EntityController localCharacter = StageScript.Instance.LocalCharacter; foreach (SurvivorController survivorController11 in StageScript.Instance.Survivors) { if (!(survivorController11 == localCharacter)) { Vector2 vector = UnityEngine.Random.insideUnitCircle * 2.5f; survivorController11.transform.position = localCharacter.transform.position + localCharacter.transform.forward * 7.5f + new Vector3(0f, 1.5f, 0f) + new Vector3(vector.x, 0f, vector.y); } } } else if (this.lastInput.EndsWith("speed")) { ((SurvivorController)StageScript.Instance.LocalCharacter).Data.Speed.SetValue(5f); } else if (this.lastInput.EndsWith("slow")) { ((SurvivorController)StageScript.Instance.LocalCharacter).Data.Speed.SetValue(1f); } else if (this.lastInput.EndsWith("killbot")) { SurvivorController survivorController12 = null; foreach (SurvivorController survivorController13 in StageScript.Instance.Survivors) { if (survivorController13.Movement.IsBot && survivorController13.Data.IsAlive) { survivorController12 = survivorController13; break; } } if (survivorController12 != null) { survivorController12.Data.Die(); } } else if (this.lastInput.EndsWith("allclear")) { RenderSettings.ambientLight = Color.white; RenderSettings.ambientMode = AmbientMode.Flat; RenderSettings.fogDensity = 0f; } else if (this.lastInput.EndsWith("music")) { this.Music(); } } }