Beispiel #1
0
    private void OnDoneAction(FigureAction action)
    {
        switch (action)
        {
        case FigureAction.Deleted:
            Destroy(gameObject);
            break;

        case FigureAction.MovedUP:
            transform.SetSiblingIndex(transform.GetSiblingIndex() - 1);
            break;

        case FigureAction.MovedDown:
            transform.SetSiblingIndex(transform.GetSiblingIndex() + 1);
            break;

        case FigureAction.MoveFirsrt:
            transform.SetAsFirstSibling();
            break;

        case FigureAction.MoveLast:
            transform.SetAsLastSibling();
            break;
        }
    }
Beispiel #2
0
 void Start()
 {
     if (GetComponent<PlayerMove> ())
         playerMove = GetComponent<PlayerMove> ();
     figureAction = GetComponent<FigureAction>();
     jumpForce.x = jumpForce.z = 0f;
 }
Beispiel #3
0
    public bool CanBePlaced(GameObject figure, FigureAction action)
    {
        // first dh

        GameObject figureClone = Instantiate(figure);
        Vector2    pos         = figureClone.transform.position;

        pos.y -= MIN_DELTA_H;
        figureClone.transform.position = pos;

        action.setObject(figureClone);
        action.performAction();

        if (!CanFigureStay(figureClone))
        {
            Destroy(figureClone);
            return(false);
        }

        // second dh

        pos    = figureClone.transform.position;
        pos.y -= (MAX_DELTA_H - MIN_DELTA_H);
        figureClone.transform.position = pos;

        if (!CanFigureStay(figureClone))
        {
            Destroy(figureClone);
            return(false);
        }

        Destroy(figureClone);
        return(true);
    }
 protected override void NeedToAwake()
 {
     data = GetComponent<FigureData>();
     action = GetComponent<FigureAction>();
     if(this.GetComponent<PlayerMove>())
         playerMove = GetComponent<PlayerMove> ();
 }
Beispiel #5
0
 protected override void NeedToAwake()
 {
     action = GetComponent<FigureAction> ();
     nameHash.Intital ();
 }
Beispiel #6
0
 public void DoAction(FigureAction action) => DoneAction?.Invoke(action);
Beispiel #7
0
 public void InitialPicker(FigureData data,FigureAction action)
 {
     pickerData = data;
     pickerAction = action;
 }
        public bool CheckForNewMatches(IFigureItem[,] figureItemsTable, FigureAction figureAction)
        {
            bool result = false;
            int  matchesCount;
            int  boardSize_X = figureItemsTable.GetLength(0);
            int  boardSize_Y = figureItemsTable.GetLength(1);

            List <Vec2> itemsToSetEmpty = new List <Vec2>();

            for (int i = 0; i < boardSize_X; i++)
            {
                matchesCount = 0;
                for (int j = 1; j < boardSize_Y; j++)
                {
                    if (figureItemsTable[i, j - 1].FigureType == figureItemsTable[i, j].FigureType)
                    {
                        matchesCount++;
                        if (matchesCount >= 2)
                        {
                            switch (figureAction)
                            {
                            case FigureAction.ReplaceRandom:
                                figureItemsTable[i, j] = InstantiateItem();
                                break;

                            case FigureAction.SetEmpty:
                                if (matchesCount == 2)
                                {
                                    itemsToSetEmpty.Add(new Vec2(i, j - 2));
                                    itemsToSetEmpty.Add(new Vec2(i, j - 1));
                                }
                                itemsToSetEmpty.Add(new Vec2(i, j));
                                break;

                            default:
                                throw new System.NotImplementedException("CheckForNewMatches functions not implemented completely!");
                            }

                            result = true;
                        }
                    }
                    else
                    {
                        matchesCount = 0;
                    }
                }
            }

            for (int j = 0; j < boardSize_Y; j++)
            {
                matchesCount = 0;
                for (int i = 1; i < boardSize_X; i++)
                {
                    if (figureItemsTable[i - 1, j].FigureType == figureItemsTable[i, j].FigureType)
                    {
                        matchesCount++;
                        if (matchesCount >= 2)
                        {
                            switch (figureAction)
                            {
                            case FigureAction.ReplaceRandom:
                                figureItemsTable[i, j] = InstantiateItem();
                                break;

                            case FigureAction.SetEmpty:
                                if (matchesCount == 2)
                                {
                                    itemsToSetEmpty.Add(new Vec2(i - 1, j));
                                    itemsToSetEmpty.Add(new Vec2(i - 2, j));
                                }
                                itemsToSetEmpty.Add(new Vec2(i, j));
                                break;

                            default:
                                throw new System.NotImplementedException("CheckForNewMatches functions not implemented completely!");
                            }

                            result = true;
                        }
                    }
                    else
                    {
                        matchesCount = 0;
                    }
                }
            }

            itemsToSetEmpty = itemsToSetEmpty.Distinct().ToList();

            foreach (var item in itemsToSetEmpty)
            {
                figureItemsTable[item.x, item.y].SetEmpty();
                Moves.Enqueue("b" + item.x + "," + item.y + "_c0,0");
            }

            return(result);
        }