public void Update()
        {
            switch (state)
            {
                case RobotStates.GetContainer:
                    drive.AlignGetContainer = true;
                    drive.DriveSpeeds = temp_HasContainer ? new point(0.5, 0) : new point(-0.5, 0);
                    driveWait = temp_HasContainer ? --driveWait : ++driveWait;
                    stacker.claw = temp_HasContainer;
                    if (temp_HasContainer) stacker.grabbingCan.ForceTrue(); else stacker.grabbingCan.ForceFalse();

                    if (temp_HasContainer && driveWait == 0)
                    {
                        //Clean up side effects
                        drive.AlignGetContainer = false;
                        drive.DriveSpeeds = new point(0, 0);
                        state = RobotStates.Stack;
                    }

                    break;
                case RobotStates.Stack:
                    stacker.state = StackerState.AlignTote;
                    drive.AlignLoad = true;
                    break;
            }
        }
Example #2
0
        private void SetRobotState(RobotStates newRobotState)
        {
            if (newRobotState == currentRobotState)
            {
                return;
            }

            switch (currentRobotState)
            {
            case RobotStates.Idle:
                idlePauseTimer = 0f;

                break;

            case RobotStates.Patrol:
                reachedPatrolPoint = false;

                break;
            }

            Debug.Log($"Changing Robot State from <color={GetStateColor(currentRobotState)}>{currentRobotState.ToString()}</color> to <color={GetStateColor(newRobotState)}>{newRobotState.ToString()}</color>");

            currentRobotState = newRobotState;
            OnStateChange?.Invoke();
        }
        private bool temp_HasContainer; //Replace with the limit switch output

        #endregion Fields

        #region Constructors

        public AutomatedRobot()
        {
            stacker = new Stacker();
            drive = new SmartDrive();
            driveWait = 0;

            state = RobotStates.Stack; //Assuming we start with can by our corner.
        }
    public void SetRobotState(RobotStates newState)
    {
        if (currentRobotState != newState)
        {
            currentRobotState = newState;

            OnStateChange?.Invoke();
        }
    }
Example #5
0
    private void PickRandomCrazyEmotion()
    {
        StartCoroutine(Freakout());
        float flipACoin = Random.Range(0, 2);

        currentState = flipACoin == 0 ? RobotStates.STATE_HOMICIDAL : RobotStates.STATE_SUICIDAL;
        PlaySingleSoundFx(breakdownZapSound);
        displayEmotionTime = Time.time + displayEmotionDelay;
        SetTarget(null);
    }
Example #6
0
        private void SetRobotState(RobotStates newRobotState)
        {
            if (newRobotState == currentRobotState)
            {
                return;
            }

            switch (currentRobotState)
            {
            case RobotStates.Idle:
                idlePauseTimer = 0f;

                break;

            case RobotStates.Patrol:
                reachedPatrolPoint = false;

                break;
            }

            switch (newRobotState)
            {
            case RobotStates.Idle:
                SetGroupRobotState(RobotGroupStates.Relaxed, false);

                break;

            case RobotStates.Patrol:
                SetGroupRobotState(RobotGroupStates.Relaxed, false);

                break;

            case RobotStates.Chase:
                SetGroupRobotState(RobotGroupStates.Agressive, false);

                break;

            case RobotStates.Attack:
                SetGroupRobotState(RobotGroupStates.Agressive, false);

                break;
            }

            Debug.Log($"Changing Robot State from <color={GetStateColor(currentRobotState)}>{currentRobotState.ToString()}</color> to <color={GetStateColor(newRobotState)}>{newRobotState.ToString()}</color>");

            currentRobotState = newRobotState;
        }
Example #7
0
        private string GetStateColor(RobotStates state)
        {
            switch (state)
            {
            case RobotStates.Idle:
                return("green");

            case RobotStates.Patrol:
                return("yellow");

            case RobotStates.Chase:
                return("orange");

            case RobotStates.Attack:
                return("red");
            }
            return("white");
        }
Example #8
0
    // do not have more than one of this coroutine running on a robot at a time
    public IEnumerator Freakout()
    {
        if (freakoutCoroutine == null)
        {
            freakoutCoroutine = Freakout();
        }
        else
        {
            yield break;
        }

        RobotStates            oldState     = currentState;
        float                  oldStability = emotionalStability;
        var                    main         = shockParticles.main;
        ParticleSystemRenderer shockPSR     = shockParticles.GetComponent <ParticleSystemRenderer> ();

        do
        {
            UIManager.instance.ShakeObject(this.gameObject, true, freakoutShakeDuration);
            shockPSR.sortingLayerID = spriteRenderer.sortingLayerID;
            if (!shockParticles.isPlaying)
            {
                main.loop = true;
                shockParticles.Play();
            }
            if (!efxSource.isPlaying)
            {
                PlayRandomSoundFx(breakdownShakeSounds);
            }

            yield return(new WaitForSeconds(freakoutShakeDuration));
        } while (currentState == oldState && emotionalStability > oldStability);

        main.loop = false;
        foreach (AudioClip clip in breakdownShakeSounds)
        {
            if (efxSource.clip == clip)
            {
                efxSource.Stop();
                break;
            }
        }
        freakoutCoroutine = null;
    }
