public override void OnCollision(GameObject other) { if (other is Guild) { currentInventory = 0; Console.WriteLine("Setting the inventory to zero"); if (currentInventory == 0) { workerState = workerBehavivor.mining; } //Console.WriteLine("I used to be an adventurer like you, but then I took an arrow to the knee"); } if (other is Buildings.Mine) { if (workerState != workerBehavivor.mining) { workerState = workerBehavivor.mining; } } if (other is Buildings.Farm) { Console.WriteLine("Farming cabbages"); } }
public Workers(string worker, Vector2 position, float layer) { workerName = worker; this.position = position; layerDepth = layer; workerThread = new Thread(workerBehaviorStates); this.workerState = workerBehavivor.moving; workerThread.Start(); }
public void MiningsWithdraw(object obj) { int amount = (int)obj; Monitor.Enter(thisLock); goToThisNewPosition = new Vector2(224, 88); try { if (amount < balance) { while (currentInventory < maxInventory) { currentInventory += amount; Thread.Sleep(500); //currentInventory++; Console.WriteLine("Current inventory: " + currentInventory); if (currentInventory > maxInventory) { Console.WriteLine(currentInventory); currentInventory = maxInventory; } } } else { balance -= currentInventory; Console.WriteLine($"The Current Balance in the mine: {balance}"); } } finally { Thread.Sleep(500); Console.WriteLine($"The current inventory is : {currentInventory}"); if (currentInventory >= maxInventory) { Console.WriteLine("Moving home"); workerState = workerBehavivor.returningToBase; } Monitor.Exit(thisLock); } }