Ejemplo n.º 1
0
        public void Create(int X, int Y)
        {
            sizeX = X;
            sizeY = Y;
            map   = new MapCompositeItem[sizeX * sizeY];
            int x = 0;
            int y = 0;

            for (int i = 0; i < sizeX * sizeY; i++)
            {
                int fg = 0;
                if (Random.value > 0.8)
                {
                    fg = 3;
                }
                int   d     = 0;
                float scale = 1f / sizeX * 13f;
                if (Mathf.PerlinNoise(x * scale, y * scale) > 0.5)
                {
                    d = 3;
                }
                map[i] = new MapCompositeItem(Random.Range(1 + d, 3 + d), fg, 0);
                x++;
                if (x >= sizeX - 1)
                {
                    x = 0;
                    y++;
                }
            }
        }
Ejemplo n.º 2
0
 public void Attach(MapCompositeItem mci)
 {
     if (items == null)
     {
         return;
     }
     for (int i = 0; i < items.Length; i++)
     {
         items[i].sr.sprite             = mci.items[i].getSprite();
         items[i].sr.color              = mci.items[i].color;
         items[i].go.transform.rotation = Quaternion.Euler(0, 0, mci.items[i].rotation);
     }
 }
Ejemplo n.º 3
0
        // Update is called once per frame

        void UpdateColorBackground()
        {
            if (currentItem != null)
            {
                currentItem.items[MapCompositeItem.BACKGROUND].color = Color.white;
            }
            currentItem = currentLevel.map.get((int)targetPos.x, (int)targetPos.y);

            if (currentItem != null)
            {
                currentItem.items[MapCompositeItem.BACKGROUND].color = new Color(0.45f, 0.8f, 1.5f);
            }
        }
Ejemplo n.º 4
0
        public void Update(float ci, float cj)
        {
            parent.transform.position = new Vector3(-(ci - Mathf.Floor(ci)) * dx, -(cj - Mathf.Floor(cj)) * dy, 0);

            for (int i = 0; i < sizeX; i++)
            {
                for (int j = 0; j < sizeY; j++)
                {
                    int pi = i + (int)ci - sizeX / 2;
                    int pj = j + (int)cj - sizeY / 2;
                    DisplayMapCompositeItem dmi = mapItems[i, j];



                    MapCompositeItem mi = map.get(pi, pj);

                    if (mi == null)
                    {
                        dmi.setActive(false);
                    }

                    else
                    {
                        mi.Update();
                        dmi.setActive(true);

                        dmi.Attach(mi);


/*                        if (mi.background.id == 0)
 *                          dmi.bgo.SetActive(false);
 *                      if (mi.foreground.id == 0)
 *                          dmi.fgo.SetActive(false);
 */
                    }
                }
            }
        }