Supermarket script. Contains product catalogue and directory information, manages shelves, and money.
Inheritance: UnityEngine.MonoBehaviour, IEmptyShelfListener
        void Awake()
        {
            animator = gameObject.GetComponentInChildren<Animator>();
            moveControl = GetComponent<NavMeshAgent>();
            supermarket = GameObject.FindGameObjectWithTag("Supermarket").GetComponent<Supermarket>();
            gui = GameObject.FindGameObjectWithTag("GUI").GetComponent<GUI>();

            // Find selection collider
            colliders = GetComponentsInChildren<Collider>();
            foreach (Collider collider in colliders)
            {
                if (collider.gameObject.tag == "Interactor")
                {
                    selectionCollider = collider;
                    break;
                }
            }
        }
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            Supermarket   market = new Supermarket();
            StringBuilder result = new StringBuilder();

            while (input != "End")
            {
                string[] command = input.Split(' ');

                switch (command[0])
                {
                case "Append":
                    result.AppendLine(market.Append(command[1]));
                    break;

                case "Serve":
                    result.AppendLine(market.Serve(int.Parse(command[1])));
                    break;

                case "Insert":
                    result.AppendLine(market.Insert(int.Parse(command[1]), command[2]));
                    break;

                case "Find":
                    result.AppendLine(market.Find(command[1]));
                    break;
                }
                input = Console.ReadLine();
            }

            Console.WriteLine(result.ToString());
        }
 public StaffState(Staff staff)
 {
     supermarket = staff.Supermarket;
     moveControl = staff.MoveControl;
     animator = staff.Animator;
     this.staff = staff;
 }
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            Supermarket market = new Supermarket();
            StringBuilder result = new StringBuilder();
            while (input != "End")
            {
                string[] command = input.Split(' ');

                switch (command[0])
                {
                    case "Append":
                        result.AppendLine(market.Append(command[1]));
                        break;
                    case "Serve":
                        result.AppendLine(market.Serve(int.Parse(command[1])));
                        break;
                    case "Insert":
                        result.AppendLine(market.Insert(int.Parse(command[1]), command[2]));
                        break;
                    case "Find":
                        result.AppendLine(market.Find(command[1]));
                        break;
                }
                input = Console.ReadLine();
            }

            Console.WriteLine(result.ToString());
        }
        static void Main(string[] args)
        {
            var market          = new Supermarket();
            var commandExecutor = new CommandExecutor(market);

            commandExecutor.ExecuteAllCommands();
            Console.WriteLine(commandExecutor.ResultMessages.ToString());
        }
        void Awake()
        {
            supermarket = GameObject.FindGameObjectWithTag("Supermarket").GetComponent<Supermarket>();
            staffManager = GameObject.FindGameObjectWithTag("Staff Manager").GetComponent<StaffManager>();

            shelfGUI = transform.Find("ShelfGUI").GetComponent<ShelfGUI>();
            customerGUI = transform.Find("CustomerGUI").GetComponent<CustomerGUI>();
        }
 void Awake()
 {
     listeners = new List<IStaffManagerListener>();
     supermarket = GameObject.FindGameObjectWithTag("Supermarket").GetComponent<Supermarket>();
     hand = GameObject.FindGameObjectWithTag("Hand").GetComponent<Hand>();
     pool = new ObjectPool<Staff>(staffPrefab, 20);
     hirePool = new List<Staff>();
     FillHirePool();
 }
        /// <summary>
        /// Конструктор эксперимента
        /// </summary>
        /// <param name="workingTime">длительность эксперимента</param>
        /// <param name="cashDeskCount">число касс</param>
        /// <param name="density">плотность прихода посетителей</param>
        /// <param name="lambda"></param>
        /// <param name="distribute">распределение по часам</param>
        public Experiment(float workingTime, int cashDeskCount, float density, float lambda, bool distribute)
        {
            this.workingTime = workingTime;
            this.cashDeskCount = cashDeskCount;
            this.density = density;
            this.lambda = lambda;

            supermarket = new Supermarket(DistributionType.Normal, density, distribute);
        }
