Пример #1
0
        private void Synchronize()
        {
            if (isLocalPlayer && GameData.IsHeadlessServer)
            {
                return;
            }

            if (!playerMove.isGhost)
            {
                CheckSpaceWalk();

                if (isLocalPlayer && playerMove.IsPushing || pushPull.pulledBy != null)
                {
                    return;
                }

                PlayerState state = isLocalPlayer ? predictedState : serverState;
                transform.localPosition = Vector3.MoveTowards(transform.localPosition, state.Position,
                                                              playerMove.speed * Time.deltaTime);

                //Check if we should still be displaying an ItemListTab and update it, if so.
                ControlTabs.CheckItemListTab();

                if (state.Position != transform.localPosition)
                {
                    lastDirection = (state.Position - transform.localPosition).normalized;
                }

                if (pullingObject != null)
                {
                    if (transform.hasChanged)
                    {
                        transform.hasChanged = false;
                        PullObject();
                    }
                    else if (pullingObject.transform.localPosition != pullPos)
                    {
                        pullingObject.transform.localPosition = pullPos;
                    }
                }

                //Registering
                if (registerTile.Position != Vector3Int.RoundToInt(state.Position))
                {
                    RegisterObjects();
                }
            }
            else
            {
                PlayerState state = isLocalPlayer ? predictedState : serverState;
                playerScript.ghost.transform.localPosition = Vector3.MoveTowards(
                    playerScript.ghost.transform.localPosition, state.Position, playerMove.speed * Time.deltaTime);
            }
        }
Пример #2
0
        private void Synchronize()
        {
            if (isLocalPlayer && GameData.IsHeadlessServer)
            {
                return;
            }
            if (isServer)
            {
                CheckTargetUpdate();
            }

            PlayerState state = isLocalPlayer ? predictedState : playerState;

            if (!playerMove.isGhost)
            {
                CheckSpaceWalk();

                if (isLocalPlayer && playerMove.IsPushing || pushPull.pulledBy != null)
                {
                    return;
                }

                if (state.Position != transform.localPosition)
                {
                    PlayerLerp(state);
                }

                if (isServer && !ServerPositionsMatch)
                {
                    //Lerp on server if it's worth lerping
                    //and inform players if serverState reached targetState afterwards
                    ServerLerp();
                    TryNotifyPlayers();
                }

                //Check if we should still be displaying an ItemListTab and update it, if so.
                ControlTabs.CheckItemListTab();

                if (PullingObject != null)
                {
                    if (transform.hasChanged)
                    {
                        transform.hasChanged = false;
                        PullObject();
                    }
                    else if (PullingObject.transform.localPosition != pullPos)
                    {
                        PullingObject.transform.localPosition = pullPos;
                    }
                }

                //Registering
                if (registerTile.Position != Vector3Int.RoundToInt(state.Position))
                {
                    RegisterObjects();
                }
            }
            else
            {
                if (state.Position != playerScript.ghost.transform.localPosition)
                {
                    GhostLerp(state);
                }
            }
        }
Пример #3
0
        private void Synchronize()
        {
            if (isLocalPlayer && GameData.IsHeadlessServer)
            {
                return;
            }
            if (isServer)
            {
                CheckTargetUpdate();
            }

            PlayerState state = isLocalPlayer ? predictedState : playerState;

            if (!playerMove.isGhost)
            {
                if (matrix != null)
                {
                    //Client zone
                    CheckMovementClient();
                    //Server zone
                    if (isServer)
                    {
                        CheckMovementServer();
                    }
                }

                if (isLocalPlayer && playerMove.IsPushing || pushPull.pulledBy != null)
                {
                    return;
                }

                //Check if we should still be displaying an ItemListTab and update it, if so.
                ControlTabs.CheckItemListTab();

                if (PullingObject != null)
                {
                    if (transform.hasChanged)
                    {
                        transform.hasChanged = false;
                        PullObject();
                    }
                    else if (PullingObject.transform.localPosition != pullPos)
                    {
                        PullingObject.transform.localPosition = pullPos;
                    }
                }

                //Registering
                if (registerTile.Position != Vector3Int.RoundToInt(state.Position))
                {
                    RegisterObjects();
                }
            }
            else
            {
                if (!GhostPositionReady)
                {
                    GhostLerp(state);
                }
            }
        }