Exemplo n.º 1
0
    private bool EvaluateLinkedList(List <GameObject> linkList, GemObject.eColorType colorType)
    {
        bool eval = false;

        foreach (GameObject linkObj in linkList)
        {
            HexObject objectScript = linkObj.GetComponent <HexObject> ();

            if (objectScript._Type == HexObject.eType.Main)
            {
                if (objectScript.ScanColor == (int)GemObject.eColorType.Black && objectScript.MarkedColor == (int)GemObject.eColorType.Black)
                {
                    GemObject.eColorType cType = objectScript.GetGemRefColorType();

                    if (cType == colorType)
                    {
                        objectScript.ScanColor = (int)colorType;
                        ScannedLinkedList.Add(linkObj);
                        eval = true;
                    }
                }
            }
        }

        return(eval);
    }
Exemplo n.º 2
0
    public void QueryScanAndMark()
    {
        QueryClearMarked();

        foreach (GameObject tObj in HexObjectList)
        {
            HexObject objectScript = tObj.GetComponent <HexObject> ();
            if (objectScript._Type == HexObject.eType.Main && objectScript.MarkedColor == (int)GemObject.eColorType.Black)
            {
                //new target so clear scan colors
                QueryClearScan();
                ScannedLinkedList.Clear();

                //do link walk
                GemObject.eColorType colorType = objectScript.GetGemRefColorType();
                objectScript.ScanColor = (int)colorType;

                //get link list for this target object
                List <GameObject> linkList = objectScript.HexLinkList;

                bool eval = EvaluateLinkedList(linkList, colorType);

                while (eval == true)
                {
                    List <GameObject> evalList = new List <GameObject>(ScannedLinkedList);
                    ScannedLinkedList.Clear();

                    if (evalList.Count == 0)
                    {
                        eval = false;
                    }

                    bool innerEval = false;
                    foreach (GameObject linkObj in evalList)
                    {
                        HexObject         objScript   = linkObj.GetComponent <HexObject> ();
                        List <GameObject> sublinkList = objScript.HexLinkList;
                        if (EvaluateLinkedList(sublinkList, colorType))
                        {
                            innerEval = true;
                        }
                    }
                    eval = innerEval;
                }

                int count = QueryCountScanColors((int)colorType);
                if (count >= 4)
                {
                    //if >= 5 -> add powerup
                    QueryScanToMarked();

                    Debug.Log("########### QueryScanToMarked for color " + colorType.ToString() + "  count = " + count);
                }
            }
        }
    }
    private bool EvaluateLinkedListForIndex(List <GameObject> linkList, GemObject.eColorType colorType, int index)
    {
        bool eval = false;

        if (linkList == null)
        {
            return(false);
        }

        if (linkList.Count == 0)
        {
            return(false);
        }

        GameObject linkObj = linkList [index];

        SquareGridObject objectScript = linkObj.GetComponent <SquareGridObject> ();

        if (objectScript._Type == SquareGridObject.eType.Main)
        {
            if (objectScript.ScanColor == (int)GemObject.eColorType.Black && objectScript.MarkedColor == (int)GemObject.eColorType.Black)
            {
                GemObject.eColorType cType = objectScript.GetGemRefColorType();

                if (cType == colorType)
                {
                    objectScript.ScanColor = (int)colorType;
                    ScannedLinkedList.Add(linkObj);
                    eval = true;
                }
            }
        }


        return(eval);
    }