Example #1
0
    public void UpdateSlot(int type, CellsSO cellSO, OrganManager.OrganType.OrganInfo.cellsType.CellSizes.CellInfo Info)
    {
        myType   = type;
        myObject = cellSO;
        if (Info != null)
        {
            myInfo = Info;
        }
        else
        {
            Debug.LogWarning("Error: info is null at - cellSlot");
        }


        BGImage.color = cellSO.MyColor;
        switch (type)
        {
        case 1:
            CellImage.sprite           = cellSO.Cellx1;
            DeathTimerCellImage.sprite = cellSO.Cellx1;
            CellImage.gameObject.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
            break;

        case 2:
            CellImage.sprite           = cellSO.Cellx10;
            DeathTimerCellImage.sprite = cellSO.Cellx10;
            CellImage.gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
            break;

        case 3:
            CellImage.sprite           = cellSO.Cellx100;
            DeathTimerCellImage.sprite = cellSO.Cellx100;
            CellImage.gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
            break;
        }
    }
Example #2
0
    public void ChangeCellType(int CellType, bool Buy = false)
    {
        //CellType -= 1;
        for (int i = 0; i < SlotSizes.Length; i++)                           // go through all sizes
        {
            if (SlotSizes[i].ActiveCellSlots.Count != 0)                     // chek if there are slots of current size
            {
                for (int o = 0; o < SlotSizes[i].ActiveCellSlots.Count; o++) //  go through all slots of current size
                {
                    SlotSizes[i].ActiveCellSlots[o].SetActive(false);
                }
                SlotSizes[i].ActiveCellSlots.Clear();
            }
        }
        CellsSO cellsSO = RedBloodCell;

        switch (CellType)
        {
        case 0:
            cellsSO = RedBloodCell;
            break;

        case 1:
            cellsSO = WhiteBloodCell;
            break;

        case 2:
            cellsSO = HelperCell;
            break;

        default:
            cellsSO = RedBloodCell;
            break;
        }

        if (myOrganManager.organTypes[myOrganManager.activeOrganType].organs.Count != 0)
        {
            //Debug.Log(myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].name);
            for (int c = 0; c < myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes.Count; c++)
            {
                if (myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes[c].CellsInfos.Count != 0)
                {
                    for (int v = 0; v < myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes[c].CellsInfos.Count; v++)
                    {
                        GameObject Cell = SpawnFroomPool(CellTag[c]);
                        Cell.transform.SetParent(UiCellCountcontainer.transform);
                        Cell.transform.localScale = new Vector3(1, 1, 1);
                        Cell.transform.SetAsFirstSibling();
                        Cell.GetComponent <CellSlot>().UpdateSlot(c + 1, cellsSO, myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes[c].CellsInfos[v]);
                        SlotSizes[c].ActiveCellSlots.Add(Cell);
                    }
                }
            }
        }
        BuyButton.color           = cellsSO.MyColor;
        BuyButtonCost.color       = cellsSO.MyColor;
        BuyButtonCellImage.sprite = cellsSO.Cellx1;

        if (Buy == false)
        {
            MyUILeanTween.FinishChangeCellType();
        }

        UpdateCellCost();
    }
Example #3
0
    void BuyCellEffect(int CellType)
    {
        //CellType -= 1;
        int[] CellTotals = new int[3];
        /* ---- et Total Number of Cell Slots ---- */
        for (int i = 0; i < SlotSizes.Length; i++)
        {
            CellTotals[i] = SlotSizes[i].ActiveCellSlots.Count;
        }

        /* ---- Assign CellType ---- */
        CellsSO cellsSO = null;

        switch (CellType)
        {
        case 0:
            cellsSO = RedBloodCell;
            break;

        case 1:
            cellsSO = WhiteBloodCell;
            break;

        case 2:
            cellsSO = HelperCell;
            break;
        }


        for (int a = 0; a < myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes.Count; a++)
        {
            /* ---- Check if cells merged ---- */
            int organNumber = myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes[a].CellsInfos.Count;
            if (organNumber == 0 && CellTotals[a] != organNumber)
            {
                for (int x = 0; x < SlotSizes[a].ActiveCellSlots.Count; x++)
                {
                    SlotSizes[a].ActiveCellSlots[x].SetActive(false);
                }
                SlotSizes[a].ActiveCellSlots.Clear();
            }
        }

        /* ---- Get New Cell Slot ---- */


        for (int a = 0; a < myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes.Count; a++)
        {
            for (int c = SlotSizes[a].ActiveCellSlots.Count; c < myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes[a].CellsInfos.Count; c++)
            {
                GameObject Cell = SpawnFroomPool(CellTag[a]);
                Cell.transform.SetParent(UiCellCountcontainer.transform);
                Cell.transform.localScale = new Vector3(0, 0, 0);
                Cell.transform.SetAsLastSibling();
                LeanTween.scale(Cell, new Vector3(1, 1, 1), 0.8f).setEase(LeanTweenType.easeOutExpo);
                Cell.TryGetComponent(out CellSlot cellslot);
                cellslot.UpdateSlot(a + 1, cellsSO, myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes[a].CellsInfos[c]);
                SlotSizes[a].ActiveCellSlots.Add(Cell);
            }
        }
    }