public static DynamicNativePoint GetDynamicNativePoint(int townId) { VArtifactTown vat = VArtifactTownManager.Instance.GetTownByID(townId); DynamicNativePoint result; DynamicNative[] dns = vat.nativeTower.dynamicNatives; System.Random randSeed = new System.Random(System.DateTime.Now.Millisecond); DynamicNative dn = dns[randSeed.Next(dns.Count())]; result.id = dn.did; result.type = dn.type; if (dn.type == 1) { result.point = GetDynamicNativeSinglePoint(vat, randSeed); } else { result.point = GetDynamicNativeGroupPoint(vat, randSeed); } return(result); }
public static void TestXxmlCreating() { string filePath = Application.dataPath + "/TestNativeCampXML"; Directory.CreateDirectory(filePath); filePath += "/VANativeCamp.xml"; using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write)) { XmlSerializer serialize = new XmlSerializer(typeof(VANativeCampDesc)); NpcIdNum[] npcIdNum = new NpcIdNum[2]; npcIdNum[0] = new NpcIdNum(); npcIdNum[1] = new NpcIdNum(); BuildingIdNum[] bdnum = new BuildingIdNum[2]; bdnum[0] = new BuildingIdNum(); bdnum[1] = new BuildingIdNum(); ArtifactUnit artifactUnit = new ArtifactUnit(); artifactUnit.id = "-1"; artifactUnit.pos = "100,200"; artifactUnit.rot = "-1"; artifactUnit.npcIdNum = npcIdNum; artifactUnit.buildingIdNum = bdnum; ArtifactUnit[] artifactUnitArray = new ArtifactUnit[] { artifactUnit, artifactUnit }; NativeCamp camp = new NativeCamp(); camp.artifactUnitArray = artifactUnitArray; DynamicNative dn = new DynamicNative(); NativeTower nt = new NativeTower(); nt.dynamicNatives = new DynamicNative[] { dn, dn }; camp.nativeTower = nt; VANativeCampDesc ncd = new VANativeCampDesc(); NativeCamp[] townArry = new NativeCamp[] { camp, camp }; ncd.nativeCamps = townArry; serialize.Serialize(fs, ncd); } }