public void HitObstacle(Hole hole) { if (!jumping.Active && !recovering.Active) { wiping.SwitchTo(); animator.Play ("Wipeout"); } }
/// <inheritdoc /> public bool Equals([AllowNull] Pie other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Type == other.Type || Type != null && Type.Equals(other.Type) ) && ( Visible == other.Visible || Visible != null && Visible.Equals(other.Visible) ) && ( ShowLegend == other.ShowLegend || ShowLegend != null && ShowLegend.Equals(other.ShowLegend) ) && ( LegendGroup == other.LegendGroup || LegendGroup != null && LegendGroup.Equals(other.LegendGroup) ) && ( Opacity == other.Opacity || Opacity != null && Opacity.Equals(other.Opacity) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( UId == other.UId || UId != null && UId.Equals(other.UId) ) && ( Equals(Ids, other.Ids) || Ids != null && other.Ids != null && Ids.SequenceEqual(other.Ids) ) && ( Equals(CustomData, other.CustomData) || CustomData != null && other.CustomData != null && CustomData.SequenceEqual(other.CustomData) ) && ( Meta == other.Meta || Meta != null && Meta.Equals(other.Meta) ) && ( Equals(MetaArray, other.MetaArray) || MetaArray != null && other.MetaArray != null && MetaArray.SequenceEqual(other.MetaArray) ) && ( HoverLabel == other.HoverLabel || HoverLabel != null && HoverLabel.Equals(other.HoverLabel) ) && ( Stream == other.Stream || Stream != null && Stream.Equals(other.Stream) ) && ( Equals(Transforms, other.Transforms) || Transforms != null && other.Transforms != null && Transforms.SequenceEqual(other.Transforms) ) && ( UiRevision == other.UiRevision || UiRevision != null && UiRevision.Equals(other.UiRevision) ) && ( Equals(Labels, other.Labels) || Labels != null && other.Labels != null && Labels.SequenceEqual(other.Labels) ) && ( Label0 == other.Label0 || Label0 != null && Label0.Equals(other.Label0) ) && ( DLabel == other.DLabel || DLabel != null && DLabel.Equals(other.DLabel) ) && ( Equals(Values, other.Values) || Values != null && other.Values != null && Values.SequenceEqual(other.Values) ) && ( Marker == other.Marker || Marker != null && Marker.Equals(other.Marker) ) && ( Equals(Text, other.Text) || Text != null && other.Text != null && Text.SequenceEqual(other.Text) ) && ( HoverText == other.HoverText || HoverText != null && HoverText.Equals(other.HoverText) ) && ( Equals(HoverTextArray, other.HoverTextArray) || HoverTextArray != null && other.HoverTextArray != null && HoverTextArray.SequenceEqual(other.HoverTextArray) ) && ( ScaleGroup == other.ScaleGroup || ScaleGroup != null && ScaleGroup.Equals(other.ScaleGroup) ) && ( TextInfo == other.TextInfo || TextInfo != null && TextInfo.Equals(other.TextInfo) ) && ( HoverInfo == other.HoverInfo || HoverInfo != null && HoverInfo.Equals(other.HoverInfo) ) && ( Equals(HoverInfoArray, other.HoverInfoArray) || HoverInfoArray != null && other.HoverInfoArray != null && HoverInfoArray.SequenceEqual(other.HoverInfoArray) ) && ( HoverTemplate == other.HoverTemplate || HoverTemplate != null && HoverTemplate.Equals(other.HoverTemplate) ) && ( Equals(HoverTemplateArray, other.HoverTemplateArray) || HoverTemplateArray != null && other.HoverTemplateArray != null && HoverTemplateArray.SequenceEqual(other.HoverTemplateArray) ) && ( TextTemplate == other.TextTemplate || TextTemplate != null && TextTemplate.Equals(other.TextTemplate) ) && ( Equals(TextTemplateArray, other.TextTemplateArray) || TextTemplateArray != null && other.TextTemplateArray != null && TextTemplateArray.SequenceEqual(other.TextTemplateArray) ) && ( TextPosition == other.TextPosition || TextPosition != null && TextPosition.Equals(other.TextPosition) ) && ( Equals(TextPositionArray, other.TextPositionArray) || TextPositionArray != null && other.TextPositionArray != null && TextPositionArray.SequenceEqual(other.TextPositionArray) ) && ( TextFont == other.TextFont || TextFont != null && TextFont.Equals(other.TextFont) ) && ( InsideTextOrientation == other.InsideTextOrientation || InsideTextOrientation != null && InsideTextOrientation.Equals(other.InsideTextOrientation) ) && ( InsideTextFont == other.InsideTextFont || InsideTextFont != null && InsideTextFont.Equals(other.InsideTextFont) ) && ( OutsideTextFont == other.OutsideTextFont || OutsideTextFont != null && OutsideTextFont.Equals(other.OutsideTextFont) ) && ( AutoMargin == other.AutoMargin || AutoMargin != null && AutoMargin.Equals(other.AutoMargin) ) && ( Title == other.Title || Title != null && Title.Equals(other.Title) ) && ( Domain == other.Domain || Domain != null && Domain.Equals(other.Domain) ) && ( Hole == other.Hole || Hole != null && Hole.Equals(other.Hole) ) && ( Sort == other.Sort || Sort != null && Sort.Equals(other.Sort) ) && ( Direction == other.Direction || Direction != null && Direction.Equals(other.Direction) ) && ( Rotation == other.Rotation || Rotation != null && Rotation.Equals(other.Rotation) ) && ( Pull == other.Pull || Pull != null && Pull.Equals(other.Pull) ) && ( Equals(PullArray, other.PullArray) || PullArray != null && other.PullArray != null && PullArray.SequenceEqual(other.PullArray) ) && ( IdsSrc == other.IdsSrc || IdsSrc != null && IdsSrc.Equals(other.IdsSrc) ) && ( CustomDataSrc == other.CustomDataSrc || CustomDataSrc != null && CustomDataSrc.Equals(other.CustomDataSrc) ) && ( MetaSrc == other.MetaSrc || MetaSrc != null && MetaSrc.Equals(other.MetaSrc) ) && ( LabelsSrc == other.LabelsSrc || LabelsSrc != null && LabelsSrc.Equals(other.LabelsSrc) ) && ( ValuesSrc == other.ValuesSrc || ValuesSrc != null && ValuesSrc.Equals(other.ValuesSrc) ) && ( TextSrc == other.TextSrc || TextSrc != null && TextSrc.Equals(other.TextSrc) ) && ( HoverTextSrc == other.HoverTextSrc || HoverTextSrc != null && HoverTextSrc.Equals(other.HoverTextSrc) ) && ( HoverInfoSrc == other.HoverInfoSrc || HoverInfoSrc != null && HoverInfoSrc.Equals(other.HoverInfoSrc) ) && ( HoverTemplateSrc == other.HoverTemplateSrc || HoverTemplateSrc != null && HoverTemplateSrc.Equals(other.HoverTemplateSrc) ) && ( TextTemplateSrc == other.TextTemplateSrc || TextTemplateSrc != null && TextTemplateSrc.Equals(other.TextTemplateSrc) ) && ( TextPositionSrc == other.TextPositionSrc || TextPositionSrc != null && TextPositionSrc.Equals(other.TextPositionSrc) ) && ( PullSrc == other.PullSrc || PullSrc != null && PullSrc.Equals(other.PullSrc) )); }
public HoleGeometry(int limit, double reflectionCoefficient, Atom.ReflectionPattern pattern, CylinderReflector nozzle, CylinderReflector subNozzle, Hole hole, Shield detector) : base(limit, reflectionCoefficient, pattern, new Structure[] { nozzle, subNozzle, hole, detector }) { }
static void Best_Fit(List <Hole> Holes, int no_Processes, List <process> processes, List <fragmantation> frag) { Sort(Holes); flag_frag = false; indicate = false; bool flag = false; for (int j = 0; j < Holes.Count(); j++) { if (processes[processes.Count() - 1].p_Size <= Holes[j].hole_Size) { flag = true; processes[processes.Count() - 1].allocating_Address = Holes[j].starting_Address; if (processes[processes.Count() - 1].p_Size == Holes[j].hole_Size) { flag_frag = true; Holes.RemoveAt(j); } else { fragmantation temp = new fragmantation(); temp.allocated_Address = Holes[j].starting_Address + processes[processes.Count() - 1].p_Size; temp.frag_Size = Holes[j].hole_Size - processes[processes.Count() - 1].p_Size; frag.Add(temp); frag_Counter++; Holes.RemoveAt(j); } break; } } if (!flag && Holes.Count() > 1) { int address = max(processes, frag); Sort_s(Holes); sum_Size = 0; int holeS = Compaction(Holes, no_Processes, processes, frag); Hole temp = new Hole(); temp.hole_Size = holeS; if (co != 0) { temp.starting_Address = address - holeS; } else { temp.starting_Address = Holes[0].starting_Address; Holes.RemoveAt(0); } Holes.Add(temp); Sort(Holes); flag_frag = false; indicate = false; for (int j = 0; j < Holes.Count(); j++) { if (processes[processes.Count() - 1].p_Size <= Holes[j].hole_Size) { flag = true; processes[processes.Count() - 1].allocating_Address = Holes[j].starting_Address; if (processes[processes.Count() - 1].p_Size == Holes[j].hole_Size) { flag_frag = true; Holes.RemoveAt(j); } else { fragmantation temp1 = new fragmantation(); temp1.allocated_Address = Holes[j].starting_Address + processes[processes.Count() - 1].p_Size; temp1.frag_Size = Holes[j].hole_Size - processes[processes.Count() - 1].p_Size; frag.Add(temp1); frag_Counter++; Holes.RemoveAt(j); } break; } } if (!flag) { indicate = true; processes.RemoveAt(processes.Count() - 1); } } else if (!flag) { indicate = true; processes.RemoveAt(processes.Count() - 1); } }
// Copy Constructor public Hole(Hole previousHole) { SetHole(previousHole); }
public void EndTunneling( Mobile target ) { Hole hole = new Hole( 0x1363 ); hole.MoveToWorld( Location, Map ); Internalize(); m_TunnelTimer = Timer.DelayCall<Mobile>( TimeSpan.FromSeconds( 3 ), new TimerStateCallback<Mobile>( Reappear ), target ); }
public void DeleteHole(Hole hole, bool triangulate = true) { holes.Remove(hole); if(triangulate) { Triangulate(); } }
public void SetupAgent(GolfCourse course) { _course = course; _curHole = course.holes[0]; ChangeState(State.WALKING_TO_HOLE); }
void Awake() { instance = this; balls = new List <Ball>(); hole = FindObjectOfType <Hole>(); }
bool TestWheelCombo(Wheel[] wheels, bool submit) { if (submit) { Debug.LogFormat("<Thread the Needle #{0}> Testing submitted wheels...", moduleId); } bool[] circleRows = new bool[8]; bool[] triangleRows = new bool[8]; for (int absoluteRoundPos = 0; absoluteRoundPos < WheelPattern.BIGGEST_SIZE; absoluteRoundPos++) { // RoundPos represents like numbers on a clock (except this increases counter-clockwise) bool allCircle = true; bool allTriangle = true; for (int i = 0; i < 6; i++) { var roundPos = absoluteRoundPos + wheels[i].Index; // Get the hole at this position in the wheel. // Remember things might not have all the holes. // In that case it's assumed they're evenly spaced. Hole hole = wheels[i].Pattern.Holes[roundPos % WheelPattern.BIGGEST_SIZE]; if (hole == Hole.None) { allCircle = false; allTriangle = false; break; // No need to continue } if (hole != Hole.Circle) { allCircle = false; } if (hole != Hole.Triangle) { allTriangle = false; } } if (allCircle) { circleRows[absoluteRoundPos] = true; } if (allTriangle) { triangleRows[absoluteRoundPos] = true; } // Otherwise, there was neither. } if (submit) { Debug.LogFormat("[Thread the Needle #{0}] Row of circular holes: {1}", moduleId, circleRows.Contains(true) ? "Found" : "Not Found"); Debug.LogFormat("[Thread the Needle #{0}] Row of triangular holes: {1}", moduleId, triangleRows.Contains(true) ? "Found" : "Not Found"); if (circleRows.Contains(true) && !triangleRows.Contains(true)) { Debug.LogFormat("[Thread the Needle #{0}] Submission was correct, module disarmed", moduleId); } else { Debug.LogFormat("[Thread the Needle #{0}] Submission was incorrect, strike", moduleId); } } if (circleRows.Contains(true) && !triangleRows.Contains(true)) { return(true); } return(false); // We never found all circles. }
public IActionResult Put(string id, Hole data) { data.ImgUrl = FileOperation.FileImg(data.ImgFile, data.Id, rootPath, Path(data.ParentId)); return(Json(_col.UpData(id, data))); }
public IActionResult Post(Hole data) { data.Id = Guid.NewGuid().ToString(); data.ImgUrl = FileOperation.FileImg(data.ImgFile, data.Id, rootPath, Path(data.ParentId)); return(Json(_col.Insert(data))); }
public override void PresentStep(int index, PresentationViewController presentationViewController) { switch (index) { case (int)ParticleSteps.Fire: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddEmptyLine(); TextManager.AddBulletAtLevel("Particle Image", 0); TextManager.AddBulletAtLevel("Color over life duration", 0); TextManager.AddBulletAtLevel("Size over life duration", 0); TextManager.AddBulletAtLevel("Several blend modes", 0); TextManager.FlipInText(SlideTextManager.TextType.Bullet); var hole = SCNNode.Create(); hole.Geometry = SCNTube.Create(1.7f, 1.9f, 1.5f); hole.Position = new SCNVector3(0, 0, HOLE_Z); hole.Scale = new SCNVector3(1, 0, 1); GroundNode.AddChildNode(hole); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.5f; hole.Scale = new SCNVector3(1, 1, 1); SCNTransaction.Commit(); var ps = SCNParticleSystem.Create("fire", "Particles"); hole.AddParticleSystem(ps); Hole = hole; break; case (int)ParticleSteps.FireScreen: ps = Hole.ParticleSystems [0]; ps.BlendMode = SCNParticleBlendMode.Screen; break; case (int)ParticleSteps.Local: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddBulletAtLevel("Local vs Global", 0); TextManager.FlipInText(SlideTextManager.TextType.Bullet); Hole.RemoveAllParticleSystems(); Hole2 = Hole.Clone(); Hole2.Geometry = (SCNGeometry)Hole.Geometry.Copy(); Hole2.Position = new SCNVector3(0, -2, HOLE_Z - 4); GroundNode.AddChildNode(Hole2); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.5; Hole2.Position = new SCNVector3(0, 0, HOLE_Z - 4); SCNTransaction.Commit(); ps = SCNParticleSystem.Create("reactor", "Particles"); ps.ParticleColorVariation = new SCNVector4(0, 0, 0.5f, 0); Hole.AddParticleSystem(ps); var localPs = (SCNParticleSystem)ps.Copy(); localPs.ParticleImage = ps.ParticleImage; localPs.Local = true; Hole2.AddParticleSystem(localPs); var animation = CABasicAnimation.FromKeyPath("position"); animation.From = NSValue.FromVector(new SCNVector3(7, 0, HOLE_Z)); animation.To = NSValue.FromVector(new SCNVector3(-7, 0, HOLE_Z)); animation.BeginTime = CAAnimation.CurrentMediaTime() + 0.75; animation.Duration = 8; animation.AutoReverses = true; animation.RepeatCount = float.MaxValue; animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut); animation.TimeOffset = animation.Duration / 2; Hole.AddAnimation(animation, new NSString("animateHole")); animation = CABasicAnimation.FromKeyPath("position"); animation.From = NSValue.FromVector(new SCNVector3(-7, 0, HOLE_Z - 4)); animation.To = NSValue.FromVector(new SCNVector3(7, 0, HOLE_Z - 4)); animation.BeginTime = CAAnimation.CurrentMediaTime() + 0.75; animation.Duration = 8; animation.AutoReverses = true; animation.RepeatCount = float.MaxValue; animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut); animation.TimeOffset = animation.Duration / 2; Hole2.AddAnimation(animation, new NSString("animateHole")); break; case (int)ParticleSteps.Gravity: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddBulletAtLevel("Affected by gravity", 0); TextManager.FlipInText(SlideTextManager.TextType.Bullet); Hole2.RemoveAllParticleSystems(); Hole2.RunAction(SCNAction.Sequence(new SCNAction[] { SCNAction.ScaleTo(0, 0.5), SCNAction.RemoveFromParentNode() })); Hole.RemoveAllParticleSystems(); Hole.RemoveAnimation(new NSString("animateHole"), 0.5f); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.5; var tube = (SCNTube)Hole.Geometry; tube.InnerRadius = 0.3f; tube.OuterRadius = 0.4f; tube.Height = 1.0f; SCNTransaction.Commit(); ps = SCNParticleSystem.Create("sparks", "Particles"); Hole.RemoveAllParticleSystems(); Hole.AddParticleSystem(ps); foreach (var child in ((SCNView)presentationViewController.View).Scene.RootNode.ChildNodes) { if (child.Geometry != null) { if (child.Geometry.GetType() == typeof(SCNFloor)) { FloorNode = child; } } } /*FloorNode = ((SCNView)presentationViewController.View).Scene.RootNode.FindNodes ((SCNNode child, out bool stop) => { * stop = false; * if (child.Geometry != null) * stop = (child.Geometry.GetType () == typeof(SCNFloor)); * return stop; * });*/ /*FloorNode = [presentationViewController.view.scene.rootNode childNodesPassingTest:^BOOL(SCNNode *child, BOOL *stop) { * return [child.geometry isKindOfClass:[SCNFloor class]]; * }][0];*/ ps.ColliderNodes = new SCNNode[] { FloorNode }; break; case (int)ParticleSteps.Collider: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddBulletAtLevel("Affected by colliders", 0); TextManager.FlipInText(SlideTextManager.TextType.Bullet); var boxNode = SCNNode.Create(); boxNode.Geometry = SCNBox.Create(5, 0.2f, 5, 0); boxNode.Position = new SCNVector3(0, 7, HOLE_Z); boxNode.Geometry.FirstMaterial.Emission.Contents = NSColor.DarkGray; GroundNode.AddChildNode(boxNode); ps = Hole.ParticleSystems [0]; ps.ColliderNodes = new SCNNode[] { FloorNode, boxNode }; animation = CABasicAnimation.FromKeyPath("eulerAngles"); animation.From = NSValue.FromVector(new SCNVector3(0, 0, (nfloat)Math.PI / 4 * 1.7f)); animation.To = NSValue.FromVector(new SCNVector3(0, 0, -(nfloat)Math.PI / 4 * 1.7f)); animation.BeginTime = CAAnimation.CurrentMediaTime() + 0.5; animation.Duration = 2; animation.AutoReverses = true; animation.RepeatCount = float.MaxValue; animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut); animation.TimeOffset = animation.Duration / 2; boxNode.AddAnimation(animation, new NSString("animateHole")); BoxNode = boxNode; break; case (int)ParticleSteps.Fields: Hole.RemoveAllParticleSystems(); Hole.RunAction(SCNAction.Sequence(new SCNAction[] { SCNAction.ScaleTo(0, 0.75), SCNAction.RemoveFromParentNode() })); BoxNode.RunAction(SCNAction.Sequence(new SCNAction[] { SCNAction.MoveBy(0, 15, 0, 1.0), SCNAction.RemoveFromParentNode() })); var particleHolder = SCNNode.Create(); particleHolder.Position = new SCNVector3(0, 20, HOLE_Z); GroundNode.AddChildNode(particleHolder); ParticleHolder = particleHolder; TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddBulletAtLevel("Affected by physics fields", 0); TextManager.FlipInText(SlideTextManager.TextType.Bullet); ps = SCNParticleSystem.Create("snow", "Particles"); ps.AffectedByPhysicsFields = true; ParticleHolder.AddParticleSystem(ps); Snow = ps; //physics field var field = SCNPhysicsField.CreateTurbulenceField(50, 1); field.HalfExtent = new SCNVector3(20, 20, 20); field.Strength = 4.0f; var fieldOwner = SCNNode.Create(); fieldOwner.Position = new SCNVector3(0, 5, HOLE_Z); GroundNode.AddChildNode(fieldOwner); fieldOwner.PhysicsField = field; FieldOwner = fieldOwner; ps.ColliderNodes = new SCNNode[] { FloorNode }; break; case (int)ParticleSteps.FieldsVortex: VortexFieldOwner = SCNNode.Create(); VortexFieldOwner.Position = new SCNVector3(0, 5, HOLE_Z); GroundNode.AddChildNode(VortexFieldOwner); //tornado var worldOrigin = new SCNVector3(FieldOwner.WorldTransform.M41, FieldOwner.WorldTransform.M42, FieldOwner.WorldTransform.M43); var worldAxis = new SCNVector3(0, 1, 0); var vortex = SCNPhysicsField.CustomField((SCNVector3 position, SCNVector3 velocity, float mass, float charge, double timeInSeconds) => { var l = new SCNVector3(); l.X = worldOrigin.X - position.X; l.Z = worldOrigin.Z - position.Z; SCNVector3 t = Cross(worldAxis, l); var d2 = (l.X * l.X + l.Z * l.Z); var vs = (nfloat)(VS / Math.Sqrt(d2)); var fy = (nfloat)(1.0 - (Math.Min(1.0, (position.Y / 15.0)))); return(new SCNVector3(t.X * vs + l.X * (nfloat)VW * fy, 0, t.Z * vs + l.Z * (nfloat)VW * fy)); }); vortex.HalfExtent = new SCNVector3(100, 100, 100); VortexFieldOwner.PhysicsField = vortex; break; case (int)ParticleSteps.SubSystems: FieldOwner.RemoveFromParentNode(); ParticleHolder.RemoveAllParticleSystems(); Snow.DampingFactor = -1; TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddBulletAtLevel("Sub-particle system on collision", 0); TextManager.FlipInText(SlideTextManager.TextType.Bullet); ps = SCNParticleSystem.Create("rain", "Particles"); var pss = SCNParticleSystem.Create("plok", "Particles"); pss.IdleDuration = 0; pss.Loops = false; ps.SystemSpawnedOnCollision = pss; ParticleHolder.AddParticleSystem(ps); ps.ColliderNodes = new SCNNode[] { FloorNode }; break; case (int)ParticleSteps.Confetti: ParticleHolder.RemoveAllParticleSystems(); TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddBulletAtLevel("Custom blocks", 0); TextManager.FlipInText(SlideTextManager.TextType.Bullet); ps = SCNParticleSystem.Create(); ps.EmitterShape = SCNBox.Create(20, 9, 5, 0); ps.BirthRate = 100; ps.ParticleLifeSpan = 10; ps.ParticleLifeSpanVariation = 0; ps.SpreadingAngle = 20; ps.ParticleSize = 0.25f; ps.ParticleVelocity = 10; ps.ParticleVelocityVariation = 19; ps.BirthDirection = SCNParticleBirthDirection.Constant; ps.EmittingDirection = new SCNVector3(0, -1, 0); ps.BirthLocation = SCNParticleBirthLocation.Volume; ps.ParticleImage = new NSImage(NSBundle.MainBundle.PathForResource("Particles/confetti", "png")); ps.LightingEnabled = true; ps.OrientationMode = SCNParticleOrientationMode.Free; ps.SortingMode = SCNParticleSortingMode.Distance; ps.ParticleAngleVariation = 180; ps.ParticleAngularVelocity = 200; ps.ParticleAngularVelocityVariation = 400; ps.ParticleColor = NSColor.Green; ps.ParticleColorVariation = new SCNVector4(0.2f, 0.1f, 0.1f, 0); ps.ParticleBounce = 0; ps.ParticleFriction = 0.6f; ps.ColliderNodes = new SCNNode[] { FloorNode }; ps.BlendMode = SCNParticleBlendMode.Alpha; var floatAnimation = CAKeyFrameAnimation.FromKeyPath(""); floatAnimation.Values = new NSNumber[] { 1, 1, 0 }; floatAnimation.KeyTimes = new NSNumber[] { 0, 0.9f, 1 }; floatAnimation.Duration = 1.0f; floatAnimation.Additive = false; //ps.PropertyControllers = @{ SCNParticlePropertyOpacity: [SCNParticlePropertyController controllerWithAnimation:floatAnimation] }; //ps.HandleEvent (SCNParticleEvent.Birth, /*[ps handleEvent:SCNParticleEventBirth forProperties:@[SCNParticlePropertyColor] withBlock:^(void **data, size_t *dataStride, uint32_t *indices , NSInteger count) { * * for (int i = 0; i < count; ++i) { * var col = (float *)((char *)data[0] + dataStride[0] * i); * if (rand() & 0x1) { // swith green for red * col[0] = col[1]; * col[1] = 0; * } * * } * }];*/ /*[ps handleEvent:SCNParticleEventCollision forProperties:@[SCNParticlePropertyAngle, SCNParticlePropertyRotationAxis, SCNParticlePropertyAngularVelocity, SCNParticlePropertyVelocity, SCNParticlePropertyContactNormal] withBlock:^(void **data, size_t *dataStride, uint32_t *indices , NSInteger count) { * * for (NSInteger i = 0; i < count; ++i) { * // fix orientation * float *angle = (float *)((char *)data[0] + dataStride[0] * indices[i]); * float *axis = (float *)((char *)data[1] + dataStride[1] * indices[i]); * * float *colNrm = (float *)((char *)data[4] + dataStride[4] * indices[i]); * SCNVector3 collisionNormal = {colNrm[0], colNrm[1], colNrm[2]}; * SCNVector3 cp = SCNVector3CrossProduct(collisionNormal, SCNVector3Make(0, 0, 1)); * CGFloat cpLen = SCNVector3Length(cp); * angle[0] = asin(cpLen); * * axis[0] = cp.x / cpLen; * axis[1] = cp.y / cpLen; * axis[2] = cp.z / cpLen; * * // kill angular rotation * float *angVel = (float *)((char *)data[2] + dataStride[2] * indices[i]); * angVel[0] = 0; * * if (colNrm[1] > 0.4) { * float *vel = (float *)((char *)data[3] + dataStride[3] * indices[i]); * vel[0] = 0; * vel[1] = 0; * vel[2] = 0; * } * } * }];*/ ParticleHolder.AddParticleSystem(ps); break; case (int)ParticleSteps.EmitterCube: ParticleHolder.RemoveAllParticleSystems(); TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddBulletAtLevel("Emitter shape", 0); TextManager.FlipInText(SlideTextManager.TextType.Bullet); ParticleHolder.RemoveFromParentNode(); ps = SCNParticleSystem.Create("emitters", "Particles"); ps.Local = true; ParticleHolder.AddParticleSystem(ps); var node = SCNNode.Create(); node.Position = new SCNVector3(3, 6, HOLE_Z); node.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy((float)Math.PI * 2, new SCNVector3(0.3f, 1, 0), 8))); GroundNode.AddChildNode(node); Bokeh = ps; node.AddParticleSystem(ps); break; case (int)ParticleSteps.EmitterSphere: Bokeh.EmitterShape = SCNSphere.Create(5); break; case (int)ParticleSteps.EmitterTorus: Bokeh.EmitterShape = SCNTorus.Create(5, 1); break; } }
void MakeHole(int level, GameObject go) { //hole = new Hole(level, go); Hole holeGo = Instantiate(hole, go.transform.position, go.transform.rotation); }
// Set the level pad and hole. public void SetRelatedObject(UILevelPad levelPad, Hole hole) { _levelPad = levelPad; _hole = hole; }
// Called during an add operation private void attach_Instance(Hole hole) { NotifyPropertyChanging("ExerciseInstance"); hole.Course = this; }
public void OnHoleChange(Hole hole) { GameObject hole_go = holeGameObjectMap[hole]; hole_go.transform.position = new Vector3(hole.X, hole.Y); }
internal LiteralHole(Literal literal, Hole hole) { Literal = literal; Hole = hole; }
internal Path(Hole left, Hole center, Hole right) { Left = left; Center = center; Right = right; }
private Expression ParsePrimaryExpression(TokenSet followers){ Expression expression = null; SourceContext sctx = this.scanner.CurrentSourceContext; switch(this.currentToken){ case Token.ArgList: this.GetNextToken(); expression = new ArglistExpression(sctx); break; case Token.Delegate:{ this.GetNextToken(); ParameterList parameters = null; if (this.currentToken == Token.LeftParenthesis) parameters = this.ParseParameters(Token.RightParenthesis, followers|Token.LeftBrace); Block block = null; if (this.currentToken == Token.LeftBrace) block = this.ParseBlock(this.scanner.CurrentSourceContext, followers); else this.SkipTo(followers, Error.ExpectedLeftBrace); sctx.EndPos = this.scanner.endPos; return new AnonymousNestedDelegate(parameters, block, sctx);} case Token.New: expression = this.ParseNew(followers|Token.Dot|Token.LeftBracket|Token.Arrow); break; case Token.Identifier: expression = this.scanner.GetIdentifier(); if (this.sink != null) { this.sink.StartName((Identifier)expression); } this.GetNextToken(); if (this.currentToken == Token.DoubleColon){ this.GetNextToken(); Identifier id = this.scanner.GetIdentifier(); id.Prefix = (Identifier)expression; id.SourceContext.StartPos = expression.SourceContext.StartPos; expression = id; if (this.currentToken != Token.EndOfFile) this.GetNextToken(); }else if (this.currentToken == Token.Lambda){ Parameter par = new Parameter((Identifier)expression, null); par.SourceContext = expression.SourceContext; return this.ParseLambdaExpression(par.SourceContext, new ParameterList(par), followers); } break; case Token.Null: expression = new Literal(null, null, sctx); this.GetNextToken(); break; case Token.True: expression = new Literal(true, null, sctx); this.GetNextToken(); break; case Token.False: expression = new Literal(false, null, sctx); this.GetNextToken(); break; case Token.Hole: //HS D expression = new Hole(sctx); this.GetNextToken(); break; case Token.CharLiteral: expression = new Literal(this.scanner.charLiteralValue, null, sctx); this.GetNextToken(); break; case Token.HexLiteral: expression = this.ParseHexLiteral(); break; case Token.IntegerLiteral: expression = this.ParseIntegerLiteral(); break; case Token.RealLiteral: expression = this.ParseRealLiteral(); break; case Token.StringLiteral: expression = this.scanner.GetStringLiteral(); this.GetNextToken(); break; case Token.This: expression = new This(sctx, false); if (this.sink != null) { this.sink.StartName(expression); } this.GetNextToken(); if (this.currentToken == Token.LeftParenthesis && (this.inInstanceConstructor==BaseOrThisCallKind.None || this.inInstanceConstructor==BaseOrThisCallKind.InCtorBodyThisSeen)){ QualifiedIdentifier thisCons = new QualifiedIdentifier(expression, StandardIds.Ctor, this.scanner.CurrentSourceContext); MethodCall thisConstructorCall = new MethodCall(thisCons, null, NodeType.Call); thisConstructorCall.SourceContext = sctx; SourceContext lpCtx = this.scanner.CurrentSourceContext; this.Skip(Token.LeftParenthesis); thisConstructorCall.Operands = this.ParseArgumentList(followers|Token.LeftBrace|Token.Semicolon, lpCtx, out thisConstructorCall.SourceContext.EndPos); expression = thisConstructorCall; this.inInstanceConstructor=BaseOrThisCallKind.InCtorBodyThisSeen; goto done; } break; case Token.Base: Base ba = new Base(sctx, false); expression = ba; if (this.sink != null) { this.sink.StartName(expression); } this.GetNextToken(); if (this.currentToken == Token.Semicolon && (this.inInstanceConstructor == BaseOrThisCallKind.ColonThisOrBaseSeen || this.inInstanceConstructor == BaseOrThisCallKind.None)) { // When there are non-null fields, then the base ctor call can happen only after they are // initialized. // In Spec#, we allow a base ctor call in the body of the ctor. But if someone is using // the C# comment convention, then they cannot do that. // So allow "base;" as a marker to indicate where the base ctor call should happen. // There may be an explicit "colon base call" or it may be implicit. // // Just leave expression as a bare "Base" node; later pipeline stages will all have // to ignore it. Mark the current ctor as having (at least) one of these bad boys // in it. ba.UsedAsMarker = true; this.currentCtor.ContainsBaseMarkerBecauseOfNonNullFields = true; goto done; } if (this.currentToken == Token.LeftParenthesis && (this.inInstanceConstructor==BaseOrThisCallKind.None || this.inInstanceConstructor==BaseOrThisCallKind.InCtorBodyBaseSeen)){ QualifiedIdentifier supCons = new QualifiedIdentifier(expression, StandardIds.Ctor, this.scanner.CurrentSourceContext); MethodCall superConstructorCall = new MethodCall(supCons, null, NodeType.Call); superConstructorCall.SourceContext = sctx; SourceContext lpCtx = this.scanner.CurrentSourceContext; this.Skip(Token.LeftParenthesis); superConstructorCall.Operands = this.ParseArgumentList(followers|Token.LeftBrace|Token.Semicolon, lpCtx, out superConstructorCall.SourceContext.EndPos); expression = superConstructorCall; this.inInstanceConstructor=BaseOrThisCallKind.InCtorBodyBaseSeen; goto done; } break; case Token.Typeof: case Token.Sizeof: case Token.Default:{ //if (this.currentToken == Token.Sizeof && !this.inUnsafeCode) //this.HandleError(Error.SizeofUnsafe); UnaryExpression uex = new UnaryExpression(null, this.currentToken == Token.Typeof ? NodeType.Typeof : this.currentToken == Token.Sizeof ? NodeType.Sizeof : NodeType.DefaultValue); uex.SourceContext = sctx; this.GetNextToken(); this.Skip(Token.LeftParenthesis); TypeNode t = null; if (this.currentToken == Token.Void && uex.NodeType == NodeType.Typeof){ t = this.TypeExpressionFor(Token.Void); this.GetNextToken(); }else t = this.ParseTypeExpression(null, followers|Token.RightParenthesis, false, false, uex.NodeType == NodeType.Typeof); if (t == null){this.SkipTo(followers); return null;} uex.Operand = new MemberBinding(null, t, t.SourceContext, null); uex.Operand.SourceContext = t.SourceContext; uex.SourceContext.EndPos = this.scanner.endPos; this.Skip(Token.RightParenthesis); expression = uex; break;} case Token.Stackalloc:{ this.GetNextToken(); TypeNode elementType = this.ParseBaseTypeExpression(null, followers|Token.LeftBracket, false, false); if (elementType == null){this.SkipTo(followers); return null;} Token openingDelimiter = this.currentToken; if (this.currentToken != Token.LeftBracket){ this.HandleError(Error.BadStackAllocExpr); if (this.currentToken == Token.LeftParenthesis) this.GetNextToken(); }else this.GetNextToken(); Expression numElements = this.ParseExpression(followers|Token.RightBracket|Token.RightParenthesis); sctx.EndPos = this.scanner.endPos; if (this.currentToken == Token.RightParenthesis && openingDelimiter == Token.LeftParenthesis) this.GetNextToken(); else this.Skip(Token.RightBracket); this.SkipTo(followers); return new StackAlloc(elementType, numElements, sctx);} case Token.Checked: case Token.Unchecked: //TODO: use NodeType.SkipCheck and NodeType.EnforceCheck Block b = new Block(new StatementList(1), this.currentToken == Token.Checked, this.currentToken == Token.Unchecked, this.inUnsafeCode); b.SourceContext = sctx; this.GetNextToken(); this.Skip(Token.LeftParenthesis); b.Statements.Add(new ExpressionStatement(this.ParseExpression(followers|Token.RightParenthesis))); this.Skip(Token.RightParenthesis); expression = new BlockExpression(b); expression.SourceContext = b.SourceContext; break; case Token.RefType:{ this.GetNextToken(); this.Skip(Token.LeftParenthesis); Expression e = this.ParseExpression(followers|Token.RightParenthesis); this.Skip(Token.RightParenthesis); expression = new RefTypeExpression(e, sctx); break; } case Token.RefValue:{ this.GetNextToken(); this.Skip(Token.LeftParenthesis); Expression e = this.ParseExpression(followers|Token.Comma); this.Skip(Token.Comma); TypeNode te = this.ParseTypeOrFunctionTypeExpression(followers|Token.RightParenthesis, false, true); Expression operand2 = new MemberBinding(null, te); if (te is TypeExpression) operand2.SourceContext = te.SourceContext; else operand2.SourceContext = sctx; this.Skip(Token.RightParenthesis); expression = new RefValueExpression(e, operand2, sctx); break; } case Token.Bool: case Token.Decimal: case Token.Sbyte: case Token.Byte: case Token.Short: case Token.Ushort: case Token.Int: case Token.Uint: case Token.Long: case Token.Ulong: case Token.Char: case Token.Float: case Token.Double: case Token.Object: case Token.String: MemberBinding mb = new MemberBinding(null, this.TypeExpressionFor(this.currentToken), sctx); this.GetNextToken(); expression = this.ParseIndexerCallOrSelector(mb, followers); goto done; case Token.LeftParenthesis: expression = this.ParseParenthesizedExpression(followers|Token.Dot|Token.LeftBracket|Token.Arrow, true); break; default: if (Parser.IdentifierOrNonReservedKeyword[this.currentToken]) goto case Token.Identifier; if (Parser.InfixOperators[this.currentToken]){ this.HandleError(Error.InvalidExprTerm, this.scanner.GetTokenSource()); this.GetNextToken(); }else this.SkipTo(followers|Parser.PrimaryStart, Error.InvalidExprTerm, this.scanner.GetTokenSource()); if (Parser.PrimaryStart[this.currentToken]) return this.ParsePrimaryExpression(followers); goto done; } if (expression is Base && this.currentToken != Token.Dot && this.currentToken != Token.LeftBracket){ this.HandleError(expression.SourceContext, Error.BaseIllegal); expression = null; } expression = this.ParseIndexerCallOrSelector(expression, followers|Token.AddOne|Token.SubtractOne); for(;;){ switch(this.currentToken){ case Token.AddOne: case Token.SubtractOne: SourceContext ctx = expression.SourceContext; ctx.EndPos = this.scanner.endPos; PostfixExpression pex = new PostfixExpression(expression, Parser.ConvertToBinaryNodeType(this.currentToken), ctx); this.GetNextToken(); expression = pex; break; case Token.Dot: expression = this.ParseIndexerCallOrSelector(expression, followers|Token.AddOne|Token.SubtractOne); break; default: goto done; } } done: this.SkipTo(followers); return expression; }
public HoleResult GetHoleResult(Hole hole) { HoleResult result = new HoleResult(); if (hole.Shots != null && hole.Shots.Any()) { result.IsEmpty = false; //Get the last shot var shot = hole.Shots.FirstOrDefault(s => s.ShotMade == true || s.ShotType.Id == 3); //If it was made, see if it was a push, steal if (shot != null && shot.ShotMade == true) { result.Shot = shot; result.LastPlayer = shot.Player; //If a push switch (shot.ShotType.Id) { case 1: result.FirstPlayer = null; result.Points = hole.Par; break; case 3: var pushedShot = hole.Shots.FirstOrDefault(s => s.Attempts == shot.Attempts && s.Id != shot.Id && s.ShotMade == true); result.FirstPlayer = pushedShot.Player; break; case 4: var stolenShot = hole.Shots.LastOrDefault(s => s.Attempts > shot.Attempts && s.ShotMade == true); result.FirstPlayer = stolenShot.Player; result.Points = hole.Par; break; //Try and find the players who pushed the hole case 5: var lastPushedShot = hole.Shots.LastOrDefault(s => s.ShotMade == true && s.Attempts > shot.Attempts); var firstPushedShot = hole.Shots.LastOrDefault(s => s.ShotMade == true && s.Attempts == lastPushedShot.Attempts && s.Id != lastPushedShot.Id); result.FirstPlayer = new Player() { Initials = lastPushedShot.Player.Initials + "/" + firstPushedShot.Player.Initials }; result.Points = hole.Par; break; default: result.FirstPlayer = null; break; } if (result.Points > 0) { //loop through previous holes adding up score until last winning shot. for (int i = hole.Id - 1; i > 0; i--) { var previousHole = Holes.FirstOrDefault(h => h.Id == i); //Check for push if ((previousHole.Shots.Count(s => s.ShotMade == true && s.ShotType.Id == 3) > 0) || previousHole.Shots.Count(s => s.ShotMade == true) == 0) { result.Points += previousHole.Par; } else { break; } } } } } return(result); }
public static void SeedDb(BAISTGolfCourseDbContext database) { var employee1 = new Employees { FirstName = "Clerk", LastName = "Mason", EmailAddress = "*****@*****.**", Address1 = "630 McAllister Loop SW", Phone = "(647)608-1541", DateCreated = DateTime.UtcNow, DateOfBirth = new DateTime(1993, 2, 19), Gender = Enums.Gender.Male, Role = Enums.Role.Administrator, UserName = "******", PCode = "T6E 123", Province = "Alberta", City = "Edmonton" }; employee1.PasswordSalt = PasswordEncryptor.CreateSalt(5); employee1.Password = PasswordEncryptor.CreatePasswordHash("Course2019@", employee1.PasswordSalt); var member1 = new Members { FirstName = "Stuart", LastName = "Mason", EmailAddress = "*****@*****.**", Address1 = "630 McAllister Loop SW", Phone = "(647)608-1541", DateCreated = DateTime.UtcNow, DateOfBirth = new DateTime(1989, 2, 9), Gender = Enums.Gender.Female, City = "Toronto", Province = "Ontario", PostalCode = "T6W 1N3", MembershipID = "123456A", MembershipType = Enums.MembershipStatus.Gold }; var counter = 6; for (int i = 0; i < counter; i++) { var memberCreate = new Members { FirstName = "Stuart" + i, LastName = "Mason" + i, EmailAddress = "stuartMember" + i + "@gmail.com", Address1 = "630 McAllister Loop SW", Phone = "(647)608-1541", DateCreated = DateTime.UtcNow, DateOfBirth = new DateTime(1989, 2, (9 + i)), Gender = Enums.Gender.Female, City = "Toronto", Province = "Ontario", PostalCode = "T6W 1N3", MembershipType = Enums.MembershipStatus.Gold, MembershipID = "12356A" + i, }; memberCreate.PasswordSalt = PasswordEncryptor.CreateSalt(5); memberCreate.Password = PasswordEncryptor.CreatePasswordHash("Course2019", memberCreate.PasswordSalt); database.Members.AddOrUpdate(p => p.EmailAddress, memberCreate); } member1.PasswordSalt = PasswordEncryptor.CreateSalt(5); member1.Password = PasswordEncryptor.CreatePasswordHash("Course2019", member1.PasswordSalt); database.Members.AddOrUpdate(p => p.EmailAddress, member1); database.Employees.AddOrUpdate(p => p.EmailAddress, employee1); var golfClub = new GolfCourse { CourseName = "Green Hill", Rating = 70, Slope = 5, DateAdded = DateTime.UtcNow, YearFounded = new DateTime(1998, 2, 19) }; var golfClub2 = new GolfCourse { CourseName = "Flat Green", Rating = 75, Slope = 5, DateAdded = DateTime.UtcNow, YearFounded = new DateTime(1998, 2, 19) }; database.GolfCourses.AddOrUpdate(p => p.ID, golfClub); database.GolfCourses.AddOrUpdate(p => p.ID, golfClub2); database.SaveChanges(); DateTime now = DateTime.Now; var validStartTeeTime = new DateTime(now.Year, /*DateTime.*/ now.Month, /* DateTime*/ now.Day + 1, 10, 0, 0); var teeTime = new TeeTime { DateCreated = DateTime.Now, StartDate = validStartTeeTime, EndDate = validStartTeeTime.AddMinutes(7), Status = Enums.TeeTimeStatus.Open, GolfCourseID = golfClub.ID }; var teeTimeTwo = new TeeTime { DateCreated = DateTime.Now, StartDate = validStartTeeTime.AddMinutes(14), EndDate = validStartTeeTime.AddMinutes(21), Status = Enums.TeeTimeStatus.Open, GolfCourseID = golfClub2.ID }; var teeTime3 = new TeeTime { DateCreated = DateTime.Now, StartDate = validStartTeeTime.AddMinutes(28), EndDate = validStartTeeTime.AddMinutes(35), Status = Enums.TeeTimeStatus.Open, GolfCourseID = golfClub.ID }; var teeTime4 = new TeeTime { DateCreated = DateTime.Now, StartDate = validStartTeeTime.AddMinutes(42), EndDate = validStartTeeTime.AddMinutes(49), Status = Enums.TeeTimeStatus.Open, GolfCourseID = golfClub2.ID }; var teeTime5 = new TeeTime { DateCreated = DateTime.Now, StartDate = validStartTeeTime.AddMinutes(56), EndDate = validStartTeeTime.AddMinutes(63), Status = Enums.TeeTimeStatus.Open, GolfCourseID = golfClub.ID }; database.TeeTime.AddOrUpdate(p => new { p.GolfCourseID, p.StartDate }, teeTime); database.TeeTime.AddOrUpdate(p => new { p.GolfCourseID, p.StartDate }, teeTimeTwo); database.TeeTime.AddOrUpdate(p => new { p.GolfCourseID, p.StartDate }, teeTime3); database.TeeTime.AddOrUpdate(p => new { p.GolfCourseID, p.StartDate }, teeTime4); database.TeeTime.AddOrUpdate(p => new { p.GolfCourseID, p.StartDate }, teeTime5); for (int i = 1; i < 19; i++) { var hole = new Hole { Name = i.ToString() }; database.Hole.AddOrUpdate(p => p.Name, hole); } database.SaveChanges(); }
private void ToggleHoleVisiblity(Hole SelectedHole) { SelectedHole.Visible = (SelectedHole.Visible) ? false : true; UpdateSketchBoltCircles(); }
//SetCue method public void SetHole(Hole previousHole) { pos = previousHole.pos; aim = previousHole.aim; r = previousHole.r; }
public void NormalizeNegativeAngle() { Assert.AreEqual(270, Hole.NormalizeAngle(-90)); }
static void de_Allocation(List <Hole> Holes, int no_Processes, List <process> processes, List <fragmantation> frag, string process_Name, ref int global, ref int frag_table) { for (int i = 0; i < processes.Count(); i++) { if (processes[i].Name == process_Name) { global = i; bool flag = false; Hole temp_set = new Hole(); for (int j = 0; j < frag.Count(); j++) { if (processes[i].allocating_Address + processes[i].p_Size == frag[j].allocated_Address) { flag = true; Hole temp = new Hole(); temp.set(processes[i].allocating_Address, frag[j].frag_Size + processes[i].p_Size); Holes.Add(temp); frag.RemoveAt(j); frag_table = j; frag_Counter--; break; } else if (processes[i].allocating_Address - frag[j].frag_Size == frag[j].allocated_Address) { flag = true; Hole temp = new Hole(); temp.set(Holes[j].starting_Address, frag[j].frag_Size + processes[i].p_Size); Holes.Add(temp); frag.RemoveAt(j); frag_table = j; frag_Counter--; break; } } if (!flag) { temp_set.set(processes[i].allocating_Address, processes[i].p_Size); Holes.Add(temp_set); } processes.RemoveAt(i); i--; break; } else { global = -1; } } Sort_s(Holes); for (int j = 0; j < Holes.Count() - 1; j++) { for (int k = j + 1; k < Holes.Count(); k++) { if (Holes[j].starting_Address + Holes[j].hole_Size == Holes[k].starting_Address) { Holes[j].set(Holes[j].starting_Address, Holes[j].hole_Size + Holes[k].hole_Size); Holes.RemoveAt(k); } } } }
/// <summary> /// Aktualizacja dziur z prawej strony. /// </summary> /// <param name="outsRight">prostok�ty na brzegu z prawej strony</param> /// <param name="outsDown">prostok�ty na brzegu z do�u</param> /// <param name="holesRight">dziury z prawej strony</param> /// <param name="holesDown">dziury z do�u</param> private void updateHolesRight(List<OutRect> outsRight, List<OutRect> outsDown, List<Hole> holesRight, List<Hole> holesDown) { OutRect orOld = null; Hole hole; // tworzona nowa lista dziur holesRight.Clear(); foreach (OutRect or in outsRight) { if (orOld == null) { if (or.LeftTop.Y > 0) { hole = new Hole(or.SideA, or.LeftTop.Y, new Point(Min_X, 0)); hole.OrientRight = true; hole.NeighbourSecond = or; holesRight.Add(hole); } } else if (or.LeftTop.Y > orOld.RightDown.Y) { hole = new Hole(Math.Min(or.SideA, orOld.SideA), or.LeftTop.Y - orOld.RightDown.Y, new Point(Min_X, orOld.RightDown.Y)); hole.OrientRight = true; hole.NeighbourOne = orOld; hole.NeighbourSecond = or; holesRight.Add(hole); } orOld = or; } if (orOld != null && orOld.RightDown.Y < Max_Y) { hole = new Hole(orOld.SideA, Max_Y - orOld.RightDown.Y, new Point(Min_X, orOld.RightDown.Y)); hole.OrientDown = true; hole.OrientRight = true; hole.NeighbourOne = orOld; if (!isCornerHole(holesDown)) { hole.Corner = true; if (outsDown.Count > 0) hole.NeighbourSecond = outsDown[outsDown.Count - 1]; } else { if (holesDown.Count > 0) hole.saveResize(hole.Rect.SideA, holesDown[holesDown.Count -1 ].Rect.LeftTop.Y - orOld.RightDown.Y); } holesRight.Add(hole); } }
protected override Geometry Copy() { return(new HoleGeometry(ReflectionLimit, ReflectionCoefficient, ReflectionPattern, (CylinderReflector)Nozzle.Copy(), (CylinderReflector)SubNozzle.Copy(), (Hole)Hole.Copy(), (Shield)Detector.Copy())); }
/// <summary> /// Prostok�t wype�nia na dan� dziur�. Ewentualnie mo�e powsta� nowa dziura. /// </summary> /// <param name="rect">dany prostok�t</param> /// <param name="newHole">powsta�a nowa dziura</param> /// <returns> /// 0 - prostok�t w ca�o�ci wype�ni� dan� dziur� - dziura do usuni�cia /// 1 - prostok�t wype�ni� cze�ciowo dan� dziur� - mo�liwa aktualizacja Min_X lub Min_Y /// -1 - prostok�t wype�ni� cz�ciowo dan� dziur� /// </returns> public int filled(Rectangle rect, out Hole newHole) { Point leftTop = new Point(_rect.LeftTop.X, _rect.LeftTop.Y); //Point rightTop = new Point(_rect.RightDown.X, _rect.RightDown.Y); int sideA = rect.SideA - _rect.SideA; int sideB = rect.SideB - _rect.SideB; int result = 0; rect.Move(leftTop); newHole = null; if (sideA >=0 && sideB >= 0) return 0; if (_orientRight && _orientDown) { result = 1; if (sideA < 0 && sideB < 0) { int holeSideA = _rect.SideA; _rect.Move(new Point(rect.RightDown.X, rect.LeftTop.Y)); saveResize(-sideA, rect.SideB); newHole = new Hole(holeSideA, -sideB, new Point(rect.LeftTop.X, rect.RightDown.Y)); if (_corner) { _corner = false; newHole.OrientRight = true; newHole.OrientDown = true; newHole.Corner = true; } } else if (sideA >= 0) { _rect.Move(new Point(rect.LeftTop.X, rect.RightDown.Y)); saveResize(rect.SideA, -sideB); } else if (sideB >= 0) { _rect.Move(new Point(rect.RightDown.X, rect.LeftTop.Y)); saveResize(-sideA, rect.SideB); } } else if (_orientRight) { if (sideB >= 0) { _rect.Move(new Point(rect.RightDown.X, rect.LeftTop.Y)); saveResize(-sideA, _rect.SideB); result = 1; } else { _rect.Move(new Point(rect.LeftTop.X, rect.RightDown.Y)); if(_neighbourSecond != null) saveResize(Math.Min(rect.SideA, _neighbourSecond.SideA), -sideB); result = -1; } } else if (_orientDown) { if (sideA >= 0) { _rect.Move(new Point(rect.LeftTop.X, rect.RightDown.Y)); saveResize(_rect.SideA, -sideB); result = 1; } else { _rect.Move(new Point(rect.RightDown.X, rect.LeftTop.Y)); if (_neighbourSecond != null) saveResize(-sideA, Math.Min(rect.SideB, _neighbourSecond.SideB)); result = -1; } } return result; }
/// <inheritdoc /> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; if (Type != null) { hashCode = hashCode * 59 + Type.GetHashCode(); } if (Visible != null) { hashCode = hashCode * 59 + Visible.GetHashCode(); } if (ShowLegend != null) { hashCode = hashCode * 59 + ShowLegend.GetHashCode(); } if (LegendGroup != null) { hashCode = hashCode * 59 + LegendGroup.GetHashCode(); } if (Opacity != null) { hashCode = hashCode * 59 + Opacity.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (UId != null) { hashCode = hashCode * 59 + UId.GetHashCode(); } if (Ids != null) { hashCode = hashCode * 59 + Ids.GetHashCode(); } if (CustomData != null) { hashCode = hashCode * 59 + CustomData.GetHashCode(); } if (Meta != null) { hashCode = hashCode * 59 + Meta.GetHashCode(); } if (MetaArray != null) { hashCode = hashCode * 59 + MetaArray.GetHashCode(); } if (HoverLabel != null) { hashCode = hashCode * 59 + HoverLabel.GetHashCode(); } if (Stream != null) { hashCode = hashCode * 59 + Stream.GetHashCode(); } if (Transforms != null) { hashCode = hashCode * 59 + Transforms.GetHashCode(); } if (UiRevision != null) { hashCode = hashCode * 59 + UiRevision.GetHashCode(); } if (Labels != null) { hashCode = hashCode * 59 + Labels.GetHashCode(); } if (Label0 != null) { hashCode = hashCode * 59 + Label0.GetHashCode(); } if (DLabel != null) { hashCode = hashCode * 59 + DLabel.GetHashCode(); } if (Values != null) { hashCode = hashCode * 59 + Values.GetHashCode(); } if (Marker != null) { hashCode = hashCode * 59 + Marker.GetHashCode(); } if (Text != null) { hashCode = hashCode * 59 + Text.GetHashCode(); } if (HoverText != null) { hashCode = hashCode * 59 + HoverText.GetHashCode(); } if (HoverTextArray != null) { hashCode = hashCode * 59 + HoverTextArray.GetHashCode(); } if (ScaleGroup != null) { hashCode = hashCode * 59 + ScaleGroup.GetHashCode(); } if (TextInfo != null) { hashCode = hashCode * 59 + TextInfo.GetHashCode(); } if (HoverInfo != null) { hashCode = hashCode * 59 + HoverInfo.GetHashCode(); } if (HoverInfoArray != null) { hashCode = hashCode * 59 + HoverInfoArray.GetHashCode(); } if (HoverTemplate != null) { hashCode = hashCode * 59 + HoverTemplate.GetHashCode(); } if (HoverTemplateArray != null) { hashCode = hashCode * 59 + HoverTemplateArray.GetHashCode(); } if (TextTemplate != null) { hashCode = hashCode * 59 + TextTemplate.GetHashCode(); } if (TextTemplateArray != null) { hashCode = hashCode * 59 + TextTemplateArray.GetHashCode(); } if (TextPosition != null) { hashCode = hashCode * 59 + TextPosition.GetHashCode(); } if (TextPositionArray != null) { hashCode = hashCode * 59 + TextPositionArray.GetHashCode(); } if (TextFont != null) { hashCode = hashCode * 59 + TextFont.GetHashCode(); } if (InsideTextOrientation != null) { hashCode = hashCode * 59 + InsideTextOrientation.GetHashCode(); } if (InsideTextFont != null) { hashCode = hashCode * 59 + InsideTextFont.GetHashCode(); } if (OutsideTextFont != null) { hashCode = hashCode * 59 + OutsideTextFont.GetHashCode(); } if (AutoMargin != null) { hashCode = hashCode * 59 + AutoMargin.GetHashCode(); } if (Title != null) { hashCode = hashCode * 59 + Title.GetHashCode(); } if (Domain != null) { hashCode = hashCode * 59 + Domain.GetHashCode(); } if (Hole != null) { hashCode = hashCode * 59 + Hole.GetHashCode(); } if (Sort != null) { hashCode = hashCode * 59 + Sort.GetHashCode(); } if (Direction != null) { hashCode = hashCode * 59 + Direction.GetHashCode(); } if (Rotation != null) { hashCode = hashCode * 59 + Rotation.GetHashCode(); } if (Pull != null) { hashCode = hashCode * 59 + Pull.GetHashCode(); } if (PullArray != null) { hashCode = hashCode * 59 + PullArray.GetHashCode(); } if (IdsSrc != null) { hashCode = hashCode * 59 + IdsSrc.GetHashCode(); } if (CustomDataSrc != null) { hashCode = hashCode * 59 + CustomDataSrc.GetHashCode(); } if (MetaSrc != null) { hashCode = hashCode * 59 + MetaSrc.GetHashCode(); } if (LabelsSrc != null) { hashCode = hashCode * 59 + LabelsSrc.GetHashCode(); } if (ValuesSrc != null) { hashCode = hashCode * 59 + ValuesSrc.GetHashCode(); } if (TextSrc != null) { hashCode = hashCode * 59 + TextSrc.GetHashCode(); } if (HoverTextSrc != null) { hashCode = hashCode * 59 + HoverTextSrc.GetHashCode(); } if (HoverInfoSrc != null) { hashCode = hashCode * 59 + HoverInfoSrc.GetHashCode(); } if (HoverTemplateSrc != null) { hashCode = hashCode * 59 + HoverTemplateSrc.GetHashCode(); } if (TextTemplateSrc != null) { hashCode = hashCode * 59 + TextTemplateSrc.GetHashCode(); } if (TextPositionSrc != null) { hashCode = hashCode * 59 + TextPositionSrc.GetHashCode(); } if (PullSrc != null) { hashCode = hashCode * 59 + PullSrc.GetHashCode(); } return(hashCode); } }
/// <summary> /// Prostok�t ma wype�ni� dan� dziur�. /// </summary> /// <param name="outsRight">lista prostok�t�w na brzegu z prawej strony</param> /// <param name="outsDown">lista prostok�t�w na brzegu z do�u</param> /// <param name="holesRight">dziury z prawej strony</param> /// <param name="holesDown">dziury z do�u</param> /// <param name="rect">do��czany prostok�t</param> /// <param name="hole">dziura do wype�nienia</param> /// <param name="rightSide">czy dziura jest z prawej strony czy z do�u</param> private void fillHole(List<OutRect> outsRight, List<OutRect> outsDown, List<Hole> holesRight, List<Hole> holesDown, Rectangle rect, Hole hole, bool rightSide) { Hole newHole; OutRect outRect, or; List<OutRect> outRects; List<Hole> holes; int result, index; result = hole.filled(rect, out newHole); updateMaxValues(rect); if (rightSide) { outRects = outsRight; holes = holesRight; } else { outRects = outsDown; holes = holesDown; } or = hole.NeighbourOne; index = -1; if (or != null) index = outRects.IndexOf(or); outRect = new OutRect(rect.SideA, rect.SideB, new Point(rect.LeftTop.X, rect.LeftTop.Y)); outRects.Insert(index + 1, outRect); hole.NeighbourOne = outRect; // dziura jest na rogu i prostok�t w ca�o�ci j� wepe�ni if (hole.OrientDown && hole.OrientRight && result == 0) { if(rect.RightDown.X > Min_X && !rightSide) outsRight.Add(new OutRect(rect.RightDown.X - Min_X, rect.SideB, new Point(Min_X, rect.LeftTop.Y))); if (rect.RightDown.Y > Min_Y && rightSide) outsDown.Add(new OutRect(rect.SideA, rect.RightDown.Y - Min_Y, new Point(rect.LeftTop.X, Min_Y))); } // dziura na rogu wype�niona cz�ciowo - powstaje nowa dziura if (hole.OrientDown && hole.OrientRight && result > 0 && newHole != null) { OutRect or2 = null; if (outsDown.Count > 0) or2 = outsDown[outsDown.Count - 1]; newHole.NeighbourOne = or2; if (newHole.Rect.LeftTop.Y >= Min_Y) holesDown.Add(newHole); } if (result == 0) holes.Remove(hole); updateHoles(outsRight, outsDown, holesRight, holesDown); }
/// <summary> /// This function lets the user set up whether the shape should be regular, type M or type Z. /// This will not interfere with existing shapes in the geometry, but will simply /// add the specified geometry to the end of the existing information. Sending a null shape /// will create a new shape of the appropriate kind. /// </summary> /// <param name="geom">A Geometries.Geometry specifying what to append to the shape. /// Simply returns mwShape unchanged if geom is null.</param> /// <param name="mwShape">An existing shape with a shapetype already specified.</param> public static void AppendGeometryToShape(IGeometry geom, ref MapWinGIS.Shape mwShape) { // we don't need to throw an error if geom is null, there is simply nothing to add. if (geom == null) { return; } // If we have to set up a new shape object, we will also have to specify a shape type. bool SpecifyShapeType = false; if (mwShape == null) { mwShape = new MapWinGIS.Shape(); SpecifyShapeType = true; } MapWinGIS.Point mwPoint; int rfPt = mwShape.numPoints; // Flexible Point Index int rfPrt = mwShape.NumParts; // Flexible Part Index if (rfPt > 0 && rfPrt == 0) { //Change single part to a multipart shapefile mwShape.InsertPart(0, ref rfPrt); rfPrt++; } #region -------------------------- POINT ------------------------------------------- if (geom.GetType() == typeof(Point)) { if (SpecifyShapeType == true) { mwShape.ShapeType = MapWinGIS.ShpfileType.SHP_POINT; } // Only allow appending to a point shape type if there isn't a point defined yet. if ((mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_MULTIPOINT || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_MULTIPOINTM || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_MULTIPOINTZ) || ((mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POINT || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POINTM || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POINTZ) && rfPt == 0)) { Point newPoint = geom as Point; mwPoint = new MapWinGIS.Point(); mwPoint.x = newPoint.X; mwPoint.y = newPoint.Y; mwShape.InsertPoint(mwPoint, ref rfPt); return; } else { if ((mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POINT || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POINTM || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POINTZ)) { throw new ArgumentException("The Shape type of mwShape must be MultiPoint, MultiPointM, or MultiPointZ in order to Append a Point Geometry to a shape that already contains a point."); } else { throw new ArgumentException("mwShape had a shape type that did not correspond to Point or MultiPoint. Point geometry not added."); } } } #endregion #region -------------------------- MULTI POINT-------------------------------------- if (geom.GetType() == typeof(MultiPoint)) { if (SpecifyShapeType == true) { mwShape.ShapeType = MapWinGIS.ShpfileType.SHP_MULTIPOINT; } if (mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_MULTIPOINT || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_MULTIPOINTM || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_MULTIPOINTZ) { MultiPoint newPoints = geom as MultiPoint; for (int iPoint = 0; iPoint < newPoints.Count; iPoint++) { Point CurPoint = newPoints.Geometries[iPoint] as Point; mwPoint = new MapWinGIS.Point(); mwPoint.x = CurPoint.X; mwPoint.y = CurPoint.Y; mwShape.InsertPoint(mwPoint, ref rfPt); rfPt++; // I don't think we can have multi-parts in a multipoint shape } return; } else { throw new ArgumentException("The shape type must be one of the multipoint types to add a multipoint geometry."); } } #endregion #region -------------------------- LINE STRING ------------------------------------- if (geom.GetType() == typeof(LineString) || geom.GetType() == typeof(LinearRing)) { if (SpecifyShapeType == true) { mwShape.ShapeType = MapWinGIS.ShpfileType.SHP_POLYLINE; } if (mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYLINE || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYLINEM || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYLINEZ) { LineString newPoints = geom as LineString; // Polymorphism should allow linear rings to be line strings for (int iPoint = 0; iPoint < newPoints.Count; iPoint++) { ICoordinate CurPoint = newPoints.Coordinates[iPoint]; mwPoint = new MapWinGIS.Point(); mwPoint.x = CurPoint.X; mwPoint.y = CurPoint.Y; mwShape.InsertPoint(mwPoint, ref rfPt); rfPt++; // I don't think we can have multi-parts in a multipoint shape } return; } else { throw new ArgumentException("The shape type must be one of the polyline types to add a LineString geometry."); } } #endregion #region -------------------------- MULTI LINESTRING -------------------------------- if (geom.GetType() == typeof(MultiLineString)) { if (SpecifyShapeType == true) { mwShape.ShapeType = MapWinGIS.ShpfileType.SHP_POLYLINE; } MultiLineString MLS = geom as MultiLineString; if (mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYLINE || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYLINEM || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYLINEZ) { for (int iGeom = 0; iGeom < MLS.NumGeometries; iGeom++) { LineString LS = MLS.Geometries[iGeom] as LineString; AppendGeometryToShape(LS, ref mwShape); // prevents a lot of code duplication } return; } else { throw new ArgumentException("Cannot append a MultiLineString geometry to a " + mwShape.ShapeType.ToString() + " shape."); } } #endregion #region -------------------------- POLYGON ----------------------------------------- if (geom.GetType() == typeof(Polygon)) { Polygon newPolygon = geom as Polygon; if (SpecifyShapeType == true) { mwShape.ShapeType = MapWinGIS.ShpfileType.SHP_POLYGON; } if (mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYGON || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYGONM || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYGONZ) { mwShape.InsertPart(rfPt, ref rfPrt); rfPrt++; ILinearRing Shell = newPolygon.Shell; for (int iPoint = 0; iPoint < Shell.NumPoints; iPoint++) { ICoordinate Coord = Shell.Coordinates[iPoint]; mwPoint = new MapWinGIS.Point(); mwPoint.x = Coord.X; mwPoint.y = Coord.Y; mwShape.InsertPoint(mwPoint, ref rfPt); rfPt++; } // The same hole may appear multiple times in overlapping polygons. // Create a list of holes in order to test clockwise. if (newPolygon.NumInteriorRings > 0) { List <ILinearRing> UniqueHoles = new List <ILinearRing>(); List <ILinearRing> Holes = GetHoles(mwShape); //holes in the existing shape for (int iHole = 0; iHole < newPolygon.NumInteriorRings; iHole++) { if (Holes.Count > 0) { for (int jHole = 0; jHole < Holes.Count; jHole++) { if (newPolygon.Holes[iHole] == Holes[jHole]) { continue; } // if we get here, the new hole is unique and should be added UniqueHoles.Add(newPolygon.Holes[iHole]); // Also add it to the list to compare against other future holes Holes.Add(newPolygon.Holes[iHole]); // Holes.Count is re-evaluated each time so this should be ok } } //else //{ // //make sure holes are added to a shape with no holes // UniqueHoles.Add(newPolygon.Holes[iHole]); // Holes.Add(newPolygon.Holes[iHole]); //} } for (int iHole = 0; iHole < UniqueHoles.Count; iHole++) { mwShape.InsertPart(rfPt, ref rfPrt); rfPrt++; ICoordinate[] Hole; if (IsClockwise(UniqueHoles[iHole].Coordinates)) { // Holes should be counter clockwise Hole = UniqueHoles[iHole].Reverse().Coordinates; } else { Hole = UniqueHoles[iHole].Coordinates; } int Count = Hole.GetUpperBound(0) + 1; for (int iPoint = 0; iPoint < Count; iPoint++) { ICoordinate Coord = Hole[iPoint]; mwPoint = new MapWinGIS.Point(); mwPoint.x = Coord.X; mwPoint.y = Coord.Y; mwShape.InsertPoint(mwPoint, ref rfPt); rfPt++; } } } } } #endregion #region -------------------------- MULTI POLYGON------------------------------------ // The reason not to just Call Add Polygon recursively with this is that we only // want to test for unique holes once. Doing so each and every time we add a polygon // would be a major inefficiency, plus the overhead from converting back and forth // to a shape object. if (geom.GetType() == typeof(MultiPolygon)) { MultiPolygon MPG = geom as MultiPolygon; if (SpecifyShapeType == true) { mwShape.ShapeType = MapWinGIS.ShpfileType.SHP_POLYGON; } if (mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYGON || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYGONM || mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POLYGONZ) { // By doing this one time up here, we prevent a lot of duplication List <ILinearRing> Holes = Holes = GetHoles(mwShape); for (int iPolygon = 0; iPolygon < MPG.NumGeometries; iPolygon++) { Polygon newPolygon = MPG.Geometries[iPolygon] as Polygon; mwShape.InsertPart(rfPt, ref rfPrt); rfPrt++; ILinearRing Shell = newPolygon.Shell; for (int iPoint = 0; iPoint < Shell.NumPoints; iPoint++) { ICoordinate Coord = Shell.Coordinates[iPoint]; mwPoint = new MapWinGIS.Point(); mwPoint.x = Coord.X; mwPoint.y = Coord.Y; mwShape.InsertPoint(mwPoint, ref rfPt); rfPt++; } // The same hole may appear multiple times in overlapping polygons. // Create a list of holes in order to test clockwise. if (newPolygon.NumInteriorRings > 0) { List <ILinearRing> UniqueHoles = new List <ILinearRing>(); for (int iHole = 0; iHole < newPolygon.NumInteriorRings; iHole++) { for (int jHole = 0; jHole < Holes.Count; jHole++) { if (newPolygon.Holes[iHole] == Holes[jHole]) { continue; } // if we get here, the new hole is unique and should be added UniqueHoles.Add(newPolygon.Holes[iHole]); // Also add it to the list to compare against other future holes Holes.Add(newPolygon.Holes[iHole]); // Holes.Count is re-evaluated each time so this should be ok } } for (int iHole = 0; iHole < UniqueHoles.Count; iHole++) { mwShape.InsertPart(rfPt, ref rfPrt); rfPrt++; ICoordinate[] Hole; if (IsClockwise(UniqueHoles[iHole].Coordinates)) { // Holes should be counter clockwise Hole = UniqueHoles[iHole].Reverse().Coordinates; } else { Hole = UniqueHoles[iHole].Coordinates; } int Count = Hole.GetUpperBound(0) + 1; for (int iPoint = 0; iPoint < Count; iPoint++) { ICoordinate Coord = Hole[iPoint]; mwPoint = new MapWinGIS.Point(); mwPoint.x = Coord.X; mwPoint.y = Coord.Y; mwShape.InsertPoint(mwPoint, ref rfPt); rfPt++; } } } } } } #endregion }
/// <summary> /// Znajdowany prostok�t, kt�ry wype�ni dziur�. /// </summary> /// <param name="rectangles">lista prostok�t�w</param> /// <param name="hole">dana dziura</param> /// <param name="rightSide">czy prostok�t ma by� dodany z prawej strony czy z do�u</param> /// <returns>znaleziony prostok�t</returns> private Rectangle findRectangle(List<Rectangle> rectangles, Hole hole, bool rightSide) { Rectangle rect = null; int sideA, sideB; int searchSide; if (hole != null) { if(rightSide) searchSide = hole.Rect.SideB; else searchSide = hole.Rect.SideA; rect = findRectangle(rectangles, searchSide); sideA = searchSide - rect.SideA; sideB = searchSide - rect.SideB; if(rightSide) { if(sideA < 0 && sideB < 0 && rect.SideA < rect.SideB) rect.Rotate(); else if(sideA == 0) rect.Rotate(); else if(sideA > 0 && sideB > 0 && rect.SideA > rect.SideB) rect.Rotate(); } else { if(sideA < 0 && sideB < 0 && rect.SideA > rect.SideB) rect.Rotate(); else if(sideB == 0) rect.Rotate(); else if(sideA > 0 && sideB > 0 && rect.SideA < rect.SideB) rect.Rotate(); } } else { rect = findAnyMaxRectangle(rectangles); if (rightSide && rect.SideB != rect.LongerSide) rect.Rotate(); else if (!rightSide && rect.SideA != rect.LongerSide) rect.Rotate(); } return rect; }
// Called during a remove operation private void detach_Instance(Hole hole) { NotifyPropertyChanging("ExerciseInstance"); hole.Course = null; }
/// <summary> /// Prostok�t do��czany do boku budowanego prostak�ta z prawej strony. /// </summary> /// <param name="outsRight">lista prostok�t�w na brzegu z prawej strony</param> /// <param name="outsDown">lista prostok�t�w na brzegu z do�u</param> /// <param name="holesRight">lista dziur z prawej strony</param> /// <param name="holesDown">lista dziur z do�u</param> /// <param name="rect">do��czany prostok�t</param> private void stickRectangleRight(List<OutRect> outsRight, List<OutRect> outsDown, List<Hole> holesRight, List<Hole> holesDown, Rectangle rect) { OutRect outRect; Hole hole; rect.Move(new Point(Min_X, 0)); updateMaxValues(rect); if (rect.SideB < Min_Y) { outRect = new OutRect(rect.SideA, rect.SideB, new Point(rect.LeftTop.X, rect.LeftTop.Y)); outsRight.Add(outRect); hole = new Hole(rect.SideA, Max_Y - rect.SideB, new Point(Min_X, rect.RightDown.Y)); hole.NeighbourOne = outRect; hole.OrientDown = true; hole.OrientRight = true; if (isCornerHole(holesDown)) hole.saveResize(rect.SideA, Min_Y - rect.SideB); else { hole.Corner = true; if (outsDown.Count > 0) hole.NeighbourSecond = outsDown[outsDown.Count - 1]; } holesRight.Add(hole); } else { if (Max_Y > Min_Y && !isCornerHole(holesDown) && outsDown.Count > 0) { hole = new Hole(Max_X - Min_X, Max_Y - Min_Y, new Point(Min_X, Min_Y)); hole.NeighbourOne = outsDown[outsDown.Count - 1]; hole.OrientDown = true; hole.OrientRight = true; hole.Corner = true; holesDown.Add(hole); } Min_X = rect.RightDown.X; } }
// Update is called once per frame void Update() { switch (_state) { case State.WALKING_TO_HOLE: float speed = Time.deltaTime * WALK_SPEED; Vector3 goalVec = (_curHole.start.transform.position + _curHole.start.startLocation) - character.transform.position - new Vector3(0, 0, 0.5f); goalVec.y = 0; if (goalVec.magnitude > speed) { character.transform.position += goalVec.normalized * speed; RaycastHit info; bool didHit = Physics.Raycast(character.transform.position + new Vector3(0, 10, 0), new Vector3(0, -1, 0), out info, 20.0f, layerMask.value); if (didHit) { character.transform.position = info.point; } character.transform.LookAt(_curHole.transform.position + _curHole.start.startLocation); } else { //Arrived at hole! character.transform.position += goalVec; ChangeState(State.WAITING_FOR_NEXT_SWING); } break; case State.WALKING_TO_BALL: speed = Time.deltaTime * WALK_SPEED; Vector3 backFromBall = CalculateGoalSwing().normalized * -.5f; goalVec = ball.transform.position - character.transform.position + backFromBall; //- new Vector3(0,0,0.5f); goalVec.y = 0; if (goalVec.magnitude > speed) { character.transform.position += goalVec.normalized * speed; RaycastHit info; bool didHit = Physics.Raycast(character.transform.position + new Vector3(0, 10, 0), new Vector3(0, -1, 0), out info, 20, layerMask.value); if (didHit) { character.transform.position = info.point; } character.transform.LookAt(new Vector3(ball.transform.position.x, character.transform.position.y, ball.transform.position.z)); } else { //Arrived at ball! character.transform.position += goalVec; ChangeState(State.WAITING_FOR_NEXT_SWING); } break; case State.WAITING_FOR_BALL_TO_STOP: _waitForStopElapsed += Time.deltaTime; if (ball.GetComponent <Rigidbody>().velocity.magnitude < .1f || _waitForStopElapsed > WAIT_FOR_STOP_TIME) { if (InHole || swingCount >= _curHole.maxSwings) { //Hole complete! Handle move to next hole? _curHole = _course.FinishHoleAndGetNext(_curHole, swingCount); totalSwingCount.Add(swingCount); swingCount = 0; if (_curHole == null) { GolfCourse.instance.RemoveAgent(this); //_course.agents.Remove(this); //GameObject.Destroy(this.gameObject); } else { ball.gameObject.SetActive(false); ChangeState(State.WALKING_TO_HOLE); } } else { ChangeState(State.WALKING_TO_BALL); } } break; } }
//首先沿Y方向扫描,把Y方向相交的存在一起ListY //将ListY里的沿X方向扫描,把X方向相交的组成大的AABB void CreateHoleByScanXY(Vector3 pos, float radius) { Hole hole = new Hole(pos, radius); mHoles.Add(hole); //如果新孔洞在已有孔洞Grid范围内,则直接操作顶点下沉而不重新生成网格 for (int i = 0; i < mHoleGrids.Count; i++) { AABB target = CalculateAABB(hole); if (mHoleGrids[i].IsContains(target)) { AddHole(pos, radius); return; } } mMesh.Clear(); mHoleGrids.Clear(); mHoles.Sort(new HoleCompareY()); List <ScanXYData> xyDatas = new List <ScanXYData>(); int holeIndex = 0; while (holeIndex < mHoles.Count) { AABB curAABB = CalculateAABB(mHoles[holeIndex]); List <AABB> rawChildrenAABB = new List <AABB>(); rawChildrenAABB.Add(new AABB(curAABB)); int count = 1; for (int nextHoleIndex = holeIndex + 1; nextHoleIndex < mHoles.Count; nextHoleIndex++) { AABB nextAABB = CalculateAABB(mHoles[nextHoleIndex]); if (curAABB.top >= nextAABB.bottom) //Y方向上相交 { count++; curAABB.UnionWith(nextAABB); rawChildrenAABB.Add(new AABB(nextAABB)); } else { break; } } holeIndex += count; List <AABB> childrenAABB = new List <AABB>(); rawChildrenAABB.Sort(); //在X方向上排序 //在X方向对子AABB做和Y方向类似的操作 int rawAABBIndex = 0; while (rawAABBIndex < rawChildrenAABB.Count) { AABB current = new AABB(rawChildrenAABB[rawAABBIndex]); int aabbCount = 1; for (int nextAABBIndex = rawAABBIndex + 1; nextAABBIndex < rawChildrenAABB.Count; nextAABBIndex++) { AABB next = rawChildrenAABB[nextAABBIndex]; if (current.right >= next.left) //X方向上相交 { aabbCount++; current.UnionWith(next); } else { break; } } rawAABBIndex += aabbCount; childrenAABB.Add(current); } ScanXYData xyData = new ScanXYData(new AABB(curAABB)); xyData.childrenAABB = childrenAABB; xyDatas.Add(xyData); mHoleGrids.AddRange(childrenAABB); } //根据数据创建网格 ScanXYCreateMesh(xyDatas); }
AABB CalculateAABB(Hole hole) { return(CalculateAABB(hole.position, hole.radius)); }
public void UpdatePosition_MoveToPositionWithHole() { var grid = Program.InitializeGrid(5, 5); var hole = new Hole(new[] {3, 3}, new[] {1, 0}, grid); grid[grid.FirstOrDefault(g => g.Key.SequenceEqual(hole.Position)).Key] = hole; var robot = new Robot(); robot = robot.UpdatePosition(hole.Position, grid); Assert.IsTrue(robot.Position.SequenceEqual(new[] { 3, 3 })); }
public void InitHoles() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { HoleState s = HoleState.NotAvailable; if ((i < 2 || i > 4) && (j < 2 || j > 4)) s = HoleState.NotAvailable; else if (i == 3 && j == 3) s = HoleState.Empty; else s = HoleState.Occupied; Hole h = new Hole(this, i, j, s); this.Holes.Add(h); this.Controls.Add(h); } } }
private void RenderHole(StringBuilder sb, Hole hole, IFormatProvider formatProvider, object value, bool legacy = false) { RenderHole(sb, hole.CaptureType, hole.Format, formatProvider, value, legacy); }
public void BeginTunneling() { Mobile m = Combatant; if ( m == null || m.Deleted || !m.Alive || !Alive || m_NextTunneling > DateTime.Now || !CanBeHarmful( m ) || !m.InRange( this, 2 ) ) return; Frozen = true; Hole hole = new Hole( 0xF34 ); hole.MoveToWorld( Location, Map ); m_NewLocation = Location; m_NewMap = Map; PlaySound( 0x21E ); Say( "* The ant lion begins tunneling into the ground *" ); m_TunnelTimer = Timer.DelayCall<Mobile>( TimeSpan.FromSeconds( 3 ), new TimerStateCallback<Mobile>( EndTunneling ), m ); m_NextTunneling = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( 12, 20 ) ); }
public void Add(Hole hole) { db.Holes.InsertOnSubmit(hole); }
public void Reappear( Mobile target ) { Hits += 50; Frozen = false; if ( !Alive || target == null || target.Deleted || !target.Alive || !target.InRange( m_NewLocation, 10 ) ) { MoveToWorld( m_NewLocation, m_NewMap ); } else { Point3D location = target.Location; if ( SpellHelper.FindValidSpawnLocation( m_NewMap, ref location, true ) ) { Hole hole = new Hole( 0xF34 ); hole.MoveToWorld( location, m_NewMap ); hole = new Hole( 0x1363 ); hole.MoveToWorld( location, m_NewMap ); MoveToWorld( location, m_NewMap ); } else MoveToWorld( m_NewLocation, m_NewMap ); } Combatant = target; }
public Hole Hole; // Not readonly to avoid struct-copy, and to avoid VerificationException when medium-trust AppDomain public LiteralHole(Literal literal, Hole hole) { Literal = literal; Hole = hole; }