Пример #1
0
 void Update()
 {
     if (animating)
     {
         TokenGridRenderer.AnimateGrid();
     }
 }
Пример #2
0
    public void Randomise(TokenTypes[] possibleTokens)
    {
        int rnd = Random.Range(0, possibleTokens.Length);

        type = possibleTokens[rnd];

        transform = TokenGridRenderer.CreateNewTokenTransform(position);

        //Debug.Log("=============================================== Spawned " + position + " Is Null? " + (TokenGridData.Grid[position.x, position.y].transform == null).ToString());
    }
Пример #3
0
    public static void SettleAndSpawnTokens()
    {
        for (int x = 0; x < GRID_SIZE; x++)
        {
            //We only need to ceck columns if there is deleted block in there.
            if (destroyedTokens[x] > 0)
            {
                //below the level on the Y axis is known to be all tokens
                //with no gaps. Tokens should be place at last token level
                int lastTokenLevel = 0;

                for (int y = 0; y < GRID_SIZE; y++)
                {
                    if (Grid[x, y].transform != null)
                    {
                        if (y == lastTokenLevel)
                        {
                            lastTokenLevel++;
                        }
                        else
                        {
                            SwapToken(new GridPos(x, y), new GridPos(x, lastTokenLevel));
                            lastTokenLevel++;
                        }
                    }

                    //this block has a null transform. generate a new one above the map
                    //to drop down
                    if (y >= GRID_SIZE - destroyedTokens[x])
                    {
                        //Debug.Log("=============================================== Try Spawn ");
                        Grid[x, y].Randomise(TokenGridManager.Level1);
                        Grid[x, y].transform.position = new Vector3(x, (GRID_SIZE + (y - (GRID_SIZE - destroyedTokens[x]))), 0);
                        TokenGridRenderer.AddToAnimationQueue(Grid[x, y]);
                    }
                }

                lastTokenLevel = 0;
            }

            destroyedTokens[x] = 0;
        }
    }
Пример #4
0
    public static void SwapToken(GridPos tp1, GridPos tp2)
    {
        TokenClass tk1v = TokenGridData.Grid[tp1.x, tp1.y];
        TokenClass tk2v = TokenGridData.Grid[tp2.x, tp2.y];

        tk1v.position = new GridPos(tp2.x, tp2.y);
        tk2v.position = new GridPos(tp1.x, tp1.y);

        TokenGridData.Grid[tp1.x, tp1.y] = tk2v;
        TokenGridData.Grid[tp2.x, tp2.y] = tk1v;

        if (tk1v.transform != null)
        {
            TokenGridRenderer.AddToAnimationQueue(tk1v);
        }

        if (tk2v.transform != null)
        {
            TokenGridRenderer.AddToAnimationQueue(tk2v);
        }

        TokenGridManager.animating = true;
    }