Exemple #9
0
        static void Main(string[] args)
        {
            BreadMediator   br_mediator     = new BreadMediator();
            CandiesMediator candy_mediator  = new CandiesMediator();
            СerealsMediator cereal_mediator = new СerealsMediator();
            Colleague       smarket;

            Colleague kyivbread = new KyivBreadColleague(br_mediator);
            Colleague flashbake = new FlashBakeColleague(br_mediator);

            Colleague roshen  = new RoshenColleague(candy_mediator);
            Colleague avk     = new AVKColleague(candy_mediator);
            Colleague svitoch = new SvitochColleague(candy_mediator);

            Colleague cerealUk = new CerealUkraineColleague(cereal_mediator);
            Colleague teppa    = new TeppaColleague(cereal_mediator);

            br_mediator.KyivBread = kyivbread;
            br_mediator.FlashBake = flashbake;

            candy_mediator.Roshen  = roshen;
            candy_mediator.AVK     = avk;
            candy_mediator.Svitoch = svitoch;

            cereal_mediator.CerealUkraine = cerealUk;
            cereal_mediator.Teppa         = teppa;
            Console.WriteLine("");

            smarket = new Supermarket(br_mediator);
            smarket.Notify(100);

            br_mediator.Send(70, kyivbread);
            br_mediator.Send(30, flashbake);
            Console.WriteLine("");

            smarket = new Supermarket(candy_mediator);
            smarket.Notify(50);

            candy_mediator.Send(30, roshen);
            candy_mediator.Send(10, svitoch);
            candy_mediator.Send(10, avk);
            Console.WriteLine("");

            smarket = new Supermarket(cereal_mediator);
            smarket.Notify(150);

            cereal_mediator.Send(100, cerealUk);
            cereal_mediator.Send(50, teppa);
            Console.WriteLine("");

            // Console.Read();
        }
 public CommandExecutor(Supermarket market)
 {
     this.market         = market;
     this.ResultMessages = new StringBuilder();
     this.separators     = new char[] { ' ' };
 }
        void Awake()
        {
            thought = GetComponentInChildren<Thought>();
            moveControl = GetComponent<NavMeshAgent>();
            moveControl.avoidancePriority = Random.Range(1, 100);

            supermarket = GameObject.FindGameObjectWithTag("Supermarket").GetComponent<Supermarket>();
            spawner = GameObject.FindGameObjectWithTag("Entrance").GetComponent<Spawner>();
            gui = GameObject.FindGameObjectWithTag("GUI").GetComponent<GUI>();
            listeners = new List<ICustomerStateListener>();

            // Find selectionCollider
            colliders = GetComponentsInChildren<Collider>();
            foreach (Collider collider in colliders)
            {
                if (collider.tag == "Interactor")
                {
                    selectionCollider = collider;
                    break;
                }
            }
        }
 public CustomerState(Customer customer)
 {
     supermarket = customer.Supermarket;
     moveControl = customer.MoveControl;
     this.customer = customer;
 }
        void Awake()
        {
            supermarket = GameObject.FindGameObjectWithTag("Supermarket").GetComponent<Supermarket>();
            interaction = GetComponent<Interactable>();

            selectionCollider = GetComponent<Collider>();
        }
 /// <summary>
 /// Конструктор эксперимента
 /// </summary>
 public Experiment()
 {
     supermarket = new Supermarket(DistributionType.Normal, 10, true);
 }
 void Awake()
 {
     spawnZones = GetComponent<Interactable>();
     supermarket = GameObject.FindGameObjectWithTag("Supermarket").GetComponent<Supermarket>();
     pool = new ObjectPool<MonoBehaviour>(Prefab, InitialObjectPoolSize);
 }
        void Start()
        {
            // Get supermarket that contains this shelf
            supermarket = GameObject.FindGameObjectWithTag("Supermarket").GetComponent<Supermarket>();
            AddListener(supermarket);       // Supermarket listens for empty shelves.

            // Fill shelf with random products and quantities
            //int nProducts = Random.Range(1, supermarket.Catalogue.Count);
            //for (int i = 0; i < nProducts; i++)
            //{
            //    Product product = supermarket.RandomProduct();
            //    Add(product);
            //}

            foreach (Product product in supermarket.Catalogue.Values)
            {
                if (Random.Range(0, 2) == 0)
                {
                    Product productToAdd = product.Split();
                    productToAdd.Quantity = Random.Range(1, 50);
                    Add(productToAdd);
                }
            }
        }