コード例 #1
0
ファイル: Product.cs プロジェクト: MichalB996/Shop-Simulation
 public Product(CellState state)
 {
     this.NameOfProduct = state;
     this.Price         = 1;
     this.Amount        = 1;
 }
コード例 #2
0
ファイル: Cell.cs プロジェクト: MichalB996/Shop-Simulation
 public Cell(Coordinates cor, CellState cstat)
 {
     TypeOfCell      = cstat;
     CellCoordinates = cor;
     Client          = null;
 }
コード例 #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);
        }
コード例 #4
0
ファイル: Cell.cs プロジェクト: MichalB996/Shop-Simulation
 public Cell(CellState cstat, Coordinates cor, Customer cust)
 {
     TypeOfCell      = cstat;
     CellCoordinates = cor;
     Client          = cust;
 }