void Awake() { if (instance == null) { instance = this; } }
void Update() { // Check for key input for bring up/hiding pause menu //if (PlayerControlManager.GetKeyDown(ControlInput.PAUSE_MENU) && TetherManager.PauseMenuAllowed() && !disablePauseMenu) if (PlayerControlManager.GetKeyDown(ControlInput.PAUSE_MENU) && !disablePauseMenu && !GameManager.CheckPause(check)) { if (!m_pauseMenuActive) { EnablePauseMenu(); } else { DisablePauseMenu(); } } if (m_pauseMenuActive) { // Continuously fade menu in pauseCanvasGroup.alpha = Mathf.Lerp(pauseCanvasGroup.alpha, 1, menuFadeInSpeed * Time.deltaTime); } else { // Continuously fade menu out pauseCanvasGroup.alpha = Mathf.Lerp(pauseCanvasGroup.alpha, 0, menuFadeOutSpeed * Time.deltaTime); } }
private void HitPlayer() { if (!playerHealth.AlreadyHit && !playerHealth.IsDead) { if (playerDashing != null && playerDashing.isActiveAndEnabled && playerDashing.Dashing) { return; } playerHealth.AlreadyHit = true; PlayerControlManager playerControl = playerHealth.GetComponentInParent <PlayerControlManager>(); playerControl.GetHit(); if (playerBlocking != null && playerBlocking.isActiveAndEnabled && playerBlocking.Blocking) { Disable(); anim.SetTrigger("recoil"); GetComponentInParent <EnemyControlManager>().KnockBack(transform.position - playerHealth.transform.position, isShort: true); playerBlocking.BlockHit(isPlayer, playerBlocking.CharacterTransform.position - transform.position); return; } playerControl.KnockBack(playerHealth.transform.position - transform.position, isShort: false); playerHealth.TakeDamage(damage); GetComponentInParent <FitnessTracker>().DamagedPlayer(damage); inflictedDamage = true; //Debug.Log("Player hit"); } }
void Awake() { anim = GetComponent <Animator>(); playerAudio = GetComponent <AudioSource>(); controlManager = GetComponentInParent <PlayerControlManager>(); startPos = transform.parent.position; ResetHealth(); }
void UpdateTimers() { if (GameManager.CheckPause((int)PauseType.GAME) || GameManager.CheckPause((int)PauseType.TETHER_MENU)) { return; } bool playerFrozen = false; foreach (DialogueObject dialogue in _activeDialogues) { int i = _activeDialogues.IndexOf(dialogue); if (dialogue.FreezePlayer) { playerFrozen = true; } if (dialogue.FollowTarget != null) { Vector3 loc = _activeDialogues [i].FollowTarget.transform.position; Vector2 screenPoint = new Vector3(loc.x, loc.y + 1.5f, loc.z); //((RectTransform)_activeDialogues [i].UIObject.transform).position = screenPoint; //((RectTransform)_activeDialogues [i].UIObject.transform).anchoredPosition = screenPoint - ((RectTransform)transform).sizeDelta / 2f; } _activeDialogues [i].Timer -= Time.deltaTime; if (_activeDialogues[i].Timer <= 0 || PlayerControlManager.GetKeyDown(ControlInput.INTERACT)) { if (_activeDialogues[i].Next != null) { CreateBox(_activeDialogues[i].Next); _activeDialogues [i].Next.FreezePlayer = false; } Destroy(_activeDialogues [i].UIObject); _activeDialogues.RemoveAt(i); return; } } if (pausePlayer != playerFrozen) { pausePlayer = playerFrozen; if (pausePlayer) { GameManager.inst.EnterPauseState(PauseType.CUTSCENE); } else { GameManager.inst.ExitPauseState(PauseType.CUTSCENE); } } if (!GameManager.CheckPause((int)PauseType.CUTSCENE) && pausePlayer) { if (pausePlayer) { GameManager.inst.EnterPauseState(PauseType.CUTSCENE); } } }
public override bool check(Controller c) { Player p = State.cast <Player>(c); if (PlayerControlManager.GetKeyDown(ControlInput.DASH) && CursorManager.CursorInGameplayState()) { return(true); } return(false); }
private void Awake() { if (S == null) { S = this; } screenMoveDelta = Vector3.zero; selectedEntity = null; firstIsAlwaysChick = true; }
// Update is called once per frame void Update() { // Test //Debug.Log("CursorIsOverATetherPoint: " + TetherManager.CursorIsOverATetherPoint() + "; CursorIsOverAStasisBubble: " + LevelStateManager.CursorIsOverAStasisBubble()); if (useBubbleAliveTimer && !GameManager.isPaused()) { bubbleAliveTimer -= Time.deltaTime; if (bubbleAliveTimer <= 0) { RemoveBubble(); } // Temporary: Make the bubble get smaller over time if (shrinkWithTimer) { transform.localScale = new Vector3((bubbleAliveTimer / bubbleAliveTime) * initScale.x, (bubbleAliveTimer / bubbleAliveTime) * initScale.y, (bubbleAliveTimer / bubbleAliveTime) * initScale.z); } // Temporary: Make the bubble fade over time if (fadeWithTimer) { if (spriteRend != null) { spriteRend.color = new Color(spriteRend.color.r, spriteRend.color.g, spriteRend.color.b, (bubbleAliveTimer / bubbleAliveTime) * maxBubbleAlpha); } } } if (canRightClickDestroy) { UpdateMouseIsOver(); } // Temporary: You can right click to remove a stasis bubble if (canRightClickDestroy && !TetherManager.CursorIsOverATetherPoint()) { if (MouseIsOver() && PlayerControlManager.GetKeyDown(ControlInput.REMOVAL)) { RemoveBubble(); } } if (source != null && !source.isPlaying) { source.loop = true; source.clip = stasisHum; source.Play(); } }
public void OnEnable() { #if FALSE pcm = (PlayerControlManager)target; try { tar = new SerializedObject(pcm); } catch (System.NullReferenceException nre) { Debug.LogError(nre.Message + "\nCould not make serialized object of " + pcm.name); } #endif }
void Start() { anim = GetComponent <Animator>(); if (gameObject.tag == "Player") { isPlayer = true; playerControl = GetComponentInParent <PlayerControlManager>(); } else if (gameObject.tag == "Enemy") { isPlayer = false; enemyControl = GetComponentInParent <EnemyControlManager>(); } }
public override void perform(Controller c) { Player p = State.cast <Player> (c); Vector3 mousePos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0)); //bool inSBBounds = LevelStateManager.StasisBubbleAtPos (mousePos); // Use Stasis Placement ablility if (PlayerControlManager.GetKeyDown(ControlInput.FIRE_STASIS)) { if (GameManager.inst.canUseStasis && //!inSBBounds && //!TetherManager.CursorIsOverATetherPoint () && CursorManager.CursorInGameplayState()) { p.setStasisShootAnim(); c.getSelf().getAbility(0).use(c.getSelf(), mousePos); } if (!LevelStateManager.canAddStasisBubble() && !GlobalAudio.ClipIsPlaying(AudioLibrary.inst.stasisError)) { AudioLibrary.PlayStasisErrorSound(); } } // Use Dash ability if (PlayerControlManager.GetKeyDown(ControlInput.DASH)) { if (GameManager.inst.canUseDash && CursorManager.CursorInGameplayState()) { if (c.getSelf().getAbility(1).isReady()) { AudioLibrary.PlayDashForwardSound(); } else { if (!GlobalAudio.ClipIsPlaying(AudioLibrary.inst.dashError)) { AudioLibrary.PlayDashErrorSound(); } }/// c.getSelf().getAbility(1).use(c.getSelf(), p.getJumpTargetPos()); } } p.move(); p.findTarget(); }
private void Awake() { _puzzles = FindObjectsOfType <Puzzle>(); playerControlManager = GetComponent <PlayerControlManager>(); fpsController = FindObjectOfType <FirstPersonController>(); controllerManager = GetComponent <ControllerManager>(); brightness = FindObjectOfType <Brightness>(); postProcessingManager = GetComponent <PostProcessingManager>(); postProcessingBehaviour = FindObjectOfType <PostProcessingBehaviour>(); blackScreen = GameObject.Find("BlackFade"); power = GetComponent <Power>(); cursorManager = GetComponent <CursorManager>(); gameplayUIManager = FindObjectOfType <GameplayUIManager>(); videoSettingsManager = FindObjectOfType <VideoSettingsManager>(); loadingScreen = FindObjectOfType <LoadingScreen>(); audioSettingsManager = FindObjectOfType <AudioSettingsManager>(); controlSettingsManager = FindObjectOfType <ControlSettingsManager>(); }
public void setAsPrimary() { primary = this; }
protected void GetPlayerController(PlayerIndex index) { controller = PlayerControlManager.GetController((XInputDotNetPure.PlayerIndex)index); }
void Start() { _playerControlManager = GetComponent <PlayerControlManager>(); _fruit = fruit.GetComponent <Fruit>(); CreateLevel(); }
void Update() { /* * Create tether point functionality */ // Creating a tether point if (tetherUIState == TetherUIState.GAMEPLAY && !GameManager.isPlayerDead() && !GameManager.CameraIsZoomedOut() && GameManager.inst.pauseType == PauseType.NONE && !GameManager.isPlayerDashing() && !GameManager.GetPlayerScript().inPlaceTetherAnim()) { if (PlayerControlManager.GetKeyDown(ControlInput.DROP_TETHER)) { //CreatePoint(); //GameManager.GetPlayer().GetComponent<Player>().setPlaceAnchorAnim(); // Order flipped so the tether point exists for the screenshot // Test! CreatePoint(); } } /* * Fast tethering functionality */ // Keep track of the fast tether back key if (allowFastTether) { // These conditions determine whether tethering is allowed if (tetherUIState == TetherUIState.GAMEPLAY && !GameManager.isPlayerDead() && !GameManager.CameraIsZoomedOut() && !GameManager.isPlayerDashing() && !GameManager.isPaused()) { // If the player presses the menu key, start the timer //if (Input.GetKeyDown(PlayerControlManager.LH_TetherMenu) || Input.GetKeyDown(PlayerControlManager.RH_TetherMenu)) if (PlayerControlManager.GetKeyDown(ControlInput.TETHER_MENU)) { fastTetherKeyTimer = fastTetherKeyTime; } // If the menu button is released before the timer has reached zero, call a fast tether back //if (Input.GetKeyUp(PlayerControlManager.LH_TetherMenu) || Input.GetKeyUp(PlayerControlManager.RH_TetherMenu)) if (PlayerControlManager.GetKeyUp(ControlInput.TETHER_MENU)) { OnFastTetherStart(LevelStateManager.curState); } } } else { fastTetherKeyTimer = 0; } // Update fastTetherKeyTimer if (fastTetherKeyTimer > 0) { fastTetherKeyTimer -= Time.deltaTime; if (fastTetherKeyTimer < 0) { fastTetherKeyTimer = 0; } } /* * Tether menu functionality */ // Bringing up the tether menu // Adding the pause menu active check prevents the cursor from getting reverted to the gameplay cursor while the pause menu is up if ((tetherUIState == TetherUIState.GAMEPLAY || tetherUIState == TetherUIState.TETHER_MENU) && !PauseMenuManager.pauseMenuActive) { // Test for bringing up the menu, while alive if (!GameManager.isPlayerDead()) { // If the tether menu key is held down //if (PlayerControlManager.GetKey(ControlInput.TETHER_MENU) && !GameManager.CameraIsZoomedOut() && fastTetherKeyTimer <= 0 && !GameManager.isPlayerDashing()) if (PlayerControlManager.GetKey(ControlInput.TETHER_MENU) && fastTetherKeyTimer <= 0 && tetherMenuDisableTimer == 0 && !GameManager.isPlayerDashing() && (GameManager.inst.pauseType == PauseType.NONE || GameManager.inst.pauseType == PauseType.TETHER_MENU)) { tetherUIState = TetherUIState.TETHER_MENU; //GameManager.setPause(true); if (GameManager.inst.pauseType == PauseType.NONE) { GameManager.inst.EnterPauseState(PauseType.TETHER_MENU); } CursorManager.inst.lockCursorType = true; CursorManager.inst.cursorState = CursorState.MENU; ShowTetherMenu(); } else { tetherUIState = TetherUIState.GAMEPLAY; //GameManager.setPause(false); if (GameManager.inst.pauseType == PauseType.TETHER_MENU) { GameManager.inst.ExitPauseState(); //Debug.Log("ExitPauseState()"); } CursorManager.inst.lockCursorType = false; CursorManager.inst.OnCursorBoundsUpdated(); HideTetherMenu(); } } // If the player is dead, force the menu to come up else { tetherUIState = TetherUIState.TETHER_MENU; //GameManager.setPause(true); GameManager.inst.EnterPauseState(PauseType.TETHER_MENU); CursorManager.inst.lockCursorType = true; CursorManager.inst.cursorState = CursorState.MENU; ShowTetherMenu(); } } /* * Tether Corner HUD visibility */ if (tetherHUDVisible) { tetherHUDGroup.alpha = Mathf.Lerp(tetherHUDGroup.alpha, 1, tetherHUDFadeInSpeed * Time.deltaTime); } else { tetherHUDGroup.alpha = Mathf.Lerp(tetherHUDGroup.alpha, 0, tetherHUDFadeOutSpeed * Time.deltaTime); } /* * Tether Corner HUD fading when zooming out */ // When zooming/zoomed out, hide the bottom left time tether HUD // JK let's not do this /* * if (GameManager.CameraIsZoomedOut()) * { * tetherHUDGroup.alpha = Mathf.Lerp(tetherHUDGroup.alpha, 0, tetherHUDFadeOutSpeed * Time.deltaTime); * } * // When zooming back in or not zoomed, reveal the bottom left time tether HUD * else * { * tetherHUDGroup.alpha = Mathf.Lerp(tetherHUDGroup.alpha, 1, tetherHUDFadeInSpeed * Time.deltaTime); * } */ /* * Other Update Stuff */ UpdateTimeArrowPos(); //ScreenshotManager.inst.UpdateScreenshotState(); if (tetherUIState == TetherUIState.TETHER_MENU) { if (menuLight != null && menuLightOn != null) { menuLight.sprite = menuLightOn; } } else { if (menuLight != null && menuLightOff != null) { menuLight.sprite = menuLightOff; } } // End level tether point collection // Once all indicator return objects have returned to the player and been destroyed, this will allow EndLevelAllTetherPointdCollected to return true if (endLevelWaitForCollection) { if (IndicatorReturnObject.NoInstancesExist()) { endLevelWaitForCollection = false; } } if (tetherMenuDisableTimer > 0) { tetherMenuDisableTimer -= Time.deltaTime; if (tetherMenuDisableTimer < 0) { // Don't allow the timer to reach 0 until the tether menu key has been released if (PlayerControlManager.GetKey(ControlInput.TETHER_MENU)) { tetherMenuDisableTimer = 0.1f; } else { tetherMenuDisableTimer = 0f; } } } }
public void Update() { // Update the bounds every frame from the separate bounds object // This isn't ideal, but is being done so that bounds can be stored in separate gameObject outside the LevelManager prefab // This way, you can change the external bounds and have that change update here, // while still allowing the CameraManager to store default camera bounds if the CameraBounds instance isn't assigned if (SceneSetup.inst != null) { b_origin = SceneSetup.inst.b_origin; b_max = SceneSetup.inst.b_max; b_min = SceneSetup.inst.b_min; } //shake the camera if (shakeDur > 0f) { cam.transform.localPosition = (Vector3)Random.insideUnitCircle * shakeInt; shakeInt -= shakeDec * Time.deltaTime; if (shakeInt <= 0f) { shakeDur = 0f; } shakeDur -= Time.deltaTime; if (shakeDur <= 0f) { shake(0, 0); cam.transform.localPosition = Vector2.zero; } } //smooth follow if (target != null && smoothFollow) { Vector3 tarPos = transform.position; Vector2 dtt = target.position - transform.position; if (dtt.magnitude > followRadius) { tarPos += (Vector3)(dtt.normalized * (dtt.magnitude - followRadius)); transform.position = Vector3.Lerp(transform.position, tarPos, Time.deltaTime * smoothSpeed); fitToBounds(transform, cam); } } if (Application.isPlaying) { /* * //if ((Input.GetKey(PlayerControlManager.LH_ZoomOut) || Input.GetKey(PlayerControlManager.RH_ZoomOut)) && TetherManager.ZoomOutAllowed() && !GameManager.isPlayerDashing()) * if (PlayerControlManager.GetKey(ControlInput.ZOOM_OUT) && TetherManager.ZoomOutAllowed() && !GameManager.isPlayerDashing()) * { * m_zoomState = true; * zoomTo(zoomOutSize, zoomOutLerpSpeed); * updateZoomPan(false); * } * else * { * m_zoomState = false; * zoomTo(regularSize, zoomInLerpSpeed); * updateZoomPan(true); * } */ if (cameraZoomZoneCollider != null && m_zoomState == false) { if (cameraZoomZoneCollider.collisionActive) { if (cam.orthographicSize <= cameraZoomZoneCollider.targetCameraSize) { zoomTo(cameraZoomZoneCollider.targetCameraSize, zoneZoomOutLerpSpeed); useZoneZoomOutSpeed = true; } else { zoomTo(cameraZoomZoneCollider.targetCameraSize, zoomInLerpSpeed); useZoneZoomOutSpeed = true; } } } // Toggle zoom state key inputs if (m_zoomState == false) { // These conditions determine whether zooming out is allowed if (PlayerControlManager.GetKeyDown(ControlInput.ZOOM_OUT) && TetherManager.ZoomOutAllowed() && !GameManager.isPlayerDashing() && !PauseMenuManager.pauseMenuActive && !GameManager.inst.IsWorldPauseType(GameManager.inst.pauseType)) { m_zoomState = true; GameManager.inst.EnterPauseState(PauseType.ZOOM); } } else { if (PlayerControlManager.GetKeyDown(ControlInput.ZOOM_OUT) && !PauseMenuManager.pauseMenuActive) { m_zoomState = false; GameManager.inst.ExitPauseState(); useZoneZoomOutSpeed = false; } } // If the player is dead, force the zoom to cancel if (GameManager.isPlayerDead()) { m_zoomState = false; } // Update zoom properties, based on m_zoomState if (m_zoomState == true) { zoomTo(zoomOutSize, zoomOutLerpSpeed); updateZoomPan(false); } else { updateZoomPan(true); if (cameraZoomZoneCollider == null || !cameraZoomZoneCollider.collisionActive) { if (useZoneZoomOutSpeed) { zoomTo(regularSize, zoneZoomInLerpSpeed); } else { zoomTo(regularSize, zoomInLerpSpeed); } //updateZoomPan(true); } } } updateAtBounds(); }
/// <summary> /// Standard movement behavior for the Player. /// DON'T CALL THIS /// </summary> public void move() { Vector2 movementVector = Vector2.zero; if (PlayerControlManager.GetKey(ControlInput.UP)) // UP { movementVector += Vector2.up; } if (PlayerControlManager.GetKey(ControlInput.LEFT)) // LEFT { movementVector += Vector2.left; } if (PlayerControlManager.GetKey(ControlInput.DOWN)) // DOWN { movementVector += Vector2.down; } if (PlayerControlManager.GetKey(ControlInput.RIGHT)) // RIGHT { movementVector += Vector2.right; } //update animator on movement direction, if we're moving if (movementVector != Vector2.zero) { float zRot = Vector2.SignedAngle(Vector2.right, movementVector); zRot += zRot < 0f ? 360f : 0f; int quadrant = (int)((zRot / 360f) * 4f); anim.SetInteger("Direction", quadrant + 1); } movementVector = movementVector.normalized * getSelf().getMovespeed() * Time.deltaTime; physbody.velocity += movementVector; if (physbody.velocity.magnitude > getSelf().getMovespeed()) { physbody.velocity = physbody.velocity.normalized * getSelf().getMovespeed(); } // Wall check / check for moving platforms RaycastHit2D[] hits = new RaycastHit2D[1]; int hitCount = 0; ContactFilter2D cf = new ContactFilter2D(); cf.SetLayerMask(moveMask); hitCount = GetComponent <Collider2D>().Cast(movementVector, cf, hits, getSelf().getMovespeed() * Time.deltaTime); //Check for Pits/platforms Collider2D[] pitsFound = new Collider2D[1]; Collider2D[] platformsFound = new Collider2D[1]; int pitCount = 0; int platformCount = 0; ContactFilter2D pitFilter = new ContactFilter2D(); ContactFilter2D platformFilter = new ContactFilter2D(); pitFilter.SetLayerMask(1 << LayerMask.NameToLayer("Pits")); pitFilter.useTriggers = true; platformFilter.SetLayerMask(1 << LayerMask.NameToLayer("SkyEnts")); platformFilter.useTriggers = true; Vector2 colSize = gameObject.GetComponent <BoxCollider2D> ().size; Vector2 moveVect = new Vector2(movementVector.normalized.x * colSize.x * 0.5f, movementVector.normalized.y * colSize.y); platformCount = Physics2D.OverlapBox((Vector3)GetComponent <Collider2D>().offset + transform.position + (Vector3)(moveVect), GetComponent <BoxCollider2D>().size, 0, platformFilter, platformsFound); pitCount = Physics2D.OverlapBox((Vector3)GetComponent <Collider2D>().offset + transform.position + (Vector3)(moveVect), GetComponent <BoxCollider2D>().size, 0, pitFilter, pitsFound); TESTPOSITION = (Vector3)GetComponent <Collider2D> ().offset + transform.position + (Vector3)(moveVect); TESTSIZE = GetComponent <BoxCollider2D> ().size; bool seesPlatform = false; for (int i = 0; i < platformsFound.Length; i++) { if (platformsFound[i] != null) { if (platformsFound [i].CompareTag("MovingPlatform")) { seesPlatform = true; } } } bool seesPit = (pitCount > 0 && !seesPlatform); //if there are no walls or pits, move if (hitCount <= 0 && !seesPit && movementVector != Vector2.zero) { transform.Translate((Vector3)movementVector); anim.SetBool("isMoving", true); } else { anim.SetBool("isMoving", false); } //if there are no walls and there is a pit, incriment the pit timer if (seesPit && hitCount <= 0) { anim.SetBool("Stumbling", true); physbody.velocity -= (physbody.velocity * pitSpeedAdjustment); pitTimer += Time.deltaTime; } else { anim.SetBool("Stumbling", false); pitTimer = 0; } //if the pit timer fills, kill the player if (pitTimer >= pitFallDelay || (seesPit && movementVector == Vector2.zero) || (movementVector != Vector2.zero && !CheckForGround())) { transform.position = transform.position + (Vector3)(moveVect * 3); anim.SetTrigger("Fall"); getSelf().onDeath(); } }
void updateZoomPan(bool panToTarget) { if (panToTarget) { panOffset = Vector2.Lerp(panOffset, Vector2.zero, 0.2f); } else { // Used to avoid double inputs stacking from both mouse and keyboard // 0 = right, 1 = left, 2 = top, 3 = bottom bool[] dirs = new bool[4]; if (useCursorPan && GameManager.inst.pauseType == PauseType.ZOOM) { // Horizontal pan // Right side if (!atRightBound && Input.mousePosition.x > Screen.width - Screen.width / horizScrollPercDivisor) { panOffset += new Vector2(panSpeed * Time.deltaTime, 0); dirs[0] = true; } // Left side else if (!atLeftBound && Input.mousePosition.x < 0 + Screen.width / horizScrollPercDivisor) { panOffset -= new Vector2(panSpeed * Time.deltaTime, 0); dirs[1] = true; } // Vertical pan // Top side if (!atTopBound && Input.mousePosition.y > Screen.height - Screen.height / vertScrollPercDivisor) { panOffset += new Vector2(0, panSpeed * Time.deltaTime); dirs[2] = true; } // Bottom side else if (!atBottomBound && Input.mousePosition.y < 0 + Screen.width / vertScrollPercDivisor) { panOffset -= new Vector2(0, panSpeed * Time.deltaTime); dirs[3] = true; } } if (useKeyboardPan && GameManager.inst.pauseType == PauseType.ZOOM) { // Horizontal pan // Right side if (!atRightBound && PlayerControlManager.GetKey(ControlInput.RIGHT) && !dirs[0]) { panOffset += new Vector2(panSpeed * Time.deltaTime, 0); } // Left side else if (!atLeftBound && PlayerControlManager.GetKey(ControlInput.LEFT) && !dirs[1]) { panOffset -= new Vector2(panSpeed * Time.deltaTime, 0); } // Vertical pan // Top side if (!atTopBound && PlayerControlManager.GetKey(ControlInput.UP) && !dirs[2]) { panOffset += new Vector2(0, panSpeed * Time.deltaTime); } // Bottom side else if (!atBottomBound && PlayerControlManager.GetKey(ControlInput.DOWN) && !dirs[3]) { panOffset -= new Vector2(0, panSpeed * Time.deltaTime); } } } //Debug.Log("panOffset: " + panOffset); //cam.transform.localPosition = Vector3.Lerp(cam.transform.localPosition, new Vector3 (panOffset.x, panOffset.y, cam.transform.localPosition.z), 10 * Time.deltaTime); cam.transform.localPosition = new Vector3(panOffset.x, panOffset.y, cam.transform.localPosition.z); }
// Update is called once per frame void Update() { Collider2D[] hits; if (moveParent != null) { transform.position = moveParent.position + offsetFromMoveParent; } /* * Radius Tether point removal * Possibly deprecated */ playerInRemoveRadius = false; if (allowRadiusRemoval) { hits = Physics2D.OverlapCircleAll(tetherPointSprite.transform.position, removeRadius); for (int i = 0; i < hits.Length; i++) { if (hits[i].CompareTag("Player")) { playerInRemoveRadius = true; } } } // Don't allow the remove prompt/action for the first tether point (when tetherIndex == 0) if (playerInRemoveRadius && tetherIndex != 0) { // Display the remove prompt if (removePrompt != null) { removePrompt.SetActive(true); } // Test for remove action // TODO- might want to have this be a hold action if (PlayerControlManager.GetKeyDown(ControlInput.INTERACT) && !beingRemoved) { TetherManager.inst.RemoveTetherPoint(tetherIndex); beingRemoved = true; } } else { if (removePrompt != null) { removePrompt.SetActive(false); } } /* * Input (right click) Tether point removal */ //if (allowKeyRemoval && tetherIndex != 0 && MouseIsOver() && PlayerControlManager.GetKeyDown(ControlInput.FIRE_STASIS) && !LevelStateManager.CursorIsOverAStasisBubble()) if (allowKeyRemoval && tetherIndex != 0 && MouseIsOver() && PlayerControlManager.GetKeyDown(ControlInput.REMOVAL) && !beingRemoved) { TetherManager.inst.RemoveTetherPoint(tetherIndex); beingRemoved = true; } // Check for Destroy if (spriteAnimator != null && spriteAnimator.GetCurrentAnimatorStateInfo(0).IsName("WaitForDestroy")) { // TODO- spawn object that flies toward the player if (spawnReturnObj) { GameObject returnObj = (GameObject)Instantiate(returnObjPrefab, platformAttachPoint.transform.position, transform.rotation); } Destroy(this.gameObject); } if (zoomParticles != null) { if (GameManager.inst.pauseType == PauseType.ZOOM) { zoomParticles.gameObject.SetActive(true); } else { zoomParticles.gameObject.SetActive(false); } } }
/// <summary> /// Checks the keyboard for movement input. /// </summary> void getInput() { if (!_beingPushed && _playerInRange && !GameManager.isPaused() && _stasisTimer == 0) { //Move in direction if key is pressed switch (_moveDirection) { case Direction.Up: if (PlayerControlManager.GetKey(ControlInput.UP)) { move(_moveDirection); } break; case Direction.Right: if (PlayerControlManager.GetKey(ControlInput.RIGHT)) { move(_moveDirection); } break; case Direction.Down: if (PlayerControlManager.GetKey(ControlInput.DOWN)) { move(_moveDirection); } break; case Direction.Left: if (PlayerControlManager.GetKey(ControlInput.LEFT)) { move(_moveDirection); } break; } } if (_beingPushed) { if (!_playerInRange || !_canMove || GameManager.isPaused() || inStasis || CheckPath() || _stasisTimer > 0) { stop(); } //stop moving when key is released switch (_moveDirection) { case Direction.Up: if (!PlayerControlManager.GetKey(ControlInput.UP)) { stop(); } break; case Direction.Right: if (!PlayerControlManager.GetKey(ControlInput.RIGHT)) { stop(); } break; case Direction.Down: if (!PlayerControlManager.GetKey(ControlInput.DOWN)) { stop(); } break; case Direction.Left: if (!PlayerControlManager.GetKey(ControlInput.LEFT)) { stop(); } break; } } }