// don't use fixed updates here because this is more about control than physics.
    public void Update()
    {
        cueController.allIsSleeping = cueController.CheckAllBallSleepingStatusAnyTime(); // cueController.CheckSleepingStatusAnyTime();

        if (current_control_status == CUE_BALL_MOVABLE_ON_TABLE)
        {
            cueController.BallMovableOnTable();
        }
        else if (current_control_status == CUE_BALL_IN_HAND)
        {
            cueController.BallInHand();
        }
        else if (current_control_status == CUE_BALL_FIXED_ON_TABLE)
        {
            cueController.BallFixedOnTable();
        }

        if (cueController.allIsSleeping)
        {
            // this controls tiny movements in the cue relative to the cue ball. I will find another place for it later
            cueController.OnControlCue();

            // this controls all the bot bullshits
            cueController.RobotUpdate();
        }
    }
Esempio n. 2
0
	IEnumerator StretchCue (CueController cueController)
	{
		float stretchTime = 1.3f;
		float time = stretchTime;
		cueController.cueDisplacement = 0.0f;
		Vector3  ballPivotLocalPosition = Random.Range(0, 2) == 0? Vector3.down:Vector3.up;
		while(time > 0.0f)
		{
			if(targetBallController)
			{
				CheckCueBallHit(cueController, ballPivotLocalPosition);
			}
			time -= stretchTime*Time.fixedDeltaTime;
			cueController.cueDisplacement = Mathf.Clamp01 ((stretchTime - time)/stretchTime)*cueController.cueMaxDisplacement;
			cueController.cueDisplacement *= Mathf.Clamp01( (allDistance/40.0f)*(1.0f/Mathf.Clamp(realHitAngle, 0.3f, 1.0f)));
			cueController.OnControlCue ();
			cueController.cueForceValue = 1.0f;
            yield return new WaitForFixedUpdate ();
        }
    }