예제 #1
0
 // サブウィンドウの初期化
 public void Init()
 {
     wantsMouseMove = true; // マウス情報を取得.
                            // グリッドデータを生成
     m_gridRect = CreateGrid();
     SetRepaint();
 }
예제 #2
0
        /// <summary>
        /// 初期化
        /// </summary>
        public void Init()
        {
            mapSize  = editor.MapSize;
            gridSize = editor.GridSize;

            // グリッドデータを生成
            gridRect = CreateGrid(mapSize - 1);

            // マップデータを初期化
            map = new string[mapSize, mapSize];

            if (editor.SquareData == null)
            {
                for (int y = 0; y < mapSize; y++)
                {
                    for (int x = 0; x < mapSize; x++)
                    {
                        map[y, x] = "";
                    }
                }
            }
            else
            {
                for (int y = 0; y < mapSize; y++)
                {
                    for (int x = 0; x < mapSize; x++)
                    {
                        map[y, x] = editor.ImagePathList[editor.SquareData.Map[y][x]];
                    }
                }
            }
        }
예제 #3
0
        private void LateUpdate()
        {
            Rect  cameraRect  = MapCamera.GetComponent <CameraController>().GetCameraRect();
            float pixelWidth  = MapCamera.GetComponent <CameraController>().GetPixelWidth();
            float masterAlpha = Mathf.Lerp(1, 0, (MapCamera.GetComponent <Camera>().orthographicSize - StartAlpha) / (EndAlpha - StartAlpha));

            Rect[,] spriteRects = Helpers.SubdivideRect(cameraRect, SpriteColumns, SpriteRows);
            for (int spriteColumn = 0; spriteColumn < SpriteColumns; spriteColumn++)
            {
                for (int spriteRow = 0; spriteRow < SpriteRows; spriteRow++)
                {
                    Sprites[spriteColumn, spriteRow].transform.position   = spriteRects[spriteColumn, spriteRow].min;
                    Sprites[spriteColumn, spriteRow].transform.localScale = spriteRects[spriteColumn, spriteRow].size;
                    Rect[,] shaderRects = Helpers.SubdivideRect(spriteRects[spriteColumn, spriteRow], ColumnsPerShader, RowsPerShader);

                    for (int shaderColumn = 0; shaderColumn < ColumnsPerShader; shaderColumn++)
                    {
                        for (int shaderRow = 0; shaderRow < RowsPerShader; shaderRow++)
                        {
                            int offset = RowsPerShader * shaderColumn + shaderRow;
                            int count  = 0;
                            Contents.GetLocalBodies(shaderRects[shaderColumn, shaderRow], BodyVectors[spriteColumn, spriteRow], MaxObjectsPerShaderSegment * offset, ref count);
                            NumberOfBodies[spriteColumn, spriteRow][offset] = count;
                        }
                    }

                    Sprites[spriteColumn, spriteRow].GetComponent <SpriteRenderer>().material.SetVectorArray("bodies", BodyVectors[spriteColumn, spriteRow]);
                    Sprites[spriteColumn, spriteRow].GetComponent <SpriteRenderer>().material.SetFloatArray("numberOfBodies", NumberOfBodies[spriteColumn, spriteRow]);
                    Sprites[spriteColumn, spriteRow].GetComponent <SpriteRenderer>().material.SetFloat("pixelWidth", pixelWidth);
                    Sprites[spriteColumn, spriteRow].GetComponent <SpriteRenderer>().material.SetFloat("masterAlpha", masterAlpha);
                }
            }
        }
예제 #4
0
    public static void LoadPlayerTextures()
    {
        playerTextureDict = new Dictionary <string, int>();

        // Load the texture sheets in a predetermined order
        Texture2D[] _playerTileSheet = Resources.LoadAll <Texture2D>(_playerTexturesPath); //

        playerIdToRect = new Rect[_playerTileSheet.Length, playerSheetSlots];
        int playerSheetCount = 0;


        foreach (Texture2D playerSheet in _playerTileSheet)
        {
            playerTextureDict.Add(playerSheet.name, playerSheetCount);
            SplitPlayerTextureSheet(playerSheet);
            playerSheetCount++;
        }

        Texture2D[] _textures = playerSplitTextures.ToArray();

        playerTextures            = new Texture2D(1, 1);
        playerRects               = playerTextures.PackTextures(_textures, 0);
        playerTextures.filterMode = FilterMode.Point;


        for (int i = 0; i < _playerTileSheet.Length; i++)
        {
            for (int u = 0; u < playerSheetSlots; u++)
            {
                playerIdToRect[i, u] = playerRects[(i * 20) + u];
            }
        }
    }
