コード例 #1
0
        /// <summary>
        /// Called to update the mouse handler
        /// </summary>
        public void Update()
        {
            // Left click
            if (m_grid && Input.GetMouseButtonDown(0))
            {
                // Get the grid square, then reveal the square
                Vector3    world   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Vector3Int gridPos = m_grid.WorldToCell(world);

                m_map.RevealSquare(gridPos.x, gridPos.y);
            }
            // Right click
            else if (m_grid && Input.GetMouseButtonDown(1))
            {
                // Get the grid square, then toggle the flag on unrevealed squares
                Vector3    world   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Vector3Int gridPos = m_grid.WorldToCell(world);

                m_map.FlagSquare(gridPos.x, gridPos.y);
            }
        }