コード例 #1
0
            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);
            }
コード例 #2
0
    public void ResetToPreviousPlatform()
    {
        animator.Rebind();

        currentPlatformRepresentation = previousPlatform;
        representation.location.laneA = GetClosestLaneFrom(currentPlatformRepresentation.location);
    }
コード例 #3
0
ファイル: LevelState.cs プロジェクト: Cosmin-B/MrWhiskers
    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);
    }
コード例 #4
0
    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.
        }
    }
コード例 #5
0
    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();
    }
コード例 #6
0
 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();
     };
 }
コード例 #7
0
 private ObjectRepresentation MakeRepresentation()
 {
     return(representation = new ObjectRepresentation
     {
         kind = objectKind,
         location = GetLocation(),
         gameObject = gameObject
     });
 }
コード例 #8
0
 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();
     };
 }
コード例 #9
0
            internal virtual void PutTo(MappingSerializer serializer, ObjectRepresentation @object, string key)
            {
                object value = Get(@object);

                if (value != null)
                {
                    (( Representation )value).PutTo(serializer, key);
                }
            }
コード例 #10
0
    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());
    }
コード例 #11
0
ファイル: JumpPad.cs プロジェクト: Cosmin-B/MrWhiskers
    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;
    }
コード例 #12
0
    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);
        }
    }
コード例 #13
0
ファイル: LevelState.cs プロジェクト: Cosmin-B/MrWhiskers
 public bool Remove(ObjectRepresentation obj)
 {
     return(objects.Remove(obj));
 }
コード例 #14
0
ファイル: LevelState.cs プロジェクト: Cosmin-B/MrWhiskers
 public void Add(ObjectRepresentation obj)
 {
     Assert.IsFalse(objects.Contains(obj));
     objects.Add(obj);
 }
コード例 #15
0
 internal abstract object Get(ObjectRepresentation @object);
コード例 #16
0
 public OnPlayerWillRespawn(ObjectRepresentation previousPlatform)
 {
     this.previousPlatform = previousPlatform;
 }
コード例 #17
0
 private bool IsCloseEnoughForSnapping(ObjectRepresentation platformRepresentation)
 {
     return(Mathf.Abs(transform.position.x - platformRepresentation.gameObject.transform.position.x) <= minPlatformSnappingDistance);
 }