Ejemplo n.º 1
0
    public void CellStart(int cellID, CellSize size, OrganManager.OrganType.OrganInfo.cellsType.CellSizes.CellInfo info)
    {
        myInfo   = info;
        cellSize = size;
        ID       = cellID;

        Vector2 randomPosition = Vector2.zero;

        switch (CellType)
        {
        case 0:     // Red Cells
            randomPosition = new Vector2(Random.Range(0.2f, 0.8f), Random.Range(0.7f, 0.87f));
            break;

        case 1:
        case 2:
            randomPosition = new Vector2(Random.Range(0.2f, 0.8f), Random.Range(0.1f, 0.68f));
            break;

        default:
            randomPosition = Vector2.zero;
            break;
        }
        target = Camera.main.ViewportToWorldPoint(randomPosition);


        UpdateHealthCoroutine = StartCoroutine(UpdateHealth());
        randomTime            = Random.Range(0.4f, 1.5f);
    }
Ejemplo n.º 2
0
    public void BuyCell(out bool Bought, int cellType = 0)
    {
        Bought = false;
        if (CanBuyCell)
        {
            if (GameManager.gameManager.pointsManager.totalPoints >= myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[cellType].currentCellCost)
            {
                /*----DATA----*/
                /*----Create new Small Cell Data----*/
                OrganManager.OrganType.OrganInfo.cellsType.CellSizes.CellInfo cellInfo = new OrganManager.OrganType.OrganInfo.cellsType.CellSizes.CellInfo();
                cellInfo.maxHealth = 1;
                cellInfo.health    = 1;
                cellInfo.timer     = 0;
                cellInfo.alive     = true;
                myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[cellType].cellSizes[0].CellsInfos.Add(cellInfo);


                /*----Check for merge in data----*/
                DataMerge(cellType, out bool merge, out bool big);

                /*----Manage points a cost data----*/
                GameManager.gameManager.pointsManager.ManagePoints(-myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[cellType].currentCellCost);
                myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[cellType].currentCellCost = myOrganManager.CalculateCosts(myOrganManager.activeOrganID, cellType);
                Bought = true;

                /*----END OF DATA----*/
                /*-------------------*/
                /*-------VISUAL------*/


                /*----Instantiate New Cell----*/
                if (merge)
                {
                    if (big)
                    {
                        myCellMerger.Merge(CellTypes[cellType].CellSizes[0].Cells, cellType, true);
                    }
                    else
                    {
                        myCellMerger.Merge(CellTypes[cellType].CellSizes[0].Cells, cellType);
                    }
                    CanBuyCell = false;
                }
                else
                {
                    InstantiateCells();
                }
            }
            else
            {
                Debug.Log("not enough points");
            }
        }
    }
Ejemplo n.º 3
0
 void DataMerge(int CellType, out bool MergeTime, out bool Big)
 {
     MergeTime = false;
     Big       = false;
     for (int i = 0; i < myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes.Count; i++)    // Check all cell Sizes of current type
     {
         if (myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes[i].CellsInfos.Count >= 10) // check if current cell size cell infos are greater than 10
         {
             OrganManager.OrganType.OrganInfo.cellsType.CellSizes.CellInfo cellInfo = new OrganManager.OrganType.OrganInfo.cellsType.CellSizes.CellInfo();
             cellInfo.health    = Mathf.Pow(10, i);
             cellInfo.maxHealth = Mathf.Pow(10, i);
             cellInfo.timer     = 0;
             cellInfo.alive     = true;
             myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes[i + 1].CellsInfos.Add(cellInfo);
             myOrganManager.organTypes[myOrganManager.activeOrganType].organs[myOrganManager.activeOrganID].CellTypes[CellType].cellSizes[i].CellsInfos.Clear();
             MergeTime = true;
             if (i == 1)
             {
                 Big = true;
             }
         }
     }
 }
Ejemplo n.º 4
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;
        }
    }