public void CreaterForest()
 {
     int type = Random.Range(0, 3);
     forestCount++;
     GameObject nextForest = GameObject.Instantiate(forest[type], new Vector3(0,0, forestCount*3000),Quaternion.identity) as GameObject;
     forest1 = forest2;
     forest2 = nextForest.GetComponent<Forest>();
 }
Example #2
0
 public void GenerateForest()
 {
     forestCount++;
     int type = Random.Range (0, 3);//包含0,不好含3
     GameObject newForest=GameObject.Instantiate(forest[type],new Vector3(0,0,forestCount*3000),Quaternion.identity) as GameObject;  //as GameObject 这是强转
     //不强转会出现错误:Assets/EnvGenerator.cs(15,28): error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
     forest1 = forest2; //这两句目前是用不上的,没任何意义呀?
     forest2 = newForest.GetComponent<Forest> ();
 }
 public void GenrateForeat()
 {
     forestCount++;
     int type = Random.Range (0, 3);
     GameObject newforest=GameObject.Instantiate (forests [type],
                    new Vector3(0,0,forestCount*3000),Quaternion.identity) as GameObject;
     Debug.Log (forestCount);
     forest1 = forest2;
     forest2 = newforest.GetComponent<Forest> ();
 }
Example #4
0
 // Use this for initialization
 void Start()
 {
     time = Time.time;
     ForestManager fM = new ForestManager();
        List<ITree> species= new List<ITree>();
     species.Add(tree);
     f = fM.createForest(map, species);
     for (int i = 0; i < 30; i++)
     {
         f.NextYear(10);
         Debug.Log(i.ToString());
     }
 }
        protected override Location CreateLocation(string locationTypeString, string locationName)
        {
            Location location = null;

            switch (locationTypeString)
            {
                case "forest": location = new Forest(locationName); break;
                case "mine": location = new Mine(locationName); break;
                default: return base.CreateLocation(locationTypeString, locationName);
            }

            return location; 
        }
