public override void Initialize(World world, WorldCell cell) { base.Initialize(world, cell); IsAlive = true; SetEnergy(MaxEnergyValue); RandomGenerator = CurrentWorld.RandomGenerator; Direction = Vector2Int.zero; NormalMoveSeconds = (float)MathFunctions.RandomDouble(RandomGenerator, MinAndMaxMoveSeconds); FastMoveDivisor = (float)MathFunctions.RandomDouble(RandomGenerator, MinAndMaxFastMoveDivisor); FastMoveSeconds = NormalMoveSeconds / FastMoveDivisor; MovementProgress = 0; IsFemale = RandomGenerator.NextDouble() >= 0.5f; FemenineSprite.enabled = IsFemale; MasculineSprite.enabled = !IsFemale; Render.transform.localScale = ChildScale.Div(transform.parent.lossyScale); transform.position = CurrentPositionToReal(); SecondsToGrow = (float)MathFunctions.RandomDouble(RandomGenerator, MinAndMaxSecondsToGrow); ReproductionCooldown = (float)MathFunctions.RandomDouble(RandomGenerator, MinAndMaxReproductionCooldown); SecondsToOld = (float)MathFunctions.RandomDouble(RandomGenerator, MinAndMaxSecondsToOld); ActionsList = CreateActionsList(); UpdateStateRenderer(); }
public void Vector3_Div() { Vector3 value = new Vector3(2f, 3f, 4f); Vector3 scale = new Vector3(2f, 3f, 4f); Vector3 expected = new Vector3(1f, 1f, 1f); Assert.That(value.Div(scale), Is.EqualTo(expected)); }
public void CanDivideVectorByScalar() { Vector3 actual = Vector3.Div(v1, scalar1); Vector3 expected = new Vector3(0.55d, -1.25d, 1.85d); Assert.AreEqual(expected.X, actual.X, 0.00001d); Assert.AreEqual(expected.Y, actual.Y, 0.00001d); Assert.AreEqual(expected.Z, actual.Z, 0.00001d); }
public void TestDiv() { var a = new Vector3(1, 2, 3); var b = 0.25f; var c = Vector3.Zero; _ = a.Div(b, ref c); Assert.AreEqual(new Vector3(4, 8, 12), c); }
/// <summary> /// Setup function /// </summary> public void Setup(MixedRealityPose pointerCentroidPose, Vector3 grabCentroid, MixedRealityPose objectPose, Vector3 objectScale) { Quaternion worldToPointerRotation = Quaternion.Inverse(pointerCentroidPose.Rotation); pointerLocalGrabPoint = worldToPointerRotation * (grabCentroid - pointerCentroidPose.Position); objectLocalGrabPoint = Quaternion.Inverse(objectPose.Rotation) * (grabCentroid - objectPose.Position); objectLocalGrabPoint = objectLocalGrabPoint.Div(objectScale); grabToObject = objectPose.Position - grabCentroid; }
/// <summary> /// Setup function /// </summary> public void Setup(MixedRealityPose pointerCentroidPose, Vector3 grabCentroid, MixedRealityPose objectPose, Vector3 objectScale) { pointerRefDistance = GetDistanceToBody(pointerCentroidPose); pointerPosIndependentOfHead = pointerRefDistance != 0; Quaternion worldToPointerRotation = Quaternion.Inverse(pointerCentroidPose.Rotation); pointerLocalGrabPoint = worldToPointerRotation * (grabCentroid - pointerCentroidPose.Position); objectLocalGrabPoint = Quaternion.Inverse(objectPose.Rotation) * (grabCentroid - objectPose.Position); objectLocalGrabPoint = objectLocalGrabPoint.Div(objectScale); grabToObject = objectPose.Position - grabCentroid; }
/// <summary> /// Setup function /// </summary> /// <param name="pointerCentroidPose"></param> /// <param name="grabCentroid"></param> /// <param name="objectPose"></param> /// <param name="objectScale"></param> public void Setup(MixedRealityPose pointerCentroidPose, Vector3 grabCentroid, MixedRealityPose objectPose, Vector3 objectScale) { Vector3 headPosition = CameraCache.Main.transform.position; pointerRefDistance = Vector3.Distance(pointerCentroidPose.Position, headPosition); Quaternion worldToPointerRotation = Quaternion.Inverse(pointerCentroidPose.Rotation); pointerLocalGrabPoint = worldToPointerRotation * (grabCentroid - pointerCentroidPose.Position); objectLocalGrabPoint = Quaternion.Inverse(objectPose.Rotation) * (grabCentroid - objectPose.Position); objectLocalGrabPoint = objectLocalGrabPoint.Div(objectScale); pointerToObject = objectPose.Position - pointerCentroidPose.Position; }
public ArchitectTilePositionGetter(Vector3 position, LayerData selectedLayer) { layer = selectedLayer; if (selectedLayer == null) { Clear(); Valid = false; } else { Vector3 TileP = position.Div(new Vector3(selectedLayer.TileWidth, selectedLayer.TileHeight, 1)).Round().SetValues(0, Axes.Z); tilePosition = new Point2((int)TileP.x, (int)TileP.y); tileWorlPosition = TileP.Mult(new Vector3(selectedLayer.TileWidth, selectedLayer.TileHeight, 1)); Valid = layer.IsInLayerBound(tilePosition.X, tilePosition.Y); } }
public static Vector3 Div(this Vector3 vector, Vector4 otherVector) { return(vector.Div((Vector3)otherVector, Axis.XYZ)); }
public static Vector3 Div(this Vector3 vector, Vector2 otherVector, Axis axis) { return(vector.Div((Vector3)otherVector, axis)); }
public static void Main(String[] args) { spheres[0] = (new Sphere( new Vector3(0, -10002, 0), 9999, new Vector3(1, 1, 1), false)); spheres[1] = (new Sphere( new Vector3(-10012, 0, 0), 9999, new Vector3(1, 0, 0), false)); spheres[2] = (new Sphere( new Vector3(10012, 0, 0), 9999, new Vector3(0, 1, 0), false)); spheres[3] = (new Sphere( new Vector3(0, 0, -10012), 9999, new Vector3(1, 1, 1), false)); spheres[4] = (new Sphere( new Vector3(0, 10012, 0), 9999, new Vector3(1, 1, 1), true)); spheres[5] = (new Sphere( new Vector3(-5, 0, 2), 2, new Vector3(1, 1, 0), false)); spheres[6] = (new Sphere( new Vector3(0, 5, -1), 4, new Vector3(1, 0, 0), false)); spheres[7] = (new Sphere( new Vector3(8, 5, -1), 2, new Vector3(0, 0, 1), false)); var data = new Vector3[RayBench.HEIGHT][]; var cam = new Camera { eye = new Vector3(0.0f, 4.5f, 75.0f), lt = new Vector3(-8, 9, 50), rt = new Vector3(8, 9, 50), lb = new Vector3(-8, 0, 50), }; var vdu = cam.rt.Sub(cam.lt).Div(RayBench.WIDTH); var vdv = cam.lb.Sub(cam.lt).Div(RayBench.HEIGHT); var options = new ParallelOptions(); options.MaxDegreeOfParallelism = Environment.ProcessorCount; Parallel.For(0, RayBench.HEIGHT, options, y => { var random = rnd.Value; data[y] = new Vector3[RayBench.WIDTH]; for (int x = 0; x < RayBench.WIDTH; ++x) { var color = new Vector3(); var ray = new Ray(); ray.origin = cam.eye; for (int i = 0; i < RayBench.SAMPLES; ++i) { ray.direction = cam.lt.Add( vdu.Mul(x + random.NextFloat()).Add( vdv.Mul(y + random.NextFloat()))); ray.direction = ray.direction.Sub(ray.origin); ray.direction = ray.direction.Unit(); color = color.Add(RayBench.trace(ray, 0, random)); } color = color.Div(RayBench.SAMPLES); data[y][x] = color; } }); RayBench.WritePPM(data); }
/// <summary> Divides this vector's components by (a, a, a). </summary> static public Vector3 Div(this Vector3 t, float a) => t.Div(a, a, a);
public static Vector3 Div(this Vector3 vector, Vector4 otherVector, string axis) { return(vector.Div((Vector3)otherVector, axis)); }
private void OnPress(bool isDown) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) if (TutorialMessage.IsActiveButton(this.get_gameObject())) { if (existsIcon && isDown && !isSimple) { this.get_gameObject().GetComponentsInChildren <ItemIcon>(true, Temporary.itemIconList); for (int i = 0; i < Temporary.itemIconList.Count; i++) { if (!(Temporary.itemIconList[i].icon.mainTexture == null) && !cacheIconNames.Contains(Temporary.itemIconList[i].icon.mainTexture.get_name())) { Reset(); break; } } Temporary.itemIconList.Clear(); } if (isDown && !wasSetup && !isSimple) { cacheObjects = new List <CacheParam>(); Transform val = CreateSprites(thisTransform, MonoBehaviourSingleton <UIManager> .I.buttonEffectTop, cacheObjects); val.set_position(thisTransform.get_position()); Setup(val); this.get_gameObject().GetComponentsInChildren <ItemIcon>(true, Temporary.itemIconList); if (Temporary.itemIconList.Count > 0) { cacheIconNames = new List <string>(); for (int j = 0; j < Temporary.itemIconList.Count; j++) { if (!(Temporary.itemIconList[j].icon.mainTexture == null)) { cacheIconNames.Add(Temporary.itemIconList[j].icon.mainTexture.get_name()); } } existsIcon = true; } Temporary.itemIconList.Clear(); } if (this.get_enabled()) { if (!mStarted) { Start(); } TweenScale.Begin(buttonScale_tweenTarget.get_gameObject(), buttonScale_duration, (!isDown) ? buttonScale_mScale : Vector3.Scale(buttonScale_mScale, buttonScale_pressed)).method = UITweener.Method.EaseInOut; if (buttonScale_Collider != null) { if (isDown) { buttonScale_Collider.set_size(buttonScale_ColliderSize.Div(buttonScale_pressed) + new Vector3(0.01f, 0.01f, 0.01f)); } else { buttonScale_Collider.set_size(buttonScale_ColliderSize); } } } } }
public static Vector3 Div(this Vector3 vector, Vector2 otherVector) { return(vector.Div((Vector3)otherVector, "XY")); }
/// <summary> Divides this vector's components by (a.x, a.y, a.z). </summary> static public Vector3 Div(this Vector3 t, Vector3 a) => t.Div(a.x, a.y, a.z);
public static void Main(String[] args) { spheres[0] = (new Sphere( new Vector3(0, -10002, 0), 9999, new Vector3(1, 1, 1), false)); spheres[1] = (new Sphere( new Vector3(-10012, 0, 0), 9999, new Vector3(1, 0, 0), false)); spheres[2] = (new Sphere( new Vector3(10012, 0, 0), 9999, new Vector3(0, 1, 0), false)); spheres[3] = (new Sphere( new Vector3(0, 0, -10012), 9999, new Vector3(1, 1, 1), false)); spheres[4] = (new Sphere( new Vector3(0, 10012, 0), 9999, new Vector3(1, 1, 1), true)); spheres[5] = (new Sphere( new Vector3(-5, 0, 2), 2, new Vector3(1, 1, 0), false)); spheres[6] = (new Sphere( new Vector3(0, 5, -1), 4, new Vector3(1, 0, 0), false)); spheres[7] = (new Sphere( new Vector3(8, 5, -1), 2, new Vector3(0, 0, 1), false)); var data = new Vector3[RayBench.HEIGHT][]; var cam = new Camera(); var vdu = cam.rt.Sub(cam.lt).Div(RayBench.WIDTH); var vdv = cam.lb.Sub(cam.lt).Div(RayBench.HEIGHT); var options = new ParallelOptions(); options.MaxDegreeOfParallelism = 4; //for(int y = 0; y < RayBench.HEIGHT; ++y) { Parallel.For(0, RayBench.HEIGHT, options, y => { data[y] = new Vector3[RayBench.WIDTH]; for (int x = 0; x < RayBench.WIDTH; ++x) { var color = new Vector3(); var ray = new Ray(); ray.origin = cam.eye; for (int i = 0; i < RayBench.SAMPLES; ++i) { ray.direction = cam.lt.Add( vdu.Mul((float)(x + rnd.NextDouble())).Add( vdv.Mul((float)(y + rnd.NextDouble())))); ray.direction = ray.direction.Sub(ray.origin); ray.direction = ray.direction.Unit(); color = color.Add(RayBench.trace(ray, 0)); } color = color.Div(RayBench.SAMPLES); data[y][x] = color; } }); RayBench.WritePPM(data); }
public static Vector3 Div(this Vector3 vector, Vector3 values) { return(vector.Div(values, Axes.XYZW)); }
public static void Main (String[] args) { spheres[0] = (new Sphere( new Vector3(0, -10002, 0), 9999, new Vector3(1, 1, 1), false)); spheres[1] = (new Sphere( new Vector3(-10012, 0, 0), 9999, new Vector3(1, 0, 0), false)); spheres[2] = (new Sphere( new Vector3(10012, 0, 0), 9999, new Vector3(0, 1, 0), false)); spheres[3] = (new Sphere( new Vector3(0, 0, -10012), 9999, new Vector3(1, 1, 1), false)); spheres[4] = (new Sphere( new Vector3(0, 10012, 0), 9999, new Vector3(1, 1, 1), true)); spheres[5] = (new Sphere( new Vector3(-5, 0, 2), 2, new Vector3(1, 1, 0), false)); spheres[6] = (new Sphere( new Vector3(0, 5, -1), 4, new Vector3(1, 0, 0), false)); spheres[7] = (new Sphere( new Vector3(8, 5, -1), 2, new Vector3(0, 0, 1), false)); var data = new Vector3[RayBench.HEIGHT][]; var cam = new Camera(); var vdu = cam.rt.Sub(cam.lt).Div(RayBench.WIDTH); var vdv = cam.lb.Sub(cam.lt).Div(RayBench.HEIGHT); var options = new ParallelOptions(); options.MaxDegreeOfParallelism = 4; //for(int y = 0; y < RayBench.HEIGHT; ++y) { Parallel.For(0, RayBench.HEIGHT, options, y => { data[y] = new Vector3[RayBench.WIDTH]; for(int x = 0; x < RayBench.WIDTH; ++x) { var color = new Vector3(); var ray = new Ray(); ray.origin = cam.eye; for(int i = 0; i < RayBench.SAMPLES; ++i) { ray.direction = cam.lt.Add( vdu.Mul((float)(x + rnd.NextDouble())).Add( vdv.Mul((float)(y + rnd.NextDouble())))); ray.direction = ray.direction.Sub(ray.origin); ray.direction = ray.direction.Unit(); color = color.Add(RayBench.trace(ray, 0)); } color = color.Div(RayBench.SAMPLES); data[y][x] = color; } }); RayBench.WritePPM(data); }
public static Vector3 Div(this Vector3 vector, Vector4 otherVector) { return vector.Div((Vector3)otherVector, "XYZ"); }
public static Vector3 Div(this Vector3 vector, Vector3 otherVector) { return(vector.Div(otherVector, "XYZ")); }
public void Setup(Transform ef) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown effect = ef; effectObj = effect.get_gameObject(); float duration = 0.35f; float num = 1.4f; tweenScale = effectObj.GetComponent <TweenScale>(); if (null == tweenScale) { tweenScale = effectObj.AddComponent <TweenScale>(); } Vector3 lossyScale = thisTransform.get_lossyScale(); lossyScale = lossyScale.Div(MonoBehaviourSingleton <UIManager> .I.uiRootTransform.get_localScale()); tweenScale.from = lossyScale; tweenScale.to = new Vector3(lossyScale.x * num, lossyScale.y * num, 1f); tweenScale.duration = duration; tweenAlpha = effectObj.GetComponent <TweenAlpha>(); if (null == tweenAlpha) { tweenAlpha = effectObj.AddComponent <TweenAlpha>(); } tweenAlpha.from = 1f; tweenAlpha.to = 0f; tweenAlpha.duration = duration; tweenAlpha.SetOnFinished(delegate { effectObj.SetActive(false); }); if (null == effectObj.GetComponent <UIWidget>()) { effectObj.AddComponent <UIWidget>(); } UIWidget component = effectObj.GetComponent <UIWidget>(); UIWidget component2 = this.get_gameObject().GetComponent <UIWidget>(); if (null != component && null != component2 && component.pivot != UIWidget.Pivot.Center) { component.pivot = UIWidget.Pivot.Center; pivotOffset = CalcPivotOffset(component2, true); Transform obj = effect; obj.set_localPosition(obj.get_localPosition() - pivotOffset); Vector3 offset = CalcPivotOffset(component2, false); int childCount = effect.get_childCount(); for (int i = 0; i < childCount; i++) { SetOffsetHierarchy(effect.GetChild(i), offset); } } CreateGlowAtlas(); if (destroyObjects != null) { int num2 = destroyObjects.Length; for (int j = 0; j < num2; j++) { FindAndDelete(destroyObjects[j].get_name()); } } FindAndDelete("SPR_BADGE"); if (toggleObjectsActive != null) { toggleTargetsActive = CollectToggleSprites(toggleObjectsActive); } if (toggleObjectsInactive != null) { toggleTargetsInactive = CollectToggleSprites(toggleObjectsInactive); } if (null != toggleObjectSwitch && toggleObjectsActive != null && toggleObjectsInactive != null) { isToggle = true; } effectObj.SetActive(false); wasSetup = true; }