Exemplo n.º 1
0
    void Awake()
    {
        if (i != null)
        {
            Destroy(gameObject);
            return;
        }

        i = this;
        originalGravity = gravity;

        SuscribeToInput();
        CommonScriptableObjects.playerUnityPosition.Set(Vector3.zero);
        CommonScriptableObjects.playerWorldPosition.Set(Vector3.zero);
        CommonScriptableObjects.playerCoords.Set(Vector2Int.zero);
        CommonScriptableObjects.playerUnityEulerAngles.Set(Vector3.zero);

        characterPosition   = new DCLCharacterPosition();
        characterController = GetComponent <CharacterController>();
        collider            = GetComponent <Collider>();

        characterPosition.OnPrecisionAdjust += OnPrecisionAdjust;
        SceneController.OnDebugModeSet      += () => supportsMovingPlatforms = true;

        lastPosition     = transform.position;
        transform.parent = null;

        CommonScriptableObjects.rendererState.OnChange += OnRenderingStateChanged;
        OnRenderingStateChanged(CommonScriptableObjects.rendererState.Get(), false);
    }
Exemplo n.º 2
0
        public BlockerInstanceHandler(DCLCharacterPosition characterPosition, IBlockerAnimationHandler animationHandler)
        {
            this.characterPosition = characterPosition;
            this.animationHandler  = animationHandler;

            RenderProfileManifest.i.OnChangeProfile += OnChangeProfile;
            OnChangeProfile(RenderProfileManifest.i.currentProfile);
        }
Exemplo n.º 3
0
    void OnPrecisionAdjust(DCLCharacterPosition charPos)
    {
        Vector3 oldPos = this.transform.position;

        this.transform.position = charPos.unityPosition;

        if (CinemachineCore.Instance.BrainCount > 0)
        {
            CinemachineCore.Instance.GetActiveBrain(0).ActiveVirtualCamera?.OnTargetObjectWarped(transform, transform.position - oldPos);
        }
    }
Exemplo n.º 4
0
        public WorldBlockersController(ISceneHandler sceneHandler, IBlockerHandler blockerHandler, DCLCharacterPosition characterPosition)
        {
            this.blockerHandler    = blockerHandler;
            this.sceneHandler      = sceneHandler;
            this.characterPosition = characterPosition;

            blockersParent          = new GameObject("WorldBlockers").transform;
            blockersParent.position = Vector3.zero;

            characterPosition.OnPrecisionAdjust += OnWorldReposition;
        }
Exemplo n.º 5
0
        private void SetPositionDirty(DCLCharacterPosition character)
        {
            var currentX = (int)Math.Floor(character.worldPosition.x / ParcelSettings.PARCEL_SIZE);
            var currentY = (int)Math.Floor(character.worldPosition.z / ParcelSettings.PARCEL_SIZE);

            positionDirty = currentX != currentGridSceneCoordinate.x || currentY != currentGridSceneCoordinate.y;

            if (positionDirty)
            {
                sceneSortDirty = true;
                currentGridSceneCoordinate.x = currentX;
                currentGridSceneCoordinate.y = currentY;
            }
        }
Exemplo n.º 6
0
        void OnCharacterMoved(DCLCharacterPosition newCharacterPosition)
        {
            if (canvas != null)
            {
                currentCharacterPosition = newCharacterPosition;

                UpdateCanvasVisibility();

                if (VERBOSE)
                {
                    Debug.Log($"set screenspace = {currentCharacterPosition}");
                }
            }
        }
Exemplo n.º 7
0
        public BlockerHandler(DCLCharacterPosition characterPosition)
        {
            this.characterPosition = characterPosition;

            if (blockerPrefab == null)
            {
                blockerPrefab = Resources.Load <GameObject>(PARCEL_BLOCKER_PREFAB);
            }

            // We need to manually create the Pool for empty game objects if it doesn't exist
            if (!PoolManager.i.ContainsPool(PARCEL_BLOCKER_POOL_NAME))
            {
                GameObject go   = Object.Instantiate(blockerPrefab);
                Pool       pool = PoolManager.i.AddPool(PARCEL_BLOCKER_POOL_NAME, go);
                pool.persistent = true;
                pool.ForcePrewarm();
            }
        }
