Esempio n. 1
0
    public void CreateLiquidFragment(SOLiquid dataModel)
    {
        CGLiquid clone = Instantiate(liquidModel).GetComponent <CGLiquid>();

        clone.Init(dataModel);
        clone.SetDrink(this);
        clone.FillAmountFloat = AmountI2F(currentAmount);
        clone.FillAmountInt   = 0;

        RenderQueueSetter.Set(clone.gameObject, renderQueueMax - liquidFragment.Count);
        liquidFragment.Add(clone);

        clone.transform.SetParent(this.transform);
        clone.gameObject.SetActive(true);
    }
Esempio n. 2
0
    public void InitRenderLiquidFill(SOLiquidFill data)
    {
        ClearFragments();
        liquidFragments = new List <CGLiquid>();

        int renderQueueMax = 2000 + data.fragmentCap;

        curFillAmount = 0;
        Color lastFragmentTopColor = data.fragments[data.fragments.Count - 1].soLiquid.topColor;

        for (int i = 0; i < data.fragments.Count; i++)
        {
            CGLiquid lqClone = Instantiate(liquidModel).GetComponent <CGLiquid>();
            lqClone.transform.SetParent(transform);

            lqClone.Init(data.fragments[i].soLiquid);
            lqClone.TopColor      = lastFragmentTopColor;
            lqClone.FillAmountInt = data.fragments[i].fillAmount;

            curFillAmount += data.fragments[i].fillAmount;
            float fillPercentage = (float)curFillAmount / (float)data.maxFillAmount;
            float fillHigh       = Mathf.Lerp(liquidLowestFA, liquidHighestFA, fillPercentage);
            lqClone.FillAmountFloat = fillHigh;

            dropReceiverBox.transform.position = new Vector3(
                dropReceiverBox.transform.position.x,
                Mathf.Lerp(dropReceiverBoxLowest, dropReceiverBoxHighest, fillPercentage),
                dropReceiverBox.transform.position.z
                );

            RenderQueueSetter.Set(lqClone.gameObject, renderQueueMax - i);

            liquidFragments.Add(lqClone);

            lqClone.gameObject.SetActive(true);
        }
    }