public IEnumerator LeaveRoomImmediate(DoorBetweenLevels door) { heldItem = combiningItem = null; targetItem = null; if (door.zoomoutCircleTransformPosition != null) { SetInCutScene(true, CutsceneTools.Type.ZoomOut, door.zoomoutCircleTransformPosition.position, false, 0.0001f); } else { SetInCutScene(true, CutsceneTools.Type.ZoomOut, transform.position + door.zoomoutCircleOffset, false, 0.0001f); } PersistentEngine.SetArrivalDoor(SceneManager.GetActiveScene().path); audioManager.Fadeout(); scene.arrivalCave = -1; if (door.GetLevelIndex() == -1) { LoadLevelInternal(0); } else { LoadLevelInternal(door.GetLevelIndex()); } yield return(null); }
void LateUpdate() { if (isHidden) { return; } string text = ""; cursorRotation = 0; CursorState newState = CursorState.IDLE; Camera cam = PersistentEngine.activeCamera ? PersistentEngine.activeCamera : Camera.main; int lastLayer = -10000; if (!cam || (player && player.inCutScene && !inPuzzle && !player.inConversation)) { newState = CursorState.INVISIBLE; } else if (player && player.inConversation) { newState = CursorState.IDLE; } else { pos = cam.ScreenToWorldPoint(Input.mousePosition); pos.z = 0; myTransform.position = pos; //move to mouse pos float height = cam.orthographicSize * 2; sca = Vector3.one * height / 25f; sca.z = 1; myTransform.localScale = sca; Collider2D[] col = Physics2D.OverlapPointAll(transform.position); //get all colliders //default state is idle if (inPuzzle) { newState = CursorState.PUZZLE_EXIT; //default state in puzzle is exit if (!puzzleHasBackground) { newState = CursorState.IDLE; //if puzzle has no background default is idle } } if (inPuzzle && cursorState == CursorState.PUZZLE_HOLD_ITEM && Input.GetButton("Fire1")) //if in puzzle and holding object do nothing { return; } int lastColliderLayer = int.MinValue; foreach (Collider2D c in col) { var ii = c.gameObject.GetComponent <InteractiveItem>(); if (ii && ii.itemLayer < lastColliderLayer) { continue; } else { if (ii) { lastColliderLayer = ii.itemLayer; } } if (ii && ii.noClickBackground) { newState = CursorState.IDLE; cursorRotation = 0; text = ""; continue; } if (inPuzzle) //if in puzzle { if (c.gameObject.layer == 13) //if in puzzle and active object { newState = CursorState.PUZZLE_OVER_ITEM; if (Input.GetButton("Fire1")) { newState = CursorState.PUZZLE_HOLD_ITEM; } text = ""; break; } if (c.gameObject.layer == 15) //if in puzzle over background { newState = CursorState.IDLE; cursorRotation = 0; text = ""; } } else { if (c.gameObject.layer == 15) //if in puzzle over background { newState = CursorState.IDLE; cursorRotation = 0; text = ""; } if (c.gameObject.layer == 10) { var d = c.gameObject.GetComponent <DoorBetweenLevels>(); if (d == null || !d.enabled) //if over item { newState = CursorState.ACTIVE; } else { DoorBetweenLevels door1 = c.gameObject.GetComponent <DoorBetweenLevels>(); InteractiveItemSwitch switchItem = c.gameObject.GetComponent <InteractiveItemSwitch>(); if (switchItem != null) //if over door with swithc on { if (door1.enableOnlyForSwitchState != InteractiveItemSwitch.State.ANY && door1.enableOnlyForSwitchState != switchItem.state) { //newState = CursorState.ACTIVE; newState = CursorState.DOOR; } else { newState = CursorState.DOOR; } } else { newState = CursorState.DOOR; } } InteractiveItem item = c.gameObject.GetComponent <InteractiveItem>(); if (item && item.enabled && item.itemLayer > lastLayer) //set text from interactive item { lastLayer = item.itemLayer; if (!string.IsNullOrEmpty(item.objectName)) { text = item.objectName; } else { text = item.name; } cursorRotation = item.cursorRotation * -1; rot.z = item.cursorRotation; //rotate pointer to rotation set on interactive item if (pointer) { pointer.localEulerAngles = rot; } } } if (c.gameObject.layer == 11) //added to disable highlightning over Inventory { newState = CursorState.IDLE; text = ""; //break; } } } } if (PersistentEngine.inventory != null) { var invItem = PersistentEngine.inventory.ItemHoveringOver(); if (invItem != null) { newState = CursorState.PUZZLE_OVER_ITEM; text = invItem.interactiveItem.GetObjectName(); } } cursorState = newState; animator.SetInteger("state", (int)cursorState); if (text != lines[0].text) { foreach (TextMeshPro line in lines) { line.text = text; } } if (newState == CursorState.PUZZLE_EXIT && Input.GetButtonDown("Fire1")) { foreach (GameObject g in puzzles) { g.SendMessage("CloseClickedGUI", SendMessageOptions.DontRequireReceiver); } } }
void HighlightIfOverInteractiveItem() { if (true) { bool enable = false; Collider2D[] col = Physics2D.OverlapPointAll(transform.position); var hoveredItem = inventory.ItemHoveringOver(); if (hoveredItem != null && hoveredItem != this) { enable = true; SetHighlight(enable); } if (col.Length > 0) { foreach (Collider2D c in col) { if (c.gameObject.layer == 10) { if (c.gameObject.GetComponent <DoorBetweenLevels>() == null) { enable = true; } else { DoorBetweenLevels door = c.gameObject.GetComponent <DoorBetweenLevels>(); InteractiveItemSwitch switchItem = c.gameObject.GetComponent <InteractiveItemSwitch>(); if (switchItem != null) { if (door.enableOnlyForSwitchState != InteractiveItemSwitch.State.ANY && door.enableOnlyForSwitchState != switchItem.state) { enable = true; } } } if (c.gameObject.GetComponent <InventoryItem>() != null) { InteractiveItem intItem = c.gameObject.GetComponent <InteractiveItem>(); bool doBreak = false; foreach (InventoryItem invItem1 in intItem.CanBeCombinedWith) { if (invItem1 == this) { enable = true; doBreak = true; break; } } if (doBreak) { break; } } } if (c.gameObject.layer == 11) { //added to disable highlightning over Inventory enable = false; break; } } } SetHighlight(enable); } }
public IEnumerator LeaveRoom(DoorBetweenLevels door, State walkOption = State.WalkSide) { heldItem = combiningItem = null; targetItem = null; if (!staticCharacter) { if (door.zoomoutCircleTransformPosition != null) { Debug.Log("LeaveRoom transfrom pos" + door); SetInCutScene(true, CutsceneTools.Type.ZoomOut, door.zoomoutCircleTransformPosition.position, false, 0.0001f, false); } else { SetInCutScene(true, CutsceneTools.Type.ZoomOut, transform.position + door.zoomoutCircleOffset, false, 0.0001f, false); } autoPilotTarget = door.outsideOffset + door.gameObject.transform.position; autoPilotDelta = autoPilotTarget - transform.position; isInAutopilot = true; autoPilotSpeed = 1 / 1.5f; autoPilotSpeed = door.walkInOutSpeed; ChangeState(walkOption); direction = transform.position.x < (autoPilotTarget.x) ? 1 : -1; ProcessDirectionAndScale(false); } PersistentEngine.SetArrivalDoor(SceneManager.GetActiveScene().path); audioManager.Fadeout(); if (!staticCharacter) { float maxTime = 1 / autoPilotSpeed; float startTime = Time.time; float dist = 100f; while (true) { dist = Vector3.Distance(transform.position, door.transform.position + door.outsideOffset); if (dist < 0.1f) { break; } if (Time.time - startTime > maxTime) { break; } yield return(new WaitForSeconds(0.02f)); } } StartCoroutine(DisableAutopilot(true)); yield return(StartCoroutine(door.ExitTranslationAnimation())); scene.arrivalCave = -1; if (door.GetLevelIndex() == -1) { LoadLevelInternal(0); } else { LoadLevelInternal(door.GetLevelIndex()); } }
public IEnumerator EnterRoom(string levelIndex) { DoorBetweenLevels door = (DoorBetweenLevels)doors[levelIndex]; InteractiveItemChangeCamera doorCam = null; if (door == null) { SetInCutScene(true, CutsceneTools.Type.ZoomIn, transform.position + Vector3.up * advCamera.yFollowOffset, false); if (!staticCharacter) { ChangeStateToIdleBasedOnDirection(); } if (!scene.stayInCutsceneAfterInitialState) { SetInCutScene(false); } } else { autoPilotSpeed = door.walkInOutSpeed; transform.position = door.gameObject.transform.position + door.outsideOffset; ProcessDirectionAndScale(); doorCam = door.gameObject.GetComponent <InteractiveItemChangeCamera>(); if (doorCam) { StartCoroutine(doorCam.ProcessArrivedAt()); } heldItem = combiningItem = null; targetItem = null; Vector3 cameraPos = transform.position + Vector3.up * advCamera.yFollowOffset; cameraPos.z = -5; advCamera.Move(new Vector3(cameraPos.x, advCamera.transform.position.y, cameraPos.z), true); if (door.zoomoutCircleTransformPosition != null) { SetInCutScene(true, CutsceneTools.Type.ZoomIn, door.zoomoutCircleTransformPosition.position, false, 0.01f, false); } else { SetInCutScene(true, CutsceneTools.Type.ZoomIn, transform.position + Vector3.up * advCamera.yFollowOffset, false, 0.01f, false); } if (door.openCloseAnimator) { transform.position = door.gameObject.transform.position + door.outsideOffset; door.openCloseAnimator.SetBool("open", true); ChangeStateToIdleBasedOnWalkAnimation(door.animationWalkIn); yield return(new WaitForSeconds(0.7f)); } if (!staticCharacter) { ChangeState(door.animationWalkIn); //mr 18.11.2014 to enable walk in front in } autoPilotTarget = door.insideOffset + door.gameObject.transform.position; autoPilotDelta = (door.insideOffset - door.outsideOffset); isInAutopilot = true; direction = transform.position.x < (autoPilotTarget.x) ? 1 : -1; ProcessDirectionAndScale(false); yield return(new WaitForSeconds(1 / autoPilotSpeed)); isInAutopilot = false; if (!staticCharacter) { ChangeStateToIdleBasedOnDirection(); } InteractiveItem interactiveItemDoor = door.GetComponent <InteractiveItem>(); if (interactiveItemDoor == null || interactiveItemDoor.realyStayInCutscene != true) { SetInCutScene(false); } advCamera.CenterOnElroy(); if (door.openCloseAnimator) { door.openCloseAnimator.SetBool("open", false); } } }