示例#1
0
    void UpdateShipScroll(int i = 0)
    {
        if (!Initialized)
        {
            Initialize();
        }
        //	OfficerRoles r = (OfficerRoles)i;

        int yOff     = -45;
        int interval = 1;

        foreach (GameObject g in ShipButtons)
        {
            Destroy(g);
        }

        ShipButtons.Clear();
        foreach (StrategicShip d in ActiveEmpire.Ships)
        {
            GameObject g = Instantiate <GameObject> (ButtonPrefab) as GameObject;
            ShipButtons.Add(g);
            RectTransform     h       = g.GetComponent <RectTransform> ();
            ShipButtonManager manager = g.AddComponent <ShipButtonManager> ();
            manager.Manager = this;
            manager.Assign(d);
            h.SetParent(ShipScrollParent.transform);
            h.anchoredPosition3D = new Vector3(0f, yOff * interval, 0f);
            h.sizeDelta          = new Vector2(800f, 35f);
            h.localScale         = new Vector3(1f, 1f, 1f);
            interval++;
        }
    }
示例#2
0
    //Gets list of nearby ships and fleets
    void UpdateLocationScroll(int i = 0)
    {
        List <Fleet>         Fleets = new List <Fleet>();
        List <StrategicShip> Ships  = new List <StrategicShip> ();

        if (!Initialized)
        {
            Initialize();
        }

        int yOff     = -55;
        int interval = 1;

        foreach (GameObject g in LocationButtons)
        {
            Destroy(g);
        }

        LocationButtons.Clear();

        if (SelectedShip.ParentFleet != null)
        {
            GameObject g = Instantiate <GameObject> (ButtonPrefab) as GameObject;
            Fleets.Add(SelectedShip.ParentFleet);
            LocationButtons.Add(g);
            RectTransform      h       = g.GetComponent <RectTransform> ();
            FleetButtonManager manager = g.AddComponent <FleetButtonManager> ();
            manager.Manager = this;
            manager.Assign(SelectedShip.ParentFleet);
            h.SetParent(LocationsScroll.transform);
            h.anchoredPosition3D = new Vector3(0f, yOff * interval, 0f);
            h.sizeDelta          = new Vector2(800f, 35f);
            h.localScale         = new Vector3(1f, 1f, 1f);
            interval++;

            foreach (StrategicShip d in SelectedShip.ParentFleet.Ships)
            {
                Ships.Add(d);
                GameObject f = Instantiate <GameObject> (ButtonPrefab) as GameObject;
                LocationButtons.Add(f);
                RectTransform     hk       = f.GetComponent <RectTransform> ();
                ShipButtonManager sManager = f.AddComponent <ShipButtonManager> ();
                sManager.Manager = this;
                sManager.Assign(d);
                hk.SetParent(LocationsScroll.transform);
                hk.anchoredPosition3D = new Vector3(0f, yOff * interval, 0f);
                hk.sizeDelta          = new Vector2(800f, 35f);
                hk.localScale         = new Vector3(1f, 1f, 1f);
                interval++;
            }
        }

        StrategicShipyard yard = null;

        SelectedShip.Emp.Yards.ForEach(x => {
            if (x.DockedShips.Contains(SelectedShip))
            {
                yard = x;
            }
        });

        if (yard != null)
        {
            foreach (StrategicShip d in yard.DockedShips)
            {
                if (!Ships.Contains(d))
                {
                    Ships.Add(d);
                    GameObject g = Instantiate <GameObject> (ButtonPrefab) as GameObject;
                    LocationButtons.Add(g);
                    RectTransform     h       = g.GetComponent <RectTransform> ();
                    ShipButtonManager manager = g.AddComponent <ShipButtonManager> ();
                    manager.Manager = this;
                    manager.Assign(d);
                    h.SetParent(LocationsScroll.transform);
                    h.anchoredPosition3D = new Vector3(0f, yOff * interval, 0f);
                    h.sizeDelta          = new Vector2(800f, 35f);
                    h.localScale         = new Vector3(1f, 1f, 1f);
                    interval++;
                }
            }
            foreach (Fleet d in yard.DockedFleets)
            {
                if (!Fleets.Contains(d))
                {
                    Fleets.Add(d);
                    GameObject g = Instantiate <GameObject> (ButtonPrefab) as GameObject;
                    LocationButtons.Add(g);
                    RectTransform      h       = g.GetComponent <RectTransform> ();
                    FleetButtonManager manager = g.AddComponent <FleetButtonManager> ();
                    manager.Manager = this;
                    manager.Assign(d);
                    h.SetParent(LocationsScroll.transform);
                    h.anchoredPosition3D = new Vector3(0f, yOff * interval, 0f);
                    h.sizeDelta          = new Vector2(800f, 35f);
                    h.localScale         = new Vector3(1f, 1f, 1f);
                    interval++;
                }
            }
        }
    }