Example #1
0
    void Awake()
    {
        intakeControl     = intake.GetComponent <IntakeControl>();
        robotSoundControl = robot.GetComponent <RobotSoundControl>();

        timer = Time.time;
    }
    private void Start()
    {
        rb = GetComponent <Rigidbody>();
        robotSoundControl = GetComponent <RobotSoundControl>();

        audioManager = GameObject.Find("ScoreKeeper").GetComponent <AudioManager>();

        previousRealTime = Time.realtimeSinceStartup;
        Console.WriteLine("Started.....");
        receiveThread = new Thread(receiveFromRC);
        receiveThread.Start();

        sendThread = new Thread(sendToRC);
        sendThread.Start();

        shooterControl = shooter.GetComponent <ShooterControl>();
        shooterControl.Commands.Add(() => motorPower6 > 0, shooterControl.shooting);
        shooterControl.Commands.Add(() => motorPower7 >= 0, () =>
        {
            robotSoundControl.playShooterRev(motorPower7);
            shooterControl.setVelocity(motorPower7);
        });

        intakeControl = intake.GetComponent <IntakeControl>();
        intakeControl.Commands.Add(() => motorPower5 != 0, () =>
        {
            robotSoundControl.playIntakeRev(motorPower5);
            intakeControl.setVelocity(motorPower5 * 150);
            intakeControl.deployIntake();
        });
        intakeControl.Commands.Add(() => motorPower5 == 0, () =>
        {
            robotSoundControl.playIntakeRev(motorPower5);
            intakeControl.retractIntake();
        });

        grabberControl = grabber.GetComponent <GrabberControl>();
        grabberControl.Commands.Add(() => motorPower8 > 0, () =>
        {
            grabberControl.startGrab();
        });
        grabberControl.Commands.Add(() => motorPower8 > 0.5, () =>
        {
            grabberControl.lift();
        });
        grabberControl.Commands.Add(() => motorPower8 == 0, () =>
        {
            grabberControl.stopGrab();
        });
    }