Example #6
0
        private void button6_Click(object sender, EventArgs e)
        {
            // load ged file into memory
            _gedtrees = new Forest();
            _gedtrees.LoadGEDCOM(_path);
            _gedLoadOK = !_gedtrees.IsEmpty;

            if (!_gedLoadOK)
            {
                MessageBox.Show(this, "Error Loading GED file. Please find another.", "Couldn't load",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            var firstP = _gedtrees.AllPeople.FirstOrDefault();

            _baseData = Data.fetchData(firstP).GetValueOrDefault();

            // enable all view buttons on success
            setButtonStates();
        }
Example #7
0
        public void GetForest_NonNullNameAndNotRootedDomain_NonUap(DirectoryContextType type, string name)
        {
            var context = new DirectoryContext(type, name);

            if (!PlatformDetection.IsDomainJoinedMachine)
            {
                Exception exception = Record.Exception(() => Forest.GetForest(context));
                Assert.NotNull(exception);
                Assert.True(exception is ActiveDirectoryObjectNotFoundException ||
                            exception is ActiveDirectoryOperationException,
                            $"We got unrecognized exception {exception}");

                // The result of validation is cached, so repeat this to make sure it's cached properly.
                exception = Record.Exception(() => Forest.GetForest(context));
                Assert.NotNull(exception);
                Assert.True(exception is ActiveDirectoryObjectNotFoundException ||
                            exception is ActiveDirectoryOperationException,
                            $"We got unrecognized exception {exception}");
            }
        }
Example #8
0
        private void GetNetworks()
        {
            cmbNetworks.Items.Clear();
            cmbNetworks.Items.Add(StringValue.LocalNetwork);
            try
            {
                //Get Domain Name
                Forest           hostForest = Forest.GetCurrentForest();
                DomainCollection domains    = hostForest.Domains;

                foreach (Domain domain in domains)
                {
                    cmbNetworks.Items.Add(domain.Name);
                }
            }
            catch
            {
                //fail silently because it's not on A/D
            }
        }
Example #9
0
        public static List <string> GetAllDomains()
        {
            var domainList = new List <string>();

            try
            {
                domainList.Add(Environment.MachineName);
                using var forest = Forest.GetCurrentForest();
                foreach (Domain domain in forest.Domains)
                {
                    domainList.Add(domain.Name);
                    domain.Dispose();
                }
                return(domainList);
            }
            catch
            {
                return(domainList);
            }
        }
Example #10
0
        /// <summary>
        /// This is a tempoaray fix/method to get the distinguished name.  Normally we would use the UserPrincipal.DistinguishedName.
        /// However there is a .NET 4.5 Active Directory bug that sometime fails when trying to get the UserPrincipal.
        /// Therefore we are using the global catalog for now, and calling this method to get the distinguished name.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="domainName"></param>
        /// <returns></returns>

        private static string GetDistinguishedName(string userName, string domainName)
        {
            string dn = null;

            try
            {
                var currentForest        = Forest.GetCurrentForest();
                var globalCatalog        = currentForest.FindGlobalCatalog();
                DirectorySearcher search = globalCatalog.GetDirectorySearcher();
                search.Filter = "(&(objectClass=user)(anr=" + userName + "))";
                search.PropertiesToLoad.Add("distinguishedname");
                SearchResult result = search.FindOne();
                dn = (string)result.Properties["distinguishedname"][0];
            }
            catch (Exception ex)
            {
                DebugLog.Message("Failed search.FindOne");
            }
            return(dn);
        }
Example #11
0
        public void CorrectChilSpouse()
        {
            // Correctly matching FAMC/CHIL + FAMS/HUSB pair
            var    txt = "0 @I1@ INDI\n1 FAMC @F1@\n1 FAMS @F2@\n0 @F1@ FAM\n1 CHIL @I1@\n0 @F2@ FAM\n1 HUSB @I1@";
            Forest f   = LoadGEDFromStream(txt);

            Assert.AreEqual(0, f.ErrorsCount);
            Assert.AreEqual(0, f.Errors.Count);

            Assert.AreEqual(1, f.NumberOfTrees);
            Assert.AreEqual(1, f.Indi.Count);
            Assert.AreEqual(2, f.Fams.Count);
            Assert.AreEqual(1, f.AllPeople.Count());
            var p = f.AllPeople.First();

            Assert.AreEqual(1, p.ChildIn.Count);
            Assert.AreEqual("F1", p.ChildIn.First().Id);
            Assert.AreEqual(1, p.SpouseIn.Count);
            Assert.AreEqual("F2", p.SpouseIn.First().Id);
        }
        static void TestForestFunctionalLevel()
        {
            Console.WriteLine("Testing forest functional level.");

            DirectoryContext dirContext    = new DirectoryContext(DirectoryContextType.Forest, _domain, null, null);
            Forest           forestContext = Forest.GetForest(dirContext);

            Console.Write("Forest Functional Level = {0} : ", forestContext.ForestMode);

            if (forestContext.ForestMode >= ForestMode.Windows2003Forest)
            {
                Console.WriteLine("PASSED");
            }
            else
            {
                Console.WriteLine("FAILED");
            }

            Console.WriteLine();
        }
Example #13
0
        public void GetForests()
        {
            Forest currentForest          = null;
            Forest alternateCurrentForest = null;
            Forest otherForest            = null;

            //create a new DirectoryContext for a Forest
            //using defaults for name and credentials
            DirectoryContext context = new DirectoryContext(
                DirectoryContextType.Forest);

            using (currentForest = Forest.GetForest(context))
            {
                Console.WriteLine(currentForest.Name);
            }

            //Use the shortcut static method on the Forest class to
            //do the same thing as above
            using (alternateCurrentForest = Forest.GetCurrentForest())
            {
                Console.WriteLine(alternateCurrentForest.Name);
            }

            //Now, connect to a completely different forest
            //specifying its name and the credentials we need to
            //access it
            DirectoryContext otherContext = new DirectoryContext(
                DirectoryContextType.Forest,
                "other.yourforest.com", //update this stuff.
                @"other\someone",
                "MySecret!0");

            using (otherForest = Forest.GetForest(otherContext))
            {
                Console.WriteLine(otherForest.Name);
            }
            //OUT:
            //main.myforest.com
            //main.myforest.com
            //other.yourforest.com
        }
Example #14
0
        public override void ProcessRule(Forest forest, long currentTick)
        {
            _ruleAge++;
            if (_ruleAge % Forest.YEAR_LENGTH == 0)
            {
                if (_bearNextYear)
                {
                    AddBear(forest);
                    // There were no bears last year. A new one has been born this year.
                    _bearNextYear = false;
                }

                var bears = from e in forest.Entities
                            where typeof(Bear).IsAssignableFrom(e.GetType())
                            select e as Bear;
                if (bears.Count() == 0)
                {
                    // No bears left this year. Add a new bear next year.
                    _bearNextYear = true;
                }
                else
                {
                    int maulCount = 0;
                    bears.ToList().ForEach((b) => maulCount += b.Maulings);
                    if (maulCount == 0)
                    {
                        // No maulings have occurred this year... add a new bear
                        // (because obviously someone out there doesn't like
                        // lumberjacks and is breeding bears)
                        AddBear(forest);
                    }
                    else
                    {
                        // If there's even one mauling, zookeepers come and remove a bear.
                        forest.RemoveEntity(bears.First());
                    }
                }
                // End of year. Reset number of maulings.
                bears.ToList().ForEach((e) => e.Maulings = 0);
            }
        }
Example #15
0
    private void generateStartTree(Forest forest, List <ITree> treesSpecies)
    {
        // List<ITree> startTrees = new List<ITree>();

        int width  = forest.forestMap.GetWidth();
        int height = forest.forestMap.GetHeight();

        for (int i = 0; i < (width / 20) + 1; i++)
        {
            for (int j = 0; j < (height / 20) + 1; j++)
            {
                foreach (ITree tree in treesSpecies)
                {
                    double treePositionX = r.NextDouble() * 20.0 + (double)(i * 20);
                    double treePositionY = r.NextDouble() * 20.0 + (double)(j * 20);
                    forest.AddTree(tree.CreateChildren(new Vector3((float)treePositionX, 0, (float)treePositionY)));
                }
            }
        }
        //return startTrees;
    }
Example #16
0
        public void SimpleGed()
        {
            var path = Path.Combine(rootPath, "export_ged_919.ged");

            Forest ged = new Forest();

            ged.ParseGEDCOM(path);
            Assert.AreEqual(0, ged.Errors.Count);

            var indis = ged.Indi;

            Assert.AreEqual(2, indis.Count);

            var indi = ged.FindIndiByIdent("I919");

            Assert.IsNotNull(indi);

            Assert.AreEqual('M', indi.Sex);
            Assert.IsNotNull(indi.CHAN.Date);
            Assert.AreEqual(1, indi.Names.Count);
        }
Example #17
0
        public void IterateOneTest()
        {
            var forest = new Forest();

            forest.UntouchedTrees.Add(new UntouchedTree(new Position(0, 0)));
            forest.UntouchedTrees.Add(new UntouchedTree(new Position(0, 1)));
            forest.UntouchedTrees.Add(new UntouchedTree(new Position(0, 2)));
            forest.UntouchedTrees.Add(new UntouchedTree(new Position(1, 0)));
            forest.UntouchedTrees.Add(new UntouchedTree(new Position(1, 2)));
            forest.UntouchedTrees.Add(new UntouchedTree(new Position(2, 0)));
            forest.UntouchedTrees.Add(new UntouchedTree(new Position(2, 1)));
            forest.UntouchedTrees.Add(new UntouchedTree(new Position(2, 2)));

            forest.FireTrees.Add(new FireTree(new Position(1, 1)));

            forest.Iterate();

            forest.UntouchedTrees.Should().HaveCount(4);
            forest.FireTrees.Should().HaveCount(4);
            forest.AshTrees.Should().HaveCount(1);
        }
Example #18
0
 protected override void DoTick(Forest forest, long currentTick)
 {
     for (int i = 0; i < _movesPerMonth; i++)
     {
         ForestEntity[] adj          = GetAdjacentEntities(forest);
         ForestEntity   pickedEntity = adj[_r.Next(adj.Length)];
         // Bears will maw lumberjacks if they come across them.
         if (typeof(LumberJack).IsAssignableFrom(pickedEntity.GetType()))
         {
             LumberJack l = (LumberJack)pickedEntity;
             Maulings++;
             ReplaceEntity(forest, this, l);
             break;
         }
         else if (pickedEntity.IsEmpty)
         {
             // Move here if its an empty location.
             ReplaceEntity(forest, this, pickedEntity);
         }
     }
 }
        public void TestForestRoleOwnersAndModes()
        {
            using (Forest forest = Forest.GetForest(ActiveDirectoryContext))
            {
                Assert.Equal(forest.Name, forest.NamingRoleOwner.Forest.Name);
                Assert.Equal(forest.Name, forest.SchemaRoleOwner.Forest.Name);

                Assert.True(
                    forest.ForestMode == ForestMode.Unknown ||
                    forest.ForestMode == ForestMode.Windows2000Forest ||
                    forest.ForestMode == ForestMode.Windows2003Forest ||
                    forest.ForestMode == ForestMode.Windows2003InterimForest ||
                    forest.ForestMode == ForestMode.Windows2008Forest ||
                    forest.ForestMode == ForestMode.Windows2008R2Forest ||
                    forest.ForestMode == ForestMode.Windows2012R2Forest ||
                    forest.ForestMode == ForestMode.Windows8Forest);

                Assert.True(forest.ForestModeLevel >= 0);
                Assert.Equal(forest.Name, forest.NamingRoleOwner.Forest.Name);
            }
        }
Example #20
0
        private int tick3; // sort of data and grid fill complete

        private void Form1_LoadGed(object sender, EventArgs e)
        {
            EmptyGrid();

            _sortedData = null;
            _gedtrees   = null;
            GC.Collect();

            tick1 = Environment.TickCount;

            _gedtrees = new Forest();
            _gedtrees.LoadGEDCOM(LastFile);

            tick2 = Environment.TickCount;

            _sortedData = _gedtrees.AllPeople.ToList();
            _sortedData.OrderBy(p => p.Id);

            fillingGrid = true;
            FillGrid();
        }
Example #21
0
 // gets all Active Directory computer objects in the current forest
 public static IEnumerable <ComputerPrincipal> getADComputers()
 {
     using (var forest = Forest.GetCurrentForest()) {
         foreach (Domain domain in forest.Domains)
         {
             using (domain) {
                 // create the domain context
                 var ctx = new PrincipalContext(ContextType.Domain, domain.Name);
                 // create a principal searcher to search for ComputerPrincipal objects
                 using (var comp = new ComputerPrincipal(ctx)) {
                     using (var srch = new PrincipalSearcher(comp)) {
                         foreach (ComputerPrincipal computer in srch.FindAll())
                         {
                             yield return(computer);
                         }
                     }
                 }
             }
         }
     }
 }
Example #22
0
    private void generateStartTree(Forest forest, List<ITree> treesSpecies)
    {
        // List<ITree> startTrees = new List<ITree>();

        int width = forest.forestMap.GetWidth();
        int height = forest.forestMap.GetHeight();

        for (int i = 0; i < (width / 20) + 1; i++)
        {
            for (int j = 0; j < (height / 20) + 1; j++)
            {
                foreach (ITree tree in treesSpecies)
                {
                    double treePositionX = r.NextDouble() * 20.0 + (double)(i * 20);
                    double treePositionY = r.NextDouble() * 20.0 + (double)(j * 20);
                    forest.AddTree(tree.CreateChildren(new Vector3((float)treePositionX, 0, (float)treePositionY)));
                }
            }
        }
        //return startTrees;
    }
Example #23
0
 protected override void DoTick(Forest forest, long currentTick)
 {
     for (int i = 0; i < _movesPerMonth; i++)
     {
         ForestEntity[] adj          = GetAdjacentEntities(forest);
         ForestEntity   pickedEntity = adj[_r.Next(adj.Length)];
         // Lumberjacks will chop down trees, but only if they're not saplings.
         if (typeof(Tree).IsAssignableFrom(pickedEntity.GetType()) && !(pickedEntity is Sapling))
         {
             Tree tree = (Tree)pickedEntity;
             _logs += tree.Chop();
             ReplaceEntity(forest, this, tree);
             break;
         }
         else if (pickedEntity.IsEmpty)
         {
             // Move here if its an empty location.
             ReplaceEntity(forest, this, pickedEntity);
         }
     }
 }
Example #24
0
        public void SimpleGed()
        {
            var path = @"E:\projects\YAGP\Sample GED\export_ged_919.ged";// TODO project-relative path

            Forest ged = new Forest();

            ged.ParseGEDCOM(path);
            Assert.AreEqual(0, ged.Errors.Count);

            var indis = ged.Indi;

            Assert.AreEqual(2, indis.Count);

            var indi = ged.FindIndiByIdent("I919");

            Assert.IsNotNull(indi);

            Assert.AreEqual('M', indi.Sex);
            Assert.IsNotNull(indi.CHAN.Date);
            Assert.AreEqual(1, indi.Names.Count);
        }
        protected override Location CreateLocation(string locationTypeString, string locationName)
        {
            Location location = null;

            switch (locationTypeString)
            {
            case "mine":
                location = new Mine(locationName);
                break;

            case "forest":
                location = new Forest(locationName);
                break;

            default:
                base.CreateLocation(locationTypeString, locationName);
                break;
            }

            return(location);
        }
Example #26
0
        internal ActiveDirectorySchema GetADSchema()
        {
            String serverName = _configuration.LDAPHostName;
            Forest forest     = null;

            if ((serverName == null) || (serverName.Length == 0))
            {
                // get the active directory schema
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Trying to lookup Domain controller for domain {0}",
                                  _configuration.DomainName);

                DirectoryContext context = new DirectoryContext(
                    DirectoryContextType.Domain,
                    _configuration.DomainName,
                    _configuration.DirectoryAdminName,
                    _configuration.DirectoryAdminPassword);

                DomainController dc = DomainController.FindOne(context);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Found Domain controller named {0} with ipAddress {1} for domain {2}",
                                  dc.Name, dc.IPAddress, _configuration.DomainName);
                forest = dc.Forest;
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Found forest");
            }
            else
            {
                DirectoryContext context = new DirectoryContext(
                    DirectoryContextType.DirectoryServer,
                    _configuration.LDAPHostName,
                    _configuration.DirectoryAdminName,
                    _configuration.DirectoryAdminPassword);
                forest = Forest.GetForest(context);
            }

            LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Getting schema from AD");
            ActiveDirectorySchema ADSchema = forest.Schema;

            LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Got schema from AD");

            return(ADSchema);
        }
