Пример #1
0
 public void CreateScheme(UIScheme scheme)
 {
     if (CurrentScheme != null)
     {
         CurrentScheme.DestroyThis();
     }
     CurrentScheme = scheme;
     mSaveButton.gameObject.SetActive(true);
     mIOGroupButton.gameObject.SetActive(true);
 }
Пример #2
0
    public void LoadScheme(string type)
    {
        if (CurrentScheme != null)
        {
            CurrentScheme.DestroyThis();
        }

        var builder = (SchemeManager.Instance.GetBuildingRule(type) as UISchemeBuilder).Clone();

        CurrentScheme = builder.BuildUIScheme();
        mSaveButton.gameObject.SetActive(true);
        mIOGroupButton.gameObject.SetActive(true);
    }
Пример #3
0
    IEnumerator StartAnotherTestCoroutine()
    {
        yield return(new WaitForEndOfFrame());

        var schameName = "AND";
        var input1     = "A";
        var input2     = "B";
        var output     = "C";

        var nandName = "Nand";

        var notType = "NOT";
        var notName = "Not";

        var notInput  = "Input";
        var notOutput = "Output";

        var scheme = new UIScheme(new UISelfSchemeBuildInfo(schameName), 3, 2, 4);

        SchemeDesigner.Instance.CreateScheme(scheme);

        var width  = IOSelfIOGroupDesign.MinCellWidth;
        var heigth = IOSelfIOGroupDesign.DefaultCellHeight;

        scheme.AddIOGroup(new UIIOGroupBuildInfo(
                              new IOGroupBuildString(input1, 1, IO.Input),
                              new Vector2(-200, -100),
                              new Vector2(width, heigth * 1)
                              ));
        scheme.AddIOGroup(new UIIOGroupBuildInfo(
                              new IOGroupBuildString(input2, 1, IO.Input),
                              new Vector2(-200, 100),
                              new Vector2(width, heigth * 1)
                              ));

        scheme.AddIOGroup(new UIIOGroupBuildInfo(
                              new IOGroupBuildString(output, 1, IO.Output),
                              new Vector2(200, 0),
                              new Vector2(width, heigth * 1)
                              ));

        scheme.AddScheme(new UIInnerSchemeBuildInfo(nandName, NAND.Type, null, Vector2.left * 50, Vector2.one * 240));
        scheme.AddScheme(new UIInnerSchemeBuildInfo(notName, notType, null, Vector2.right * 50, Vector2.one * 240));

        scheme.AddLink(new LinkBuilder(schameName, nandName, input1, NAND.Input, 0, 1, 0, 1));
        scheme.AddLink(new LinkBuilder(schameName, nandName, input2, NAND.Input, 0, 1, 1, 1));
        scheme.AddLink(new LinkBuilder(nandName, notName, NAND.Output, notInput, 0, 1, 0, 1));
        scheme.AddLink(new LinkBuilder(notName, schameName, notOutput, output, 0, 1, 0, 1));

        yield break;
    }
Пример #4
0
    IEnumerator StartTestCoroutine()
    {
        yield return(new WaitForEndOfFrame());

        var input  = "Input";
        var output = "Output";
        var nand   = "Nand";
        var not    = "NOT";
        var log    = new Action <string>((message) => Console.Instance.Log(message));

        var scheme = new UIScheme(new UISelfSchemeBuildInfo(not), 2, 1, 2);

        SchemeDesigner.Instance.CreateScheme(scheme);

        var width  = IOSelfIOGroupDesign.MinCellWidth;
        var heigth = IOSelfIOGroupDesign.DefaultCellHeight;

        scheme.AddIOGroup(new UIIOGroupBuildInfo(
                              new IOGroupBuildString(input, 1, IO.Input),
                              new Vector2(-200, 0),
                              new Vector2(width, heigth * 1)
                              ));
        scheme.AddIOGroup(new UIIOGroupBuildInfo(
                              new IOGroupBuildString(output, 1, IO.Output),
                              new Vector2(200, 0),
                              new Vector2(width, heigth * 1)
                              ));

        scheme.AddScheme(new UIInnerSchemeBuildInfo(nand, NAND.Type, null, Vector2.zero, Vector2.one * 240));

        scheme.AddLink(new LinkBuilder(not, nand, input, NAND.Input, 0, 1, 0, 2));
        scheme.AddLink(new LinkBuilder(nand, not, NAND.Output, output, 0, 1, 0, 1));

        log(scheme.IOGroups[input].IOArray.Print());
        log(scheme.IOGroups[output].IOArray.Print());

        scheme.SetIO(input, Extensions.Array(true), 0, 1, 0, 1);

        log(scheme.IOGroups[input].IOArray.Print());
        log(scheme.IOGroups[output].IOArray.Print());

        scheme.SetIO(input, Extensions.Array(false), 0, 1, 0, 1);

        log(scheme.IOGroups[input].IOArray.Print());
        log(scheme.IOGroups[output].IOArray.Print());

        SchemeDesigner.Instance.SaveScheme();

        yield break;
    }
Пример #5
0
    public UIScheme BuildUIScheme()
    {
        var scheme = new UIScheme(SelfSchemeBuildInfo, (byte)IOGroupsInfo.Count, (byte)InnerSchemesBuildInfo.Count, (byte)LinksBuildInfo.Count);

        foreach (var ioGroup in IOGroupsInfo)
        {
            scheme.AddIOGroup(ioGroup);
        }

        foreach (var innerScheme in InnerSchemesBuildInfo)
        {
            scheme.AddScheme(innerScheme);
        }

        foreach (var link in LinksBuildInfo)
        {
            scheme.AddLink(link);
        }

        return(scheme);
    }