public Need GetNeed(NeedDefinition needToGet) { foreach (var need in needs) { if (need.thisNeed == needToGet) { return(need); } } return(null); }
public ModInfo(string name, string spriteLocation, int spriteSortingLayer, Color color, float price, float wVal, ObjectType type, PlacedObjectType objectType, NeedDefinition fulfilsNeed, Vector3 childPos, bool rotatable, bool changableColor) { this.name = name; this.spriteName = spriteLocation; this.spriteSortingLayer = spriteSortingLayer; this.color = color; this.price = price; this.wVal = wVal; this.type = type; this.objectType = objectType; this.fulfilsNeed = fulfilsNeed; this.childPos = childPos; this.rotatable = rotatable; this.changableColor = changableColor; }
private NeedFulfiller GetNearestNeed(NeedDefinition need) { NeedFulfiller nearestNeed = null; NeedFulfiller[] workerButtons = FindObjectsOfType <NeedFulfiller>(); float nearest = 20; foreach (var desk in workerButtons) { float dist = Vector2.Distance(transform.position, desk.transform.position); if (dist < nearest && desk.Fulfills == need) { nearestNeed = desk; nearest = dist; } } return(nearestNeed); }
public TaskSystem.Task FulfilNeed(NeedDefinition need) { TaskSystem.Task fulfil = null; if (GetNearestNeed(need) != null) { fulfil = new TaskSystem.Task { moveToPosition = new TaskSystem.Task.MoveTo(GetNearestNeed(need).transform.position, 1f, () => { GetNearestNeed(need).FulFillneed(worker); currentThought = DialogueSys.GetCelebration(); state = State.WaitingForNewTask; }), }; currentTask = "Taking a break."; } return(fulfil); }