Example #27
0
        public static void Main(string[] args)
        {
            //if (args == null)
            //    throw new ArgumentNullException(nameof(args));

            var options = new Options();

            if (!Parser.Default.ParseArguments(args, options))
            {
                return;
            }

            //LDAPS
            ldaps |= options.Ldaps;

            //Domain
            if (options.Domain != null)
            {
                try
                {
                    var context = new DirectoryContext(DirectoryContextType.Domain, options.Domain);
                    domain = Domain.GetDomain(context);
                    forest = domain.Forest;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    return;
                }
            }
            else
            {
                domain = Domain.GetCurrentDomain();
                forest = Forest.GetCurrentForest();
            }



            Collector();
        }
Example #28
0
        private void LoadMap(Bytemap bitmap)
        {
            _tiles = new ITile[WIDTH, HEIGHT];

            for (int x = 0; x < WIDTH; x++)
            {
                for (int y = 0; y < HEIGHT; y++)
                {
                    ITile tile;
                    bool  special = TileIsSpecial(x, y);
                    switch (bitmap[x, y])
                    {
                    case 2: tile = new Forest(x, y, special); break;

                    case 3: tile = new Swamp(x, y, special); break;

                    case 6: tile = new Plains(x, y, special); break;

                    case 7: tile = new Tundra(x, y, special); break;

                    case 9: tile = new River(x, y); break;

                    case 10: tile = new Grassland(x, y); break;

                    case 11: tile = new Jungle(x, y, special); break;

                    case 12: tile = new Hills(x, y, special); break;

                    case 13: tile = new Mountains(x, y, special); break;

                    case 14: tile = new Desert(x, y, special); break;

                    case 15: tile = new Arctic(x, y, special); break;

                    default: tile = new Ocean(x, y, special); break;
                    }
                    _tiles[x, y] = tile;
                }
            }
        }
