Ejemplo n.º 1
0
        // Use this for initialization
        void Awake()
        {
            S = this; // Initialize the private Singleton
#if (UsePlayerPrefsForFileName)
            // Read the most recent fileName from PlayerPrefs
            if (PlayerPrefs.HasKey("fileName"))
            {
                mapNameInput.text = PlayerPrefs.GetString("fileName");
            }
#endif

            ROOM_HAS_CONTENT = new bool[mapSize, mapSize];

            // Set up EditorTiles for each position on the map
            float x0 = size / 8f;
            float y0 = size / 8f;
            for (int j = 0; j < roomH; j++)
            {
                for (int i = 0; i < roomW; i++)
                {
                    GameObject go = Instantiate(uiTilePrefab);
                    go.name = i.ToString("D3") + "x" + j.ToString("D3");
                    EditorTile et = go.GetComponent <EditorTile>();
                    et.x = i;
                    et.y = j;
                    RectTransform rt = go.GetComponent <RectTransform>();
                    rt.SetParent(mapAnchor);
                    rt.anchoredPosition = new Vector2(x0 + (i * size), y0 + (j * size));
                    roomTiles[i, j]     = et;
                }
            }

//        LoadMap();
        }
Ejemplo n.º 2
0
        // Use this for initialization
        void Start()
        {
            S = this;

            eMap = transform.parent.GetComponent <EditorMap>();
            RectTransform recT = GetComponent <RectTransform>();

            miniMapRooms = new EditorMiniMapRoom[EditorMap.mapSize, EditorMap.mapSize];
            for (int j = 0; j < EditorMap.mapSize; j++)
            {
                for (int i = 0; i < EditorMap.mapSize; i++)
                {
                    GameObject        go   = Instantiate(miniMapRoomPrefab);
                    RectTransform     rt   = go.GetComponent <RectTransform>();
                    EditorMiniMapRoom emmr = go.GetComponent <EditorMiniMapRoom>();
                    miniMapRooms[i, j] = emmr;
                    emmr.sprite        = spriteOff;
                    emmr.x             = i;
                    emmr.y             = j;
                    rt.SetParent(recT);
                    rt.anchoredPosition = new Vector2(i * 32, j * 22);
                }
            }

            HighlightRoom();
        }
Ejemplo n.º 3
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (eventData.button == PointerEventData.InputButton.Left)
     {
         EditorMap.ChangeTile(this);
     }
     else if (eventData.button == PointerEventData.InputButton.Middle)
     {
         // Do nothing
     }
     else if (eventData.button == PointerEventData.InputButton.Right)
     {
         EditorMap.CopyTile(this);
     }
 }