示例#1
0
    protected virtual void Awake()
    {
        sortingElementID   = SORTING_ELEMENT_NR++;
        name               = MyRole();
        elementInteraction = GetComponent <ElementInteraction>();
        sortingTable       = FindObjectOfType <SortingTable>();

        rigidBody             = GetComponent <Rigidbody>();
        rigidBody.constraints = RigidbodyConstraints.None;
    }
示例#2
0
        private static void SortData()
        {
            _logger.Info("Write down number of sorters");
            var readLine = Console.ReadLine();
            var isParsed = int.TryParse(readLine, out var sortersCount);

            if (!isParsed)
            {
                _logger.Info($"Expected number of sorters but got:{readLine}");
                return;
            }

            var sw = Stopwatch.StartNew();
            List <PenPallet> pallets;

            try
            {
                pallets = _generator.GetPallets();
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                return;
            }
            _logger.Info($"Got pallets data in {sw.Elapsed.TotalMilliseconds}ms");
            sw.Restart();
            var sortingTable = new SortingTable(sortersCount, SORTING_TABLE_CAPACITY, _logger);

            _logger.Info($"Found {pallets.Count} pallets");
            _logger.Info($"Total pens: {pallets.Sum(t=>t.PensColorCodes.Count)}");
            try
            {
                sortingTable.Sort(pallets, PEN_PACK_SIZE).ContinueWith(t =>
                {
                    _logger.Info($"Formed {t.Result.Count} packs.");
                    _logger.Info($"Total cost of packs: {t.Result.Count * PEN_PACK_COST}$.");
                    return(Task.CompletedTask);
                }).ContinueWith(t =>
                {
                    sw.Stop();
                    _logger.Info($"Sorted pallets data in {sw.Elapsed.TotalMilliseconds}ms");
                }).Wait();
            }
            catch (AggregateException ex)
            {
                _logger.Error(ex);
            }
            finally
            {
                sw.Stop();
            }
            _logger.Info($"Sorting ended");
        }
 private void Start()
 {
     sortingTable           = FindObjectOfType <SortingTable>();
     player                 = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>();
     animator               = GetComponent <Animator>();
     playTimer              = timeLeftToPlay;
     sortingSlider          = sortingSliderGO.GetComponent <Slider>();
     sortingSlider.maxValue = timeLeftToPlay;
     sortingSlider.value    = playTimer;
     inventory              = FindObjectOfType <Inventory>();
     animator.SetTrigger("isAppearing");
 }
示例#4
0
    protected override void Awake()
    {
        base.Awake();

        // >>> Objects
        holderManager      = GetComponent(typeof(HolderManager)) as HolderManager;
        elementManager     = GetComponent(typeof(ElementManager)) as ElementManager;
        demoManager        = GetComponent(typeof(DemoManager)) as DemoManager;
        userTestManager    = GetComponent(typeof(UserTestManager)) as UserTestManager;
        displayUnitManager = displayUnitManagerObj.GetComponent(typeof(DisplayUnitManager)) as DisplayUnitManager;

        sortingTable = FindObjectOfType <SortingTable>();
    }
示例#5
0
        private static void SortData()
        {
            _logger.Info("Write down number of sorters");
            var readLine = Console.ReadLine();
            var isParsed = int.TryParse(readLine, out var sortersCount);

            if (!isParsed)
            {
                _logger.Info($"Expected number of sorters but got:{readLine}");
                return;
            }

            var sw      = Stopwatch.StartNew();
            var pallets = _generator.GetPallets();

            _logger.Info($"Got pallets data in {sw.Elapsed.TotalMilliseconds}ms");
            sw.Restart();
            var sortingTable = new SortingTable(sortersCount, 2000, _logger);

            _logger.Info($"Found {pallets.Count} pallets");
            _logger.Info($"Total pens: {pallets.Sum(t=>t.PensColorCodes.Count)}");
            sortingTable.Sort(pallets, 4).ContinueWith(t =>
            {
                _logger.Info($"Formed {t.Result.Count} packs.");
                var costInUsd = t.Result.Count * 10;
                _logger.Info($"Total cost of packs: {costInUsd}$.");
                var costInRubles = _costCalculator.CalculateCost(costInUsd, "USD", "RUB");
                _logger.Info($"Converted cost of packs: {costInRubles:F2}Rub.");

                return(Task.CompletedTask);
            }).ContinueWith(t =>
            {
                sw.Stop();
                _logger.Info($"Sorted pallets data in {sw.Elapsed.TotalMilliseconds}ms");
            }).Wait();
            _logger.Info($"Sorting ended");
        }