internal override object get(ObjectRepresentation @object) { Exception e; try { return(_method.invoke(@object)); } catch (InvocationTargetException ex) { e = ex.TargetException; if (e is Exception) { throw ( Exception )e; } else if (e is Exception) { throw ( Exception )e; } } catch (Exception ex) { e = ex; } throw new System.InvalidOperationException("Serialization failure", e); }
public void ResetToPreviousPlatform() { animator.Rebind(); currentPlatformRepresentation = previousPlatform; representation.location.laneA = GetClosestLaneFrom(currentPlatformRepresentation.location); }
public ObjectRepresentation CheckIntersect(ObjectRepresentation obj, ObjectKind allowedKinds, float margin = 0f, bool aboveLaneMatters = true) { // TODO Broadphase optimization here foreach (ObjectRepresentation other in objects) { if ((other.kind & allowedKinds) == 0) { continue; } if (aboveLaneMatters && obj.location.isAboveLane != other.location.isAboveLane) { continue; } if (!CommonLanes(obj.location, other.location)) { continue; } if (obj.location.bounds.Intersects(other.location.bounds, margin)) { return(other); } } return(null); }
public void JumpTo(Lane targetLane) { Vector3 targetPosition; if (targetLane != null) { targetPosition = targetLane.GetJumpDestinationFrom(transform.position); targetPosition.z += currentSpeed * jumpDuration; KillEnemyAtJumpDestination(targetLane, targetPosition); } else { // Temp targetPosition = transform.position + Vector3.right * 3f; targetPosition.z += currentSpeed * jumpDuration; } currentJumpAnimation = new PlayerJump(transform, targetPosition, jumpPower, jumpDuration) .OnComplete(() => { currentJumpAnimation = null; isJumping = false; representation.location.laneA = targetLane; representation.location.laneB = null; representation.location.isMovingBetweenLanes = false; representation.location.isAboveLane = false; }); isJumping = true; wasJumpPressedDuringJump = false; previousJumpStartTime = Time.unscaledTime; if (currentPlatformRepresentation != null) { previousPlatform = currentPlatformRepresentation; } representation.location.laneB = targetLane; representation.location.isMovingBetweenLanes = currentLane && currentLane != targetLane; representation.location.isAboveLane = true; PlayJumpSound(); if (targetLane == currentLane.leftNeighbor) { animator.SetTrigger("Jump_L"); } else if (targetLane == currentLane.rightNeighbor) { animator.SetTrigger("Jump_R"); } else if (targetLane == currentLane) { animator.SetTrigger("Jump_F"); } else { animator.SetTrigger("Jump_R"); // TEMP. Jump to a null lane is right by default. } }
private void KillEnemyAtJumpDestination(Lane targetLane, Vector3 targetPosition) { float laneTargetPosition = targetLane.GetPositionOnLane(targetPosition); ObjectRepresentation enemyRecord = LevelState.instance.CheckByKind(ObjectKind.Enemy, targetLane, laneTargetPosition, enemyJumpOnErrorTolerance); enemyRecord?.gameObject.GetComponent <Enemy>().JumpedOn(); }
public RestSnapshot(IOidStrategy oidStrategy, ObjectContextFacade objectContext, HttpRequestMessage req, RestControlFlags flags, HttpStatusCode httpStatusCode = HttpStatusCode.OK) : this(oidStrategy, objectContext, req, true) { populator = () => { HttpStatusCode = httpStatusCode; Representation = ObjectRepresentation.Create(oidStrategy, objectContext, req, flags); SetHeaders(); }; }
private ObjectRepresentation MakeRepresentation() { return(representation = new ObjectRepresentation { kind = objectKind, location = GetLocation(), gameObject = gameObject }); }
public RestSnapshot(ObjectContextSurface objectContext, HttpRequestMessage req, RestControlFlags flags, HttpStatusCode httpStatusCode = HttpStatusCode.OK) : this(objectContext, req, true) { populator = () => { this.httpStatusCode = httpStatusCode; representation = ObjectRepresentation.Create(objectContext, req, flags); SetHeaders(); }; }
internal virtual void PutTo(MappingSerializer serializer, ObjectRepresentation @object, string key) { object value = Get(@object); if (value != null) { (( Representation )value).PutTo(serializer, key); } }
public void On(OnPlayerWillRespawn message) { ObjectRepresentation platform = message.previousPlatform; Vector3 targetPos = platform.gameObject.transform.position; targetPos.y = 0.75f; targetPos.z = platform.location.bounds.min; transform.position = targetPos; StartCoroutine(EnableController()); }
void FixedUpdate() { ObjectRepresentation playerRepresentation = LevelState.instance.CheckIntersect( representation, ObjectKind.Player, playerDetectionMargin ); if (playerRepresentation == null) { return; } if (playerRepresentation.location.isMovingBetweenLanes) { return; } /// TODO Meh. Fix direct dependency. Something like new JumpToLane(taretLane).PostEvent()? playerRepresentation.gameObject.GetComponent <PlayerController>().JumpTo(targetLane); enabled = false; }
private void UpdateCurrentPlatform() { if (currentLane == null) { currentPlatformRepresentation = null; } else { currentPlatformRepresentation = LevelState.instance.CheckByKind( ObjectKind.Platform, currentLane, positionOnLane, platformErrorTolerance, areMovingObjectsAllowed: true ); } if (currentPlatformRepresentation != null && !IsCloseEnoughForSnapping(currentPlatformRepresentation)) { currentPlatformRepresentation = null; } if (currentPlatformRepresentation != null) { previousPlatform = currentPlatformRepresentation; representation.location.laneA = GetClosestLaneFrom(currentPlatformRepresentation.location); } }
public bool Remove(ObjectRepresentation obj) { return(objects.Remove(obj)); }
public void Add(ObjectRepresentation obj) { Assert.IsFalse(objects.Contains(obj)); objects.Add(obj); }
internal abstract object Get(ObjectRepresentation @object);
public OnPlayerWillRespawn(ObjectRepresentation previousPlatform) { this.previousPlatform = previousPlatform; }
private bool IsCloseEnoughForSnapping(ObjectRepresentation platformRepresentation) { return(Mathf.Abs(transform.position.x - platformRepresentation.gameObject.transform.position.x) <= minPlatformSnappingDistance); }