예제 #5
0
        public void init(int x, int y)
        {
            first = true;
            //imgDrawing = new ImageDrawing[x, y];
            //_drawingGroup = new DrawingGroup();

            x_count = x / cells_in_rect_x;
            if (x_count % cells_in_rect_x != 0)
            {
                x_count++;
            }
            y_count = y / cells_in_rect_y;
            if (y_count % cells_in_rect_y != 0)
            {
                y_count++;
            }


            rtbs  = new RenderTargetBitmap[x_count, y_count];
            rects = new Rect[x_count, y_count];
            for (int i = 0; i < x_count; i++)
            {
                for (int j = 0; j < y_count; j++)
                {
                    rtbs[i, j]  = new RenderTargetBitmap(cells_in_rect_x * 32, cells_in_rect_y * 32, 96, 96, PixelFormats.Default);
                    rects[i, j] = new Rect(i * 32 * cells_in_rect_x, j * 32 * cells_in_rect_y, cells_in_rect_x * 32, cells_in_rect_y * 32);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// 初期化
        /// </summary>
        public void init()
        {
            mapSize  = parent.MapSize;
            gridSize = parent.GridSize;

            //マップデータを初期化
            map = new string[mapSize, mapSize];
            for (int i = 0; i < mapSize; i++)
            {
                for (int j = 0; j < mapSize; j++)
                {
                    map[i, j] = "0";
                }
            }
            mapNmae = new string[mapSize, mapSize];
            for (int i = 0; i < mapSize; i++)
            {
                for (int j = 0; j < mapSize; j++)
                {
                    mapNmae[i, j] = "";
                }
            }
            //グリッドデータを生成
            gridRect = CreateGrid(mapSize);
        }
예제 #7
0
    public InventoryWindow()
    {
        GameManager gameManager = UnityEngine.MonoBehaviour.FindObjectOfType <GameManager> ();

        things = gameManager.GetCrew().inventory;

        float windowSize = Screen.height * 0.8f;

        windowRect = new Rect(Screen.width / 4 - windowSize / 2, Screen.height * 0.05f,
                              windowSize, windowSize);

        //set all thing icon rects
        rowCount        = Crew.inventorySize / thingsPerRow;
        thingIconRects  = new Rect[thingsPerRow, rowCount];
        thingTooltipIDs = new string[thingsPerRow, rowCount];

        iconSize = windowSize / (thingsPerRow + 2);
        for (int i = 0; i < thingsPerRow; i++)
        {
            for (int j = 0; j < rowCount; j++)
            {
                thingIconRects [i, j]  = new Rect(iconSize + i * iconSize, iconSize + j * iconSize, iconSize, iconSize);
                thingTooltipIDs [i, j] = "inventory(" + i + "," + j + ")";
            }
        }
    }
예제 #8
0
    // サブウィンドウの初期化
    public void init()
    {
        mapSize  = parent.MapSize;
        gridSize = parent.GridSize;

        // マップデータを初期化
        terramap = new Terra[mapSize, mapSize];
        objmap   = new MovingObject[mapSize, mapSize];
        for (int i = 0; i < mapSize; i++)
        {
            for (int j = 0; j < mapSize; j++)
            {
                terramap[i, j] = Terra.NONE;
                objmap[i, j]   = MovingObject.NONE;
            }
        }
        // グリッドデータを生成
        gridRect = CreateGrid(mapSize);
        if (parent.LoadTerra != null)
        {
            string path = AssetDatabase.GetAssetPath(parent.LoadTerra);
            path     = path.Remove(0, 6);
            terramap = CSVDataReader.DataToTerra(CSVDataReader.readCSVData(path));
        }
        if (parent.LoadObj != null)
        {
            string path = AssetDatabase.GetAssetPath(parent.LoadObj);
            path   = path.Remove(0, 6);
            objmap = CSVDataReader.DataToObj(CSVDataReader.readCSVData(path));
        }
    }
예제 #9
0
        private void InitPictures()
        {
            if (_puzzlePicture == null)
            {
                _puzzlePicture = GetPuzzlePicture();
            }

            float w, h;

            w = gamePanel.rect.width / size;  // 512 P.width / size = 128
            h = gamePanel.rect.height / size;

            float offsetX, offsetY;

            offsetX = w / 2;    // 128/2 = 64
            offsetY = h / 2;

            puzzles      = new PuzzleSelection[size, size];
            puzzlesParts = new Rect[size, size];

            //        4x4
            //  0.3|1.3|2.3|3.3
            //  0.2|1.2|2.2|3.2
            //  0.1|1.1|2.1|3.1
            //  0.0|1.0|2.0|3.0

            Vector2 offset;
            Vector2 m_scale = new Vector2(1.0f / size, 1.0f / size);


            for (int x = 0; x < size; x++)
            {
                for (int y = 0; y < size; y++)
                {
                    PuzzleSelection newImg = _puzzlePooler.GetPooledObject();
                    newImg.gameObject.SetActive(true);  //Instantiate(puzzlePrefab);
                    newImg.transform.localPosition = new Vector2(x * w + offsetX, y * h + offsetY);

                    newImg.transform.SetParent(gamePanel, false);
                    newImg.GetComponent <RectTransform>().sizeDelta = new Vector2(w, h);
                    newImg.transform.rotation = gamePanel.rotation;
                    newImg.name = (y * size + x).ToString();
                    newImg.GetComponent <Button>().onClick.AddListener(() => { this.OnClick(newImg.name); });

                    puzzles[x, y] = newImg;
                    offset        = new Vector2(x * m_scale.x, y * m_scale.y);
                    puzzles[x, y].AssignImage(m_scale, offset);

                    puzzlesParts[x, y] = puzzles[x, y].PuzzlePart;

                    //images[x, y].CreatePuzzlePiece(size);
                }
            }
        }
예제 #10
0
 private void ShowLimits_triangle(Rect[,] rects, SerializedProperty limitsProp)
 {
     limitsProp.arraySize = 3;
     EditorGUI.LabelField(rects[0, 0], "");
     EditorGUI.PropertyField(rects[1, 0], limitsProp.GetArrayElementAtIndex(1), GUIContent.none);
     EditorGUI.LabelField(rects[2, 0], "");
     EditorGUI.LabelField(rects[3, 0], "");
     EditorGUI.PropertyField(rects[0, 1], limitsProp.GetArrayElementAtIndex(0), GUIContent.none);
     EditorGUI.LabelField(rects[1, 1], "");
     EditorGUI.LabelField(rects[2, 1], "");
     EditorGUI.PropertyField(rects[3, 1], limitsProp.GetArrayElementAtIndex(2), GUIContent.none);
 }
예제 #11
0
        public static Rect[,] Padding(this Rect[,] source, float top, float right, float bottom, float left)
        {
            var result = new Rect[source.GetLength(0), source.GetLength(1)];

            for (int i = 0; i < source.GetLength(0); i++)
            {
                for (int j = 0; j < source.GetLength(1); j++)
                {
                    result[i, j] = source[i, j].Padding(top, right, bottom, left);
                }
            }

            return(result);
        }
예제 #12
0
    /**
     * Calculate inventory dimensions based on current screen size
     * Create a 2d array of Rects representing each square in the grid and in the hotkey list
     */
    public override void UpdateDimensions()
    {
        invWidthToHeightRatio = (float)numTilesX / numTilesY;

        // Calculate inventory dimensions based on screen size
        invHeight = Screen.height - 2 * padding_y * Screen.height;
        invWidth  = invWidthToHeightRatio * invHeight;
        if (invWidth > Screen.width - 2 * padding_x * Screen.width)
        {
            invWidth  = Screen.width - 2 * padding_x * Screen.width;
            invHeight = invWidth / invWidthToHeightRatio;
        }
        invX = (Screen.width - invWidth) / 2;
        invY = (Screen.height - invHeight) / 2;

        float tileWidth  = (invWidth - ((numTilesX - 1) * tilePadding)) / numTilesX;
        float tileHeight = (invHeight - ((numTilesY - 1) * tilePadding)) / numTilesY;

        // Create tile rects in the main inventory grid
        tileRects = new Rect[numTilesX, numTilesY];
        for (int i = 0; i < numTilesX; i++)
        {
            for (int j = 0; j < numTilesY; j++)
            {
                Rect rect = new Rect(
                    invX + i * (tileWidth + tilePadding),
                    invY + j * (tileHeight + tilePadding),
                    tileWidth,
                    tileHeight
                    );
                tileRects[i, j] = rect;
            }
        }

        // Create tile rects for the hotkeys
        hotkeyTileRects = new Rect[numHotkeys];
        float hotkeysX = (Screen.width - (tileWidth * numHotkeys) - (tilePadding * (numHotkeys - 1))) / 2;
        float hotkeysY = Screen.height - tileHeight - tilePadding;

        for (int i = 0; i < numHotkeys; i++)
        {
            Rect rect = new Rect(
                hotkeysX + i * (tileWidth + tilePadding),
                hotkeysY,
                tileWidth,
                tileHeight
                );
            hotkeyTileRects[i] = rect;
        }
    }
예제 #13
0
        public void close()
        {
            //if (imgDrawing != null)
            //{
            //    for (int i = 0; i < imgDrawing.GetLength(0); i++)
            //        for (int j = 0; j < imgDrawing.GetLength(1); j++)
            //            imgDrawing[i, j] = null;
            //}
            //imgDrawing = null;
            //_drawingGroup.Children.Clear();

            rtbs  = null;
            rects = null;
        }
예제 #14
0
    public void Init()
    {
        MapCreator mapCreator = FindObjectOfType <MapCreator>();

        tiles       = mapCreator.GetTiles();
        gimmicks    = mapCreator.GetGimmicks();
        enemies     = mapCreator.GetEnemies();
        bgImages    = mapCreator.GetBackImages();
        mapData     = new int[gridNum, gridNum];
        gimmickData = new int[gridNum, gridNum];
        enemyData   = new int[gridNum, gridNum];
        gridRect    = new Rect[gridNum, gridNum];
        //gridColor = Color.white;
    }
예제 #15
0
 /// <Summary>
 /// Draw map icons to the destination selection map.
 /// </Summary>
 void SetMapAttrIconToMap(Rect[,] r, List <MapInfo> mapInfoList, int horizontal, int vertical)
 {
     for (int y = 0; y < vertical; y++)
     {
         for (int x = 0; x < horizontal; x++)
         {
             int     index = x + y * horizontal;
             MapInfo info  = mapInfoList[index];
             if (info.mapAttr != MapAttributeDefine.HALL_WAY)
             {
                 GUI.DrawTexture(r[x, y], mapIconList[info.mapAttr]);
             }
         }
     }
 }
예제 #16
0
    private void Start()
    {
        Section initialSection = new Section(new Rect(0, 0, rows, columns));

        Partition(initialSection);
        initialSection.CreateRoom();


        floorPositions = new GameObject[rows, columns];
        zones          = new Rect[rows, columns];
        InitialiseZones(initialSection.rect);
        mapSize = initialSection.rect;


        DrawRooms(initialSection);
    }
    private void OnGUI()
    {
        Rect rect = new Rect(5, 5, 400, 400);

        Rect[,] rects = GridRects(Vector2Int.one * 10, Vector2.one * 100, Vector2.one * 10);

        for (int x = 0; x < 10; x++)
        {
            for (int y = 0; y < 10; y++)
            {
                //DrawCurve (rects[x, y], (int) EasingCurves);
            }
        }


        //DrawCurve (rect, EasingCurves.easeOutBounce);
    }
예제 #18
0
    private void CreateTextures()
    {
        Texture2D[,] temp = new Texture2D[X, Y];
        Rects             = new Rect[X, Y];

        //int x_size = 0;
        //int y_size = 0;

        for (int y = 0; y < Y; y++)
        {
            for (int x = 0; x < X; x++)
            {
                int size = (int)Math.Sqrt(Data[x, y].Length / 4);

                //x_size = size * X;
                //y_size = size * Y;

                temp[x, y] = new Texture2D(size, size, TextureFormat.RGBA32, false);
                temp[x, y].LoadRawTextureData(Data[x, y]);
                temp[x, y].Apply();

                Rects[x, y] = new Rect((X - 1 - x) * size, y * size, size, size);
            }
        }

        Textures = temp;

        //Texture2D textureToSave = new Texture2D(x_size, y_size, TextureFormat.RGBAFloat, false);
        //List<byte> fullArray = new List<byte>();

        //foreach (Texture2D tex in Textures)
        //{
        //    foreach (byte b in tex.GetRawTextureData())
        //    {
        //        fullArray.Add(b);
        //    }
        //}

        //textureToSave.LoadRawTextureData(fullArray.ToArray());
        //textureToSave.Apply();

        //byte[] bytes = textureToSave.EncodeToPNG();
        //File.WriteAllBytes("Assets/BIN/dataImage.png", bytes);
    }
예제 #19
0
    private void Awake()
    {
        this.contents = new GUIContent[3, 4];
        this.rects    = new Rect[3, 4];
        float top = 400f;

        for (int i = 0; i < 3; i++)
        {
            float left = 20f;
            for (int j = 0; j < 4; j++)
            {
                this.contents[i, j] = new GUIContent();
                this.rects[i, j]    = new Rect(left, top, 100f, 30f);
                left += 102f;
            }
            top += 32f;
        }
        this.contents[2, 0].text = "Degrees:";
    }
예제 #20
0
    private void Awake()
    {
        this.contents = new GUIContent[3, 4];
        this.rects    = new Rect[3, 4];
        float single = 400f;

        for (int i = 0; i < 3; i++)
        {
            float single1 = 20f;
            for (int j = 0; j < 4; j++)
            {
                this.contents[i, j] = new GUIContent();
                this.rects[i, j]    = new Rect(single1, single, 100f, 30f);
                single1             = single1 + 102f;
            }
            single = single + 32f;
        }
        this.contents[2, 0].text = "Degrees:";
    }
예제 #21
0
        /// <Summary>
        /// Show setting GUI about destination map that relates move position event.
        /// </Summary>
        void ShowSelectDestinationMapParts()
        {
            if (!isShowMap || editingEventParts.destMap == null || editingEventParts.destDungeon == null)
            {
                return;
            }

            int horizontal = editingEventParts.destMap.floorSizeHorizontal;
            int vertical   = editingEventParts.destMap.floorSizeVertical;

            mapBg = MapEditorUtil.RepaintMapTexture(horizontal, vertical, cellSize, gridColor, baseColor);
            EditorGUILayout.BeginVertical("Box");
            {
                GUIContent content = new GUIContent(mapBg);
                GUILayout.Box(content);

                Rect mapRect = GUILayoutUtility.GetLastRect();
                Rect[,] iconRect = MapEditorUtil.GetMapRectArray(mapRect, horizontal, vertical, cellSize);
                SetMapAttrIconToMap(iconRect, editingEventParts.destMap.mapInfo, horizontal, vertical);
                Rect[,] highlightRect = MapEditorUtil.GetMapRectArray(mapRect, horizontal, vertical, cellSize);
                if (isPosSelected)
                {
                    SetHoverColor(highlightRect[selectedGridPos.x, selectedGridPos.y], selectedTex);
                }

                wantsMouseMove = true;
                if (mapRect.Contains(Event.current.mousePosition))
                {
                    Vector2 pos = new Vector2(Event.current.mousePosition.x - mapRect.position.x, Event.current.mousePosition.y - mapRect.position.y);
                    hoverGridPos = MapEditorUtil.GetPosInGrid(pos, horizontal, vertical, cellSize);
                    SetHoverColor(highlightRect[hoverGridPos.x, hoverGridPos.y], hoverTex);

                    if (Event.current.type == EventType.MouseUp)
                    {
                        Undo.RecordObject(this, undoName);
                        selectedGridPos = MapEditorUtil.GetPosInGrid(pos, horizontal, vertical, cellSize);
                        isPosSelected   = true;
                    }
                    Repaint();
                }
            }
            EditorGUILayout.EndVertical();
        }
예제 #22
0
    private void OnGUI()
    {
        GUILayout.BeginHorizontal();
        //  マップデータを書き出し
        if (GUILayout.Button("ファイル出力"))
        {
            ExportMapData();
        }
        //  マップの読み込み
        if (GUILayout.Button("ファイル入力"))
        {
            ImportMapData();
        }
        //  グリッドをリセットをする
        if (GUILayout.Button("リセット"))
        {
            ResetMapData();
        }
        GUILayout.EndHorizontal();

        //  グリッドのサイズを設定
        gridRect = CreateGrid();
        DrawBackGround();
        //  グリッドの描画
        DrawGridAll();

        // クリックされた場所の配列にデータを追加
        SetMapDate();

        // グリッドに画像を描画する
        DrawTileTextures();
        //  グリッド分の空白を挿入
        GUILayout.Space(280);
        //  背景の属性設定
        backGround = (BackGround)EditorGUILayout.EnumPopup("背景", backGround);
        //  タイルの種類を分ける
        toolberInt = GUILayout.Toolbar(toolberInt, new string[] { "地面", "ギミック", "エネミー" });
        //  タイルのボタンを描画
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
        DrawTileButtons();
        EditorGUILayout.EndScrollView();
    }
    public static MyRect[,] RectToMyRect(Rect[,] r)
    {
        if (r == null)
        {
            return(null);
        }
        var w  = r.GetLength(0);
        var h  = r.GetLength(1);
        var re = new MyRect[w, h];

        for (int i = 0; i < w; i++)
        {
            for (int j = 0; j < h; j++)
            {
                var t = r[i, j];
                re[i, j] = new MyRect(t.x, t.y, t.width, t.height);
            }
        }
        return(re);
    }
예제 #24
0
    public void StoreData(Manager manager)
    {
        var opticalFlowCamerasController = manager.opticalFlowCamerasController;

        opticalFlowCamerasController.GetDownsampleSize(out downsampleWidth, out downsampleHeight);
        pixelSaliency    = opticalFlowCamerasController.pixelSaliency;
        regionalSaliency = opticalFlowCamerasController.regionalSaliency;
        pixelOpticalFlow = opticalFlowCamerasController.pixelOpticalFlow;
        pixelMask        = opticalFlowCamerasController.pixelMaskList;
        rectOfPixel      = opticalFlowCamerasController.rectOfPixel;
        initialPath      = opticalFlowCamerasController.initialPath;
        fovAwarePath     = opticalFlowCamerasController.fovAwarePath;
        smoothPath       = opticalFlowCamerasController.smoothPath;
        Debug.Log("***storeData, smoothPath.length: " + smoothPath.Length);

        downsamplePixelBlend       = opticalFlowCamerasController.GetDownsamplePixelBlendSaliencyMask(downsampleWidth, downsampleHeight, false);
        downsamplePixelOpticalFlow = opticalFlowCamerasController.GetDownsamplePixelOpticalFlow(downsampleWidth, downsampleHeight, true);
        List <float> maxRegionalSaliencyEveryFrame = null;

        downsampleRegionalSaliency = opticalFlowCamerasController.PreprocessRegionalSaliency(downsamplePixelBlend, downsampleWidth, downsampleHeight, ref maxRegionalSaliencyEveryFrame, false);


        videoURL = manager.videoPlayer.url;
    }
        /// <summary>
        /// Splits a rect into a multidimensional arrary of individual rects.
        /// </summary>
        public static Rect[,] Grid(this HUMMath.Data.SplitInto into, int columns, int rows)
        {
            var averageHeight = (into.split.rect.height / rows);
            var averageWidth  = (into.split.rect.width / columns);

            Rect[,] rects = (Rect[, ])Array.CreateInstance(typeof(Rect), columns, rows);

            for (int x = 0; x < columns; x++)
            {
                for (int y = 0; y < rows; y++)
                {
                    var rect = new Rect(
                        into.split.rect.x + (averageWidth * x),
                        into.split.rect.y + (averageHeight * y),
                        averageWidth,
                        averageHeight
                        );

                    rects[x, y] = rect;
                }
            }

            return(rects);
        }
예제 #26
0
	// Method that create a grid with the position of every slot
	void createInventorySlot(){
		
		// COORDENATES INVENTORY REGION
		this.inventory_box.x = Screen.width - this.inventory_box.width;
		this.inventory_box.y = 0;//Screen.height - this.inventory_box.height - Screen.height*.2f;
		
		// SLOTS REGIONS
		
		
		//WEAPON REGION
		this.weaponRegion_box = new Rect (this.inventory_box.x + weaponX,
		                                  this.inventory_box.y + weaponY,
		                                  weaponW,
		                                  weaponH);
		
		// SHIELD REGION
		this.shieldRegion_box = new Rect (this.inventory_box.x + shieldX,
		                                  this.inventory_box.y + shieldY,
		                                  shieldW,
		                                  shieldH);

		//HELMET REGION
		this.helmetRegion_box = new Rect (this.inventory_box.x + helmetX,
		                                  this.inventory_box.y + helmetY,
		                                  helmetW,
		                                  helmetH);

		//ARMOR REGION
		this.armorRegion_box = new Rect (this.inventory_box.x + armorX,
		                                  this.inventory_box.y + armorY,
		                                  armorW,
		                                  armorH);

		// BOOT REGION
		this.bootRegion_box = new Rect (this.inventory_box.x + bootX,
		                                  this.inventory_box.y + bootY,
		                                  bootW,
		                                  bootH);

		
		// ITEMS REGION
		this.slot = new Slot[this.slot_row, this.slot_column];
		this.s = new Rect[this.slot_row, this.slot_column];
		
		for (int i = 0; i < this.slot_row; i++)
		for (int j = 0; j < this.slot_column; j++){

			this.slot [i, j] = new Slot (new Rect(this.slotX + (this.slot_w*i),
			                                      this.slotY + (this.slot_h*j),
			                                      this.slot_w,
			                                      this.slot_h));
			
			this.s[i,j] = new Rect(this.inventory_box.x + this.slot[i,j].position.x,
			                       this.inventory_box.y + this.slot[i,j].position.y,
			                       this.slot_w,
			                       this.slot_h);
		}
	}
예제 #27
0
    /**
     * Calculate inventory dimensions based on current screen size
     * Create a 2d array of Rects representing each square in the grid and in the hotkey list
     */
    public override void UpdateDimensions()
    {
        invWidthToHeightRatio = (float)numTilesX / numTilesY;

        // Calculate inventory dimensions based on screen size
        invHeight = Screen.height - 2 * padding_y * Screen.height;
        invWidth = invWidthToHeightRatio * invHeight;
        if (invWidth > Screen.width - 2 * padding_x * Screen.width) {
            invWidth = Screen.width - 2 * padding_x * Screen.width;
            invHeight = invWidth / invWidthToHeightRatio;
        }
        invX = (Screen.width - invWidth) / 2;
        invY = (Screen.height - invHeight) / 2;

        float tileWidth = (invWidth - ((numTilesX - 1) * tilePadding)) / numTilesX;
        float tileHeight = (invHeight - ((numTilesY - 1) * tilePadding)) / numTilesY;

        // Create tile rects in the main inventory grid
        tileRects = new Rect[numTilesX, numTilesY];
        for (int i = 0; i < numTilesX; i++) {
            for (int j = 0; j < numTilesY; j++)
            {
                Rect rect = new Rect(
                    invX + i * (tileWidth + tilePadding),
                    invY + j * (tileHeight + tilePadding),
                    tileWidth,
                    tileHeight
                );
                tileRects[i,j] = rect;
            }
        }

        // Create tile rects for the hotkeys
        hotkeyTileRects = new Rect[numHotkeys];
        float hotkeysX = (Screen.width - (tileWidth * numHotkeys) - (tilePadding * (numHotkeys - 1))) / 2;
        float hotkeysY = Screen.height - tileHeight - tilePadding;
        for (int i = 0; i < numHotkeys; i++) {
            Rect rect = new Rect(
                hotkeysX + i * (tileWidth + tilePadding),
                hotkeysY,
                tileWidth,
                tileHeight
            );
            hotkeyTileRects[i] = rect;
        }
    }
예제 #28
0
	// Use this for initialization
	void Start () 
	{
		
		myGameData = GameObject.FindGameObjectWithTag("GameData").GetComponent<SaveData>();
		// Loading the background:
		backgroundPath = "PNG/MainScreen";
		_backgroundTexture = (Texture2D)Resources.Load( backgroundPath, typeof(Texture2D));

		#region Menu Buttons
		// Menu buttons
		_menuButtonTexture = new Texture2D[3,2];
		menuButtonPath = Globals.menuButtonNameList;
		menuButtonPos = Globals.menuButtonRectList;
		for ( i = 0; i < 3; i++ )
		{
			_menuButtonTexture[i,0] = (Texture2D)Resources.Load( menuButtonPath[i,0], typeof(Texture2D));
			_menuButtonTexture[i,1] = (Texture2D)Resources.Load( menuButtonPath[i,1], typeof(Texture2D));
		}
		#endregion

		#region Words
		// setup the words: Title, Width, Height
		menuWordsPos = Globals.menuWordsList;
		menuWordsPath = Globals.menuWordsNameList;
		_menuWordsTexture = new Texture2D[3];
		for ( i = 0; i < 3; i++ )
		{
			_menuWordsTexture[i] = (Texture2D)Resources.Load( menuWordsPath[i], typeof(Texture2D));
			
		}
		#endregion
		
		#region Arrows
		//Arrows
		arrowUpButtonPath = "Numbers/ArrowUp";
		arrowDownButtonPath = "Numbers/ArrowDown";
		ArrowPos = Globals.menuArrowsRectList; // first up arrow in the 100's
		_arrowUp = (Texture2D)Resources.Load( arrowUpButtonPath, typeof(Texture2D));
		_arrowDown = (Texture2D)Resources.Load( arrowDownButtonPath, typeof(Texture2D));
		#endregion
		
		#region numbers
		//Numbers
		_numbers = new Texture2D[10];
		numbersPath = new string[10];
		numbersPos = Globals.menuNumbersRectList;
		for ( i = 0; i < 10; i++ )
		{
			numbersPath[i] = "Numbers/" + i.ToString() ;
			_numbers[i] = (Texture2D)Resources.Load( numbersPath[i], typeof(Texture2D));
		}
		
		#endregion
		// The default maze width and height
		_MazeWidth = 25; 
		_MazeHeight = 25; 
		_MinMazeWidth = 10; // the smallest possible size
		_MinMazeHeight = 10;// the smallest possible size
		_MaxMazeWidth = 999; // the max for now
		_MaxMazeHeight = 999; // the max for nwo
		
		//Timer stuff
		myTimer = 0.0f;
		
		ButtonActive = -1;
	}
예제 #29
0
        /// <summary>
        /// Event handler for Kinect sensor's SkeletonFrameReady event
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            Skeleton[] skeletons = new Skeleton[0];

            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(skeletons);
                }
            }

            using (DrawingContext dc = this.drawingGroup.Open())
            {

                #region gridDraw
                // Draw a transparent background to set the render size
                grid = new Rect[5,4];
                //dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, RenderWidth, RenderHeight));
                for(int i = 0; i < 5; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        grid[i, j] = new Rect(RenderWidth * (i) / 5, RenderHeight * (j) / 4, RenderWidth * (i + 1) / 5, RenderHeight * (j + 1) / 4);
                        if(i == (int)lastSquareHit.X && j == (int)lastSquareHit.Y) dc.DrawRectangle(Brushes.White, null, grid[i,j]);
                        else dc.DrawRectangle(brushes[i,j], null, grid[i,j]);
                        if (j == 3)
                        {
                            switch (i)
                            {
                                case 1:
                                    dc.DrawText(new FormattedText("Drum",
                                              CultureInfo.GetCultureInfo("en-us"),
                                              FlowDirection.LeftToRight,
                                              new Typeface("Verdana"),
                                              36, System.Windows.Media.Brushes.White),
                                              new System.Windows.Point(RenderWidth * (i) / 5, RenderHeight * (j) / 4 + 80));
                                    break;
                                case 2:
                                    dc.DrawText(new FormattedText("Piano",
                                              CultureInfo.GetCultureInfo("en-us"),
                                              FlowDirection.LeftToRight,
                                              new Typeface("Verdana"),
                                              36, System.Windows.Media.Brushes.White),
                                              new System.Windows.Point(RenderWidth * (i) / 5, RenderHeight * (j) / 4 + 80));
                                    break;
                                case 3:
                                    dc.DrawText(new FormattedText("Sax",
                                              CultureInfo.GetCultureInfo("en-us"),
                                              FlowDirection.LeftToRight,
                                              new Typeface("Verdana"),
                                              36, System.Windows.Media.Brushes.White),
                                              new System.Windows.Point(RenderWidth * (i) / 5, RenderHeight * (j) / 4 + 80));
                                    break;
                                default:
                                    break;
                            }

                        }
                    }
                }
                Pen p = new Pen();
                p.Brush = Brushes.White;
                for (int i = 1; i < 5; i++)
                {
                    dc.DrawLine(p, new Point(RenderWidth*i / 5, 0.0), new Point(RenderWidth*i / 5, RenderHeight));
                }
                for (int i = 1; i < 4; i++)
                {
                    dc.DrawLine(p, new Point(0.0, RenderHeight*i/4), new Point(RenderWidth, RenderHeight*i/4));
                }
                #endregion gridDraw

                if (skeletons.Length != 0)
                    {
                        foreach (Skeleton skel in skeletons)
                        {
                            RenderClippedEdges(skel, dc);

                            if (skel.TrackingState == SkeletonTrackingState.Tracked)
                            {
                                this.DrawBonesAndJoints(skel, dc);
                            }
                            else if (skel.TrackingState == SkeletonTrackingState.PositionOnly)
                            {
                                dc.DrawEllipse(
                                this.centerPointBrush,
                                null,
                                this.SkeletonPointToScreen(skel.Position),
                                BodyCenterThickness,
                                BodyCenterThickness);
                            }
                        }
                    }

                // prevent drawing outside of our render area
                this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, RenderWidth, RenderHeight));
            }
        }
