Exemple #1
0
        public ActionResult CreateStall(string Name, string Description, HttpPostedFileBase ImageData)
        {
            if (!IsAuthorized())
            {
                return(View("Error"));
            }
            Stall obj = new Stall();

            obj.Fields.Name        = Name;
            obj.Fields.Description = Description;
            obj.Fields.UserID      = UserID;
            var type = ImageData.ContentType;

            obj.Fields.ContentType = type;
            MemoryStream target = new MemoryStream();

            ImageData.InputStream.CopyTo(target);
            obj.Fields.Logo = target.ToArray();

            if (obj.Fields.Logo.Length > 1000000 || (type != "image/x-png" && type != "image/gif" && type != "image/jpeg"))
            {
                return(RedirectToAction("CreateStall"));
            }
            obj.Save();
            return(RedirectToAction("Index"));
        }
        public void OnPointerClick(PointerEventData eventData)
        {
            // The current selected stall.
            Stall selectedStall = UIManager.instance.SelectedStallSpace.GetComponent <Stall>();

            // Allow to restock if the player has enough money and if the stall's stock is already not at max.
            if (ProgressManager.Money - selectedStall.StallRestockCost >= 0)
            {
                if (selectedStall.StockCount + StockIncreaseAmount <= selectedStall.MaxStockCount)
                {
                    // Update the profit tracker.
                    ProfitTracker.instance.StallProfit[selectedStall.StallSpaceNumber] -= selectedStall.StallRestockCost;

                    // Decrease the player's money by the cost of restocking.
                    ProgressManager.Money -= selectedStall.StallRestockCost;
                    // Increase the stall's stock.
                    selectedStall.StockCount += StockIncreaseAmount;

                    PlaySound();
                }
                else
                {
                    WarningText.GetComponent <Text>().text = "Stall Full";
                    Instantiate(WarningText, gameObject.transform.parent.parent);
                }
            }
            else
            {
                WarningText.GetComponent <Text>().text = "Not Enough Money";
                Instantiate(WarningText, gameObject.transform.parent.parent);
            }

            OnRestockClicked();
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            int cases = int.Parse(Console.ReadLine());

            for (int i = 0; i < cases; i++)
            {
                var input     = Console.ReadLine().Split(' ');
                int numStalls = int.Parse(input[0]) + 2;
                int people    = int.Parse(input[1]);

                var stalls = new Stall[numStalls];
                for (int j = 0; j < numStalls; j++)
                {
                    stalls[j] = new Stall(j);
                }

                for (int j = 0; j < numStalls; j++)
                {
                    if (j > 0)
                    {
                        stalls[j].Neighbors.Add(stalls[j - 1]);
                    }
                    if (j < numStalls - 1)
                    {
                        stalls[j].Neighbors.Add(stalls[j + 1]);
                    }
                }
                stalls[0].Occupied             = true;
                stalls[numStalls - 1].Occupied = true;

                var result = OccupyStalls(stalls, people);
                Console.WriteLine(string.Format("Case #{0}: {1} {2}", i + 1, Math.Max(result[0], result[1]), Math.Min(result[0], result[1])));
            }
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,StallNo,StallName,CatId,StallVolume,Level")] Stall stall)
        {
            if (id != stall.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stall);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StallExists(stall.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CatId"] = new SelectList(_context.Categories, "Id", "Id", stall.CatId);
            return(View(stall));
        }
Exemple #5
0
        public Task DeleteAsync(Stall stall)
        {
            var dbContext = _unitOfWork.DbContext();

            dbContext.Stalls.Remove(stall);
            return(dbContext.SaveChangesAsync());
        }
        private void updateGBXStall(int stallId)
        {
            Stall stall = dbContext.Stalls.Find(stallId);

            lblStallTypeValue.Text    = stall.StallType;
            lblCapacityValue.Text     = stall.StallCapacity.ToString();
            lblLocationCodeValue.Text = stall.StallLocationCode;
            lblFilledValue.Text       = dbContext.AttendeeStalls.Where(a => a.StallId == stallId).Count().ToString();
        }
Exemple #7
0
        static void Main(string[] args)
        {
            int       N   = 500000;
            Random    rn  = new Random();
            Stopwatch sw1 = new Stopwatch();
            Stopwatch sw2 = new Stopwatch();
            Stopwatch sw3 = new Stopwatch();
            Stopwatch sw4 = new Stopwatch();

            Trading_Establishment[]      Arr1 = new Trading_Establishment[N];        // массив
            List <Trading_Establishment> Arr2 = new List <Trading_Establishment>(N); // типизированная коллекция
            ArrayList      Arr3 = new ArrayList(N);                                  // не типизированная колллекция
            UserCollection Arr4 = new UserCollection(N);                             // пользовательская коллекция

            for (int a = 0; a < N; a++)
            {
                int house = rn.Next(1, 3);
                switch (house)
                {
                case 1:
                    Arr1[a] = new Supermarket();
                    Arr2.Add(new Supermarket());
                    Arr3.Add(new Supermarket());
                    Arr4.Add(new Supermarket());
                    break;

                case 2:
                    Arr1[a] = new Stall();
                    Arr2.Add(new Stall());
                    Arr3.Add(new Stall());
                    Arr4.Add(new Stall());
                    break;
                }
            }
            sw1.Start();
            Array.Sort(Arr1);
            sw1.Stop();

            sw2.Start();
            Arr2.Sort();
            sw2.Stop();

            sw3.Start();
            Arr3.Sort();
            sw3.Stop();

            sw4.Start();
            Arr4.Sorts();
            sw4.Stop();

            Console.WriteLine($"Время на сортировку обычного массива -> {sw1.Elapsed}");
            Console.WriteLine($"Время на сортировку типизированной коллекции -> {sw2.Elapsed}");
            Console.WriteLine($"Время на сортировку не типизированной коллекции -> {sw3.Elapsed}");
            Console.WriteLine($"Время на сортировку пользовательской коллекции -> {sw4.Elapsed}");
            Console.ReadKey();
        }
        public Salesman(string name, Gender gender, Stall stall)
            : base(name, gender)
        {
            if (stall == null)
            {
                throw new ArgumentNullException("stall");
            }

            _stall = stall;
        }
        public Stall StallStatusGet(int id, bool occupied)
        {
            Stall status = new Stall();

            status.id       = id;
            status.occupied = occupied;
            Stall.UpdateStatus(status);                            //store update
            BathroomInfoController.bathrooms = Bathroom.LoadAll(); //reload bathroom data
            return(status);
        }
Exemple #10
0
        public async Task <IActionResult> CreateAsync([FromBody] Stall stall)
        {
            if (stall == null)
            {
                return(BadRequest());
            }

            await _stallManager.SaveAsync(stall);

            return(CreatedAtRoute("FindStallById", new { id = stall.Id }, stall));
        }
Exemple #11
0
        public override bool CanUseStall(Stall stall)
        {
            bool canUse = stall.OccupiedNeighborCount == 0;

            if (!canUse) {
                this.SpeechText = "";
                this.SpeechText = "No way! Germs!";
            }

            return canUse;
        }
Exemple #12
0
        public ActionResult CreateStall(string Name, string Description, HttpPostedFileBase Logo)
        {
            Stall obj = new Stall();

            obj.Fields.Name        = Name;
            obj.Fields.Description = Description;
            obj.Fields.UserID      = UserID;
            //using (var binaryReader = new BinaryReader(Logo.InputStream))
            //	obj.Fields.Logo = binaryReader.ReadBytes(Logo.ContentLength);
            obj.Save();
            return(RedirectToAction("Index"));
        }
Exemple #13
0
    static void Main()
    {
        int   amount = 5;
        Stall stall  = new Stall();

        for (int i = 0; i < amount; i++)
        {
            Cow name = new Cow(i, 32.02);
            stall.addToList(name);
        }
        Console.WriteLine(stall.place[0].euter.giveMilk(10));
    }
        private IList <Stall> CreateStaller(int number)
        {
            var staller = new List <Stall>();

            for (var ii = 1; ii < number + 1; ii++)
            {
                var stall = new Stall();
                CreateHester(10).Each(stall.AddHest);
                staller.Add(stall);
            }
            return(staller);
        }
Exemple #15
0
        public async Task <IActionResult> Create([Bind("Id,StallNo,StallName,CatId,StallVolume,Level")] Stall stall)
        {
            if (ModelState.IsValid)
            {
                _context.Add(stall);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CatId"] = new SelectList(_context.Categories, "Id", "Id", stall.CatId);
            return(View(stall));
        }
Exemple #16
0
        public void InsertOrUpdateStall(Stall stall)
        {
            var t0 = DateTime.Now;
            var s  = _cgContext.Stalls.Find(stall.X, stall.Y);

            if (s != null)
            {
                _cgContext.Stalls.Remove(s);
            }
            _cgContext.Stalls.Add(stall);
            _cgContext.SaveChanges();
            Console.WriteLine((DateTime.Now.Ticks - t0.Ticks) / 10000);
        }
        public IActionResult Update(IFormCollection data)
        {
            Stall s = new Stall
            {
                StallName   = data["txtname"],
                StallVolume = int.Parse(data["txtvolum"]),
                Level       = (Level)Enum.Parse(typeof(Level), data["txtLevel"]),
                Id          = int.Parse(data["txtId"]),
                CatId       = int.Parse(data["txtcat"])
            };

            db.Entry(s).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("GetAll"));
        }
        /// <summary>
        /// Calculates if a customer is attracted to a stall.
        /// </summary>
        /// <param name="stall"></param>
        /// <returns></returns>
        private bool IsAttractedToStall(Stall stall)
        {
            foreach (StallSpaceType hatedType in HatedStallTypes)
            {
                if (stall.SpaceType == hatedType)
                {
                    return(false);
                }
            }

            // Get random number of attraction.
            int attraction = Random.Range(0, 100);

            // Stall attracts customer if the attraction acquired is less than the attaction percentage of the stall.
            return(attraction <= stall.AttractionPercentage);
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //using (dbContext = new ConventionManagerDbContext())
            //{
            MethodController methodController = new MethodController();

            if (methodController.stallCapacityStatus((int)cbxStall.SelectedValue))
            {
                AttendeeStall attendeeStall = new AttendeeStall()
                {
                    AttendeeId  = (int)cbxAttendee.SelectedValue,
                    StallId     = (int)cbxStall.SelectedValue,
                    IsExhibitor = chkIsExhibitor.Checked
                };

                Stall stall = dbContext.Stalls.Find(attendeeStall.StallId);
                if (methodController.attendeeStatus(attendeeStall.AttendeeId, stall.StallStartDate, stall.StallEndDate))
                {
                    dbContext.AttendeeStalls.Add(attendeeStall);
                    try
                    {
                        dbContext.SaveChanges();

                        MessageBox.Show("Attendee added to the stall successfully!!!");
                        updateGBXStall((int)cbxStall.SelectedValue);
                        loadDGV();
                        return;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Duplicate entry!!!");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Attendee busy on other event or seminar or stall");
                }
            }
            else
            {
                MessageBox.Show("Stall full!!!");
                return;
            }
            //}
        }
Exemple #20
0
        public async Task <IActionResult> UpdateAsync(string id, [FromBody] Stall updatedStall)
        {
            if (updatedStall == null || updatedStall.Id != id)
            {
                return(BadRequest());
            }

            var stall = await _stallManager.FindByIdAsync(id);

            if (stall == null)
            {
                return(NotFound());
            }

            await _stallManager.SaveAsync(updatedStall);

            return(NoContent());
        }
Exemple #21
0
        private void dgvStall_Click(object sender, EventArgs e)
        {
            stallCode = int.Parse(dgvStall.CurrentRow.Cells["StallId"].Value.ToString());
            int columnIndex = dgvStall.CurrentCell.ColumnIndex;

            if (dgvStall.CurrentRow.Cells[columnIndex].Value.ToString().Equals("Edit"))
            {
                btnAdd.Text          = "UPDATE";
                stall                = dbContext.Stalls.Find(stallCode);
                txtName.Text         = stall.StallName;
                txtLocationCode.Text = stall.StallLocationCode;
                txtCapacity.Text     = stall.StallCapacity.ToString();
                txtResources.Text    = stall.StallResources;
                txtStallType.Text    = stall.StallType;
                dtpStartDate.Value   = stall.StallStartDate;
                dtpEndDate.Value     = stall.StallEndDate;
            }
            else if (dgvStall.CurrentRow.Cells[columnIndex].Value.ToString().Equals("Delete"))
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure ?", "Confirm Delete", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    // on delete cascade only on AttendeeId in AttendeeStall
                    // first remove data held by foreign key in AttendeeStall
                    var stalls = dbContext.AttendeeStalls.Where(a => a.StallId == stallCode).ToList();
                    foreach (var del in stalls)
                    {
                        dbContext.AttendeeStalls.Remove(del);
                    }
                    dbContext.SaveChanges();

                    // then remove stall
                    dbContext.Stalls.Remove(dbContext.Stalls.Find(stallCode));
                    dbContext.SaveChanges();
                    reloadDGV();

                    MessageBox.Show("Stall deleted!!!");
                }
                btnAdd.Text = "ADD";
            }
        }
