Esempio n. 1
0
    public void ChainAddDot(Dot dot)
    {
        // If still dealing with last chain, need to wait
        if (state != State.MAKINGCHAIN)
            return;

        // If still adding dots (because still touching) but the chain has been cleared, skip
        if (chain.Count == 0)
            return;

        // If touching same dot as last frame, skip
        if (dot == chain[chain.Count - 1])
            return;

        // If new dot is different colour, reset
        if (dot.GetColour() != chainColour)
        {
            CompleteChain ();
            return;
        }

        // If new dot is not 1 away on horizontal or vertical line, reset
        float xdif = Mathf.Abs (dot.xPos - chain[chain.Count - 1].xPos);
        float ydif = Mathf.Abs (dot.yPos - chain[chain.Count - 1].yPos);
        if ((xdif > 1 || ydif > 1) || (xdif == 1 && ydif == 1))
        {
            CompleteChain ();
            return;
        }

        // If doubling back on existing chain, reset
        for (int n = 0; n < chain.Count - 1; n++)
        {
            if (chain[n] == dot)
            {
                CompleteChain ();
                return;
            }
        }

        // Otherwise extend the chain
        chain.Add (dot);
        dot.SetHighlight (true);
        m_Click.Play ();
    }
Esempio n. 2
0
    // Called when first touch a dot
    public void NewChain(Dot dot)
    {
        // If still dealing with last chain, need to wait
        if (state != State.MAKINGCHAIN)
            return;

        chainColour = dot.GetColour ();
        chain.Add (dot);
        dot.SetHighlight (true);
        m_Click.Play ();
    }