Esempio n. 1
0
    private void DrawBlockSet(BlockSet blockSet)
    {
        GUILayout.BeginVertical(GUI.skin.box);

        int oldSelectedBlock = selectedBlock;

        selectedBlock = BlockSetViewer.SelectionGrid(blockSet, selectedBlock, GUILayout.MinHeight(200), GUILayout.MaxHeight(300));
        if (selectedBlock != oldSelectedBlock)
        {
            GUIUtility.keyboardControl = 0;
        }

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        foreach (Type type in blockTypes)
        {
            string name = type.ToString();
            if (name.EndsWith("Block"))
            {
                name = name.Substring(0, name.Length - 5);
            }
            if (GUILayout.Button(name))
            {
                Block newBlock = (Block)System.Activator.CreateInstance(type);
                newBlock.SetName("New " + type.ToString());
                newBlock.Init(blockSet);

                Block[] blocks = blockSet.GetBlocks();
                ArrayUtility.Add <Block>(ref blocks, newBlock);
                blockSet.SetBlocks(blocks);
                selectedBlock = blocks.Length - 1;
                EditorGUIUtility.keyboardControl = 0;
                GUI.changed = true;
            }
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Remove"))
        {
            Block[] blocks = blockSet.GetBlocks();
            ArrayUtility.RemoveAt <Block>(ref blocks, selectedBlock);
            blockSet.SetBlocks(blocks);
            selectedBlock = Mathf.Clamp(selectedBlock, 0, blocks.Length - 1);
            GUI.changed   = true;
        }

        GUILayout.EndVertical();
    }
Esempio n. 2
0
    private void DrawBlockSet(BlockSet blockSet)
    {
        GUILayout.BeginVertical(GUI.skin.box);

        Block oldSelectedBlock = selectedBlock;

        selectedBlock = BlockSetViewer.SelectionGrid(blockSet, selectedBlock, GUILayout.MinHeight(200), GUILayout.MaxHeight(300));

        if (selectedBlock != oldSelectedBlock)
        {
            GUIUtility.keyboardControl = 0;
        }

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("New Block"))
        {
            Block newBlock = (Block)Activator.CreateInstance(typeof(Block));
            newBlock.Name = "NewBlock";
            blockSet.Blocks.Add(newBlock);

            EditorGUIUtility.keyboardControl = 0;
            GUI.changed = true;
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Remove"))
        {
            blockSet.Blocks.Remove(selectedBlock);
            GUI.changed = true;
        }

        if (GUILayout.Button("Force Save"))
        {
            EditorUtility.SetDirty(blockSet);
        }

        GUILayout.EndVertical();
    }
Esempio n. 3
0
        private void HostGotNextBlockSet(object sender, EventArgs e)
        {
            List <BlockSet> QueueList = Host.BlockSetQueueList;

            QueueViewer.Children.Clear();

            int minus = (int)Host.Difficulty;
            int count = 0;

            foreach (BlockSet bs in QueueList)
            {
                count++;
                if (count >= QueueList.Count - minus)
                {
                    break;
                }
                BlockSetViewer bsv = new BlockSetViewer()
                {
                    BlockSet = bs,
                    Margin   = new Thickness(5)
                };
                QueueViewer.Children.Add(bsv);
            }
        }
Esempio n. 4
0
    private void DrawBlockSet(BlockSet blockSet)
    {
        if (GUILayout.Button("Refresh Indexes"))
        {
            Block[] blocks = blockSet.GetBlocks();
            for (int i = 0; i < blocks.Length; ++i)
            {
                blocks[i].Index = i;
            }
            blockSet.SetBlocks(blocks);
        }
        GUILayout.BeginVertical(GUI.skin.box);

        int oldSelectedBlock = selectedBlock;

        selectedBlock = BlockSetViewer.SelectionGrid(blockSet, selectedBlock, GUILayout.MinHeight(200), GUILayout.MaxHeight(300));
        if (selectedBlock != oldSelectedBlock)
        {
            GUIUtility.keyboardControl = 0;
        }

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        foreach (Type type in blockTypes)
        {
            string name = type.ToString();
            if (name.EndsWith("Block"))
            {
                name = name.Substring(0, name.Length - 5);
                if (GUILayout.Button(name))
                {
                    Block newBlock = (Block)System.Activator.CreateInstance(type);
                    newBlock.SetName("New " + type.ToString());
                    newBlock.Init(blockSet);

                    Block[] blocks = blockSet.GetBlocks();
                    newBlock.Index = blocks.Length;
                    ArrayUtility.Add <Block>(ref blocks, newBlock);
                    blockSet.SetBlocks(blocks);
                    selectedBlock = blocks.Length - 1;
                    EditorGUIUtility.keyboardControl = 0;
                    GUI.changed = true;
                }
            }
            else if (name.EndsWith("Item"))
            {
                name = name.Substring(0, name.Length - 5);
                if (GUILayout.Button(name))
                {
                    Item newItem = (Item)System.Activator.CreateInstance(type);
                    newItem.SetName("New " + type.ToString());
                    newItem.Init(blockSet);

                    Item[] items = blockSet.GetItems();
                    newItem.Index = blockSet.GetBlockCount() + items.Length;
                    ArrayUtility.Add <Item>(ref items, newItem);
                    blockSet.SetItems(items);
                    selectedBlock = items.Length - 1 + blockSet.GetBlockCount();
                    EditorGUIUtility.keyboardControl = 0;
                    GUI.changed = true;
                }
            }
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Remove"))
        {
            if (selectedBlock < blockSet.GetBlockCount())
            {
                Block[] blocks = blockSet.GetBlocks();
                ArrayUtility.RemoveAt <Block>(ref blocks, selectedBlock);
                blockSet.SetBlocks(blocks);
                selectedBlock = Mathf.Clamp(selectedBlock, 0, blocks.Length - 1);
                GUI.changed   = true;
            }
            else if (selectedBlock >= blockSet.GetBlockCount())
            {
                Item[] items = blockSet.GetItems();
                ArrayUtility.RemoveAt <Item>(ref items, selectedBlock - blockSet.GetBlockCount());
                blockSet.SetItems(items);
                selectedBlock = Mathf.Clamp(selectedBlock, 0, items.Length - 1 + blockSet.GetBlockCount());
                GUI.changed   = true;
            }
        }

        GUILayout.EndVertical();
    }
Esempio n. 5
0
 void Start()
 {
     viewer = GetComponent <BlockSetViewer>();
     viewer.SetBlockSet(blockSetList[index]);
 }