Exemplo n.º 1
0
        public static void DeleteTree(CTree pTree)
        {
            if (pTree.treeIndex == 169)
            {
                bool i = true;
            }

            if (!Trees.Contains(pTree))
            {
                CDebug.Error("Trees dont contain " + pTree);
                return;
            }
            pTree.peakDetailField.RemoveTree(pTree);
            pTree.peakNormalField.RemoveTree(pTree);
            foreach (CTreeField field in pTree.detailFields)
            {
                field.RemoveTree(pTree);
            }
            foreach (CTreeField field in pTree.normalFields)
            {
                field.RemoveTree(pTree);
            }
            //shouldnt be neccessary
            //pTree.peakDetailField.RemoveTree(pTree);
            //pTree.peakNormalField.RemoveTree(pTree);
            Trees.Remove(pTree);
            //if(!pTree.treeDetailField.GetDetectedTrees().Contains(pTree))
            //{
            //	CDebug.Error("element " + pTree.treeDetailField + " doesnt contain " + pTree);
            //	return;
            //}
        }
Exemplo n.º 2
0
        private void GenerateTrees(int amountOfTrees)
        {
            int    treeCounter = 0;
            Random r           = new Random();

            for (int i = 0; i < amountOfTrees; i++)
            {
                int  random1 = r.Next(1, Xmax - 1);
                int  random2 = r.Next(1, Ymax - 1);
                Tree newTree = new Tree {
                    Id = treeCounter++, X = random1, Y = random2
                };

                if (!Trees.Contains(newTree))
                {
                    Global.Log.TaskList.Add(Task.Run(() => Global.Log.TreeLog(this, newTree)));
                    Console.WriteLine($"[{Id}]: Creating tree at {newTree.X},{newTree.Y} with ID: {newTree.Id}");
                    Trees.Add(newTree);
                }
                else
                {
                    i--;
                }
            }
            Console.WriteLine($"[{Id}]: Generated forest with {Trees.Count} amount of trees with ID: {Id}");
            Global.Log.CreateBitmap(this);
        }