Example #1
0
        public void Piece_Should_Stop()
        {
            var line = new LinePiece();

            line.Stop();

            Assert.IsFalse(line.IsActive);
        }
Example #2
0
        public void Line_Should_TurnRight()
        {
            var line             = new LinePiece();
            var collisionMapList = line.DecomposeCollisionMapInLinesOfBlocks();

            line.Turn();
            var turnedCollisionMapList = line.DecomposeCollisionMapInLinesOfBlocks();

            Assert.AreEqual(collisionMapList.Count, turnedCollisionMapList.First().Count);
        }
Example #3
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        GameObject collO = coll.gameObject;
        LinePiece  line  = collO.GetComponent <LinePiece> ();

        //Debug.Log ("Collided with line");
        if (line != null)
        {
            GameObject.Find("Rain").GetComponent <Rain> ().AddToCurrent(value);
            GameObject.Find("Rain").GetComponent <Rain> ().LastLetters.Add(this);
            GetComponent <Renderer> ().material = Yellow;
            Destroy(GetComponent <BoxCollider2D> ());
        }
    }
Example #4
0
 protected void RenderPiece(LinePiece piece)
 {
     RenderPiece(_textNotRendered); _textNotRendered=null;
     if (_line==null) {
         _line=new List<LinePiece>();
     }
     float lineWidth=LineWidth();
     if (piece.width+lineWidth>_maxWidth) {
         RenderLine();
     }
     if (_line==null) {
         _line=new List<LinePiece>();
     }
     AddPiece(piece);
 }
Example #5
0
 protected void RenderPiece(FSprite sprite)
 {
     LinePiece piece=new LinePiece(sprite,sprite.textureRect.width*sprite.scaleX,sprite.textureRect.height*sprite.scaleY);
     RenderPiece (piece);
 }
Example #6
0
 protected void RenderPiece(FButton button)
 {
     LinePiece piece=new LinePiece(button,button.hitRect.width*button.scaleX,button.hitRect.height*button.scaleY);
     RenderPiece (piece);
 }
Example #7
0
 protected void AddPiece(LinePiece piece)
 {
     _line.Add(piece);
     _charCount+=piece.charCount;
 }
Example #8
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (started == false)
        {
            if (Input.GetMouseButtonDown(0))
            {
                AStart();
                Destroy(GameObject.Find("StartText"));
                started = true;
            }
        }
        if (started == true)
        {
            if (Input.GetMouseButton(0) && GameOver == false)
            {
                if (Drawing == false)
                {
                    GameObject line = Instantiate(Line) as GameObject;
                }
                Drawing = true;

                if (GetMousePosition() != LastPos)
                {
                    GameObject CurrentLine = Instantiate(LinePiece) as GameObject;
                    LinePiece  lp          = CurrentLine.GetComponent <LinePiece> ();
                    lp.inuse = true;
                    //if its not the first line segment

                    if (LastPosMatters == true)
                    {
                        if (CurrentLine != null && PreviousLine != false)
                        {
                            CurrentLine.transform.position   = ((GetMousePosition() + LastPos) / 2);
                            CurrentLine.transform.localScale = new Vector3(Vector3.Distance(CurrentLine.transform.position, LastPos) + (PreviousLine.transform.localScale.x / 2), .15f, .1f);
                        }
                    }
                    //if its the first line segment
                    else if (LastPosMatters == false)
                    {
                        CurrentLine.transform.position   = (GetMousePosition());
                        CurrentLine.transform.localScale = new Vector3(.15f, .1f, .1f);
                    }


                    if (LastPosMatters == true)
                    {
                        CurrentLine.transform.Rotate(GetRot(LastPos, CurrentLine.transform.position));
                    }
                    LastPos = CurrentLine.transform.position;
                    try {
                        CurrentLine.transform.SetParent(GameObject.Find("Line(Clone)").transform);
                    } catch {
                    }
                    PreviousLine = CurrentLine;
                    lp.inuse     = false;
                }
                LastPosMatters = true;
            }
            else if (!Input.GetMouseButtonDown(0))
            {
                if (Drawing == true)
                {
                    LastPosMatters = false;
                    Drawing        = false;
                    last           = current;

                    //compare string
                    GameObject dicO = GameObject.Find("Dictionary");
                    Dictionary dic  = dicO.GetComponent <Dictionary> ();

                    //if it is real
                    if (dic.RealWord(current))
                    {
                        score = score + GetScore(current);
                        AllWords.Add(current);
                        GameObject.Find("ScoreText").GetComponent <Text> ().text = "Score: " + score;
                        foreach (Letter l in LastLetters)
                        {
                            l.GetComponent <Renderer> ().material = Green;
                            l.finish(true);
                        }
                    }
                    //if not real word
                    else
                    {
                        foreach (Letter l in LastLetters)
                        {
                            l.GetComponent <Renderer> ().material = Red;
                            l.finish(false);
                        }
                    }
                    current = "";
                    LastLetters.Clear();
                    Destroy(GameObject.Find("Line(Clone)"));
                }
            }
            GameObject.Find("CurrentString").GetComponent <Text> ().text = current;

            if (time <= 0 && GameOver == false)
            {
                EndGame();
            }
        }
    }
Example #9
0
        public void Line_Should_Be_Four_Contiguous_Blocks()
        {
            var line = new LinePiece();

            Assert.IsTrue(line.IsFourContiguousBlocks);
        }
Example #10
0
        public void Start_Should_Create_Piece()
        {
            var line = new LinePiece();

            Assert.IsTrue(line.IsFourContiguousBlocks);
        }