Example #29
0
        public string buscar_jefe()
        {
            var    lista    = new List <string>();
            string manager  = "No encuentro nada";
            string username = "******";

            using (var forest = Forest.GetCurrentForest())
            {
                foreach (Domain domain in forest.Domains)
                {
                    var userdomain = domain.Name.Split(Convert.ToChar("."))[0].ToUpper();

                    List <string> gruposEncontrados = new List <string>();
                    // Creamos un objeto DirectoryEntry para conectarnos al directorio activo
                    DirectoryEntry adsRoot = new DirectoryEntry("LDAP://" + userdomain);
                    // Creamos un objeto DirectorySearcher para hacer una búsqueda en el directorio activo
                    DirectorySearcher adsSearch = new DirectorySearcher(adsRoot);
                    adsSearch.PropertiesToLoad.Add("manager");

                    // Ponemos como filtro que busque el usuario actual
                    adsSearch.Filter = "samAccountName=" + username;

                    SearchResult oResult;
                    // Extraemos la primera coincidencia
                    oResult = adsSearch.FindOne();

                    if (oResult != null)
                    {
                        manager = oResult.Properties["manager"][0].ToString();

                        string[] words = manager.Split(',');
                        manager = words[0];
                        string[] words2 = manager.Split('=');
                        manager = words2[1];
                        return(manager);
                    }
                }
            }
            return("manager");
        }
