Ejemplo n.º 1
0
    void touchJumpTile()
    {
        //버튼을 누르고 있으면
        if (Input.GetMouseButton(0))
        {
            //게임종료 상황이 아니면(종료시 터치 막힘)
            if (!EventSystem.current.IsPointerOverGameObject())
            {
                //어떤 오브젝트를 터치했는지 알아내서
                Vector2      touchPos       = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                RaycastHit2D hitInformation = Physics2D.Raycast(touchPos, Camera.main.transform.forward);
                if (hitInformation.collider != null)
                {
                    GameObject touchedObject = hitInformation.transform.gameObject;
                    Vector3    pos           = touchedObject.transform.position;

                    string key = pos.x.ToString() + "," + pos.y.ToString();
                    if (board.getJump(key) && touchAble(pos))
                    {
                        // bangObj.transform.localScale = new Vector3(0.6f, 0.6f, 0);
                        Instantiate(bangObj, pos, Quaternion.identity);
                        // bangObj.transform.localScale = new Vector3(1f, 1f, 0);
                        guideText.deleteMessage("터치가 이어져야 한다찌!");
                        touchedObject.transform.GetChild(0).gameObject.SetActive(false);
                        board.putTileInTouchList(key);  //첫번째터치는 완료된 셈이므로 터치리스트에 넣어준다.
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    //뒤로가기
    public void revokeTouch()
    {
        //마지막으로 터치한 타일의 키를 구해서
        string key = touchList[touchList.Count - 1];

        if (!getJump(key))
        {
            //터치를 false로
            m_TilesDictionary[key].touched = false;
            renewPos(key);
        }
        else                                            //취소한애가 점프타일위치에 있는 애면
        {
            if (m_TilesDictionary[key].touched)         // 2번터치->1번터치
            {
                m_TilesDictionary[key].touched = false; //터치를 false로
                renewPos(key);
            }
            else  //1번터치->0번터치 (점프타일 되돌리기)
            {
                m_TilesDictionary[key].transform.GetChild(0).gameObject.SetActive(true);
                m_TilesDictionary[key].touched  = false;
                m_TilesDictionary[key].jumpTile = true;
                renewPos(key);
            }
        }
        //테두리를 없애주고
        m_TilesDictionary[touchList[touchList.Count - 1]].setLastPosF();
        //터치리스트에서 삭제
        touchList.RemoveAt(touchList.Count - 1);
        //새로운 마지막터치타일에 테두리
        if (touchList.Count != 0)
        {
            m_TilesDictionary[touchList[touchList.Count - 1]].setLastPosT();
        }

        //취소한애가 색타일이었으면  ColorSeq--
        if (getTouchCol(key))
        {
            m_SeqTilesDictionary[ColorSeq].gameObject.SetActive(true);
            m_SeqTilesDictionary[ColorSeq].touched = false;
            ColorSeq--;
            ColorTouchList.RemoveAt(ColorTouchList.Count - 1);
            //취소로 인해 색타일 터치순서가 올바르게 되었으면 경고 메세지 없앰
            if (checkColorSeq())
            {
                guideText.deleteMessage("순서가 틀렸다찌!");
            }
        }
        //취소한 색에 해당되는 쌓인타일이 없어졌는지 안없어졌는지 체크-없어졌던애면 다시만들기
    }
Ejemplo n.º 3
0
    //믹스타일의 위치 파악
    // void findMixKey()
    // {
    //     board.colorPos[];
    // }
    //색 칠할수 있는지 체크 함수
    bool touchAble(Vector3 pos, GameObject touchedObject)
    {
        if (board.getStartOrNot())
        {
            string start = board.getStart();
            int    x     = int.Parse(start.Substring(0, 1));
            int    y     = int.Parse(start.Substring(2, 1));
            if (pos.x == x && pos.y == y)
            {
                guideText.deleteMessage("첫 터치는 시작점부터다찌!");
                return(true);
            }
            else
            {
                guideText.addMessage("첫 터치는 시작점부터다찌!");
                return(false);
            }
        }
        //초기상태가 아닐경우
        else
        {
            string key = pos.x.ToString() + "," + pos.y.ToString();

            //한번 터치한 타일을 중복터치 불가능
            if (board.getChecked(key))
            {
                return(false);
            }
            else if (board.getJump(key) && board.touchJumpCount(key) == 0) //점프타일 위치이고, 점프속성을 가지고 있는 상태이면
            {
                if (miniTouchAble(pos, touchedObject))
                {
                    Lastpos  = pos;   //라스트포지션을 해당위치로 갱신
                    jumpTile = false; //이제 더이상 점프타일 속성을 갖지 않음...
                }
                return(false);
            }

            //
            else if (board.getMix(key) && board.touchJumpCount(key) == 0)
            {
                if (miniTouchAble(pos, touchedObject))
                {
                    Lastpos = pos; //위치갱신
                    board.colorTouch(key);
                    board.putTileInTouchList(key);
                    GameObject child = board.m_TilesDictionary[key].transform.GetChild(1).gameObject;
                    render = child.GetComponent <SpriteRenderer>();
                    Color color;
                    ColorUtility.TryParseHtmlString("#A6A6A6", out color);
                    render.color = color;
                }
                return(false);
            }

            else
            {
                //가장 마지막으로 터치한 타일의 위, 아래, 옆만 터치 가능.
                if ((Lastpos.x == pos.x - 1) && (Lastpos.y == pos.y))
                {
                    return(true);
                }
                else if ((Lastpos.x == pos.x + 1) && (Lastpos.y == pos.y))
                {
                    return(true);
                }
                else if ((Lastpos.x == pos.x) && (Lastpos.y == pos.y - 1))
                {
                    return(true);
                }
                else if ((Lastpos.x == pos.x) && (Lastpos.y == pos.y + 1))
                {
                    return(true);
                }
                else
                {
                    //믹스타일에서 똑같은거 연속터치했을때 경고 안뜨게 if문
                    if (board.touchJumpCount(key) == 0)
                    {
                        guideText.addMessage("터치가 이어져야 한다찌!");
                    }

                    return(false);
                }
            }
        }
    }