Exemplo n.º 1
0
        void TaskThreadProcess()
        {
            while (true)
            {
                switch (state)
                {
                case TaskBallHandlingManagementState.PasDeBalle:
                    sw.Restart();
                    parent.ballHandlingState = BallHandlingState.NoBall;
                    state = TaskBallHandlingManagementState.PasDeBalleEnCours;
                    break;

                case TaskBallHandlingManagementState.PasDeBalleEnCours:
                    parent.MessageDisplay = "No Ball : " + (sw.ElapsedMilliseconds / 1000).ToString();
                    //if(parent.isHandlingBall)
                    //    state = TaskBallHandlingManagementState.PossessionBalle;
                    break;

                case TaskBallHandlingManagementState.PossessionBalle:
                    sw.Restart();
                    parent.ballHandlingState = BallHandlingState.HasBall;
                    state = TaskBallHandlingManagementState.PossessionBalleEnCours;
                    break;

                case TaskBallHandlingManagementState.PossessionBalleEnCours:
                    parent.MessageDisplay = "Ball : " + (sw.ElapsedMilliseconds / 1000).ToString();
                    if (sw.ElapsedMilliseconds > 3000)
                    {
                        /// On demande un tir ou une passe
                        parent.OnShootRequest(parent.robotId, 2);
                        state = TaskBallHandlingManagementState.Tir;
                    }
                    break;

                case TaskBallHandlingManagementState.Passe:
                    sw.Restart();
                    parent.ballHandlingState = BallHandlingState.PassInProgress;
                    state = TaskBallHandlingManagementState.PasseEnCours;
                    break;

                case TaskBallHandlingManagementState.PasseEnCours:
                    parent.MessageDisplay = "Passe";
                    if (sw.ElapsedMilliseconds > 2000)
                    {
                        state = TaskBallHandlingManagementState.PasDeBalle;
                    }
                    break;

                case TaskBallHandlingManagementState.Tir:
                    sw.Restart();
                    parent.ballHandlingState = BallHandlingState.ShootInProgress;
                    state = TaskBallHandlingManagementState.TirEnCours;
                    break;

                case TaskBallHandlingManagementState.TirEnCours:
                    parent.MessageDisplay = "Tir";
                    if (sw.ElapsedMilliseconds > 2000)
                    {
                        state = TaskBallHandlingManagementState.PasDeBalle;
                    }
                    break;

                default:
                    break;
                }

                parent.OnBallHandlingState(parent.robotId, parent.ballHandlingState);
                Thread.Sleep(20);
            }
        }
Exemplo n.º 2
0
 public void SetTaskState(TaskBallHandlingManagementState state)
 {
     this.state = state;
 }