コード例 #1
0
ファイル: StrokeManager.cs プロジェクト: jmgregor/IMGS-624
 // Start is called before the first frame update
 void Start()
 {
     playerBallRB    = ball.GetComponent <Rigidbody>();
     audioSource     = ball.GetComponent <AudioSource>();
     StrokeMode      = StrokeModeEnum.AIMING;
     StrokeCount     = 0;
     StrokeText.text = "Strokes: " + StrokeCount.ToString();
 }
コード例 #2
0
ファイル: StrokeManager.cs プロジェクト: jmgregor/IMGS-624
    // Update is called once per frame
    void Update()
    {
        StrokeText.text = "Strokes: " + StrokeCount.ToString();
        if (StrokeMode == StrokeModeEnum.AIMING)
        {
            arrow.gameObject.SetActive(true);
            //change putt angle
            StrokeAngle += Input.GetAxis("Horizontal") * 100f * Time.deltaTime;

            //switch to powering up
            if (Input.GetButtonUp("Fire1"))
            {
                StrokeMode = StrokeModeEnum.POWERING;
                return;
            }
        }

        if (StrokeMode == StrokeModeEnum.POWERING)
        {
            //power meter fills up and back down
            StrokePower += (fillTime * fill) * Time.deltaTime;
            if (StrokePower > maxPower)
            {
                StrokePower = maxPower;
                fill        = -1;
            }
            else if (StrokePower < 0)
            {
                StrokePower = 0;
                fill        = 1;
            }
            //if hits button, shoot
            if (Input.GetButtonUp("Fire1"))
            {
                StrokeMode = StrokeModeEnum.PUTT;
            }
        }
    }