void CheckPlayerOrAirBubbleSeen() { // check if airbubbles noticed and only dispatch once if (!m.isDrillAirBubbleNoticed) { foreach (Vector2 drillAirBubblePosition in drillAirBubblePositionList) { // do not discover the same bubble again if (m.discoveredDrillAirBubbleList.Contains(drillAirBubblePosition)) { continue; } // check if the bubble is within the spotlight's mesh if (IsPointInPolygon(mesh.vertices, drillAirBubblePosition - (Vector2)transform.position)) { // add to the list of discovered air bubble list m.discoveredDrillAirBubbleList.Add(drillAirBubblePosition); // make sure this only runs once for now StartCoroutine(DoNotNoticeDrillAirBubbleTemporarily()); // dispatch the signal _spotlightSunkShipNoticedSignal.Dispatch(drillAirBubblePosition); // slow down the parent patrol boat if it's a patrol boat if (transform.parent.GetComponent <ShipPatrolView>() != null) { transform.parent.GetComponent <ShipPatrolView>().spotLightSunkShipNoticedSignalDirectCall(); } // look at bubbles OnSmokeBombExplodedSignal(drillAirBubblePosition, Const.ShipPatrolAlertSlowLength); } } } // check if player is within the spotlight and not hidden under a bridge or dock or embarked uboat bool newIsPlayerNoticed = IsPointInPolygon(mesh.vertices, playerModel.getCachedPosition() - (Vector2)transform.position) && playerModel.isHiddenUnderDockOrBridge == 0 && !playerModel.isEmbarkedUBoat; if (newIsPlayerNoticed != m.isPlayerNoticed) { m.isPlayerNoticed = newIsPlayerNoticed; _spotlightPlayerNoticedSignal.Dispatch(GetInstanceID()); // restart color lerp-ing lerpColorTimer = 0; } if (newIsPlayerNoticed) { m.playerLastNoticedAt = Time.time; } }
void UpdatePerSecond() { // if stuck then put a bit back if (_sIsSwimForceAppliedSecondAgo && _isSwimForceApplied && ((playerModel.getCachedPosition() - _sLastMemorizedPosition).magnitude < IsStuckMinMoveDistance) && !playerModel.isMountingTimeBomb && !_isDrilling) { transform.position = playerModel.pathGoal = _sLastMemorizedPosition = playerModel.getCachedPosition() + (_sLastNonStuckPosition - playerModel.getCachedPosition()) * .1f; } // if not stuck then update the variables else { _sLastNonStuckPosition = _sLastMemorizedPosition; _sLastMemorizedPosition = transform.position; } _sIsSwimForceAppliedSecondAgo = _isSwimForceApplied; }