コード例 #1
0
    void CheckOtherSquare(BlockScript otherSquare, BlockScript thisSquare)
    {
        if (thisSquare.bc == otherSquare.bc)
        {
            //print("samanväriset " + thisSquare + " ja " + otherSquare);
            //samanvärisiä joten laitetaan samaan ryhmään ja tuhotaan edellinen
            otherSquare.group.Add(thisSquare);
            AllGroups.Remove(thisSquare.group);

            //tämän saa tehdä vasta tuhoamisen jälkeen!!
            thisSquare.SetGroup(otherSquare.group);
        }
        else if (thisSquare.group.Count == 0)
        {
            //tee uusi ryhmä
            List <BlockScript> tempList = new List <BlockScript> {
                thisSquare
            };
            AllGroups.Add(tempList);
            // int tempInt = AllGroups.IndexOf(tempList);
            thisSquare.SetGroup(tempList);
            //print("uusi ryhmä tehty blokille " + thisSquare + " ryhmä: " + AllGroups.IndexOf(tempList));
        }
    }