예제 #30
0
    void SetUpBounds()
    {
        //Inventory bounds
        bagBounds = new Rect();

        bagBounds.width = InvTexture.width*Bag_Scale;
        bagBounds.height = (InvTexture.height*Bag_Scale);
        bagBounds.x = ( 0 );
        bagBounds.y = ( 0 );

        windowRect = new Rect((Screen.width / 2) - (bagBounds.width / 2), (Screen.height / 2) - (bagBounds.height / 2), bagBounds.width, bagBounds.height);

        //Button Bounds
        DropBounds = new Rect(bagBounds.x + Button_DropItem_x, bagBounds.y + Button_DropItem_y, Button_DropItem_width, Button_DropItem_height);
        CloseBounds = new Rect(bagBounds.x + Button_Close_x, bagBounds.y + Button_Close_y, Button_Close_width, Button_Close_height);

        //The held item
        heldBounds = new Rect(0,0,Slot_Size,Slot_Size);

        //Slot bounds
        slotBounds = new Rect[Bag_Width,Bag_Height];
        slotNumBounds = new Rect[Bag_Width, Bag_Height];
        equiptSlotBounds = new Rect[4];

        for (int i = 0; i < 4; i++)
        {
            int slotX2 = (int)bagBounds.x + (Slot_StartX + (6 * Slot_PaddingX));
            int slotY2 = (int)bagBounds.y + (Slot_StartY + (i * Slot_PaddingY));
            equiptSlotBounds[i] = new Rect(slotX2, slotY2, Slot_Size, Slot_Size);
        }

        for(int x = 0; x < Bag_Width; x++) {
            for(int y = 0; y < Bag_Height; y++) {

                int slotX = (int)bagBounds.x + (Slot_StartX + (x * Slot_PaddingX));
                int slotY = (int)bagBounds.y + (Slot_StartY + (y * Slot_PaddingY));

                Rect r = new Rect(slotX, slotY, Slot_Size, Slot_Size);

                slotBounds[x,y] = r;
                slotNumBounds[x, y] = new Rect(slotX + Slot_Size / 2, slotY + Slot_Size / 2, Slot_Size / 2, Slot_Size / 2);
            }
        }
    }
 public static extern int core_Mat_nGetRect(IntPtr obj, int row, int col,
                                            [In, Out, MarshalAs(UnmanagedType.LPArray)] Rect[,] vals, int valsLength);
