Пример #1
0
        public PopupBaseHex getBaseHex()
        {
            GameObject   obj      = Instantiate(prefabBaseHex) as GameObject;
            PopupBaseHex specific = obj.GetComponent <PopupBaseHex>();

            return(specific);
        }
Пример #2
0
        public void setup(World world, Map map)
        {
            this.world = world;
            this.map   = map;

            //Scale 1 is for x = 48, y = 32
            float scale = 1;

            float s1 = 48f / map.sizeX;
            float s2 = 32f / map.sizeY;

            scale = Math.Min(s1, s2);


            float ox = 10;
            float oy = 4f;

            if (s2 > s1)
            {
                oy *= s1 / s2;
            }

            scale *= 0.9f;
            float stepx = 0.35f * scale;
            float stepy = 0.3f * scale;

            ox = (map.sizeX / 2) * stepx;



            PopupBaseHex hidden = world.prefabStore.getBaseHex();

            hidden.sprite.color = new Color(255, 0, 0, 0);
            midpoint            = hidden.gameObject;

            hexes = new PopupBaseHex[map.sizeX, map.sizeY];
            for (int i = 0; i < map.sizeX; i++)
            {
                for (int j = 0; j < map.sizeY; j++)
                {
                    PopupBaseHex hex = world.prefabStore.getBaseHex();
                    hex.sprite.color         = new Color(0, 0, 0, 0);
                    hexes[i, j]              = hex;
                    hex.transform.localScale = new Vector3(0.25f * scale, 0.25f * scale, 1f);
                    hex.transform.SetParent(midpoint.transform);

                    float lx = ox - (stepx * i);
                    float ly = oy - (stepy * j);
                    if (j % 2 == 0)
                    {
                        lx -= stepx * 0.5f;
                    }
                    hex.transform.localPosition = new Vector3(lx, ly, -0.1f);
                }
            }

            world.ui.setToBackground();
        }