Example #30
0
        public bool FindOneDesc(String desc)
        {
            DirectorySearcher USER_SEARCH = getUserSearcher();

            if (!isValidDisplayName(desc))
            {
                Console.WriteLine("User name   of '" + desc + "': Invalid display name.");
                return(false);
            }
            if (desc == null)
            {
                return(false);
            }
            if (USERS.ContainsKey(desc))
            {
                return(true);
            }
            desc = desc.Trim();
            if (desc.Length == 0)
            {
                return(false);
            }
            foreach (Domain d in Forest.GetCurrentForest().Domains)
            {
                string filter_save = USER_SEARCH.Filter;
                USER_SEARCH.SearchRoot = d.GetDirectoryEntry();
                USER_SEARCH.Filter     = "(&(ObjectClass=user)(!ObjectClass=computer)(employeeID=*)(displayName=" + desc + "))";
                SearchResult r = USER_SEARCH.FindOne();
                USER_SEARCH.Filter = filter_save;
                if (r != null)
                {
                    string u = AddUser(r);
                    //Console.WriteLine("UsersInfo.FindOneDesc " + desc + " (" + u + ")");

                    return(true);
                }
            }
            Console.WriteLine("User name   of '" + desc + "': Not found.");
            return(false);
        }
        public override string[] Execute(ParsedArgs args)
        {
            try
            {
                Amass            forestDomains    = new Amass();
                Forest           theCurrentForest = forestDomains.GetForestObject();
                DomainCollection forestDomainList = theCurrentForest.Domains;

                List <string> result = new List <string>();

                foreach (Domain internalDomain in forestDomainList)
                {
                    result.Add(internalDomain.Name);
                }

                return(result.ToArray());
            }
            catch (Exception e)
            {
                return(new string[] { "[X] Failure to enumerate info - " + e });
            }
        }
