VacuumCleaner.Env.Environment.AcceptAction C# (CSharp) Method

AcceptAction() public method

public AcceptAction ( ActionType action ) : void
action ActionType
return void
        public void AcceptAction(ActionType action)
        {
            bump_ = false;
            cleanedDirty_ = 0;
            switch (action)
            {
                case ActionType.actSUCK:
                    if (maze_[agentPosX_][agentPosY_] > 0)
                    {
                        cleanedDirty_ = (maze_[agentPosX_][agentPosY_] > CLEAN_PER_TIME ? CLEAN_PER_TIME : maze_[agentPosX_][agentPosY_]);
                        maze_[agentPosX_][agentPosY_] -= (int)cleanedDirty_;
                    }
                    break;
                case ActionType.actUP:
                    if (maze_[agentPosX_ - 1][agentPosY_] != OBSTACLE) agentPosX_ -= 1;
                    else bump_ = true;
                    break;
                case ActionType.actDOWN:
                    if (maze_[agentPosX_ + 1][agentPosY_] != OBSTACLE) agentPosX_ += 1;
                    else bump_ = true;
                    break;
                case ActionType.actLEFT:
                    if (maze_[agentPosX_][agentPosY_ - 1] != OBSTACLE) agentPosY_ -= 1;
                    else bump_ = true;
                    break;
                case ActionType.actRIGHT:
                    if (maze_[agentPosX_][agentPosY_ + 1] != OBSTACLE) agentPosY_ += 1;
                    else bump_ = true;
                    break;
            }
            preAction_ = action;
        }