Пример #1
0
    public ShipHullScrollList(Rect rect, HullListEntry.ButtonPress changeHullCallBack, CheckHullValid checkHulls)
    {
        ScrollWindowRect = rect;
        ScrollViewRect   = new Rect(0, 0, ScrollWindowRect.width * 0.92f, ScrollWindowRect.height * 1.02f);
        ScrollPosition   = Vector2.zero;

        HullList.Clear();
        float EntrySize = ScrollViewRect.width / 5f;
        int   index     = 0;

        foreach (KeyValuePair <string, ShipHullData> keyVal in ResourceManager.GetShipHulls())
        {
            if (checkHulls(keyVal.Value))
            {
                Rect          entryRect = new Rect(EntrySize * (HullList.Count % 5), EntrySize * (HullList.Count / 5), EntrySize, EntrySize);
                HullListEntry HLE       = new HullListEntry(entryRect, keyVal.Value, index, changeHullCallBack, ChangeSelectionIndex);
                HullList.Add(HLE);
                index++;
            }
        }

        ScrollViewRect.height = Mathf.Max(ScrollWindowRect.height * 1.02f, EntrySize * (HullList.Count / 5 + (HullList.Count % 5 != 0 ? 1 : 0)));
    }
Пример #2
0
    public FighterScrollList(Rect rect, FighterListEntry.ButtonPress changeFighterCallBack, CheckHullValid checkFighters)
    {
        ScrollWindowRect = rect;
        ScrollViewRect   = new Rect(0, 0, ScrollWindowRect.width * 0.92f, ScrollWindowRect.height * 1.02f);
        ScrollPosition   = Vector2.zero;

        FighterList.Clear();
        float EntrySize = ScrollViewRect.width / 5f;
        int   index     = 0;

        foreach (KeyValuePair <string, FighterDefinition> fighterDefinitions in ResourceManager.GetFighterDefinitions())
        {
            if (checkFighters(fighterDefinitions.Value))
            {
                Rect             entryRect = new Rect(EntrySize * (FighterList.Count % 5), EntrySize * (FighterList.Count / 5), EntrySize, EntrySize);
                FighterListEntry HLE       = new FighterListEntry(entryRect, fighterDefinitions.Value, index, changeFighterCallBack, ChangeSelectionIndex);
                FighterList.Add(HLE);
                index++;
            }
        }
        ScrollViewRect.height = Mathf.Max(ScrollWindowRect.height * 1.02f, EntrySize * (FighterList.Count / 5 + (FighterList.Count % 5 != 0 ? 1 : 0)));
    }