コード例 #1
0
ファイル: Appliance.cs プロジェクト: Rachellie/Crecipe
    //adds and ingredient into the appliance
    public void addIngToApp(FoodObject food, HashSet <FoodObject> foodSet)
    {
        Transform onHead = player.GetChild(2);

        onHead.SetParent(null, true);
        StartCoroutine(Slerp(onHead));

        food.subOneQ();
        PlayerData.player.SetCurrentFood(food);

        food = new FoodObject(food);
        food.setQuantity(1);

        foreach (FoodObject ing in foodSet)
        {
            if (ing.getName() == food.getName())
            {
                Debug.Log("match");
                ing.addOneQ();
                prevIng = food.getName();
                return;
            }
        }
        foodSet.Add(food);
        prevIng = food.getName();
    }
コード例 #2
0
ファイル: ClientHandle.cs プロジェクト: Rachellie/Crecipe
    public static void UpdateCounter(Packet _packet)
    {
        int    num      = _packet.ReadInt();
        string name     = _packet.ReadString();
        int    quantity = _packet.ReadInt();

        if (name != "null")
        {
            FoodObject food = new FoodObject(FindFood(name));
            food.setQuantity(quantity);
            PlayerData.player.GetCounters()[num] = food;
        }
        else
        {
            PlayerData.player.GetCounters()[num] = null;
        }

        if (SceneManager.GetActiveScene().name == "KitchenScene")
        {
            GameObject counters = GameObject.Find("Counters");

            foreach (Transform counter in counters.transform)
            {
                if (counter.GetComponent <Counter>().counterNum == num)
                {
                    counter.GetComponent <Counter>().Refresh();
                    return;
                }
            }
        }
    }
コード例 #3
0
ファイル: ClientHandle.cs プロジェクト: Rachellie/Crecipe
    public static void SetAppliance(HashSet <FoodObject> ingSet, Packet _packet)
    {
        ingSet.Clear();

        int amount = _packet.ReadInt();

        for (int i = 0; i < amount; ++i)
        {
            string name     = _packet.ReadString();
            int    quantity = _packet.ReadInt();

            FoodObject food = new FoodObject(FindFood(name));
            food.setQuantity(quantity);

            ingSet.Add(food);
        }
    }
コード例 #4
0
 private void AddFoodItem(FoodObject foodToAdd, ShopScrollList shopList)
 {
     if (shopList.isPlayer)         // if shop that we add to is the player's:
     {
         cost += foodToAdd.getPrice();
         // find if foodItem exists, then increment quantity
         for (int i = 0; i < shopList.foodList.Count; ++i)
         {
             if (shopList.foodList[i].getName() == foodToAdd.getName())
             {
                 shopList.foodList[i].addOneQ();
                 return;
             }
         }
         // if foodItem not found in list then add it to the list with quantity 1
         foodToAdd.setQuantity(1);
         shopList.foodList.Add(foodToAdd);
     }
 }
コード例 #5
0
ファイル: Counter.cs プロジェクト: Rachellie/Crecipe
    public void OnPointerDown(PointerEventData data)
    {
        float distance = Vector3.Distance(player.transform.position, gameObject.transform.position);

        if (distance <= range)
        {
            if (PlayerData.player.GetCurrentFood() != null && PlayerData.player.GetCounterFood(counterNum) == null)
            {
                // place ONE food on counter
                FoodObject food = PlayerData.player.GetCurrentFood();
                food.subOneQ();
                PlayerData.player.SetCurrentFood(food);

                FoodObject counter = new FoodObject(food);
                counter.setQuantity(1);
                PlayerData.player.SetCounterFood(counterNum, counter);
                Refresh();
            }
            else if (PlayerData.player.GetCurrentFood() != null && PlayerData.player.GetCounterFood(counterNum) != null)
            {
                // stack food back if same name
                FoodObject food = PlayerData.player.GetCurrentFood();
                if (PlayerData.player.GetCounterFood(counterNum).getName() == food.getName())
                {
                    food.addOneQ();
                    PlayerData.player.SetCurrentFood(food);
                    PlayerData.player.SetCounterFood(counterNum, null);
                    Refresh();
                }
            }
            else if (PlayerData.player.GetCurrentFood() == null && PlayerData.player.GetCounterFood(counterNum) != null)
            {
                // remove food from counter
                PlayerData.player.SetCurrentFood(PlayerData.player.GetCounterFood(counterNum));
                PlayerData.player.SetCounterFood(counterNum, null);
                Refresh();
            }
        }
    }
コード例 #6
0
ファイル: Appliance.cs プロジェクト: Rachellie/Crecipe
    //removes the most recent added ingredient from appliance
    public FoodObject removeIngFromApp()
    {
        FoodObject food = new FoodObject();

        foreach (FoodObject ing in ingredientSet)
        {
            if (ing.getName() == prevIng)
            {
                //decrease quantity by one
                ing.subOneQ();
                food = new FoodObject(ing);
                food.setQuantity(1);
                if (ing.getQuantity() <= 0)
                {
                    //remove from set
                    ingredientSet.Remove(ing);
                }
                return(food);
            }
        }
        return(food);
    }
コード例 #7
0
ファイル: ClientHandle.cs プロジェクト: Rachellie/Crecipe
    public static void AddToApp(HashSet <FoodObject> foodSet, FoodObject food)
    {
        Debug.Log(food.getQuantity());
        bool notFound = true;

        food.setQuantity(1);

        if (food.getName() != "Plate")
        {
            foreach (FoodObject ing in foodSet)
            {
                if (ing.getName() == food.getName())
                {
                    ing.addOneQ();
                    notFound = false;
                    break;
                }
            }
            if (notFound)
            {
                foodSet.Add(food);
            }
        }
        else
        {
            foodSet.Clear();
        }

        if (SceneManager.GetActiveScene().name == "KitchenScene")
        {
            GameObject appIng = GameObject.Find("AppIng");

            if (appIng != null)
            {
                appIng.GetComponent <AppIng>().Refresh();
            }
        }
    }
コード例 #8
0
ファイル: ClientHandle.cs プロジェクト: Rachellie/Crecipe
    public static void SetCounters(Packet _packet)
    {
        List <FoodObject> newCounters = new List <FoodObject>();

        for (int i = 0; i < 36; ++i)
        {
            string name     = _packet.ReadString();
            int    quantity = _packet.ReadInt();

            if (name != "null")
            {
                FoodObject food = new FoodObject(FindFood(name));
                food.setQuantity(quantity);
                newCounters.Add(food);
            }
            else
            {
                newCounters.Add(null);
            }
        }

        PlayerData.player.SetCounters(newCounters);
    }
コード例 #9
0
ファイル: ClientHandle.cs プロジェクト: Rachellie/Crecipe
    public static void UpdateFridge(Packet _packet)
    {
        int    slot     = _packet.ReadInt();
        string name     = _packet.ReadString();
        int    quantity = _packet.ReadInt();

        if (name != "null")
        {
            FoodObject food = new FoodObject(FindFood(name));
            food.setQuantity(quantity);
            PlayerData.player.GetFridge()[slot] = food;
        }
        else
        {
            PlayerData.player.GetFridge()[slot] = null;
        }

        if (SceneManager.GetActiveScene().name == "InventoryScene")
        {
            GameObject fridge = GameObject.Find("Content");
            fridge.GetComponent <Bag>().Refresh();
        }
    }