Exemple #1
0
    public void Setup(FoodObject currentFood, Canvas newCanvas, Bag bag, int indx)
    {
        food = currentFood;

        image.sprite      = Resources.Load <Sprite>(food.getIcon());
        quantityText.text = food.getQuantity().ToString();
        canvas            = newCanvas;
        bagScript         = bag;
        index             = indx;
        model             = food.getModel();
    }
Exemple #2
0
    public void Refresh()
    {
        FoodObject food = PlayerData.player.GetCounterFood(counterNum);

        for (int i = gameObject.transform.childCount - 1; i >= 0; --i)
        {
            Destroy(gameObject.transform.GetChild(i).gameObject);
        }

        if (food != null)
        {
            Instantiate(Resources.Load(food.getModel()), gameObject.transform);
            gameObject.transform.GetChild(0).localPosition += new Vector3(0f, -0.21f, 0f);
            // gameObject.transform.GetChild(0).rotation = Quaternion.identity;
        }
    }
Exemple #3
0
    public static void SetFood(Packet _packet)
    {
        int    fromClient = _packet.ReadInt();
        string foodName   = _packet.ReadString();

        foreach (GameObject _player in GameObject.FindGameObjectsWithTag("OtherPlayer"))
        {
            if (_player.GetComponent <PlayerManager>().id == fromClient)
            {
                for (int i = _player.transform.childCount - 1; i >= 2; --i)
                {
                    Destroy(_player.transform.GetChild(i).gameObject);                     // third child is hat
                }
                if (foodName == "null")
                {
                    return;
                }

                FoodObject food = FindFood(foodName);
                Instantiate(Resources.Load(food.getModel()), _player.transform);
                return;
            }
        }
    }
Exemple #4
0
    public void Refresh()
    {
        for (int i = 0; i < slotsList.Count; ++i)
        {
            for (int j = slotsList[i].childCount - 1; j >= 0; --j)
            {
                Destroy(slotsList[i].GetChild(j).gameObject);
            }
        }

        List <FoodObject> bag;

        if (!inventory)
        {
            bag = PlayerData.player.GetBag();
        }
        else
        {
            bag = PlayerData.player.GetFridge();
        }

        for (int i = 0; i < bag.Count; ++i)
        {
            if (bag.Count == 16 && slotsList.Count == 15 && i == 15)
            {
                break;
            }

            if (bag[i] != null)
            {
                GameObject food = Instantiate(foodItemPrefab, slotsList[i]);

                DragDrop dragDrop = food.GetComponent <DragDrop>();
                dragDrop.Setup(bag[i], canvas, this, i);
                dragDrop.tag = inventory;
            }
        }

        // create model
        if (Model != null)
        {
            FoodObject currentFood = PlayerData.player.GetCurrentFood();

            for (int i = Model.childCount - 1; i >= 0; --i)
            {
                Destroy(Model.GetChild(i).gameObject);
            }

            if (currentFood != null)
            {
                Instantiate(Resources.Load(currentFood.getModel()), Model);                //
            }
        }
        //put Food Name
        if (PlayerData.player.GetCurrentFood() != null && text != null)
        {
            text.text = PlayerData.player.GetCurrentFood().getName();
        }
        else if (text != null)
        {
            text.text = "";
        }
    }