void GetLevelCreatorInfo() { levelCreatorInfo = AssetDatabase.LoadAssetAtPath("Assets/Resources/Prefabs/LevelCreatorInfo.prefab", typeof(LevelCreatorInfo)) as LevelCreatorInfo; levelBasePrefab = levelCreatorInfo.levelBase; basicRoomPrefab = levelCreatorInfo.basicRoom; doorPrefab = levelCreatorInfo.doorPrefab; }
public void DoorCollide(SlidingDoor door1, SlidingDoor door2) { if (!doorStates.ContainsKey(door1) || !doorStates.ContainsKey(door2)) return; if (doorStates[door1] == SlidingDoorState.MovingClose) { if (doorStates[door2] == SlidingDoorState.MovingOpen) { door2.MoveClose(); doorStates[door2] = SlidingDoorState.MovingClose; EventDispatcher.TriggerEvent(Events.GearEvent.TrapEnd, gearType); } } else if (doorStates[door2] == SlidingDoorState.MovingClose) { if (doorStates[door1] == SlidingDoorState.MovingOpen) { door1.MoveClose(); doorStates[door1] = SlidingDoorState.MovingClose; EventDispatcher.TriggerEvent(Events.GearEvent.TrapEnd, gearType); } } }
public void DoorCollide(SlidingDoor door1, SlidingDoor door2) { if (!doorStates.ContainsKey(door1) || !doorStates.ContainsKey(door2)) { return; } if (doorStates[door1] == SlidingDoorState.MovingClose) { if (doorStates[door2] == SlidingDoorState.MovingOpen) { door2.MoveClose(); doorStates[door2] = SlidingDoorState.MovingClose; EventDispatcher.TriggerEvent(Events.GearEvent.TrapEnd, gearType); } } else if (doorStates[door2] == SlidingDoorState.MovingClose) { if (doorStates[door1] == SlidingDoorState.MovingOpen) { door1.MoveClose(); doorStates[door1] = SlidingDoorState.MovingClose; EventDispatcher.TriggerEvent(Events.GearEvent.TrapEnd, gearType); } } }
public SlidingDoor GetSlidingDoor() { if (this.slidingDoor == null) { this.slidingDoor = GetComponentInChildren <SlidingDoor> (); } return(this.slidingDoor); }
IEnumerator callEvevator() { if (!elevatorIsMoving) { elevatorIsMoving = true; SlidingDoor oppositeDoor = null; foreach (ElevatorMove moveScript in moveScripts) { /* * bool doorOpen = moveScript.eleDoor.doorIsOpen; * if(moveScript.eleDoor.doorStartsOpen) * { * doorOpen = !doorOpen; * } */ if (moveScript.eleDoor.doorIsOpen) { moveScript.eleDoor.moveDoor(false); //Close all doors that are open } else { oppositeDoor = moveScript.eleDoor; } foreach (Transform eleObject in moveScript.objectsInEle) { if (eleObject.root.tag == "Player") { playerScript = eleObject.root.gameObject.GetComponent <PlayerEvents>(); } } } foreach (ElevatorMove moveScript in moveScripts) { yield return(new WaitUntil(() => !moveScript.eleDoor.doorChanging)); //Wait until doors are closed } if (playerScript != null) { yield return(new WaitForSeconds(ding.length)); playerScript.playSound(movement); } yield return(new WaitForSeconds(movement.length - 4f)); foreach (ElevatorMove moveScript in moveScripts) { moveScript.swapElevators(); //Swap objects } yield return(new WaitForSeconds(4f)); if (playerScript != null) { playerScript.playSound(ding); } oppositeDoor.moveDoor(true); //Open all doors that are closed playerScript = null; elevatorIsMoving = false; } }
public override void OnInspectorGUI() { DrawDefaultInspector(); door = target as SlidingDoor; if (GUILayout.Button("Toggle")) { door.Toggle(); } }
public void Open() { foreach (Transform child in transform) { GameObject childObject = child.gameObject; SlidingDoor childScript = childObject.GetComponent <SlidingDoor>(); childScript.Open(); } }
protected void AddMessageOffset(string topic, int partition, long offset) { var slidingDoor = SlidingDoors.GetOrAdd(SlidingDoor.GetSlidingDoorKey(topic, partition), key => new SlidingDoor(CommitOffset, topic, partition, Configuration.Instance.GetCommitPerMessage())); slidingDoor.AddOffset(offset); }
private void OnTriggerEnter(Collider other) { if (other.tag == "Door") { SlidingDoor doorScript = other.gameObject.GetComponent <SlidingDoor>(); if (!doorScript.doorIsLocked && doorScript.EnemyCanOpen) { doorsInRange.Add(other.transform); } } }
void OnTriggerEnter(Collider other) { //取过一遍值就不要分开两次取 SlidingDoor temp = other.GetComponent <SlidingDoor>(); if (temp) { LoggerHelper.Debug("SlidingDoor" + other.name); group.DoorCollide(this, temp); } }
// Use this for initialization void Start() { if (!lockedObject) { Debug.LogWarning("No locked object assigned."); return; } // Lock the door door = lockedObject.GetComponent <SlidingDoor>(); door.LockedWithSwitch = true; }
//Instantiates new rooms at each of the exits and opens the doors 'SlidingDoor.cs' -Tom public void Activekey() { key.SetActive(true); //doors.SetActive(false); Clock.GetComponent <Countdown_Clock>().gameIsPlaying = false; GM.ChallengeCompleted(); //for (int i = 0; i < points.Length; i++) //{ // Instantiate(roomnode, points[i].transform.position, points[i].transform.rotation); //} for (int i = 0; i < slide.Length; i++) { if (slide[i] != null) { open = slide[i].GetComponent <SlidingDoor>(); open.keyon(); } } }
void Update() { if (this.setLock == false && this.StatusIcon != null) { bool isUnlocked = this.State.Require(new StateName[] { StateName.IsUnlocked }); if (isUnlocked == false) this.StatusIcon.Icon = "lock"; this.setLock = true; } if (this.slidingDoor == null) { this.slidingDoor = this.GetComponent<SlidingDoor>(); } if (this.slidingDoor != null) { this.slidingDoor.Locked = !this.State.Require(new[] { StateName.IsUnlocked }); } }
// Use this for initialization void Start() { GM = GameObject.Find("Game_Manager").GetComponent <Game_Manager>(); open = null; }
public void SetDoorClose(SlidingDoor slidingDoor) { doorStates[slidingDoor] = SlidingDoorState.MovingClose; }
public void SetDoorOpen(SlidingDoor slidingDoor) { doorStates[slidingDoor] = SlidingDoorState.MovingOpen; }
protected override IEnumerator chooseRoamingDest() //TODO: Fix bug where doctor always targets NavEnd instead of one furthest away from him { isChoosingDest = true; yield return(new WaitForSeconds(1f)); List <Transform> closestDoors = new List <Transform>(); List <Transform> doorsInRange = detectDoors.doorsInRange; foreach (Transform door in doorsInRange) //Cannot use previous doors { if (!prevDoors.Contains(door)) { Debug.Log("ADDING " + door.gameObject.name); closestDoors.Add(door); } } closestDoors = sortByClosestFirst(closestDoors); //Sort doors in range by closest first to establish priority if (closestDoors.Count > 2) { closestDoors.RemoveRange(2, closestDoors.Count - 2); //Use only the 2 closest doors } foreach (Transform door in prevDoors) { Debug.Log("PREVIOUS DOOR: " + door.gameObject.GetInstanceID()); } foreach (Transform door in doorsInRange) { Debug.Log("DOORSINRANGE: " + door.gameObject.GetInstanceID()); } prevDoors = new List <Transform>(); foreach (Transform door in closestDoors) { prevDoors.Add(door); } for (int i = 0; i < 2; i++) { Transform closestDoor = getClosestDoor(closestDoors); Debug.Log("CLOSEST DOOR: " + closestDoor.gameObject.name); SlidingDoor doorScript = closestDoor.gameObject.GetComponent <SlidingDoor>(); //Set dest to door, go thru door, remove door from closest doors array, repeat 1 more time OffMeshLink closestDoorLink = closestDoor.GetComponent <OffMeshLink>(); Transform[] startAndEnd = { closestDoorLink.startTransform, closestDoorLink.endTransform }; furthestPoint = getFurthestNav(startAndEnd); enemyNav.SetDestination(furthestPoint.position + (-furthestPoint.transform.right * 2)); if (i == 0 && closestDoors.Count > 1) { bool enemyHasReachedDest = false; while (!enemyHasReachedDest) { if (!enemyNav.pathPending) { if (enemyNav.remainingDistance <= enemyNav.stoppingDistance) { if (!enemyNav.hasPath || enemyNav.velocity.sqrMagnitude == 0f) { enemyHasReachedDest = true; Debug.Log("Doctor has reached dest"); } } } yield return(null); } while (enemyNav.isOnOffMeshLink) { if (!enemyNav.isOnOffMeshLink) { Debug.Log("Doctor has stopped off mesh link"); break; } yield return(null); } closestDoors.Remove(closestDoor); } } isChoosingDest = false; }
// Start is called before the first frame update void Start() { door = this.transform.parent.GetComponent <SlidingDoor>(); }
private void Awake() { slidingDoor = GetComponentInParent <SlidingDoor>(); }
// Use this for initialization void Start() { doorScript = door.GetComponent <SlidingDoor>(); }
IEnumerator delayedOpen(float secs, SlidingDoor sd) { yield return(new WaitForSeconds(secs)); sd.InteractWithSlidingDoor(); }
private TileMap ParseFile(HashSet <string> input) { Tile[, ,] tiles; IEvent[,,] events; Building[] buildings; ScriptedEvent[, ,] se; string mapName, line; int mapL, mapW, mapH, numNonNull, numEvents, numBuildings, buildingNum = 0; line = input.ElementAt(0); line = line.Substring(line.IndexOf('(') + 1).Trim(); mapName = line.Substring(0, line.IndexOf(',')); line = line.Substring(line.IndexOf('[') + 1).Trim(); mapL = System.Convert.ToInt32(line.Substring(0, line.IndexOf(','))); line = line.Substring(line.IndexOf(',') + 1).Trim(); mapW = System.Convert.ToInt32(line.Substring(0, line.IndexOf(','))); line = line.Substring(line.IndexOf(',') + 1).Trim(); mapH = System.Convert.ToInt32(line.Substring(0, line.IndexOf(']'))); line = line.Substring(line.IndexOf(',') + 1).Trim(); numNonNull = System.Convert.ToInt32(line.Substring(0, line.IndexOf(','))); line = line.Substring(line.IndexOf(',') + 1).Trim(); numEvents = System.Convert.ToInt32(line.Substring(0, line.IndexOf(','))); line = line.Substring(line.IndexOf(',') + 1).Trim(); numBuildings = System.Convert.ToInt32(line.Substring(0, line.IndexOf(')'))); tiles = new Tile[mapL, mapW, mapH]; events = new IEvent[mapL, mapW, mapH]; buildings = new Building[numBuildings]; se = ScriptInvoke.GetScriptedEvents(mapName, new int[3] { events.GetLength(0), events.GetLength(1), events.GetLength(2) }); numEvents += ScriptInvoke.GetNumEvents(mapName); //Basic Data down! for (int i = 1; i < input.Count; i++) { line = input.ElementAt(i).Trim(); if (line[0] == 'T') { int[] arrayPos = new int[3]; int[] mapPos = new int[3]; Tile.TileStyle style = Tile.TileStyle.FLAT; Tile.Direction dir, secondDir; line = line.Substring(line.IndexOf('[') + 1).Trim(); arrayPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); arrayPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); arrayPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(']')).Trim()); line = line.Substring(line.IndexOf('(') + 1).Trim(); style = (Tile.TileStyle)Enum.Parse(typeof(Tile.TileStyle), line.Substring(0, line.IndexOf(',')).Trim(), true); line = line.Substring(line.IndexOf('{') + 1).Trim(); mapPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); mapPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); mapPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf('}')).Trim()); if (line.IndexOf(',') == -1) { tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile( style, mapPos, null, null); } else { line = line.Substring(line.IndexOf(',') + 1).Trim(); if (line.IndexOf(',') == -1) { dir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(')')).Trim(), true); tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile( style, mapPos, dir, null); } else { dir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(',')).Trim(), true); line = line.Substring(line.IndexOf(',') + 1).Trim(); if (line.IndexOf(',') == -1) { secondDir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(')')).Trim(), true); tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile( style, mapPos, dir, secondDir); } else { secondDir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(',')).Trim(), true); line = line.Substring(line.IndexOf('{') + 1).Trim(); bool[] passage = new bool[4]; passage[0] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); passage[1] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); passage[2] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); passage[3] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf('}')).Trim()); if (line.IndexOf(',') == -1) { tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile( style, mapPos, dir, secondDir ); tiles[arrayPos[0], arrayPos[1], arrayPos[2]].passage = passage; } else { line = line.Substring(line.IndexOf('\'')).Trim(); string tPath = line.Substring(0, line.IndexOf('\'')).Trim(); tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile( style, tPath, mapPos, passage, dir, secondDir ); } } } } } else if (line[0] == 'C') { //make me a character! string texturePath = ""; int[] mapPos = new int[3]; Tile.Direction dir; line = line.Substring(line.IndexOf('\'') + 1).Trim(); texturePath = line.Substring(0, line.IndexOf('\'')).Trim(); line = line.Substring(line.IndexOf('{') + 1).Trim(); mapPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); mapPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); mapPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf('}')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); dir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(')')).Trim(), true); events[mapPos[0], mapPos[1], mapPos[2]] = new OWPlayer(texturePath, mapPos, dir); } else if (line[0] == 'S' && line[1] == 'D') { //make me a sliding door! //SD('Images/Events/slidingDoor',{3,2,0},SOUTH,[],'stairMap'); string texturePath = ""; int[] mapPos = new int[3]; int[] destPos = new int[3]; Tile.Direction dir, playerDir; bool givenSect; Rectangle section = new Rectangle(0, 0, 0, 0); string mapDestKey = ""; line = line.Substring(line.IndexOf('\'') + 1).Trim(); texturePath = line.Substring(0, line.IndexOf('\'')).Trim(); line = line.Substring(line.IndexOf('{') + 1).Trim(); mapPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); mapPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); mapPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf('}')).Trim()); line = line.Substring(line.IndexOf('{') + 1).Trim(); destPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); destPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); destPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf('}')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); dir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(',')).Trim(), true); line = line.Substring(line.IndexOf(',') + 1).Trim(); playerDir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(',')).Trim(), true); line = line.Substring(line.IndexOf('[') + 1).Trim(); givenSect = (line[0] != ']'); if (givenSect) { float x = System.Convert.ToSingle(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); float y = System.Convert.ToSingle(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); float w = System.Convert.ToSingle(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); float h = System.Convert.ToSingle(line.Substring(0, line.IndexOf(']')).Trim()); section = new Rectangle((int)x, (int)y, (int)w, (int)h); } line = line.Substring(line.IndexOf('\'') + 1).Trim(); mapDestKey = line.Substring(0, line.IndexOf('\'')).Trim(); if (givenSect) { events[mapPos[0], mapPos[1], mapPos[2]] = new SlidingDoor(texturePath, mapPos, destPos, dir, playerDir, section, mapDestKey); } else { events[mapPos[0], mapPos[1], mapPos[2]] = new SlidingDoor(texturePath, mapPos, destPos, dir, playerDir, mapDestKey); } } else if (line[0] == 'B') { //make me a building //"B(Block264Tex,{5,6,0});"+ Name name; int[] mapPos = new int[3]; line = line.Substring(line.IndexOf('(') + 1).Trim(); string str = line.Substring(0, line.IndexOf(',')).Trim(); name = (Name)Enum.Parse(typeof(Name), str, true); line = line.Substring(line.IndexOf('{') + 1).Trim(); mapPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); mapPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim()); line = line.Substring(line.IndexOf(',') + 1).Trim(); mapPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf('}')).Trim()); buildings[buildingNum] = new Building(name, mapPos); buildingNum++; } } for (int i = 0; i < se.GetLength(0); i++) { for (int j = 0; j < se.GetLength(1); j++) { for (int k = 0; k < se.GetLength(2); k++) { if (se[i, j, k] != null) { events[i, j, k] = se[i, j, k]; } } } } return(new TileMap(mapName, tiles, events, buildings, numNonNull, numEvents)); }
// Update is called once per frame void FixedUpdate() { transform.localPosition = startPos + new Vector3(0, Mathf.Sin(counter) / 3, 0); counter += 0.01f; if (Time.time > 5 && Time.time < 5.2f) { transform.Rotate(new Vector3(0, 1, 0)); } if (Time.time > 7.7f && Time.time < 7.9f) { transform.Rotate(new Vector3(0, -1, 0)); } if (Time.time > 9f && tempcount < 90) { tempcount++; transform.Rotate(new Vector3(0, -1, 0)); } if (Time.time > 10f && tempcount < 390) { tempcount++; startPos += new Vector3(0.01f, 0, 0); } if (Time.time > 13f && tempcount < 525) { tempcount++; transform.Rotate(new Vector3(0, 1, 0)); } if (Time.time > 20f && tempcount < 570) { tempcount++; transform.Rotate(new Vector3(0, 1, 0)); } if (Time.time > 21f && tempcount < 1170) { tempcount++; startPos += new Vector3(-0.01f, 0, 0); } if (Time.time > 27f && tempcount < 1280) { tempcount++; transform.Rotate(new Vector3(0, -1, 0)); } if (Time.time > 38f && tempcount < 1350) { tempcount++; transform.Rotate(new Vector3(0, -1, 0)); } if (Time.time > 39f && tempcount < 1650) { tempcount++; startPos += new Vector3(0.01f, 0, 0); } if (Time.time > 42f && tempcount < 1740) { tempcount++; transform.Rotate(new Vector3(0, 1, 0)); } if (Time.time > 45f && tempcount < 1750) { tempcount++; SlidingDoor.activateDoor(); } }