Beispiel #1
0
    //public bool GetRuleResult(int state, int fitness)
    private void ProcessRule(GameObject _cellObj, int fitness)
    {
        CellObj cellObjectScript = _cellObj.GetComponent <CellObj> ();

        bool isAlive = cellObjectScript.GetCurrentSliceIsAlive();

        bool lifeState = false;

        //survive
        if (isAlive == true)
        {
            for (int i = 0; i < surroundingCells; i++)
            {
                int rule = rulesSurvive [i];
                if (rule == -1)
                {
                    break;
                }
                else
                {
                    if (fitness == rule)
                    {
                        lifeState = true;
                        break;
                    }
                }
            }
        }

        //born
        if (isAlive == false)
        {
            for (int i = 0; i < surroundingCells; i++)
            {
                int rule = rulesBorn [i];
                if (rule == -1)
                {
                    break;
                }
                else
                {
                    if (fitness == rule)
                    {
                        lifeState = true;
                        break;
                    }
                }
            }
        }

        cellObjectScript.SetOffScreenSliceState(lifeState);
    }
Beispiel #2
0
    private int GetCellLife(GameObject _cellObj)
    {
        CellObj cellObjectScript = _cellObj.GetComponent <CellObj> ();

        if (cellObjectScript.GetCurrentSliceIsAlive())
        {
            return(1);
        }
        else
        {
            return(0);
        }
    }