コード例 #1
0
ファイル: CameraFollow.cs プロジェクト: MaximePhilipp/Blob
    // Update is called once per frame
    private void FixedUpdate()
    {
        this.transform.position = Vector3.Lerp(
            transform.position,
            new Vector3(targetPlayer.transform.position.x, targetPlayer.transform.position.y, transform.position.z),
            CAMERA_SPEED * Time.deltaTime
            );

        float groundAngle      = GroundTiltController.GetEulerAngleZ();
        float cameraZAngle     = 0;
        float cameraTiltFactor = AppData.GetCurrentTiltType() == AppData.GroundTiltType.Touch ? 0.3f : 0.9f;

        if (groundAngle <= 180f)
        {
            cameraZAngle = groundAngle * cameraTiltFactor;
        }
        else
        {
            cameraZAngle = (-360f + groundAngle) * cameraTiltFactor;
        }

        this.transform.rotation = Quaternion.Euler(
            0f,
            0f,
            cameraZAngle
            );
    }
コード例 #2
0
    ///////////////
    // LIFECYCLE //
    ///////////////

    private void Awake()
    {
        instance = this;

        InitAccelerometer();

        registeredJellySprites = new List <JellySprite>();
        mapColliders           = GetComponents <PolygonCollider2D>().ToList();
    }
コード例 #3
0
ファイル: JumpController.cs プロジェクト: MaximePhilipp/Blob
    private void FixedUpdate()
    {
        if (jumpRegistered)
        {
            if (Time.time - lastJumpTime > DELAY_BETWEEN_JUMPS)
            {
                float groundAngle = GroundTiltController.GetEulerAngleZ();
                jumpForce.x = groundAngle <= 180f ? groundAngle * -4 : (360f - groundAngle) * 4f;
                jellySprite.AddForce(jumpForce);

                lastJumpTime = Time.time;
            }

            jumpRegistered = false;
        }
    }
コード例 #4
0
 void Start()
 {
     GroundTiltController.RegisterJellySprite(GetComponent <JellySprite>());
 }