コード例 #1
0
    public static void Show(string[] menuItemsCaptions = null, float delay = 0)
    {
        Hide();

        if (menuItemsCaptions != null)
        {
            CurrentMenuSet = menuItemsCaptions;
        }

        panel = PanelWithChildren.Create <SelectableTextList> ();
        panel.gameObject.name    = "panel_MainMenu";
        panel.DelayBeforeShowing = delay;
        panel.Initialize(CurrentMenuSet);

        Utils.ProvideCanvas(panel.gameObject);
        RectTransform rt = panel.gameObject.transform as RectTransform;

        rt.SetParent(Design.visibleArea.transform);
        rt.offsetMin = offsetMin;
        rt.offsetMax = rt.offsetMin + new Vector2(itemSize.x, itemSize.y * panel.itemCount);

        panel.SetAligner_FixedTile(itemSize);
        panel.alignDirection = Aligner.AlignDirection.adTop;
        panel.Rebuild();

        panel.OnSelectItem = new UnityAction <string> (ExecuteAction);
    }
コード例 #2
0
    public static void Test_Pivot()
    {
        PanelWithChildren panel = Prepare();

        panel.SetAligner_Pivot();
        panel.Rebuild();
    }
コード例 #3
0
        private void Update()
        {
            PanelWithChildren panel = gameObject.GetComponent <PanelWithChildren> ();

            if (Input.GetMouseButtonDown(0))
            {
                panel.alignDirection = (Aligner.AlignDirection)((int)(panel.alignDirection + 1) % System.Enum.GetNames(typeof(Aligner.AlignDirection)).Length);
                Debug.Log(panel.alignDirection);
                panel.Rebuild();
            }

            if (Input.GetMouseButtonDown(1))
            {
                panel.inverted = !panel.inverted;
                Debug.Log(panel.inverted);
                panel.Rebuild();
            }

            if (Input.GetMouseButtonDown(2))
            {
                RectTransform rt = this.gameObject.transform as RectTransform;
                Debug.Log(panel.inverted);
                rt.offsetMax *= 1.1f;
                panel.Rebuild();
            }
        }
コード例 #4
0
    public static void Test_AdaptiveTile()
    {
        PanelWithChildren panel = Prepare();

        panel.SetAligner_AdaptiveTile(5, 3);
        panel.Rebuild();
    }
コード例 #5
0
    public static void Test_FixedTile()
    {
        PanelWithChildren panel = Prepare();

        panel.SetAligner_FixedTile(new Vector2(0.5f, 0.75f));
        panel.Rebuild();
    }
コード例 #6
0
ファイル: StageInfo.cs プロジェクト: scythae/Shmup
    private static new StageInfo Create()
    {
        StageInfo result = PanelWithChildren.Create <StageInfo> ();

        result.gameObject.name = "panel_StageInfo";

        RectTransform rt = result.gameObject.transform as RectTransform;

        rt.offsetMin = new Vector2(6, 0);
        rt.offsetMax = new Vector2(8, 6);

        result.items = new List <GameObject> ();

        result.LiScore = CreateScore();
        result.items.Add(result.LiScore.gameObject);

        result.LiHitPoints = CreateHitPoints();
        result.items.Add(result.LiHitPoints.gameObject);

        result.buffCaption = CreateBuffCaption();
        result.items.Add(result.buffCaption.gameObject);

        result.buffZone = BuffZone.Create();
        result.items.Add(result.buffZone.gameObject);

        result.alignDirection = Aligner.AlignDirection.adTop;
        result.SetAligner_Pivot();
        result.Rebuild();

        return(result);
    }
コード例 #7
0
    private static PanelWithChildren Prepare()
    {
        PanelWithChildren panel = PanelWithChildren.Create();

        panel.gameObject.AddComponent <AlignIterator> ();

        panel.items = new List <GameObject> ();
        for (int i = 0; i < 10; i++)
        {
            panel.items.Add(CreateChild());
        }
        return(panel);
    }
コード例 #8
0
ファイル: BuffZone.cs プロジェクト: scythae/Shmup
    public static new BuffZone Create()
    {
        BuffZone result = PanelWithChildren.Create <BuffZone> ();

        RectTransform rt = result.gameObject.transform as RectTransform;

        rt.offsetMax = rt.offsetMin + selfSize;

        result.SetAligner_FixedTile(itemSize);
        result.alignDirection = Aligner.AlignDirection.adTop;

        return(result);
    }
コード例 #9
0
ファイル: PanelWithChildren.cs プロジェクト: scythae/Shmup
    public void SetGrid(int linesCount, int tilesCountInLine, PanelWithChildren panel)
    {
        if (linesCount * tilesCountInLine == 0)
        {
            SetDefaultData();
            return;
        }

        this.linesCount       = linesCount;
        this.tilesCountInLine = tilesCountInLine;

        RectTransform rtp = panel.gameObject.transform as RectTransform;

        if (rtp == null)
        {
            return;
        }

        tileSize.x = Mathf.Max(0, rtp.rect.width / (float)tilesCountInLine - panel.spacing.x);
        tileSize.y = Mathf.Max(0, rtp.rect.height / (float)linesCount - panel.spacing.y);
    }
コード例 #10
0
ファイル: LabeledInformation.cs プロジェクト: scythae/Shmup
    public static new LabeledInformation Create()
    {
        LabeledInformation result = PanelWithChildren.Create <LabeledInformation>();

        result.gameObject.name = "panel_LabeledInformation";

        result.SetAligner_AdaptiveTile(2, 1);
        result.alignDirection = Aligner.AlignDirection.adTop;

        result.items = new List <GameObject> ();

        GameObject item = Instantiate(Prefab.textItem);

        item.name       = "text_Caption";
        result.fCaption = item.GetComponent <Text> ();
        result.items.Add(item);

        item          = Instantiate(Prefab.textItem);
        item.name     = "text_Value";
        result.fValue = item.GetComponent <Text> ();
        result.items.Add(item);

        return(result as LabeledInformation);
    }