示例#1
0
    void ViewBlockColor()
    {
        Array ary = System.Enum.GetValues(typeof(BLOCKCOLOR));
        int   len = ary.Length;

        EditorGUILayout.LabelField("BLOCKCOLOR", GUILayout.Width(90));

        for (int i = 0; i < len; i++)
        {
            int    enumVal  = (int)ary.GetValue(i);
            string enumName = System.Enum.GetName(typeof(BLOCKCOLOR), enumVal);

            if (GUILayout.Button(enumName, EditorStyles.miniButton, GUILayout.Width(120)))
            {
                if (m_SelectBlock != null)
                {
                    BlockHive info = m_SelectBlock.GetComponent <BlockHive>();
                    if (info != null)
                    {
                        info.SetBlockColor((BLOCKCOLOR)enumVal);
                    }
                }
            }
        }
    }
示例#2
0
    public void LoadBlock(Map.SAVEBLOCKDATA SaveMapdata, bool InGameLoad = false)
    {
        row = SaveMapdata.row;
        col = SaveMapdata.col;

        blocks = new GameObject[row * col];

        Transform go_parent = this.gameObject.transform;

        float xposInterval = Mathf.Sqrt(BLOCKWIDTH / 2);
        float startxpos    = (row * xposInterval) / 2 * -1 + (xposInterval / 2);
        float startypos    = (row * BLOCKHEIGHT) / 2;
        float halfheight   = BLOCKHEIGHT / 2;

        for (int r = 0; r < row; r++)
        {
            for (int c = 0; c < col; c++)
            {
                if (InGameLoad)
                {
                    if (SaveMapdata.blocks[(r * row) + (c)].type == Map.BLOCKTYPPE.NONE)
                    {
                        blocks[(r * row) + (c)] = null;
                        continue;
                    }
                }
                GameObject HiveGo = Instantiate <GameObject>(Resources.Load <GameObject>(BlockHivePath));
                HiveGo.transform.parent        = go_parent;
                HiveGo.transform.localPosition = Vector3.zero;
                float xpos = startxpos + (xposInterval * r);
                HiveGo.name = ((r * row) + c).ToString();
                int yInterval = r % 2;

                float ypos = startypos - (BLOCKHEIGHT * c) - (halfheight * yInterval);
                HiveGo.transform.localPosition = new Vector3(xpos, ypos, 0);

                blocks[(r * row) + (c)] = HiveGo;

                GameObject BlockGo = Instantiate <GameObject>(Resources.Load <GameObject>(BlockObjPath));

                BlockHive hive = HiveGo.GetComponent <BlockHive>();
                hive.SetBlockObject(BlockGo);
                hive.SetBlockColor(SaveMapdata.blocks[(r * row) + (c)].color);
                hive.SetBlockType(SaveMapdata.blocks[(r * row) + (c)].type);

                if (Game.instance != null)
                {
                    Game.instance.BlockPool.AddObjectNuse(BlockGo);
                }
            }
        }
    }
示例#3
0
    IEnumerator CreateBlock()
    {
        while (true)
        {
            if (CreateBlockCount == 0)
            {
                break;
            }
            if (DropAnimaionCount == 0)
            {
                GameObject go = BlockPool.GetPool();

                BlockHive hiveinfo = CreateBlockPosition[0].GetComponent <BlockHive>();
                hiveinfo.SetBlockObject(go);
                hiveinfo.SetBlockType(Map.BLOCKTYPPE.BLOCK);
                hiveinfo.SetBlockColor((Map.BLOCKCOLOR)GetRandoomColor());
                go.transform.parent        = CreateBlockPosition[0].transform;
                go.transform.localPosition = Vector3.zero;
                go.SetActive(true);

                CreateBlockCount--;

                DropBlock();
                while (true)
                {
                    if (DropAnimaionCount == 0)
                    {
                        if (!WaterDrop())
                        {
                            break;
                        }
                    }
                    yield return(null);
                }

                MatchCheck();

                if (CreateBlockCount <= 0)
                {
                    break;
                }
            }

            yield return(null);
        }

        MoveDisAble = false;
    }