Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     trackObject    = GameObject.Find("track");
     throwBall      = GameObject.Find("ThrowBall");
     ballController = throwBall.GetComponent("ThrowBallController") as ThrowBallController;
     gui            = GameObject.Find("console").GetComponent("ConsoleController") as ConsoleController;
     ram            = GameObject.Find("ram").GetComponent("RamTrigger") as RamTrigger;
     ballController.setState(ThrowBallController.ON_CART);
 }
Ejemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     trackObject = GameObject.Find("track");
     throwBall = GameObject.Find("ThrowBall");
     ballController = throwBall.GetComponent("ThrowBallController") as ThrowBallController;
     gui = GameObject.Find("console").GetComponent("ConsoleController") as ConsoleController;
     ram = GameObject.Find("ram").GetComponent("RamTrigger") as RamTrigger;
     ballController.setState(ThrowBallController.ON_CART);
 }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        // Don't do anything if not 'active'
        if (!activated)
        {
            return;
        }

        float delta = forward ? forwardVelocity : -backVelocity;

        delta = delta * 0.05f;

        transform.Translate(0, 0, delta);
        if (transform.position.x <= stopForwardThreshold && forward)
        {
            if (gameObject.audio != null)
            {
                gameObject.audio.Play();
            }
            if (trackObject != null && trackObject.audio != null)
            {
                trackObject.audio.Stop();
            }
            ballController.setState(ThrowBallController.RELEASED);
            forward = false;
        }
        else if (transform.position.x >= stopReverseThreshold && !forward)
        {
            forward = true;
            reset();
            if (gameObject.audio != null)
            {
                gameObject.audio.Stop();
            }
        }
    }