public void CheckCollideEvent() { var obj1 = new Object1() { Position = new Position(new Point(0, 0), new Size(2, 2)) }; var obj2 = new Object2() { Position = new Position(new Point(2, 2), new Size(2, 2)) }; var world = new World( new FourWays(), new GameObject[] { obj1, obj2 }); var fake = new FakeCollideInteraction(); world.AddIConditionalEvent(fake); world.Tick(); Assert.AreEqual(fake.ShouldCount, 1); Assert.AreEqual(fake.HappenCount, 0); obj2.Position = new Position(new Point(1, 1), new Size(2, 2)); world.Tick(); Assert.AreEqual(fake.ShouldCount, 2); Assert.AreEqual(fake.HappenCount, 1); }
public void SaveCondEvent_fake() { var obj1 = new Object1() { Position = new Position(new Point(0, 0), new Size(1, 1)) }; var obj2 = new Object2() { Position = new Position(new Point(1, 1), new Size(1, 1)) }; collideEvent = A.Fake <CollideInteraction <Object1, Object2> >(); var world = new World( new FourWays(), new GameObject[] { obj1, obj2 }); world.AddIConditionalEvent(collideEvent); world.Tick(); A.CallTo(() => collideEvent.ShouldHappenNow(obj1, obj2)). MustHaveHappenedOnceExactly(); A.CallTo(() => collideEvent.Happen(obj1, obj2)). MustNotHaveHappened(); }
static void Main(string[] args) { var src = new Object1(); var dst = new Object2(); src.Prop = new Property(); src.Prop.Value = 1; bool valueOnly = true; if (valueOnly) { SetProp(src, dst); src.Prop.Value = 5; // -> src.Prop.Value : 5 // -> dst.Prop.Value : 1 } else { SetPropSameRef(src, dst); src.Prop.Value = 5; // -> src.Prop.Value : 5 // -> dst.Prop.Value : 5 } }
public static void Main(string[] args) { try { Object1 target = new Object1 { Value1 = 10, Value2 = 20, Value3 = new Object2 { Value1 = 100, Value2 = 200, Value3 = 300 } }; System.Type t = target.GetType(); String propertyName = "Value3"; Object2 child = (Object2)t.InvokeMember(propertyName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty, null, target, new object [] {}); Console.WriteLine("child: {0}", child); } catch (System.Exception exc1) { Console.WriteLine("Exception: {0}", exc1.ToString()); } }
public override void Grab(Controller123 controller, Rigidbody attach) { GameObject gameobject = Object2.Instantiate(gamePrefab); switch (selectObjectToSpawn) { case Thing.Rock: gameobject.GetComponent <Rock>().Grab(controller, attach); break; case Thing.Tree: gameobject.GetComponent <Treee>().Grab(controller, attach); break; case Thing.House: gameobject.GetComponent <HousingMaster>().Grab(controller, attach); break; case Thing.ConstructionFrame: gameobject.GetComponent <ConstructionFrame>().Grab(controller, attach); break; default: break; } }
}// pt.parent.gameObject は pt.gameObject でも同じ意味のハズ public void MakeLineLog(int _id, int _o1, int _o2, GameObject _pa, bool _active, string _pname) { ObjectType = "Line"; Id = _id; Object1Id = _o1; Object2Id = _o2; Point[] OBJs = FindObjectsOfType <Point>(); for (int i = 0; i < OBJs.Length; i++) { if (OBJs[i].Id == _o1) { Object1 = OBJs[i].gameObject; } if (OBJs[i].Id == _o2) { Object2 = OBJs[i].gameObject; } } parent = _pa; Active = _active; Show = Util.ShowLog; PName = _pname; Position.x = Util.LogLeft; Text1 = "直線 " + PName; Text2 = Object1.GetComponent <Point>().PointName + "-" + Object2.GetComponent <Point>().PointName; }
public void Test2() { ObjectMapper om = Map.GetObjectMapper(typeof(Object2)); Object2 o = new Object2(); om.SetValue(o, "Int", 456); Assert.AreEqual(456, o.Int); Assert.AreEqual(45, om.GetValue(o, "Int")); }
public void CheckCondEvent() { var obj1 = new Object1(); // { Position = new Position(new Point(0, 0), new Size(1, 1)) }; var obj2 = new Object2(); // { Position = new Position(new Point(1, 1), new Size(1, 1)) }; var condEvent = new FakeEvent(); var world = new World( new FourWays(), new GameObject[] { obj1, obj2 }); world.AddIConditionalEvent(condEvent); world.Tick(); Assert.AreEqual(condEvent.ShouldCount, 1); Assert.AreEqual(condEvent.HappenCount, 0); }
protected override void OnCollisionEnter(Collision collision) { base.OnCollisionEnter(collision); activateDestroyTimer = true; //Debug.Log("Activate DestroyTimer"); if (rigi.velocity.sqrMagnitude >= vfxSpawnThreshold) { if (particleSystem) { var obj = Object2.Instantiate <GameObject>(particleSystem, collision.GetContact(0).point, Quaternion.identity, null); Destroy(obj, 1.0f); } } }
public override void Grab(Controller123 controller, Rigidbody attach) { if (isGrabbable) { Regrow(); pineParticles.Play(); //base.Grab(attach); GameObject gameobject = Object2.Instantiate(treePrefab); gameobject.GetComponent <Treee>().Grab(controller, attach); } else { //Debug.Log("Tree is not ready yet"); } }
private void IncBinding2_Button_Click(object sender, EventArgs e) { if (TopMount_radioButton.Checked == true) { if (Object4.Get_Height() + 0.5f < Object2.Get_Height()) { Object4.Set_Height(Object4.Get_Height() + 0.5f); } } else { if (Object4.Get_Height() - 0.5f > Object1.Get_Height()) { Object4.Set_Height(Object4.Get_Height() - 0.5f); } } }
public void NullableMemberTest() { Object2 o = new Object2(); short? s = 125; Guid g = Guid.NewGuid(); DayOfWeek de = DayOfWeek.Thursday; int di = (int)de; ObjectMapper <Object2> .SetValue(o, "Int16", s); ObjectMapper <Object2> .SetValue(o, "Int32", 123.56); ObjectMapper <Object2> .SetValue(o, "Int64", null); ObjectMapper <Object2> .SetValue(o, "Float", 123.57.ToString()); ObjectMapper <Object2> .SetValue(o, "Guid", (Guid?)g); ObjectMapper <Object2> .SetValue(o, "Guid", g); ObjectMapper <Object2> .SetValue(o, "Dow1", de); ObjectMapper <Object2> .SetValue(o, "Dow1", (DayOfWeek?)de); ObjectMapper <Object2> .SetValue(o, "Dow2", di); Assert.AreEqual(125, o.Int16); Assert.AreEqual(123, o.Int32); Assert.IsNull(o.Int64); Assert.AreEqual(g, o.Guid); Assert.AreEqual(de, o.Dow1); Assert.AreEqual(de, o.Dow2); Assert.IsTrue(Math.Abs(123.57 - o.Float.Value) < 0.0001); Assert.AreEqual(125, ObjectMapper <Object2> .GetValue(o, "Int16")); Assert.AreEqual(123, ObjectMapper <Object2> .GetValue(o, "Int32")); Assert.IsNull(ObjectMapper <Object2> .GetValue(o, "Int64")); Assert.AreEqual(g, ObjectMapper <Object2> .GetValue(o, "Guid")); Assert.AreEqual(de, ObjectMapper <Object2> .GetValue(o, "Dow1")); Assert.AreEqual(de, ObjectMapper <Object2> .GetValue(o, "Dow2")); Assert.IsTrue(Math.Abs(123.57 - (float)ObjectMapper <Object2> .GetValue(o, "Float")) < 0.0001); }
public void DoSomethingElse(int param0, string param1, Object2 param2) {}
public string ValidateDoSomethingElse(int param0, string param1, Object2 param2) { if (ValidateProp1(param0) != null || ValidateProp2(param1) != null || ValidateProp3(param2) != null) { return "Something amiss"; } return null; }
public string ValidateProp3(Object2 value) { if (!value.Prop1.StartsWith("a")) { return "Invalid Object"; } return null; }
public string Validate2DoSomething(Object2 value) { return ValidateProp3(value); }
//Non void method public bool RemoveFromColl4(Object2 value) { return true; }
public void RemoveFromColl1(Object2 value) { Coll1.Remove(value); RemoveFromCalled = true; }
//No matching collection public void RemoveFromColl3(Object2 value) {}
public void AddToColl1(Object2 value) { Coll1.Add(value); AddToCalled = true; }
//Non void method public bool AddToColl4(Object2 value) { return true; }
//No matching collection public void AddToColl3(Object2 value) {}
public void NullableMemberTest() { Object2 o = new Object2(); short? s = 125; Guid g = Guid.NewGuid(); DayOfWeek de = DayOfWeek.Thursday; int di = (int)de; ObjectMapper<Object2>.SetValue(o, "Int16", s); ObjectMapper<Object2>.SetValue(o, "Int32", 123.56); ObjectMapper<Object2>.SetValue(o, "Int64", null); ObjectMapper<Object2>.SetValue(o, "Float", 123.57.ToString()); ObjectMapper<Object2>.SetValue(o, "Guid", (Guid?)g); ObjectMapper<Object2>.SetValue(o, "Guid", g); ObjectMapper<Object2>.SetValue(o, "Dow1", de); ObjectMapper<Object2>.SetValue(o, "Dow1", (DayOfWeek?)de); ObjectMapper<Object2>.SetValue(o, "Dow2", di); Assert.AreEqual(125, o.Int16); Assert.AreEqual(123, o.Int32); Assert.IsNull ( o.Int64); Assert.AreEqual(g, o.Guid); Assert.AreEqual(de, o.Dow1); Assert.AreEqual(de, o.Dow2); Assert.IsTrue (Math.Abs(123.57 - o.Float.Value) < 0.0001); Assert.AreEqual(125, ObjectMapper<Object2>.GetValue(o, "Int16")); Assert.AreEqual(123, ObjectMapper<Object2>.GetValue(o, "Int32")); Assert.IsNull ( ObjectMapper<Object2>.GetValue(o, "Int64")); Assert.AreEqual(g, ObjectMapper<Object2>.GetValue(o, "Guid")); Assert.AreEqual(de, ObjectMapper<Object2>.GetValue(o, "Dow1")); Assert.AreEqual(de, ObjectMapper<Object2>.GetValue(o, "Dow2")); Assert.IsTrue (Math.Abs(123.57 - (float)ObjectMapper<Object2>.GetValue(o, "Float")) < 0.0001); }