예제 #1
0
        public override void LeaveObjOn(CharacterControllerAct player)
        {
            if (!hasObjectOn)
            {
                item = player.attachedObject.GetComponent <Item>();

                if (item.itemType == ItemType.Vial)
                {
                    VialItem vialItem = item.GetComponent <VialItem>();

                    //   Crear ordre o mirar si a llist of orders hi ha ordres d'aquest item
                    bool check = OrderManager.Instance.CheckAllOrder(vialItem);
                    Debug.Log("orderc check" + check);
                    if (check)
                    {
                        StartCoroutine(TextWide(5f, "Order get"));
                    }
                    else
                    {
                        StartCoroutine(TextWide(5f, "Order Wrong"));
                    }
                    vialItem.ResetVial();
                    base.LeaveObjOn(player);
                    VialPool.Instance.ReturnToPool(vialItem);
                    hasObjectOn = false;
                }
                else
                {
                    StartCoroutine(TextWide(5f, "Needs a Vial"));
                }
            }
        }
예제 #2
0
    public bool CheckAllOrder(VialItem item)
    {
        foreach (var order in listOrders)
        {
            Debug.Log("checkings");
            if (!order.isServed)
            {
                List <Item> In1OfOrderList  = order._ingredients.OfType <Ing11>().ToList <Item>();
                List <Item> Ing2OfOrderList = order._ingredients.OfType <Ingredient2>().ToList <Item>();
                List <Item> equalItems2Ing2 = item.listItem.OfType <Ingredient2>().ToList <Item>();
                List <Item> equalItems2Ing1 = item.listItem.OfType <Ing11>().ToList <Item>();
                if (equalItems2Ing1.Count == In1OfOrderList.Count && equalItems2Ing2.Count == Ing2OfOrderList.Count)
                {
                    Debug.Log("lists has same numbros of each ingredient");
                    order.isServed = true;
                    order.HideUIOrder();
                    points += order._points;
                    OrderManager.Instance.RemoveOrder(order);
                    return(true);
                }
                // checkeo si els ingredients de la ordre q em donen el tinc a una ordre de la llista
                //FoundOrder = null;
                //if (order._ingredients.Count == 0)
                //    return false;
                //if (item.listItem.Count == 0)
                //    return false;
                //if (order._ingredients.Count != item.listItem.Count)
                //    return false;
                //for (int i = 0; i < order._ingredients.Count; i++)
                //{
                //    if (order._ingredients[i].ing != item.listItem[i].ing)
                //        return false;
                //}
                // found1 = true;
                //    FoundOrder = order;


                //    return found1;
                //if (Utils.CompareLists2<Item>(order._ingredients, item.listItem))
                //{
                //
                //   // break;
                //}
            }
        }
        return(false);
        // com compares 2 llistes
    }