void Awake() { if (!LeverScript.GetInstance().RegisterLever(this)) { Destroy(this); } }
public override void Compare(UnityEngine.Object obj) { LeverScript mech = (LeverScript)obj; if (mech.gameObject.name.Contains(mechName)) { value++; } }
//returns a reference to the LeverScript object in the scene public static LeverScript GetInstance() { // if this is the first time this was called, create an instance if (instance == null) { instance = new LeverScript(); } return(instance); }
private void OnTriggerExit(Collider other) { grabbableInCol = false; if (other.gameObject.tag == "Handle") { ls = other.gameObject.GetComponentInParent <LeverScript>(); //ls.yesUse = false; ls.hand = null; handleInCol = false; } }
public void StartSpecificLeak(LeakZone leakZone, List <LeakZone> pipeLeakZones, LeverScript associatedLever, int associatedPipe, LeverScript.RessourcesType ressource = LeverScript.RessourcesType.none) { GameObject leak = Instantiate(leakPrefab, leakZone.GetRandomLeakPosition(), Quaternion.identity); Leak leakScript = leak.GetComponent <Leak>(); leakScript.associatedPipeLeaksZones = pipeLeakZones; leakScript.associatedLever = associatedLever; leakScript.associatedPipe = associatedPipe; leakScript.currentRessource = ressource; associatedLever.allLeaksZones[associatedPipe] = null; allLeaks.Add(leak); SoundsManager.instance.PlaySoundOneShot(SoundsManager.SoundName.StartLeak, leakSource); CharacterController2D.instance.animatorFace.SetTrigger("Choc"); }
public static void DeselectPlanet() { if (selectedPlanet != null) { LeverScript lever = LeverScript.GetInstance(); lever.SetThrottle(lever.GetDefaultThrottle()); PlanetDisplay disp = PlanetDisplay.GetInstance(); if (disp.GetViewTarget() == selectedPlanet.transform) { disp.SetVisible(false); disp.SetViewTarget(null); disp.GetTravelInteractable().SetExeString(""); } selectedPlanet.Highlight("none"); selectedPlanet = null; } }
//checkaa onko colliderissa grabbable object private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Handle") { ls = other.gameObject.GetComponentInParent <LeverScript>(); handleInCol = true; print("handle detected"); } if (other.gameObject.tag == "Grabbable") { grabbableInCol = true; grabbed = other.GetComponent <Rigidbody>(); } //TODO: rizzalle omat hommat other.gameObject.tag == "Rizza" }
public void CheckAllLeversEnabled() { int count = 0; foreach (GameObject lever in levers) { LeverScript ls = lever.GetComponent <LeverScript>(); if (ls.isEnabled) { count++; } } Debug.Log("count = " + count + " / Levers count = " + levers.Count); if (count == levers.Count) { endDoor.DoorOpen(); } }
void CleanPreviousAssociatedObjects() { if (currentAssociatedLever) { currentAssociatedLever.currentRessource = RessourcesType.none; currentAssociatedLever = null; } if (currentAssociatedPrimarySystem) { currentAssociatedPrimarySystem.filling = false; currentAssociatedPrimarySystem = null; } if (currentAssociatedSecondarySystem) { currentAssociatedSecondarySystem.filling = false; currentAssociatedSecondarySystem = null; IsSecondarySystemFilling(false); } }
void UseActivateable() { Collider2D[] hitActivateables = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, activateableLayer); foreach (Collider2D activateable in hitActivateables) { if (activateable.CompareTag("Activateable")) { LeverScript lever = activateable.GetComponent <LeverScript>(); if (lever.isEnabled) { lever.LeverOff(); } else if (!lever.isEnabled) { lever.LeverOn(); } } } }
public void MapGen(int seed) { maze.seed = seed < 0 ? Random.Range(0, 1000000000) : seed; if (NetworkManager.manager != null) { NetworkManager.manager.SendNext(maze.seed); } maze.MazeGen(maze.seed); next = 0; door[next].SetActive(true); Vector2 dir = new Vector2(3, 3) - maze.nodes[0].pos; doortrans[next++].localPosition = maze.nodes[0].pos + dir * .5f; PlaceDoor(5); PlaceDoor(6); PlaceDoor(13); PlaceDoor(14); PlaceDoor(15); nextflame = 0; AdjustFlame(0, 0); AdjustFlame(11, 1); AdjustFlame(12, 1); AdjustFlame(21, 2); AdjustFlame(22, 2); AdjustFlame(23, 2); for (var i = 4; i > 0; i--) { int rand = Random.Range(0, i); LeverScript temp = traplever[i]; traplever[i] = traplever[rand]; traplever[rand] = temp; } }
public void PointerClick() { if (selectedPlanet == this) { LeverScript lever = LeverScript.GetInstance(); lever.SetThrottle(lever.GetDefaultThrottle()); PlanetDisplay disp = PlanetDisplay.GetInstance(); if (disp.GetViewTarget() == transform) { disp.SetVisible(false); disp.SetViewTarget(null); disp.GetTravelInteractable().SetExeString(""); } selectedPlanet = null; Highlight("none"); // disables highlights } else { LeverScript.GetInstance().SetThrottle(0.0f); PlanetDisplay disp = PlanetDisplay.GetInstance(); disp.SetVisible(true); disp.SetViewTarget(transform); disp.UpdateInfo(data.title, data.creator, data.description, data.year, data.des_tag, data.image); disp.GetTravelInteractable().SetExeString(ExecutableSwitch.GetFullPath(data.executable + ".exe", data.executable, data.year)); if (selectedPlanet != null) { selectedPlanet.Highlight("none"); } selectedPlanet = this; Highlight("selected"); } }
private void Start() { if (doubleEntry) { if (endObject.GetComponent <LeverScript>()) { currentAssociatedLever = endObject.GetComponent <LeverScript>(); } else if (endObject.GetComponent <PrimarySystem>()) { if (endObject.GetComponent <LungsManager>()) { currentAssociatedPrimarySystem = endObject.GetComponent <LungsManager>(); } else { currentAssociatedPrimarySystem = endObject.GetComponent <StomachManager>(); } } else if (endObject.GetComponent <SecondarySystem>()) { currentAssociatedSecondarySystem = endObject.GetComponent <SecondarySystem>(); } else { Debug.LogError("There is no correct object associated at the end of this lever : " + gameObject.name + " current end object : " + endObject); } } for (int i = 0; i < pipes.Length; i++) { pipes[i].shapeRenderer = pipes[i].pipe.GetComponent <SpriteShapeRenderer>(); pipes[i].shapeController = pipes[i].pipe.GetComponent <SpriteShapeController>(); } UpdatePipe(); foreach (LeakZone item in pipes[0].pipe.GetComponentsInChildren <LeakZone>()) { pipe0LeaksZones.Add(item); } foreach (LeakZone item in pipes[1].pipe.GetComponentsInChildren <LeakZone>()) { pipe1LeaksZones.Add(item); } if (pipe0LeaksZones.Count != 0) { allLeaksZones[0] = pipe0LeaksZones; } if (pipe1LeaksZones.Count != 0) { allLeaksZones[1] = pipe1LeaksZones; } if (allLeaksZones[0] != null || allLeaksZones[1] != null) { LeaksManager.instance.leversWithLeaksZones.Add(this); } foreach (GameObject item in associatedObjects) { if (item.GetComponent <LeverScript>()) { item.GetComponent <LeverScript>().previousLever = this; } if (item.GetComponent <SecondarySystem>()) { item.GetComponent <SecondarySystem>().associatedLever = this; } } if (endObject) { if (endObject.GetComponent <LeverScript>()) { endObject.GetComponent <LeverScript>().previousLever = this; } if (endObject.GetComponent <SecondarySystem>()) { endObject.GetComponent <SecondarySystem>().associatedLever = this; } } anim = GetComponent <Animator>(); }
void UpdatePipe() { if (doubleEntry) { UpdateDoubleEntry(); return; } CleanPreviousAssociatedObjects(); if (associatedObjects[currentPipe].GetComponent <LeverScript>()) { currentAssociatedLever = associatedObjects[currentPipe].GetComponent <LeverScript>(); currentAssociatedLever.currentRessource = currentRessource; } else if (associatedObjects[currentPipe].GetComponent <PrimarySystem>()) { if (initialPipes) { if (associatedObjects[currentPipe].GetComponent <LungsManager>()) { currentRessource = RessourcesType.oxygen; } else { currentRessource = RessourcesType.energy; } currentAssociatedPrimarySystem = associatedObjects[currentPipe].GetComponent <PrimarySystem>(); currentAssociatedPrimarySystem.filling = true; } else { if (associatedObjects[currentPipe].GetComponent <LungsManager>()) { if (currentRessource == RessourcesType.oxygen) { currentAssociatedPrimarySystem = associatedObjects[currentPipe].GetComponent <PrimarySystem>(); currentAssociatedPrimarySystem.filling = true; } else { //WRONG RESSOURCE } } else { if (currentRessource == RessourcesType.energy) { currentAssociatedPrimarySystem = associatedObjects[currentPipe].GetComponent <PrimarySystem>(); currentAssociatedPrimarySystem.filling = true; } else { //WRONG RESSOURCE } } } } else if (associatedObjects[currentPipe].GetComponent <SecondarySystem>()) { currentAssociatedSecondarySystem = associatedObjects[currentPipe].GetComponent <SecondarySystem>(); if (currentAssociatedSecondarySystem.energyNeeded) { if (currentRessource == RessourcesType.energy) { currentAssociatedSecondarySystem.filling = true; SoundsManager.instance.PlaySoundOneShot(SoundsManager.SoundName.StartFillingSecondarySystem, currentAssociatedSecondarySystem.audioSource); IsSecondarySystemFilling(true); } else { //WRONG RESSOURCE } } else if (currentAssociatedSecondarySystem.oxygenNeeded) { if (currentRessource == RessourcesType.oxygen) { currentAssociatedSecondarySystem.filling = true; SoundsManager.instance.PlaySoundOneShot(SoundsManager.SoundName.StartFillingSecondarySystem, currentAssociatedSecondarySystem.audioSource); IsSecondarySystemFilling(true); } else { //WRONG RESSOURCE } } } else { Debug.LogError("There is no correct object associated to this pipe : " + pipes[currentPipe] + " actual object : " + associatedObjects[currentPipe]); } UpdatePipesDisplay(); lastFrameRessource = currentRessource; }
/// <summary> /// Called before the game begins. /// /// Gets all the important components for handling the dungeon, and sets their state to a default state. /// </summary> private void Awake() { #region Singleton if (controller != null) { Debug.LogWarning("more than one controller script"); return; } controller = this; #endregion for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(i).CompareTag("Lever")) { leverList.Add(transform.GetChild(i)); } if (transform.GetChild(i).CompareTag("Door")) { doorList.Add(transform.GetChild(i)); } } for (int i = 0; i < triggerParent.transform.childCount; i++) { if (triggerParent.transform.GetChild(i).CompareTag("DoorTrigger")) { doorTriggerList.Add(triggerParent.transform.GetChild(i)); } } playerObject = GameObject.Find("Player"); playerObject.GetComponent <PlayerController>().MovePlayerToSpawn(); firstLever = leverList[0].GetComponent <LeverScript>(); secondLever = leverList[1].GetComponent <LeverScript>(); thirdLever = leverList[2].GetComponent <LeverScript>(); fourthLever = leverList[3].GetComponent <LeverScript>(); firstDoor = doorList[0].GetComponent <DoorScript>(); secondDoor = doorList[1].GetComponent <DoorScript>(); thirdDoor = doorList[2].GetComponent <DoorScript>(); fourthDoor = doorList[3].GetComponent <DoorScript>(); firstDoor.locked = false; secondDoor.locked = false; thirdDoor.locked = false; fourthDoor.locked = false; doorTriggerList[1].gameObject.SetActive(false); doorTriggerList[2].gameObject.SetActive(false); doorTriggerList[3].gameObject.SetActive(false); itemLocation = transform.Find("ItemLocation"); PlaceItems(); turnCount = 0; }
private void FlipLever(LeverScript lever) { lever.Flip(); }