Exemple #22
0
        public bool SaveNewStall(StallModel stall)
        {
            if (stall != null) // maybe  take out
            {
                using (var context = new ShukRoutingContext())
                {
                    var Stall = new Stall()
                    {
                        StallID     = stall.StallID,
                        StallName   = stall.StallName,
                        FirstCoord  = stall.FirstCoord,
                        SecondCoord = stall.SecondCoord
                    };

                    context.Stalls.Add(Stall);
                    context.SaveChanges();
                }
                return(true);
            }
            return(false);
        }
Exemple #23
0
        private static string BruteForce(int n, int k)
        {
            IList <Stall> stalls = new List <Stall>();

            foreach (var x in Enumerable.Range(0, n + 2))
            {
                stalls.Add(new Stall(stalls, x, x == 0 || x == n + 1));
            }

            Stall lastEnteredStall = null;

            for (var i = 0; i < k; i++)
            {
                var orderedStalls = stalls.Where(stall => stall.IsAvailable())
                                    .OrderByDescending(stall => Math.Min(stall.L, stall.R))
                                    .ThenByDescending(stall => Math.Max(stall.L, stall.R))
                                    .ThenBy(stall => stall.Index);

                lastEnteredStall          = orderedStalls.First();
                lastEnteredStall.Occupied = true;
            }

            return($"{Math.Max(lastEnteredStall.L, lastEnteredStall.R)} {Math.Min(lastEnteredStall.L, lastEnteredStall.R)}");
        }
 public override void Visit(Stall node)
 {
     throw new InterpretException("TODO");
 }