Example #9
0
    public void ToggleCrazyEmotion()
    {
        StartCoroutine(Freakout());
        switch (currentState)
        {
        case RobotStates.STATE_FINDBOX:
            currentState       = RobotStates.STATE_SUICIDAL;
            emotionalStability = 1.0f;
            break;

        case RobotStates.STATE_SUICIDAL:
            currentState       = RobotStates.STATE_HOMICIDAL;
            emotionalStability = 1.0f;
            break;

        case RobotStates.STATE_HOMICIDAL:
            currentState       = RobotStates.STATE_FINDBOX;
            emotionalStability = 0.0f;
            break;
        }
        PlaySingleSoundFx(breakdownZapSound);
        displayEmotionTime = Time.time + displayEmotionDelay;
        SetTarget(null);
    }
Example #10
0
    public void UpdateEmotionalState()
    {
        if (emotionalStability < 1.0f)
        {
            currentState = RobotStates.STATE_FINDBOX;

            if (!haltAndCommand)
            {
                float stabilityMod = (emotionalStability > freakoutThreshold ? 1.0f : (float)Random.Range(0, 2));
                emotionalStability += emotionalDistressRate * Time.deltaTime * stabilityMod;
            }

            if (emotionalStability > freakoutThreshold)
            {
                StartCoroutine(Freakout());
            }
        }

        if (emotionalStability >= 1.0f && currentState == RobotStates.STATE_FINDBOX)
        {
            emotionalStability = 1.0f;
            PickRandomCrazyEmotion();
        }
    }
        public void Step()
        {
            if (this.game.HasWon())
            {
                return;
            }

            switch (this.state)
            {
            case RobotStates.Ready:
                if (!this.game.MoveAnyPlaySet())
                {
                    state = RobotStates.PlaySetsChecked;
                }
                else
                {
                    this.moveMade = true;
                    this.TotalMoves++;
                }

                break;

            case RobotStates.PlaySetsChecked:
                if (this.game.MoveCurentDeckCard())
                {
                    state         = RobotStates.Ready;
                    this.moveMade = true;
                    this.TotalMoves++;
                }
                else
                {
                    state = RobotStates.DeckChecked;
                }

                break;

            case RobotStates.DeckChecked:
                if (game.HaveGoneThroughEntireDeck() && !this.moveMade)
                {
                    if (this.game.PileAnyPlaySetCards())
                    {
                        state         = RobotStates.Ready;
                        this.moveMade = true;
                        this.TotalMoves++;
                    }
                    else if (this.game.PileAnyDeckCard())
                    {
                        state         = RobotStates.Ready;
                        this.moveMade = true;
                        this.TotalMoves++;
                    }
                    else
                    {
                        state = RobotStates.PilesChecked;
                    }
                }
                else if (game.HaveGoneThroughEntireDeck() && this.moveMade)
                {
                    this.moveMade = false;
                    game.CycleDeck();
                    state = RobotStates.Ready;
                    this.TotalMoves++;
                }
                else
                {
                    game.CycleDeck();
                    state = RobotStates.Ready;
                    this.TotalMoves++;
                }

                break;

            case RobotStates.PilesChecked:
                if (!this.game.HasWon())
                {
                    this.game.NoSolution();
                }
                break;
            }
        }
 public SolitaireBot(SolitaireGame g)
 {
     this.state      = RobotStates.Ready;
     this.game       = g;
     this.TotalMoves = 0;
 }
        public void Step()
        {
            if (this.game.HasWon())
            {
                return;
            }

            switch(this.state)
            {
                case RobotStates.Ready:
                    if (!this.game.MoveAnyPlaySet())
                    {
                        state = RobotStates.PlaySetsChecked;
                    }
                    else
                    {
                        this.moveMade = true;
                        this.TotalMoves++;
                    }

                    break;
                case RobotStates.PlaySetsChecked:
                    if (this.game.MoveCurentDeckCard())
                    {
                        state = RobotStates.Ready;
                        this.moveMade = true;
                        this.TotalMoves++;
                    }
                    else
                    {
                        state = RobotStates.DeckChecked;
                    }

                    break;
                case RobotStates.DeckChecked:
                    if (game.HaveGoneThroughEntireDeck() && !this.moveMade)
                    {
                        if(this.game.PileAnyPlaySetCards())
                        {
                            state = RobotStates.Ready;
                            this.moveMade = true;
                            this.TotalMoves++;
                        }
                        else if (this.game.PileAnyDeckCard())
                        {
                            state = RobotStates.Ready;
                            this.moveMade = true;
                            this.TotalMoves++;
                        }
                        else
                        {
                            state = RobotStates.PilesChecked;
                        }
                    }
                    else if (game.HaveGoneThroughEntireDeck() && this.moveMade)
                    {
                        this.moveMade = false;
                        game.CycleDeck();
                        state = RobotStates.Ready;
                        this.TotalMoves++;
                    }
                    else
                    {
                        game.CycleDeck();
                        state = RobotStates.Ready;
                        this.TotalMoves++;
                    }

                    break;
                case RobotStates.PilesChecked:
                    if (!this.game.HasWon())
                    {
                        this.game.NoSolution();
                    }
                    break;
            }
        }
 public SolitaireBot(SolitaireGame g)
 {
     this.state = RobotStates.Ready;
     this.game = g;
     this.TotalMoves = 0;
 }
Example #15
0
 internal void changeState(RobotStates targetState)
 {
     this._RobotState = targetState;
 }