void InstanceMap(MapConfig mapConfig) { if (War.sceneData == null) { this.ShowNotification(new GUIContent("请先'选择关卡'或者'创建关卡'")); return; } WarEditor.LoadRes(mapConfig.terrain); War.sceneData.mapConfig = mapConfig; War.map.Clear(); War.map.Instance(); GameObject root = GameObject.Find("Scene/Caserns"); if (root != null) { int count = root.transform.childCount; for (int i = 0; i < count; i++) { BuildAgent buildAgent = root.transform.GetChild(i).GetComponent <BuildAgent>(); if (buildAgent != null) { buildAgent.InitBuildGround(); } } } }
public void CombinedTest() { var configurationTemplate = DomainConfigurationFactory.Create(); configurationTemplate.Types.Register(typeof(BuildAgent).Assembly, typeof(BuildAgent).Namespace); var initialConfiguration = configurationTemplate.Clone(); initialConfiguration.UpgradeMode = DomainUpgradeMode.Recreate; Dictionary <Type, int> typeIdentifiers; using (var initialDomain = Domain.Build(initialConfiguration)) { typeIdentifiers = initialDomain.Model.Types .ToDictionary(type => type.UnderlyingType, type => type.TypeId); using (var session = initialDomain.OpenSession()) using (var ts = session.OpenTransaction()) { new BuildAgent("Agent Smith") .CompatibleConfigurations.Add(new BuildConfiguration("SQL Server")); new BuildAgent("Agent Thompson") .CompatibleConfigurations.Add(new BuildConfiguration("PostgreSQL")); new BuildAgent("Agent Johnson") .CompatibleConfigurations.Add(new BuildConfiguration("Oracle")); ts.Complete(); } } var testedConfiguration = configurationTemplate.Clone(); testedConfiguration.UpgradeMode = DomainUpgradeMode.Skip; using (var testedDomain = Domain.Build(testedConfiguration)) { Assert.AreEqual(typeIdentifiers.Count, testedDomain.Model.Types.Count); foreach (var typeInfo in testedDomain.Model.Types) { var oldTypeId = typeIdentifiers[typeInfo.UnderlyingType]; var newTypeId = typeInfo.TypeId; Assert.AreEqual(oldTypeId, newTypeId); } using (var session = testedDomain.OpenSession()) using (var ts = session.OpenTransaction()) { var trinity = new BuildAgent("Trinity"); Assert.AreEqual(4, session.Query.All <BuildAgent>().Count()); Assert.AreEqual(3, session.Query.All <BuildConfiguration>().Count()); foreach (var agent in session.Query.All <BuildAgent>().Where(a => a != trinity).ToList()) { foreach (var configuration in agent.CompatibleConfigurations.ToList()) { agent.CompatibleConfigurations.Remove(configuration); trinity.CompatibleConfigurations.Add(configuration); } } Assert.AreEqual(3, trinity.CompatibleConfigurations.Count()); ts.Complete(); } } }
static void LaunchBuildAgent(Options options) { var agent = new BuildAgent(options); agent.RunAgent(); }