public void Add_IntKeys_Works()
        {
            var dict = new DoubleKeyDictionary<int, int, int>();
            dict.Add(1, 1, 2);
            dict.Add(2, 2, 4);

            Assert.IsTrue(dict.ContainsKey(1, 1));
            Assert.IsTrue(dict.ContainsKey(2, 2));
        }
        public void Index_IntKeys_Works()
        {
            var dict = new DoubleKeyDictionary<int, int, int>();
            dict[1, 1] = 2;
            dict[2, 2] = 4;

            Assert.IsTrue(dict.ContainsKey(1, 1));
            Assert.IsTrue(dict.ContainsKey(2, 2));
        }
        public void Add_StringAndIntKeys_Works()
        {
            var dict = new DoubleKeyDictionary<string, int, int>();
            dict.Add("1", 1, 2);
            dict.Add("2", 2, 4);

            Assert.IsTrue(dict.ContainsKey("1", 1));
            Assert.IsTrue(dict.ContainsKey("2", 2));
        }
        public void Index_IntKeys_Works()
        {
            var dict = new DoubleKeyDictionary <int, int, int>();

            dict[1, 1] = 2;
            dict[2, 2] = 4;

            Assert.IsTrue(dict.ContainsKey(1, 1));
            Assert.IsTrue(dict.ContainsKey(2, 2));
        }
        public void Add_StringAndIntKeys_Works()
        {
            var dict = new DoubleKeyDictionary <string, int, int>();

            dict.Add("1", 1, 2);
            dict.Add("2", 2, 4);

            Assert.IsTrue(dict.ContainsKey("1", 1));
            Assert.IsTrue(dict.ContainsKey("2", 2));
        }
        public void Add_IntKeys_Works()
        {
            var dict = new DoubleKeyDictionary <int, int, int>();

            dict.Add(1, 1, 2);
            dict.Add(2, 2, 4);

            Assert.IsTrue(dict.ContainsKey(1, 1));
            Assert.IsTrue(dict.ContainsKey(2, 2));
        }
Ejemplo n.º 7
0
    void DropTerrainAt(int i, int j)
    {
        // Check if terrain exists, if it does, activate it.
        if (terrainUsage.ContainsKey(i, j) && terrainUsage[i, j] != -1)
        {
            // Tile mapped, use it.
        }
        // If terrain doesn't exist, drop it.
        else
        {
            terrainUsage[i, j] = FindNextAvailableTerrainID();
            if (terrainUsage[i, j] == -1)
            {
                Debug.LogError("No more tiles, failing...");
            }
        }
        if (terrainUsageData.ContainsKey(i, j))
        {
            // Restore the data for this tile
        }
        else
        {
            // Create a new data object
            terrainUsageData[i, j] = CreateNewTerrainData();
        }

        ActivateUsedTile(i, j);
        usedTiles[terrainUsage[i, j]]    = true;
        touchedTiles[terrainUsage[i, j]] = true;
    }
Ejemplo n.º 8
0
        /// <inheritdoc />
        public Tile GetTile(Vector2d point)
        {
            int i = Convert.ToInt32(point.X / _tileSize);
            int j = Convert.ToInt32(point.Y / _tileSize);

            if (_allSceneTiles.ContainsKey(i, j))
            {
                return(_allSceneTiles[i, j]);
            }

            if (_allOverviewTiles.ContainsKey(i, j))
            {
                return(_allOverviewTiles[i, j]);
            }

            return(null);
        }
        public void Add_SameKeys_Allowed()
        {
            var dict = new DoubleKeyDictionary<string, string, int>();
            dict.Add("1", "1", 2);
            dict.Add("1", "1", 4);

            Assert.IsTrue(dict.ContainsKey("1", "1"));
        }
        public void Add_SameKeys_Allowed()
        {
            var dict = new DoubleKeyDictionary <string, string, int>();

            dict.Add("1", "1", 2);
            dict.Add("1", "1", 4);

            Assert.IsTrue(dict.ContainsKey("1", "1"));
        }
Ejemplo n.º 11
0
        //method to destroy object
        //had to do this as destroy can only be called from the main thread
        void Destroy(int x, int z)
        {
            //Create the voxel data


            if (m_voxelChunk[x, z].HasChanged && m_voxelChunk[x, z].shouldrender)
            {
                m_voxelChunk[x, z].SaveVoxels();
            }

            if (m_voxelChunk.ContainsKey(x, z))
            {
                ToDestroy.Add(m_voxelChunk[x, z]);
            }

            if (m_voxelChunk.ContainsKey(x, z))
            {
                m_voxelChunk.Remove(x, z);
            }
        }
Ejemplo n.º 12
0
        internal IEnumerable <JiraNamedEntity> GetFieldsForAction(Issue issue, string actionId)
        {
            if (issue.Key == null)
            {
                issue = GetOneIssueFromProject(issue.Project);
            }

            if (!_cachedFieldsForAction.ContainsKey(issue.Project, actionId))
            {
                WithToken((token, service) =>
                {
                    _cachedFieldsForAction.Add(issue.Project, actionId, _jiraService.GetFieldsForAction(token, issue.Key.Value, actionId)
                                               .Select(f => new JiraNamedEntity(f)));
                });
            }

            return(_cachedFieldsForAction[issue.Project, actionId]);
        }
Ejemplo n.º 13
0
        void CreateChunks()
        {
            try
            {
                //basic routine for creating chunks
                for (int i = 0; i < distanceToLoad * m_voxelWidthLength; i += m_voxelWidthLength)
                {
                    //set player positon relative to chunks basically rounding to chunk size

                    for (int x = 0; x < i; x += m_voxelWidthLength)
                    {
                        if (CanGenerate)
                        {
                            for (int z = 0; z < i; z += m_voxelWidthLength)
                            {
                                if (CanGenerate)
                                {
                                    //this is for the voxel editing at runtime
                                    //if theres any new chunks that need to be updated they are added here


                                    /*if the terrain has been edited calling saveTerrains() method
                                     * will save the voxel data to a file
                                     * here i just set the flag of this script to cansave =true; and it saves automatically*/
                                    if (Save)
                                    {
                                        SaveTerrains();

                                        Save = false;
                                    }
                                    //set up variables for distance checking
                                    Vector2 chunkpos = new Vector2(x, z);

                                    Vector2 playerpos = Vector2.zero;
                                    float   Dist      = Vector2.Distance(playerpos, chunkpos);

                                    //check if the chunk already exists if not create a chunk with x *y * z of voxels
                                    if (!m_voxelChunk.ContainsKey(new Vector3(x, 0, z), new Vector3(m_voxelWidthLength, m_voxelHeight, m_voxelWidthLength) * minLod))
                                    {
                                        if (Dist <= distanceToLoad)
                                        {
                                            Vector3 Pos = new Vector3(x, 0, z);

                                            //set variables for chunk creation
                                            VoxelChunk Chunk = new VoxelChunk(Pos, m_voxelWidthLength, m_voxelHeight, minLod);



                                            //add chunk to double key dictionary
                                            m_voxelChunk.Add(Pos, new Vector3(m_voxelWidthLength, m_voxelHeight, m_voxelWidthLength) * minLod, Chunk);

                                            //set flag on chunk
                                            Chunk.hasproccessed = true;

                                            //add chunk to list of chunks that need noise added to them
                                            GenerateVoxels.Enqueue(Chunk);
                                            return;
                                        }
                                    }

                                    //if the chunk already exists and its distance is greater then render distance
                                }
                            }
                        }
                    }
                }
            }catch (Exception e)
            { Debug.LogError(e.StackTrace); }
        }