예제 #1
0
    public ShotControllerState GetControllerState()
    {
        ShotControllerState ret = new ShotControllerState();

        ret.shotA = Input.GetMouseButtonDown(0);
        ret.shotB = Input.GetMouseButtonDown(1);
        ret.toss  = Input.GetKeyDown("space");
        return(ret);
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        Vector2 cStateMove = moveController.GetDirection();

        rb.AddForce(new Vector3(cStateMove.x, 0, cStateMove.y) * runSpeed - rb.velocity, ForceMode.VelocityChange);
        if (cStateMovePrev == Vector2.zero && cStateMove != Vector2.zero)
        {
            runSound.Play();
        }
        else if (cStateMovePrev != Vector2.zero && cStateMove == Vector2.zero)
        {
            runSound.Stop();
        }
        cStateMovePrev = cStateMove;

        AimControllerState cStateAim = aimController.GetAim();

        aimMark.transform.position = cStateAim.aim;

        ShotControllerState cStateShot = shotController.GetControllerState();

        aimVia = cStateAim.aimVia;
        if (shottable)
        {
            if (cStateShot.shotA)
            {
                ballController.projectile(cStateAim.aim, cStateAim.aimVia, spinA);
                shotSound.Play();
            }
            else if (cStateShot.shotB)
            {
                ballController.projectile(cStateAim.aim, cStateAim.aimVia, spinB);
                shotSound.Play();
            }
        }
        else if (cStateShot.toss)
        {
            if (ballController.bounds >= 2)
            {
                toss(3);
            }
        }
    }
예제 #3
0
    public ShotControllerState GetControllerState()
    {
        ShotControllerState cState = new ShotControllerState();

        if (Mathf.Sign(ballRigidbody.transform.position.z) == Mathf.Sign(gameObject.transform.position.z) &&
            Mathf.Sign(ballRigidbody.velocity.z) == Mathf.Sign(gameObject.transform.position.z))
        {
            result = !result;
            if (Random.Range(0.0f, 1.0f) < 0.5f)
            {
                cState.shotA = result;
            }
            else
            {
                cState.shotB = result;
            }
        }
        prev = cState;
        return(cState);
    }
예제 #4
0
 void Awake()
 {
     ballRigidbody = ball.GetComponent <Rigidbody>();
     prev          = new ShotControllerState();
 }