Exemple #1
0
    public void CreateWaterColumn(int row, int col, WaterColumn.WaterType type)
    {
        GameObject obj = Instantiate(Resources.Load("Prefabs/waterColumn") as GameObject);

        Vector3 position = new Vector3(col * GameConst.tileWidth + GameConst.tileWidth / 2,
                                       -(row * GameConst.tileHeight + GameConst.tileHeight / 2),
                                       transform.position.z);

        obj.transform.position = position;
        WaterColumn waterColumn = obj.gameObject.GetComponent <WaterColumn>();

        waterColumn.setType(type);
        waterColumn.col = col;
        waterColumn.row = row;
        GameConst.waterColumns[row, col] = waterColumn;
    }
Exemple #2
0
    public void FindLoop(ref PreWaterNode[,] vector, int row, int col, WaterColumn.WaterType type1, WaterColumn.WaterType type2, int type)
    {
        int index = 0;
        int col_  = col;
        int row_  = row;

        while (index < power)
        {
            if (type == 0)
            {
                row_ -= 1;
                if (row_ < 0)
                {
                    break;
                }
            }
            else if (type == 1)
            {
                col_ += 1;
                if (col_ >= GameConst.width)
                {
                    break;
                }
            }
            else if (type == 2)
            {
                row_ += 1;
                if (row_ >= GameConst.height)
                {
                    break;
                }
            }
            else
            {
                col_ -= 1;
                if (col_ < 0)
                {
                    break;
                }
            }
            PreWaterNode node = vector[row_, col_];
            if (node == null)
            {
                node     = new PreWaterNode();
                node.row = row_;
                node.col = col_;
                //mid
                if (index < power - 1)
                {
                    node.type = type1;
                }
                //end
                else
                {
                    node.type = type2;
                }
                vector[row_, col_] = node;
                if (GameConst.sceneObstacles[row_, col_] != null)
                {
                    node.isObstacle = true;
                    node.isBubble   = false;
                }
                else if (GameConst.bubbles[row_, col_] != null)
                {
                    node.isObstacle = false;
                    node.isBubble   = true;
                    Bubble bubble = GameConst.bubbles[row_, col_];
                    node.type = WaterColumn.WaterType.Center;
                    bubble.find(ref vector);
                }
                else
                {
                    node.isObstacle = false;
                    node.isBubble   = false;
                }
            }
            else
            {
                if (index < power - 1)
                {
                    node.type = type1;
                }
            }

            if (GameConst.sceneObstacles[row_, col_] != null)
            {
                Block block = GameConst.sceneObstacles[row_, col_].GetComponent <Block>();
                if (block == null)
                {
                    break;
                }
                else if (!canWall)
                {
                    break;
                }
            }
            index++;
        }
    }