예제 #32
0
 public RenderingArena(int _x, int _y, int _tileSize)
 {
     arenaTile = new Rect[_x, _y];
     TileSize  = _tileSize;
     Init();
 }
 public void Set(int downSampleWidth, int downSampleHeight, Rect[,] rectOfPixel)
 {
     this.downSampleWidth  = downSampleWidth;
     this.downSampleHeight = downSampleHeight;
     this.rectOfPixel      = RectToMyRect(rectOfPixel);
 }
예제 #34
0
 // Use this for initialization
 public void init(Rect[,] tileUVs)
 {
     // set up our array of Tiles
     this.tiles = tileUVs;
     meshFilter.mesh = makeMapMesh();
 }
예제 #35
0
    // サブウィンドウの初期化
    public void init()
    {
        mapSize = parent.MapSize;
        gridSize = parent.GridSize;

        // マップデータを初期化
        map = new string[mapSize, mapSize];
        for (int i = 0; i < mapSize; i++) {
            for (int j = 0; j < mapSize; j++) {
                map[i,j] = "";
            }
        }
        // グリッドデータを生成
        gridRect = CreateGrid(mapSize);
    }
예제 #36
0
파일: RectSet.cs 프로젝트: Yodde/RectState
 public RectSet()
 {
     rectArray = new Rect[MainWindow.count, MainWindow.count];
 }