Exemple #25
0
 public Task SaveAsync(Stall stall)
 {
     return(_stallStore.SaveAsync(stall));
 }
 /// <summary>
 /// The kwekkwek bowl increases the maximum stock count.
 /// </summary>
 /// <param name="stallToAffect">The stall to be affected by the music box.</param>
 public override void TakeEffect(Stall stallToAffect)
 {
     stallToAffect.MaxStockCount += MaximumStockIncrease;
 }
Exemple #27
0
        public void GoToStall(Stall stall)
        {
            this.State = PersonState.HeadedToStall;

            stall.PersonEntering(this);
            this.stall = stall;

            Point stallPosition = stall.TransformToVisual((FrameworkElement)this.Parent).Transform(new Point(0, 0));
            stallPosition.X += stall.ActualWidth / 2 - this.ActualWidth / 2;
            stallPosition.Y += 30;

            Storyboard sb = this.AnimateTo(stallPosition);

            this.Level.RemoveFromLine(this);

            sb.Completed += this.HandleGoToStallAnimationCompleted;

            VisualStateManager.GoToState(this, "Backwards", true);

            this.OnHeadingToStall();
        }
 public override void Awake()
 {
     base.Awake();
     knockback = GetComponent <Knockback>();
     stall     = GetComponent <Stall>();
 }
 /// <summary>
 /// The upgrade adds attraction percentage.
 /// </summary>
 /// <param name="stallToAffect">The stall to be affected by the upgrade.</param>
 public override void TakeEffect(Stall stallToAffect)
 {
     stallToAffect.AttractionPercentage += AttractionPercentageIncrease;
 }
