private void OnWrongAnswer(LostFoundItem lfItem, CustomerBehaviour customer) { SetRiddleLabel(null); WrongSource.Play(); Debug.Log("wrong answer"); CustomerControl.ExitCustomer(customer); }
public void RemoveItem(LostFoundItem item, bool shouldDestroy) { _items.Remove(item); if (shouldDestroy) { GameObject.Destroy(item.gameObject); } }
private void OnRightAnswer(LostFoundItem lfItem, CustomerBehaviour customer) { SetRiddleLabel(null); RightSource.Play(); Debug.Log("right answer"); Storage.RemoveItem(lfItem, true); CustomerControl.ExitCustomer(customer); }
private void ProcessDrop(LostFoundItem droppedItem, Action rejectCallback) { if (ItemDropResolver == null) { rejectCallback(); } else { ItemDropResolver(droppedItem, rejectCallback); } }
private void ProcessDrop(Transform itemTransform, Action rejectCallback) { LostFoundItem droppedItem = _items.Find(item => item.transform == itemTransform); if (droppedItem == null) { rejectCallback(); } else { ProcessDrop(droppedItem, rejectCallback); } }
private LostFoundItem CreateItem(string item) { GameObject inst = Instantiate(LostFoundItemPrefab, transform); LostFoundItem lfItem = inst.GetComponent <LostFoundItem>(); lfItem.SetItem(item); DragDrop dDrop = inst.GetComponent <DragDrop>(); dDrop.Container = Container; dDrop.ProcessDrop = (t, call) => ProcessDrop(lfItem, call); return(lfItem); }
public void ProcessItemDrop(LostFoundItem lfItem, Action rejectCallback) { Vector3 pos = lfItem.transform.position; if (pos.y > BoardsTransform.position.y) { rejectCallback(); } else { int index = 0; int bestIndex = -1; float bestDist = 1000000f; float dist; foreach (Transform t in BoardsTransform.Cast <Transform>().OrderBy(t => t.name)) { dist = Vector3.Distance(t.position, pos); if (dist < bestDist) { bestDist = dist; bestIndex = index; } index++; } CustomerBehaviour target = CustomerControl.GetCustomerAt(bestIndex); if (target == null) //no customer there { rejectCallback(); } else if (!target.Riddle.answer.Equals(lfItem.Item)) { //Wrong answer rejectCallback(); OnWrongAnswer(lfItem, target); } else { //Right answer OnRightAnswer(lfItem, target); } } }