Ejemplo n.º 1
0
 public Product(CellState state)
 {
     this.NameOfProduct = state;
     this.Price         = 1;
     this.Amount        = 1;
 }
Ejemplo n.º 2
0
 public Cell(Coordinates cor, CellState cstat)
 {
     TypeOfCell      = cstat;
     CellCoordinates = cor;
     Client          = null;
 }
Ejemplo n.º 3
0
        public List <Coordinates> GeneratePath(Coordinates currentPosition)
        {
            List <Coordinates> tempPath        = new List <Coordinates>();
            Coordinates        tempCoordinates = new Coordinates(currentPosition.x, currentPosition.y);

            tempPath.Add(currentPosition);

            if (ListOfProducts.Count == 0)
            {
                while (!IsTheProductInAlley(tempCoordinates) && !(ShopMap[tempCoordinates].StateOfCell == CellState.TypeOfCell.EXIT))
                {
                    tempCoordinates = new Coordinates(tempCoordinates.x, tempCoordinates.y + 1);
                    tempPath.Add(tempCoordinates);
                }
            }
            else
            {
                while (!IsTheProductInAlley(tempCoordinates))
                {
                    tempCoordinates = new Coordinates(tempCoordinates.x, tempCoordinates.y + 1);
                    tempPath.Add(tempCoordinates);
                }
                if (IsTheProductInTopAlley(tempCoordinates))
                {
                    tempCoordinates = new Coordinates(tempCoordinates.x - 1, tempCoordinates.y);
                    while (IsTheProductInTopAlley(tempCoordinates))
                    {
                        if (ShopMap[new Coordinates(tempCoordinates.x - 1, tempCoordinates.y)].StateOfCell == CellState.TypeOfCell.WALL)
                        {
                            tempCoordinates = new Coordinates(tempCoordinates.x, tempCoordinates.y + 1);
                            tempPath.Add(tempCoordinates);
                            while (!IsTheProductInTopAlley(tempCoordinates))
                            {
                                tempCoordinates = new Coordinates(tempCoordinates.x, tempCoordinates.y + 1);
                                tempPath.Add(tempCoordinates);
                            }
                        }
                        while (IsTheProductInTopAlley(tempCoordinates))
                        {
                            tempPath.Add(tempCoordinates);
                            RemoveProductFromListIfPossible(tempCoordinates);
                            tempCoordinates = new Coordinates(tempCoordinates.x - 1, tempCoordinates.y);
                        }
                    }
                }
                else if (IsTheProductInDownAlley(tempCoordinates))
                {
                    tempCoordinates = new Coordinates(tempCoordinates.x + 1, tempCoordinates.y);
                    while (IsTheProductInDownAlley(tempCoordinates))
                    {
                        if (ShopMap[new Coordinates(tempCoordinates.x + 1, tempCoordinates.y)].StateOfCell == CellState.TypeOfCell.WALL)
                        {
                            tempCoordinates = new Coordinates(tempCoordinates.x, tempCoordinates.y + 1);
                            tempPath.Add(tempCoordinates);
                            while (!IsTheProductInDownAlley(tempCoordinates))
                            {
                                tempCoordinates = new Coordinates(tempCoordinates.x, tempCoordinates.y + 1);
                                tempPath.Add(tempCoordinates);
                            }
                        }
                        while (IsTheProductInDownAlley(tempCoordinates))
                        {
                            tempPath.Add(tempCoordinates);
                            RemoveProductFromListIfPossible(tempCoordinates);
                            tempCoordinates = new Coordinates(tempCoordinates.x + 1, tempCoordinates.y);
                        }
                    }
                }
                Coordinates leftCoordinates  = new Coordinates(tempPath[tempPath.Count - 1].x, tempPath[tempPath.Count - 1].y - 1);
                Coordinates rightCoordinates = new Coordinates(tempPath[tempPath.Count - 1].x, tempPath[tempPath.Count - 1].y + 1);

                if (!CellState.IsProduct(ShopMap[leftCoordinates].StateOfCell))
                {
                    tempPath.Add(leftCoordinates);
                    tempCoordinates = new Coordinates(leftCoordinates.x, leftCoordinates.y);
                }
                else if (!CellState.IsProduct(ShopMap[rightCoordinates].StateOfCell))
                {
                    tempPath.Add(rightCoordinates);
                    tempCoordinates = new Coordinates(rightCoordinates.x, rightCoordinates.y);
                }
                if (IsCustomerIsOnTop(tempCoordinates))
                {
                    while (!InTheMainAlleyTop(tempCoordinates))
                    {
                        tempCoordinates = new Coordinates(tempCoordinates.x + 1, tempCoordinates.y);
                        tempPath.Add(tempCoordinates);
                    }
                }
                else
                {
                    while (!InTheMainAlleyDown(tempCoordinates))
                    {
                        tempCoordinates = new Coordinates(tempCoordinates.x - 1, tempCoordinates.y);
                        tempPath.Add(tempCoordinates);
                    }
                }
            }
            ActualCoordinates = new Coordinates(tempPath[tempPath.Count - 1].x, tempPath[tempPath.Count - 1].y);
            return(tempPath);
        }
Ejemplo n.º 4
0
 public Cell(CellState cstat, Coordinates cor, Customer cust)
 {
     TypeOfCell      = cstat;
     CellCoordinates = cor;
     Client          = cust;
 }