public override TclCommand[] Translate(StructurePart targetElement, out string elementTag) { var elm = targetElement as TriangleElement; var sec = elm.Section.GetThicknessAt(0);// as Sections.UniformParametric1DSection; var mat = elm.Material as Materials.UniformIsotropicMaterial; var g = mat.YoungModulus / (2 * (1 + mat.PoissonRatio)); var buf = new List <TclCommand>(); var eleTag = TargetGenerator.GetCounter("element"); var matTag = TargetGenerator.GetCounter("nDMaterial"); buf.Add(new TclCommand("nDMaterial", "ElasticIsotropic", matTag, mat.YoungModulus, mat.PoissonRatio)); buf.Add(new TclCommand("element", "tri31 ", eleTag, elm.Nodes[0].GetIndex(), elm.Nodes[1].GetIndex(), elm.Nodes[2].GetIndex(), sec, "PlaneStrain", matTag)); TargetGenerator.SetCounter("element", eleTag + 1); TargetGenerator.SetCounter("nDMaterial", matTag + 1); elementTag = eleTag.ToString(CultureInfo.CurrentCulture); return(buf.ToArray()); }
public override TclCommand[] Translate(StructurePart targetElement, out string elementTag) { var elm = targetElement as TetrahedronElement; var e = elm.Material.GetMaterialPropertiesAt(0, 0, 0).Ex; var nu = elm.Material.GetMaterialPropertiesAt(0, 0, 0).NuXy; var buf = new List <TclCommand>(); var eleTag = TargetGenerator.GetCounter("element"); //var transTag = TargetGenerator.GetCounter("geomTransf"); var matTag = TargetGenerator.GetCounter("nDMaterial"); //var vec = elm.GetTransformationManager().TransformLocalToGlobal(Vector.K).GetUnit(); buf.Add(new TclCommand("nDMaterial", "ElasticIsotropic", matTag, e, nu)); buf.Add(new TclCommand("element", "FourNodeTetrahedron", eleTag, elm.Nodes[0].GetIndex(), elm.Nodes[1].GetIndex(), elm.Nodes[2].GetIndex(), elm.Nodes[3].GetIndex(), matTag, 0, 0, 0)); TargetGenerator.SetCounter("element", eleTag + 1); TargetGenerator.SetCounter("nDMaterial", matTag + 1); elementTag = eleTag.ToString(CultureInfo.CurrentCulture); return(buf.ToArray()); }
public override TclCommand[] Translate(StructurePart targetElement, out string elementTag) { var elm = targetElement as BarElement; var sec = elm.Section as Sections.UniformParametric1DSection; var mat = elm.Material as Materials.UniformIsotropicMaterial; var g = mat.YoungModulus / (2 * (1 + mat.PoissonRatio)); var buf = new List <TclCommand>(); var eleTag = TargetGenerator.GetCounter("element"); var transTag = TargetGenerator.GetCounter("geomTransf"); var vec = elm.GetTransformationManager().TransformLocalToGlobal(Vector.K).GetUnit(); buf.Add(new TclCommand("geomTransf", "Linear ", transTag, vec.X, vec.Y, vec.Z)); buf.Add(new TclCommand("element", "elasticBeamColumn", eleTag, elm.StartNode.GetIndex(), elm.EndNode.GetIndex(), sec.A, mat.YoungModulus , g , sec.J, sec.Iz, sec.Iy, transTag)); TargetGenerator.SetCounter("element", eleTag + 1); TargetGenerator.SetCounter("geomTransf", transTag + 1); elementTag = eleTag.ToString(); return(buf.ToArray()); }
public override TclCommand[] Translate(StructurePart targetElement, out string elementTag) { var elm = targetElement as TriangleElement; var sec = elm.Section.GetThicknessAt(0);// as Sections.UniformParametric1DSection; var mat = elm.Material as Materials.UniformIsotropicMaterial; var g = mat.YoungModulus / (2 * (1 + mat.PoissonRatio)); var buf = new List <TclCommand>(); var eleTag = TargetGenerator.GetCounter("element"); var secTag = TargetGenerator.GetCounter("section"); var vec = elm.GetTransformationManager().TransformLocalToGlobal(Vector.K).GetUnit(); buf.Add(new TclCommand("section", "ElasticMembranePlateSection", secTag, mat.YoungModulus, mat.PoissonRatio, sec, 0)); buf.Add(new TclCommand("element", "ShellDKGT", eleTag, elm.Nodes[0].GetIndex(), elm.Nodes[1].GetIndex(), elm.Nodes[2].GetIndex(), secTag)); TargetGenerator.SetCounter("element", eleTag + 1); TargetGenerator.SetCounter("section", secTag + 1); elementTag = eleTag.ToString(CultureInfo.CurrentCulture); return(buf.ToArray()); }
public static TargetGenerator GetInstance() { if (_instance == null) { _instance = new TargetGenerator(); } return(_instance); }
private void Run() { if (!generators.ContainsKey(currentTag)) { Debug.Log(currentTag + ": Not Exist!"); return; } current = generators[currentTag] as TargetGenerator; current.gen.SendMessage("OnGeneratorStart"); }
void Start() { if (!Instance) { Instance = this; } for (int i = 0; i < startingTargets; i++) { StartCoroutine(CreateTarget(0)); } }
public void That_GetTarget_ReturnsX6Y5WhenAskedForX6Y5() { // Give a target generator INumberGenerator numberGenerator = new NumberGenerator(); ITargetGenerator serviceToTest = new TargetGenerator(numberGenerator); // When I ask for target x = 6, y = 5 Coordinate actual = serviceToTest.GetTarget(x: 6, y: 5); // then I get x = 6, y = 5 Assert.AreEqual(6, actual.X); Assert.AreEqual(5, actual.Y); }
private void AddGenerator( RandomGenerator generater ) { Debug.Log("AddGenerator"); if (generater == null) return; GameObject target = generater.Target(); Debug.Log("Target:" + target.tag); if (target == null) return; string tag = target.tag; TargetGenerator targetGenerator = new TargetGenerator(); targetGenerator.clearCondition = false; targetGenerator.gen = generater; generators.Add(tag, targetGenerator); }
public void That_GetTarget_DoesNotCallNumberGeneratorWhenTargetAsked() { // Give a target generator var mockNumberGenerator = new Mock <INumberGenerator>(); mockNumberGenerator.Setup(x => x.GetNumber()).Returns(5); ITargetGenerator serviceToTest = new TargetGenerator( mockNumberGenerator.Object); // When I ask for a target Coordinate actual = serviceToTest.GetTarget(x: 5, y: 5); // then number generator not called mockNumberGenerator.Verify(x => x.GetNumber(), Times.Never); }
public void That_GetTarget_CallsNumberGeneratorTwiceWhenNoTargetAsked() { // Give a target generator var mockNumberGenerator = new Mock <INumberGenerator>(); mockNumberGenerator.Setup(x => x.GetNumber()).Returns(5); ITargetGenerator serviceToTest = new TargetGenerator( mockNumberGenerator.Object); // When I do not ask for a target Coordinate actual = serviceToTest.GetTarget(); // then number generator called twice mockNumberGenerator.Verify(x => x.GetNumber(), Times.Exactly(2)); }
private void AddGenerator(RandomGenerator generater) { Debug.Log("AddGenerator"); if (generater == null) { return; } GameObject target = generater.Target(); Debug.Log("Target:" + target.tag); if (target == null) { return; } string tag = target.tag; TargetGenerator targetGenerator = new TargetGenerator(); targetGenerator.clearCondition = false; targetGenerator.gen = generater; generators.Add(tag, targetGenerator); }
public override TclCommand[] Translate(StructurePart targetElement, out string elementTag) { var elm = targetElement as Tetrahedral; //var sec = elm.Section as Sections.UniformParametric1DSection; //var mat = elm.Material as Materials.UniformIsotropicMaterial; //var g = mat.YoungModulus / (2 * (1 + mat.PoissonRatio)); var e = elm.E; var buf = new List <TclCommand>(); var eleTag = TargetGenerator.GetCounter("element"); //var transTag = TargetGenerator.GetCounter("geomTransf"); var matTag = TargetGenerator.GetCounter("nDMaterial"); //var vec = elm.GetTransformationManager().TransformLocalToGlobal(Vector.K).GetUnit(); buf.Add(new TclCommand("nDMaterial", "ElasticIsotropic", matTag, elm.E, elm.Nu)); buf.Add(new TclCommand("element", "FourNodeTetrahedron", eleTag, elm.Nodes[0].GetIndex(), elm.Nodes[1].GetIndex(), elm.Nodes[2].GetIndex(), elm.Nodes[3].GetIndex(), matTag, 0, 0, 0)); TargetGenerator.SetCounter("element", eleTag + 1); TargetGenerator.SetCounter("nDMaterial", matTag + 1); elementTag = eleTag.ToString(CultureInfo.CurrentCulture); return(buf.ToArray()); }
void OnClearCondition(string tag) { // クリア条件. bool allClear = true; foreach (string key in generators.Keys) { // 条件を達成していたタグのTargetObjectをtrueにする. TargetGenerator target = generators[key] as TargetGenerator; if (tag.CompareTo(key) == 0) { target.clearCondition = true; } // 全部クリアできてるかチェック. allClear &= target.clearCondition; } if (allClear) { // ゲーム終了、次のステージへ. GameObject adapter = GameObject.Find("/Adapter"); adapter.SendMessage("OnGameEnd", true); } }
void OnClearCondition(string tag) { // 清空条件 bool allClear = true; foreach (string key in generators.Keys) { // 将用于表示条件满足的标签TargetObject值设置为true TargetGenerator target = generators[key] as TargetGenerator; if (tag.CompareTo(key) == 0) { target.clearCondition = true; } // 检测是否全部清空 allClear &= target.clearCondition; } if (allClear) { // 游戏结束,进入下一步骤 GameObject adapter = GameObject.Find("/Adapter"); adapter.SendMessage("OnGameEnd", true); } }