Exemple #30
0
        public override bool CanUseStall(Stall stall)
        {
            bool canUse = stall.OccupiedNeighborCount == 0;

            if (!canUse)
                this.cantUseStallMessages.DoSomething();

            return canUse;
        }
Exemple #31
0
        private void HandleBladderFillAnimationCompleted(object sender, EventArgs e)
        {
            VisualStateManager.GoToState(this, "PeedPants", true);

            this.Level.AccidentHappened();

            if (this.stall != null) {
                this.stall.PersonLeft();
                this.stall = null;
            }
            else {
                if (this.Level != null)
                    this.Level.RemoveFromLine(this);
            }

            if (this.IsSelected)
                this.Level.Deselect(this);

            Storyboard exitingAnimation = this.AnimateTo(this.exitPoint);
            exitingAnimation.Completed += this.HandleExitCompleted;

            VisualStateManager.GoToState(this, "Forwards", true);
        }
Exemple #32
0
 /// <summary>
 /// The upgrade increases patience.
 /// </summary>
 /// <param name="stallToAffect">The stall to be affected by the upgrade.</param>
 public override void TakeEffect(Stall stallToAffect)
 {
     stallToAffect.PatienceIncrease += PatiencePercentageIncrease;
 }
Exemple #33
0
 public virtual bool CanUseStall(Stall stall)
 {
     return true;
 }