Example #32
0
        public void NoIndi()
        {
            // FAM.HUSB and no INDI
            var    txt = "0 @F1@ FAM\n1 HUSB @I1@";
            Forest f   = LoadGEDFromStream(txt);

            Assert.AreEqual(1, f.ErrorsCount);
            Assert.AreEqual(Issue.IssueCode.SPOUSE_CONN_MISS, f.Issues.First().IssueId);
            Assert.AreEqual(0, f.Errors.Count);

            Assert.AreEqual(0, f.NumberOfTrees);
            Assert.AreEqual(0, f.Indi.Count);
            Assert.AreEqual(1, f.Fams.Count);
            Assert.AreEqual(0, f.AllPeople.Count());

            /* TODO what should happen here? keep the INDI id even though the INDI doesn't exist?
             * var fam = f.AllUnions.First();
             * Assert.AreEqual("I1", fam.Husband.Id);
             * Assert.AreEqual(1, fam.Spouses.Count);
             * Assert.AreEqual("I1", fam.Spouses.First().Id);
             */
        }
Example #33
0
        private bool GetIsOneWayTrust()
        {
            var forest = Forest.GetCurrentForest();

            if (this.GetIsInCurrentForest())
            {
                return(false);
            }

            var trusts = forest.GetAllTrustRelationships();

            foreach (var trust in trusts.OfType <TrustRelationshipInformation>())
            {
                if (string.Equals(this.DomainDnsName, trust.TargetName) &&
                    trust.TrustDirection == TrustDirection.Inbound)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #34
0
        public bool FindOneDomainUser(String domainuser)
        {
            DirectorySearcher USER_SEARCH = getUserSearcher();
            string            domain      = domainuser.Split('\\')[0].ToUpper();
            string            user        = domainuser.Split('\\')[1].ToUpper();

            if (USRDU.ContainsKey(user))
            {
                return(true);
            }

            bool found = false;

            foreach (Domain d in Forest.GetCurrentForest().Domains)
            {
                if (d.GetDirectoryEntry().Properties["name"].Value.ToString().ToUpper().Equals(domain))
                {
                    USER_SEARCH.SearchRoot = d.GetDirectoryEntry();
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                return(false);
            }

            //string filter_save = USER_SEARCH.Filter;
            USER_SEARCH.Filter = "(&(ObjectClass=user)(!ObjectClass=computer)(employeeID=*)(sAMAccountName=" + user + "))";
            SearchResult r = USER_SEARCH.FindOne();

            //USER_SEARCH.Filter = filter_save;
            if (r == null)
            {
                return(false);
            }
            AddUser(r);
            return(true);
        }
Example #35
0
        public bool FindOneUser(String user)
        {
            if (USRDU.ContainsKey(user))
            {
                return(true);
            }
            DirectorySearcher USER_SEARCH = getUserSearcher();

            //string filter_save = USER_SEARCH.Filter;
            foreach (Domain d in Forest.GetCurrentForest().Domains)
            {
                USER_SEARCH.SearchRoot = d.GetDirectoryEntry();
                USER_SEARCH.Filter     = "(&(ObjectClass=user)(!ObjectClass=computer)(employeeID=*)(sAMAccountName=" + user + "))";
                SearchResult r = USER_SEARCH.FindOne();
                if (r != null)
                {
                    AddUser(r); return(true);
                }
            }
            //USER_SEARCH.Filter = filter_save;
            return(false);
        }
Example #36
0
        private Forest GetResult(SearchResult result)
        {
            Forest forest = new Forest();

            try
            {
                if (result != null)
                {
                    return(GetProperties(forest, result.Properties));
                }
                else
                {
                    Console.WriteLine("Forest not found!");
                    return(null);
                }
            }
            catch (System.DirectoryServices.DirectoryServicesCOMException e)
            {
                Console.WriteLine("\r\nUnexpected exception occurred:\r\n\t" + e.GetType() + ":" + e.Message);
                return(null);
            }
        }
	public void UpdateTrustRelationship(Forest targetForest, TrustDirection newTrustDirection) {}
	public void CreateTrustRelationship(Forest targetForest, TrustDirection direction) {}
	public void VerifyTrustRelationship(Forest targetForest, TrustDirection direction) {}
	public void DeleteTrustRelationship(Forest targetForest) {}
Example #41
0
	/**
	 * Called when the script is loaded, before the game starts
	 */
	void Awake () {
		S = this;
	}
Example #42
0
 protected override void Initialize()
 {
     Window.Title = "3D Project";
     //IsMouseVisible = true;
     graphics.PreferredBackBufferWidth = 1280;
     graphics.PreferredBackBufferHeight = 1024;
     graphics.ApplyChanges();
     land = new Ground("x6");
     camera = new Camera();
     dome = new Sky();
     trees = new Forest();
     this.Components.Add(new FrameRateCounter(this));
     this.Components.Add(new ShowFPS(this));
     base.Initialize();
 }
Example #43
0
 public Forest createForest(Map map, List<ITree> treesSpecies, Texture2D texture)
 {
     Forest forest = new Forest(new List<ITree>(), treesSpecies, map, texture);
     generateStartTree(forest, treesSpecies, texture);
     return forest;
 }
Example #44
0
 void Awake()
 {
     forest = Forest;
 }
	public void RepairTrustRelationship(Forest targetForest) {}
Example #46
0
    /// <summary>
    /// button for counting next years check all conditions
    /// </summary>
    public void NextYear()
    {
        if (prefabs[0] == null)
        {
            Debug.Log("load tree data");
            f = null;
        }
        else
        {
            Map map = FindObjectOfType(typeof(Map)) as Map;
            if (map == null)
            {
                # region NeniMapaAniStromyVytvoritVse
                if (mapPrefab == null)
                {
                    Debug.Log("cannot find map");
                    return;
                }
                f = null;
                Debug.Log("Loading map or trees");
                List<ITree> species = new List<ITree>();
                for (int i = 0; i < treePrefabsCount; i++)
                {
                    if (prefabs[i] != null)
                    {
                        ITree tree = ((GameObject)Instantiate(prefabs[i].gameObject)).GetComponent<ITree>();
                        tree.transform.position = new Vector3(-20, -200, -20);
                        species.Add(tree);

                    }
                    else
                    {
                        break;
                    }
                }

                Map tempMap = ((GameObject)Instantiate(mapPrefab.gameObject)).GetComponent<Map>();
                tempMap.transform.position = new Vector3(0, 0, 0);
                // max size which tree can growth
                Forest.treeSize = prefabs[0].GetComponent<Renderer>().bounds.size.y;
                if (texture == null)
                {
                    f = new ForestManager().createForest(tempMap, species);
                }else
                {
                    f = new ForestManager().createForest(tempMap, species, texture);
                }
                f.DeleteDead(species);
                # endregion
            }
            else
            {
                # region MapaJeStromyNagenerovat
                //check if there is enought trees on map (at least prefabcount+1 trees in scene or loading new
                if (f == null)// || Resources.FindObjectsOfTypeAll(typeof(ITree)).GetLength(0)+1 <=treePrefabsCount)
                {
                    f = LoadForest();
                }
                if (f.allTrees.Count <= treePrefabsCount + 1)
                {
                    List<ITree> species = new List<ITree>();
                    for (int i = 0; i < treePrefabsCount; i++)
                    {
                        if (prefabs[i] != null)
                        {
                            ITree tree = ((GameObject)Instantiate(prefabs[i].gameObject)).GetComponent<ITree>();
                            tree.transform.position = new Vector3(-20, -200, -20);
                            species.Add(tree);

                        }
                        else
                        {
                            break;
                        }
                    }
                    Forest.treeSize = prefabs[0].GetComponent<Renderer>().bounds.size.y;

                    if (texture == null)
                    {
                        f = new ForestManager().createForest(map, species);
                    }else
                    {
                        f = new ForestManager().createForest(map, species, texture);
                    }
                    f.DeleteDead(species);

                }
                else
                {
                    Debug.Log("enought trees");
                }
                #endregion

            }
Example #47
0
// MonoBehaviour
//
	void Awake () {
		Forest.globalInstance = this;

		savageSpawnWaitTime = Random.Range (0.0f, savageSpawnDelay);
		animalSpawnWaitTime = Random.Range (0.0f, animalSpawnDelay);
	}
Example #48
0
    /// <summary>
    /// loading already contained forest (gameobjects-trees)
    /// </summary>
    /// <returns></returns>
    public Forest LoadForest()
    {
        Object [] objects = Resources.FindObjectsOfTypeAll(typeof(ITree));

        List<ITree> trees = new List<ITree>();
        Debug.Log(objects.GetLength(0) + "finded trees");
        for (int i = 0; i < objects.Length; i++)
        {
            if (PrefabUtility.GetPrefabParent((ITree)objects[i]) == null && PrefabUtility.GetPrefabObject((ITree)objects[i]) != null)
            {
            }// Is a prefab
            else
            {
                trees.Add((ITree)objects[i]);
            }
        }
        Map map = FindObjectOfType(typeof(Map)) as Map;
           // pokud se najde malo stromu je třeba generovat znova
        if (texture != null)
        {
            f = new Forest(trees, null, map, texture);
        }
        else
        {
            f = new Forest(trees, null, map);
        }
        return f;
    }
Example #49
0
 public void ResetForset()
 {
     Forest = new Forest();
     selectedTreeIndex = 0;
     selectedNodeIndex = 0;
 }
Example #50
0
 public void UpdateForest() {
     forest1 = forest2;
     forest2 = GenerateForest();
 }
Example #51
0
        public MapResource(SimulationWorld world, ConfigurationSection sect)
        {
            string type = sect["Type"].ToLowerInvariant();

            switch (type)
            {
                case "petro":
                    OilField oil = new OilField(world);
                    oil.Parse(sect);

                    Longitude = oil.Longitude;
                    Latitude = oil.Latitude;

                    Type = NaturalResourceType.Petro;
                    Amount = oil.CurrentAmount;

                    break;
                case "wood":
                    Forest fores = new Forest(world);
                    fores.Parse(sect);

                    Longitude = fores.Longitude;
                    Latitude = fores.Latitude;

                    Type = NaturalResourceType.Wood;
                    Amount = fores.CurrentAmount;
                    Radius = fores.Radius;
                    break;
            }

        }