示例#1
0
文件: Player.cs 项目: SukkoyF/Ho-K
    private void Update()
    {
        if (playing == true)
        {
            if (waitForPuckInput == true)
            {
                shotDirection = _InputSource.GetShotDirection();
                shotDirection.Normalize();
            }
            else
            {
                direction = _InputSource.GetDirection();
                direction.Normalize();
            }

            if (_InputSource.AdjustPower() < 0)
            {
                if (waitForPuckInput == true)
                {
                    shotPower--;
                }
                else
                {
                    power--;
                }
            }
            else if (_InputSource.AdjustPower() > 0)
            {
                if (waitForPuckInput == true)
                {
                    shotPower++;
                }
                else
                {
                    power++;
                }
            }

            power     = Mathf.Clamp(power, 1, 3);
            shotPower = Mathf.Clamp(shotPower, 1, 3);

            powerLine.rotation = Quaternion.LookRotation(Vector3.forward, new Vector2(-direction.y, direction.x));
            powerLine.Rotate(new Vector3(0, 0, -90));

            shotLine.rotation = Quaternion.LookRotation(Vector3.forward, new Vector2(-shotDirection.y, shotDirection.x));
            shotLine.Rotate(new Vector3(0, 0, -90));

            if (waitForPuckInput == true)
            {
                _SL.SetDisplay(shotPower);
            }

            _PL.SetDisplay(power);

            if (_InputSource.ListenForTurnEnd())
            {
                EndTurn();
            }
        }
    }