Exemplo n.º 8
0
    void Awake()
    {
        if (i != null)
        {
            Destroy(gameObject);
            return;
        }

        i = this;
        originalGravity = gravity;

        SubscribeToInput();
        CommonScriptableObjects.playerUnityPosition.Set(Vector3.zero);
        CommonScriptableObjects.playerWorldPosition.Set(Vector3.zero);
        CommonScriptableObjects.playerCoords.Set(Vector2Int.zero);
        CommonScriptableObjects.playerUnityEulerAngles.Set(Vector3.zero);

        characterPosition      = new DCLCharacterPosition();
        characterController    = GetComponent <CharacterController>();
        freeMovementController = GetComponent <FreeMovementController>();
        collider = GetComponent <Collider>();

        CommonScriptableObjects.worldOffset.OnChange          += OnWorldReposition;
        Environment.i.platform.debugController.OnDebugModeSet += () => supportsMovingPlatforms = true;

        lastPosition     = transform.position;
        transform.parent = null;

        CommonScriptableObjects.rendererState.OnChange += OnRenderingStateChanged;
        OnRenderingStateChanged(CommonScriptableObjects.rendererState.Get(), false);

        if (avatarGameObject == null || firstPersonCameraGameObject == null)
        {
            throw new System.Exception("Both the avatar and first person camera game objects must be set.");
        }

        avatarReference = new DCL.Models.DecentralandEntity {
            gameObject = avatarGameObject
        };
        firstPersonCameraReference = new DCL.Models.DecentralandEntity {
            gameObject = firstPersonCameraGameObject
        };
    }
Exemplo n.º 9
0
        private void SetPositionDirty(DCLCharacterPosition character)
        {
            var currentX = (int)Math.Floor(character.worldPosition.x / ParcelSettings.PARCEL_SIZE);
            var currentY = (int)Math.Floor(character.worldPosition.z / ParcelSettings.PARCEL_SIZE);

            positionDirty = currentX != currentGridSceneCoordinate.x || currentY != currentGridSceneCoordinate.y;

            if (positionDirty)
            {
                sceneSortDirty = true;
                currentGridSceneCoordinate.x = currentX;
                currentGridSceneCoordinate.y = currentY;

                // Since the first position for the character is not sent from Kernel until just-before calling
                // the rendering activation from Kernel, we need to sort the scenes to get the current scene id
                // to lock the rendering accordingly...
                if (!CommonScriptableObjects.rendererState.Get())
                {
                    SortScenesByDistance();
                }
            }
        }
Exemplo n.º 10
0
 void OnPrecisionAdjust(DCLCharacterPosition position)
 {
     avatarTransform.position = position.WorldToUnityPosition(currentWorldPosition);
 }
Exemplo n.º 11
0
 private void PrecisionAdjust(DCLCharacterPosition obj)
 {
     avatarUserInfo.worldPosition = entity.gameObject.transform.position;
     MinimapMetadataController.i?.UpdateMinimapUserInformation(avatarUserInfo);
 }
Exemplo n.º 12
0
        void OnWorldReposition(DCLCharacterPosition charPos)
        {
            var newPosition = charPos.WorldToUnityPosition(Vector3.zero); // Blockers parent original position

            blockersParent.position = newPosition;
        }
Exemplo n.º 13
0
        public static WorldBlockersController CreateWithDefaultDependencies(ISceneHandler sceneHandler, DCLCharacterPosition characterPosition)
        {
            var blockerAnimationHandler = new BlockerAnimationHandler();

            var blockerInstanceHandler = new BlockerInstanceHandler(
                characterPosition,
                blockerAnimationHandler
                );

            var worldBlockersController = new WorldBlockersController(
                sceneHandler,
                blockerInstanceHandler,
                characterPosition);

            return(worldBlockersController);
        }
Exemplo n.º 14
0
 void OnCharacterMoved(DCLCharacterPosition position)
 {
     ChangeOrientation();
 }
Exemplo n.º 15
0
 void OnPrecisionAdjust(DCLCharacterPosition position)
 {
     gameObject.transform.position = position.WorldToUnityPosition(Utils.GridToWorldPosition(sceneData.basePosition.x, sceneData.basePosition.y));
 }
 private void OnTeleport(DCLCharacterPosition characterPosition)
 {
     DCLCharacterController.OnPositionSet -= OnTeleport;
     isWelcomeHudVisible = false;
 }
Exemplo n.º 17
0
 private void OnTeleport(DCLCharacterPosition characterPosition)
 {
     characterTeleported = true;
     TutorialController.i.SkipToNextStep();
 }
Exemplo n.º 18
0
 private void OnCharacterMove(DCLCharacterPosition position)
 {
     characterMoved = true;
 }
Exemplo n.º 19
0
 public bool IsInsideSceneBoundaries(DCLCharacterPosition charPosition)
 {
     return(IsInsideSceneBoundaries(Utils.WorldToGridPosition(charPosition.worldPosition)));
 }
 void ExitAfterCharacterTeleport(DCLCharacterPosition position)
 {
     ExitEditMode();
 }