private void UpdatePosition(AIActor targetActor = null) { Vector2 unitBottomLeft = m_room.area.UnitBottomLeft; Vector2 unitTopRight = m_room.area.UnitTopRight; if (TracksRandomEnemy) { if (targetActor != null && targetActor.healthHaver != null) { if (!targetActor.healthHaver.IsDead) { if (targetActor.specRigidbody) { m_LastKnownPosition = targetActor.specRigidbody.GetUnitCenter(ColliderType.Ground); } else { m_LastKnownPosition = targetActor.sprite.WorldCenter; } } } } else { m_LastKnownPosition = m_targetPlayer.CenterPosition; } m_LastKnownPosition = BraveMathCollege.ClampToBounds(m_LastKnownPosition, unitBottomLeft + Vector2.one, unitTopRight - Vector2.one); transform.position = (m_LastKnownPosition - m_targetOffset).Quantize(0.0625f); TargetAnimator.sprite.UpdateZDepth(); sprite.UpdateZDepth(); }
public static void StartTeleport(PlayerController user, Vector2 newPosition) { user.healthHaver.TriggerInvulnerabilityPeriod(0.001f); user.DidUnstealthyAction(); Vector2 clampedPosition = BraveMathCollege.ClampToBounds(newPosition, GameManager.Instance.MainCameraController.MinVisiblePoint, GameManager.Instance.MainCameraController.MaxVisiblePoint); BlinkToPoint(user, clampedPosition); }
public static Vector2 GetCursorPosition(this PlayerController user, float noCursorControllerRange) { Vector2 m_cachedBlinkPosition = Vector2.zero; GungeonActions m_activeActions = OMITBReflectionHelpers.ReflectGetField <GungeonActions>(typeof(PlayerController), "m_activeActions", user); bool IsKeyboardAndMouse = BraveInput.GetInstanceForPlayer(user.PlayerIDX).IsKeyboardAndMouse(false); if (IsKeyboardAndMouse) { m_cachedBlinkPosition = user.unadjustedAimPoint.XY() - (user.CenterPosition - user.specRigidbody.UnitCenter); } else { m_cachedBlinkPosition = user.PositionInDistanceFromAimDir(5); //if (m_activeActions != null) { m_cachedBlinkPosition += m_activeActions.Aim.Vector.normalized * BraveTime.DeltaTime * 15f; } } m_cachedBlinkPosition = BraveMathCollege.ClampToBounds(m_cachedBlinkPosition, GameManager.Instance.MainCameraController.MinVisiblePoint, GameManager.Instance.MainCameraController.MaxVisiblePoint); return(m_cachedBlinkPosition); }
public void HandleBlink(PlayerController Owner) { if (GameManager.Instance.Dungeon && GameManager.Instance.Dungeon.IsEndTimes) { ClearBlinkShadow(); return; } if (Owner.WasPausedThisFrame) { ClearBlinkShadow(); return; } // if (!CheckDodgeRollDepth(Owner)) { return; } /*PlayerController.DodgeRollState? m_dodgeRollState = ReflectionHelpers.ReflectGetField<PlayerController.DodgeRollState>(typeof(PlayerController), "m_dodgeRollState", Owner); * if (m_dodgeRollState.HasValue) { * if (m_dodgeRollState == PlayerController.DodgeRollState.AdditionalDelay) { return; } * }*/ // if (Owner.IsFlying && !CanDodgeRollWhileFlying(Owner)) { return; } BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(Owner.PlayerIDX); GungeonActions m_activeActions = ReflectionHelpers.ReflectGetField <GungeonActions>(typeof(PlayerController), "m_activeActions", Owner); Vector2 currentDirection = AdjustInputVector(m_activeActions.Move.Vector, BraveInput.MagnetAngles.movementCardinal, BraveInput.MagnetAngles.movementOrdinal); bool WillBlink = false; bool flag2 = false; if (instanceForPlayer.GetButtonDown(GungeonActions.GungeonActionType.DodgeRoll)) { flag2 = true; } if (instanceForPlayer.ActiveActions.DodgeRollAction.IsPressed) { m_timeHeldBlinkButton += BraveTime.DeltaTime; if (m_timeHeldBlinkButton < 0.3f) { m_cachedBlinkPosition = Owner.specRigidbody.UnitCenter; } else { Vector2 cachedBlinkPosition = m_cachedBlinkPosition; bool IsKeyboardAndMouse = BraveInput.GetInstanceForPlayer(Owner.PlayerIDX).IsKeyboardAndMouse(false); if (IsKeyboardAndMouse) { m_cachedBlinkPosition = Owner.unadjustedAimPoint.XY() - (Owner.CenterPosition - Owner.specRigidbody.UnitCenter); } else { if (m_activeActions != null) { m_cachedBlinkPosition += m_activeActions.Aim.Vector.normalized * BraveTime.DeltaTime * 15f; } } m_cachedBlinkPosition = BraveMathCollege.ClampToBounds(m_cachedBlinkPosition, GameManager.Instance.MainCameraController.MinVisiblePoint, GameManager.Instance.MainCameraController.MaxVisiblePoint); UpdateBlinkShadow(Owner, m_cachedBlinkPosition - cachedBlinkPosition, CanBlinkToPoint(Owner, m_cachedBlinkPosition, Owner.transform.position.XY() - Owner.specRigidbody.UnitCenter)); } } else if (instanceForPlayer.ActiveActions.DodgeRollAction.WasReleased || flag2) { if (m_timeHeldBlinkButton >= 0.3f) { WillBlink = true; } } else { m_timeHeldBlinkButton = 0f; } if (WillBlink) { /*if (m_timeHeldBlinkButton < 0.3f) { * m_cachedBlinkPosition = Owner.specRigidbody.UnitCenter + currentDirection.normalized * Owner.rollStats.GetModifiedDistance(Owner); * }*/ Owner.healthHaver.TriggerInvulnerabilityPeriod(0.001f); // Owner.rollStats.blinkDistanceMultiplier = 1f; Owner.DidUnstealthyAction(); BlinkToPoint(Owner, m_cachedBlinkPosition); m_timeHeldBlinkButton = 0; WillBlink = false; } }