public static IEnumerator TestBasicFiring() { TestHarness.OnSOF(() => { var mokou = BehaviorEntity.GetExecForID("mokou"); var red = BM.TPool("strip-red/w"); var green = BM.TPool("strip-green/w"); TestHarness.RunBehaviorScript("Regular Fire", "mokou"); TAssert.VecEq(mokou.rBPI.loc, Vector2.zero, "Location is zero"); TestHarness.Check(0, () => { //Bullet commands are dispatched during IEnum, which occurs sometime during frame 0 Assert.AreEqual(red.Count, 2); TAssert.VecEq(red[0].bpi.loc, new Vector2(1, 0)); TAssert.VecEq(red[1].bpi.loc, new Vector2(-1, 0)); TAssert.PoolEq(red, green); }); TestHarness.Check(4, () => { Assert.AreEqual(red.Count, 6); TAssert.VecEq(red[0].bpi.loc, M.PolarToXY(1 + 4f / 120, 0)); TAssert.VecEq(red[2].bpi.loc, M.PolarToXY(1 + 2f / 120, 15)); Assert.AreEqual(red[5].bpi.index, 2); TAssert.VecEq(red[5].bpi.loc, M.PolarToXY(1, 210)); TAssert.PoolEq(red, green); }); }); while (TestHarness.Running) { yield return(null); } }
public static void TGenericCompile() { var func = CompileDelegate <Func <float, float, float, Vector3>, Vector3>( "pxyz(&myVar1, &myVar2, &myVar3)", new DelegateArg <float>("myVar1"), new DelegateArg <float>("myVar2"), new DelegateArg <float>("myVar3") ); TAssert.VecEq(func(4f, 7f, 8f), new Vector3(4f, 7f, 8f)); Assert.Throws <Reflector.CompileException>(() => CompileDelegate <Func <float, float>, float>("&doesNotExist", new DelegateArg <float>("myVar1"))); Assert.Throws <Reflector.BadTypeException>(() => CompileDelegate <Func <float, Vector2, float>, float>("&myVec", new DelegateArg <float>("myFloat"), new DelegateArg <Vector2>("myVec"))); }
public static void TPivot() { var pivoter = TP(Pivot(BPYRepo.T(), _ => 3f, bp => PolarToXY(1f, bp.t.Mul(90f)), PX(bp => Mul <float>(bp.t, 2f)))); var bpi = ParametricInfo.WithRandomId(Vector2.down * 100f, 0); bpi.t = 0f; TAssert.VecEq(pivoter(bpi), Vector2.right); bpi.t = 2f; TAssert.VecEq(pivoter(bpi), Vector2.left); bpi.t = 3f; TAssert.VecEq(pivoter(bpi), Vector2.down); bpi.t = 4f; TAssert.VecEq(pivoter(bpi), new Vector2(2f, -1f)); bpi.t = 5f; TAssert.VecEq(pivoter(bpi), new Vector2(4f, -1f)); }