Esempio n. 1
0
    private void OnPatternDrag(Vector2 position, PatternScript pattern)
    {
        if (this._bActiveHammer)
        {
            return;
        }

        Vector3 pos = Camera.main.ScreenToWorldPoint(new Vector3(position.x, position.y));

        Vector2 position2 = pattern.transform.parent.InverseTransformPoint(pos);

        pattern.UpdatePosDrag(position2);

        Vector2 p = pattern.GetPositionTriangleCenter();

        PointerEventData pointer = new PointerEventData(EventSystem.current);

        pointer.position = Input.mousePosition;
        List <RaycastResult> raycastResults = new List <RaycastResult>();

        EventSystem.current.RaycastAll(pointer, raycastResults);

        if (raycastResults.Count != 0)
        {
            Debug.LogError("Length = " + raycastResults.Count);
            TriangelScript component = getTriangel(raycastResults);// array[0].collider.GetComponent<TriangelScript>();
            if (component != null)
            {
                int row = component.Row;
                int col = component.Col;
                if (this._nChoseRow == row && this._nChoseCol == col)
                {
                    return;
                }
                this._bAllowAddPattern = false;
                this._nChoseRow        = row;
                this._nChoseCol        = col;
                this._listMapping      = pattern.GetListMapping(this._nChoseRow, this._nChoseCol);
                this.DebugLisMapping(this._listMapping);
                this._bAllowAddPattern = this.CheckAllowAddPattern(this._listMapping, pattern.Color);
                if (this._bAllowAddPattern)
                {
                    this.ClearHint();
                    this.GetListHint(this._listMapping);
                    this.ShowHint(pattern.Color);
                }
                else
                {
                    this.ClearHint();
                }
            }
        }
        else
        {
            this._nChoseRow = -1;
            this._nChoseCol = -1;
            this.ClearHint();
        }
    }
Esempio n. 2
0
    void Awake()
    {
        patternScript = GetComponent <PatternScript>();

        if (patternScript == null)
        {
            Debug.LogError("No patternScript found!");
        }
    }
Esempio n. 3
0
    public void RecordPattern(PatternScript patt)
    {
        myCode += patt.gameObject.name;
        Vector2 myPos = patt.transform.position;

        line.SetPosition(line.positionCount - 1, myPos);
        line.positionCount++;
        activatedPatterns.Add(patt);
    }
Esempio n. 4
0
 private void OnPatternBeginDrag(Vector2 position, PatternScript pattern)
 {
     if (this._bActiveHammer)
     {
         return;
     }
     this._nChoseRow             = -1;
     this._nChoseCol             = -1;
     this._bAllowAddPattern      = false;
     this._bCreateSpecialPattern = false;
     //SoundManager.GetInstance().PlaySelectBlock();
 }
Esempio n. 5
0
    public void GenerateLevel()
    {
        for (int i = 0; i < HowManyPatterns; i++)
        {
            //There are two indicators that indicate bottom and top level of the pattern.
            //We're going to first find the localposition of the bottom and add it to the offset
            GameObject    p  = Patterns[Random.Range(0, Patterns.Length)];
            PatternScript ps = p.GetComponent <PatternScript>();
            Offset += Mathf.Abs(ps.GetBottomPositionOffset().y); //add bottom offset
            Vector3 offsetVector = new Vector3(0, Offset, 0);
            Instantiate(p, InitialPoint.position + offsetVector, Quaternion.identity);
            Offset += ps.GetTopPositionOffset().y; //add top offset
            //Give 2 extra units of offset
            Offset += 2.0f;
        }
        //Little bit of extra offset
        Offset += 3.0f;
        Vector3 goalPos = new Vector3(0, Offset, 0);

        Instantiate(Goal, goalPos, Quaternion.identity);
    }
Esempio n. 6
0
    private void OnPatternEndDrag(Vector2 position, PatternScript pattern)
    {
        if (this._bActiveHammer)
        {
            return;
        }
        position = pattern.GetPositionTriangleCenter();
        RaycastHit[] array = Physics.RaycastAll(new Vector3(position.x, position.y, -1f), Vector3.forward, 1000f, LayerMask.GetMask(new string[]
        {
            "Triangle"
        }));

        PointerEventData pointer = new PointerEventData(EventSystem.current);

        pointer.position = Input.mousePosition;
        List <RaycastResult> raycastResults = new List <RaycastResult>();

        EventSystem.current.RaycastAll(pointer, raycastResults);

        this.ClearHint();
        if (raycastResults.Count != 0)
        {
            TriangelScript component = getTriangel(raycastResults);// array[0].collider.GetComponent<TriangelScript>();
            if (component != null)
            {
                this._nChoseRow   = component.Row;
                this._nChoseCol   = component.Col;
                this._listMapping = pattern.GetListMapping(this._nChoseRow, this._nChoseCol);
                this.DebugLisMapping(this._listMapping);
                this._bAllowAddPattern = this.CheckAllowAddPattern(this._listMapping, pattern.Color);
                if (this._bAllowAddPattern)
                {
                    this.GetListHint(this._listMapping);
                    this.ShowPatternTriangle(pattern.Color, this._listHint);
                    List <PosMap> list = this._algorithmCheckHexa.CheckHexa(this._listHint, this._mapData, pattern.TypePattern);
                    int           num  = this.CaculateScore(pattern.NumberTriangle, list.Count, pattern.Color, ref this._bCanGetDouble);
                    if (this._bCanGetDouble)
                    {
                        //this._bCreateSpecialPattern = this._specialPatternManager.CanCreateSpecial();
                    }
                    //this.PlayEffectGetScore(num, pattern.transform.position, pattern.Color);
                    //base.StartCoroutine("ClearPatternTriangle", list);
                    // this.CheckTransferColor();
                    pattern.DestroyPattern();
                    //base.StartCoroutine("DelayCheckOutOfMove");
                    //Messenger.Broadcast<bool>(Constant.MsgCanUseHammer, this.CanUseHammer());
                    this.testCreate();
                    //this.AddNewPattern(pattern.IndexInPanel, this._bCreateSpecialPattern);
                    //if (num >= 60)
                    //{
                    //    SoundManager.GetInstance().PlayAfterScore();
                    //}
                }
                else
                {
                    //this.ResetPosPattern(pattern);
                }
            }
        }
        else
        {
            //this.ResetPosPattern(pattern);
        }
    }