Esempio n. 1
0
    public void SwitchPlayer()
    {
        isFpsActive = !isFpsActive;

        GameBusyHandler.SetJob(true);

        if (isFpsActive)
        {
            homePlayer.enabled = false;
            StartCoroutine(FpsSetActiveRoutine(true, 1f));
            CameraFollow.Instance.ReplaceCamera(FpsPlayer.transform.position, FpsPlayer.transform.localEulerAngles, 57, 1f, false);

            MasterAudio.StopAllOfSound(SoundManager.Instance.Music2);
            MasterAudio.PlaySound(SoundManager.Instance.Music1);
        }
        else
        {
            homePlayer.enabled = true;
            StartCoroutine(FpsSetActiveRoutine(false));

            CameraFollow.Instance.mainCamera.transform.position = fpsPlayer.transform.position;
            CameraFollow.Instance.mainCamera.transform.rotation = fpsPlayer.transform.rotation;

            CameraFollow.Instance.ReplaceCamera(CameraFollow.Instance.TargetPosition, CameraFollow.Instance.defaultRotation, 30, 1f, true);

            MasterAudio.StopAllOfSound(SoundManager.Instance.Music1);
            MasterAudio.PlaySound(SoundManager.Instance.Music2);
        }
    }
Esempio n. 2
0
    IEnumerator FpsSetActiveRoutine(bool isActivated, float delay = 0)
    {
        yield return(new WaitForSeconds(delay));

        FpsPlayer.SetActive(isActivated);
        CameraFollow.Instance.mainCamera.enabled = !isActivated;
        LeanTween.delayedCall(1, () => { GameBusyHandler.SetJob(false); });
    }
Esempio n. 3
0
    private void Move(Side side)
    {
        if (_isMoving)
        {
            Debug.LogError("Player is already moving!");
            return;
        }

        if (!CanMove(side))
        {
            return;
        }

        var nextPiece = GetPieceBySide(side);

        var offset2D = side.ToVector();
        var farPoint = Position + (MainVariables.Instance.GridWidth / 2 * offset2D);

        var axis = (side == Side.North || side == Side.South) ? Vector3.left : Vector3.forward;
        var rotationDirectionMultiplier = (side == Side.North || side == Side.East) ? -1 : 1;

        // Rotate
        var startPos     = transform.position;
        var lastRotation = 0f;

        LeanTween.value(gameObject, 0, 90 * rotationDirectionMultiplier, MainVariables.Instance.PlayerRotationDuration)
        .setEase(MainVariables.Instance.PlayerRotationEasing)
        .setOnUpdate((float f) =>
        {
            var rotation = f - lastRotation;
            transform.RotateAround(farPoint, axis, rotation);
            lastRotation = f;
        })
        .setOnStart(() =>
        {
            GameBusyHandler.SetJob(true);
            _isMoving = true;
        })
        .setOnComplete(() =>
        {
            transform.position = startPos + (side.ToVector() * MainVariables.Instance.GridWidth);

            GameBusyHandler.SetJob(false);

            if (nextPiece.IsTrigger && RoofSide == nextPiece.TriggerSide)
            {
                nextPiece.Trigger();
                OnDidTriggerPiece(nextPiece);
                MasterAudio.PlaySoundAndForget(SoundManager.Instance.LevelEnd);
            }

            _isMoving = false;

            MasterAudio.PlaySoundAndForget(SoundManager.Instance.Move);
        });
    }