Exemple #34
0
 public Task DeleteAsync(Stall stall)
 {
     return(_stallStore.DeleteAsync(stall));
 }
Exemple #35
0
        protected virtual void OnPeedPants()
        {
            VisualStateManager.GoToState(this, "PeedPants", true);

            this.Level.AccidentHappened();

            if (this.stall != null) {
                this.stall.PersonLeft();
                this.stall = null;
            }
            else {
                if (this.Level != null)
                    this.Level.RemoveFromLine(this);
            }

            if (this.IsSelected)
                this.Level.Deselect(this);

            Storyboard exitingAnimation = this.AnimateTo(this.exitPoint);
            exitingAnimation.Completed += this.HandleExitCompleted;

            VisualStateManager.GoToState(this, "Forwards", true);

            this.peedMessages.DoSomething();
        }
        /// <summary>
        /// Called once every Delta time.
        /// </summary>
        void FixedUpdate()
        {
            // Keep the customer going until it reaches the endpoint.
            if ((IsGoingRight && gameObject.transform.position.x < EndPoint) ||
                (!IsGoingRight && gameObject.transform.position.x > EndPoint))
            {
                // Perform the necessary action depending on the customer state.
                switch (CustomerStatus)
                {
                case CustomerState.Walking:
                    #region Walking Procedure
                    // Customer has a random chance to perform a special move.
                    if (Random.Range(0, CustomerSpecialChance) < 1)
                    {
                        animator.SetTrigger("IsSpecial");

                        break;
                    }

                    // Only allow the customer to walk when it is doing a special move.
                    if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Special"))
                    {
                        // Keep the customer walking straight (depending on the direction), until attracted to a stall.
                        Walk(IsGoingRight ? Speed : Speed * -1, 0);
                    }


                    // Raycast which contains the stall that is detected by the customer.
                    RaycastHit2D hit;
                    // If a stall exists above, determine if the customer will be attracted to the stall.
                    if (IsStallAbove(out hit))
                    {
                        // Get the stall detected above.
                        currentStall = hit.transform.GetComponent <Stall>();

                        // If it has already been seen, do not attempt to attract.
                        // Try to attract otherwise.
                        if (!seenStalls.Contains(currentStall))
                        {
                            // Add the stall to the list of stalls already seen by the customer.
                            seenStalls.Add(currentStall);

                            if ((IsAttractedToStall(currentStall) || IsAttractedToEverything) && currentStall.gameObject.GetComponent <StallSpace.Stall>().StockCount > 0)
                            {
                                // Only try to attract the customer when the stall line is not yet full.
                                if (currentStall.CustomersInLine + 1 <= currentStall.MaxCustomersInLine)
                                {
                                    currentStall.AddACustomerToLine();
                                    // If attracted, set the customer to walk to the stall.
                                    currentCustomerPatience += currentStall.PatienceIncrease;

                                    customerStatus = CustomerState.WalkingToStall;
                                    animator.SetTrigger("IsWalkingUp");

                                    // Bring customer to the front of all other objects.
                                    transform.GetComponent <SpriteRenderer>().sortingOrder += 1;
                                    // Set the customer who is walking behind to be in the upmost layer.
                                    SetCustomerBehindToUpperLayer();
                                    // Save the position where the customer will return to after buying.
                                    positionToReturn = transform.position;
                                }
                            }
                        }
                    }

                    break;
                    #endregion

                case CustomerState.WalkingToStall:
                    #region Walk to Stall Procedure
                    // Set the customer who is walking behind to be in the upmost layer.
                    SetCustomerBehindToUpperLayer();

                    if (currentStall.GetComponent <StallSpace.Stall>().StockCount <= 0)
                    {
                        customerStatus = CustomerState.WalkingAwayFromStall;
                        animator.SetTrigger("IsWalkingDown");

                        break;
                    }

                    // Keep walking to the stall if there are no customers in line.
                    if (!IsOtherCustomerInFrontBuying())
                    {
                        Walk(0, Speed);

                        // Check if the customer has reached the stall, then the customer can start buying.
                        if (HasReachedStall())
                        {
                            // Reset customer's patience.
                            currentCustomerPatience = CustomerPatience;

                            // When stall is reached, set the customer to buy from the stall.
                            customerStatus = CustomerState.BuyingFromStall;
                            animator.SetTrigger("IsIdle");

                            // Play buying sound.
                            PlaySound(BuyingSound);

                            // Generate different bubble depending on stall type.
                            switch (currentStall.SpaceType)
                            {
                            case StallSpaceType.EmptyStall:
                                break;

                            case StallSpaceType.KwekKwekStall:
                                GenerateBubble(CustomerBubbleType.Kwekkwek);
                                break;

                            case StallSpaceType.IsawStall:
                                GenerateBubble(CustomerBubbleType.Isaw);
                                break;

                            case StallSpaceType.IcecreamStall:
                                GenerateBubble(CustomerBubbleType.Icecream);
                                break;

                            case StallSpaceType.FruitShakeStall:
                                GenerateBubble(CustomerBubbleType.FruitShake);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    else
                    {
                        //Wait in line if there are other customers
                        customerStatus = CustomerState.WaitingInLine;
                        animator.SetTrigger("IsIdle");
                        break;
                    }

                    break;
                    #endregion

                case CustomerState.WaitingInLine:
                    #region Waiting in Line Procedure
                    if (currentStall.GetComponent <StallSpace.Stall>().StockCount <= 0)
                    {
                        customerStatus = CustomerState.WalkingAwayFromStall;
                        animator.SetTrigger("IsWalkingDown");

                        break;
                    }

                    // If there are no more customers in front, walk to the stall.
                    if (!IsOtherCustomerInFrontBuying())
                    {
                        customerStatus = CustomerState.WalkingToStall;
                        animator.SetTrigger("IsWalkingUp");
                        break;
                    }
                    // If customer lost all patience, make customer leave.
                    if (currentCustomerPatience <= 0)
                    {
                        PlaySound(ImpatientSound);

                        GenerateBubble(CustomerBubbleType.Time);
                        customerStatus = CustomerState.WalkingAwayFromStall;
                        animator.SetTrigger("IsWalkingDown");

                        currentStall.RemoveACustomerFromLine();

                        currentCustomerPatience = CustomerPatience;
                        break;
                    }

                    // Keep losing patience while waiting in line.
                    currentCustomerPatience--;

                    break;
                    #endregion

                case CustomerState.BuyingFromStall:
                    #region Buying from Stall Procedure
                    // If customer lost all patience, make customer leave.
                    if (currentCustomerPatience <= 0)
                    {
                        PlaySound(ImpatientSound);

                        GenerateBubble(CustomerBubbleType.Time);
                        customerStatus = CustomerState.WalkingAwayFromStall;
                        animator.SetTrigger("IsWalkingDown");

                        currentStall.RemoveACustomerFromLine();

                        // Reset patience time.
                        currentCustomerPatience = CustomerPatience;

                        break;
                    }
                    // Check if stall has already finished serving.
                    if (currentStall.CurrentServeTime >= currentStall.ServingTime)
                    {
                        PlaySound(BoughtSound);
                        GenerateBubble(CustomerBubbleType.Happy);
                        customerStatus = CustomerState.BoughtFromStall;
                        animator.SetTrigger("IsWalking");
                        if (!IsGoingRight)
                        {
                            transform.gameObject.GetComponent <SpriteRenderer>().flipX = true;
                        }

                        currentStall.Buy(1, ExtraPayment);

                        // Get the position where the customer will walk to after buying.
                        positionAfterBuying = transform.position + new Vector3(1, 0, 0);

                        // Reset stall serve time.
                        currentStall.ResetServeTime();
                        // Reset customer patience.
                        currentCustomerPatience = CustomerPatience;

                        break;
                    }

                    // Customer keeps losing patience until stall has finished preparing and serving.
                    currentCustomerPatience--;
                    currentStall.IncrementServeTime();

                    break;
                    #endregion

                case CustomerState.BoughtFromStall:
                    #region Bought from Stall Procedure
                    // Make the customer walk to a position on the right after buying.
                    Walk(Speed, 0);
                    if (transform.position.x >= positionAfterBuying.x)
                    {
                        customerStatus = CustomerState.WalkingAwayFromStall;
                        animator.SetTrigger("IsWalkingDown");
                        if (!IsGoingRight)
                        {
                            transform.gameObject.GetComponent <SpriteRenderer>().flipX = false;
                        }

                        // Remove the customer from the stall's line after buying.
                        currentStall.RemoveACustomerFromLine();
                        break;
                    }

                    break;
                    #endregion

                case CustomerState.WalkingAwayFromStall:
                    #region Walking Away from Stall Procedure
                    // Make the customer walk away from the stall until it reaches the original position on the street.
                    Walk(0, -Speed);
                    if (transform.position.y <= positionToReturn.y)
                    {
                        // Make the customer walk normally again upon reaching the street.
                        customerStatus = CustomerState.Walking;
                        animator.SetTrigger("IsWalking");
                    }

                    break;
                    #endregion

                default:
                    throw new System.ArgumentException("Customer state invalid.");
                }
            }
            else
            {
                // Destory customer once it reaches the endpoint.
                Destroy(gameObject);
            }
        }