void Start() { seeker = GetComponent <Seeker>(); controller = GetComponent <CharacterController>(); stats = GetComponent <WorkerStats>(); atDestination = true; }
// Use this for initialization void Start() { routine = GetComponent <WorkerRoutine>(); stats = GetComponent <WorkerStats>(); anim = GetComponent <WorkerAnimationManager>(); path = GetComponent <PathFinding>(); inventory = GameObject.FindWithTag("GameManager").GetComponent <TotalInventory>(); }
// Use this for initialization void Start() { routine = GetComponent <WorkerRoutine>(); stats = GetComponent <WorkerStats>(); anim = GetComponent <WorkerAnimationManager>(); path = GetComponent <PathFinding>(); taskInitiated = false; constructionInProgress = false; }
public Worker(int id, int boundedCapacity, CancellationToken token) { WorkerId = id; _semaphore = new ManualResetEvent(true); _stats = new WorkerStats(); _buffer = new BufferBlock <T>( new DataflowBlockOptions { CancellationToken = token, BoundedCapacity = boundedCapacity }); _blockingQueue = new BlockingCollection <T>(new ConcurrentQueue <T>()); _feederTask = Task.Factory.StartNew(() => { while (true) { if (token.IsCancellationRequested) { break; } if (!_buffer.TryReceive(out var item)) { Thread.Sleep(2000); continue; } _blockingQueue.Add(item); _stats.IncrementItemsInQueue(); } _blockingQueue.CompleteAdding(); }, token); _processorTask = Task.Factory.StartNew(async() => { while (!_blockingQueue.IsCompleted) { if (!_blockingQueue.TryTake(out var item, 100)) { Thread.Sleep(2000); } if (item != null) { await Do(item) .ContinueWith(task => { _stats.DecrementItemsInQueue(); _semaphore.Set(); } ); } } }, token); }
public void SelectMinion(GameObject _minion) { buildingUI.SetActive(false); selectedObject = _minion; workerStats = selectedObject.GetComponent <WorkerStats>(); minionName.text = workerStats.GetName(); minionSpeed.text = workerStats.GetMovementSpeed().ToString(); minionProductivity.text = workerStats.GetProductivity().ToString(); minionWood.text = workerStats.GetWood().ToString(); minionStone.text = workerStats.GetStone().ToString(); minionUI.SetActive(true); }
public void OnStats(WorkerStats s) { Console.WriteLine($"Msg count: {s.MessageCount} Av msg time: {s.AverageProcessingTimeMs} Max msg time: {s.MaxProcessingTimeMs}"); }