public PathView(WallCollision wc, ViewController v) { BackgroundColor = UIColor.Clear; path = new CGPath(); wallCol = wc; mainView = v; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ScaleImage); // Register our sensor listener _sensorManager = (SensorManager)GetSystemService(SensorService); _sensorListener = new CustomListener(_sensorManager); _sensorListener.AccelerationProcessor.OnValueChanged += AccelerationProcessorOnValueChanged; _sensorListener.RotationProcessor.OnValueChanged += RotationProcessorOnValueChanged; // Class that will handle drawing of the map _mapMaker = new MapMaker(); _mapMaker.Initialize(Resources); var graphAsset = Assets.Open("dcsGroundFloor.xml"); var graphInstance = Graph.Load(graphAsset); _mapMaker.PathfindingGraph = graphInstance; _collision = new Collision(graphInstance, new StepDetector()); _collision.SetLocation(707.0f, 677.0f); _collision.PassHeading(90); _collision.PositionChanged += CollisionOnPositionChanged; _collision.StepDetector.OnStep += StepDetectorOnStep; collisionMap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.dcsFloor); _walCol = new WallCollision((x, y) => collisionMap.GetPixel(x, y)); _collision.WallCol = _walCol; pf = new Pathfinding.Pathfinding(new Dictionary <int, Stream>() { { 0, Assets.Open("dcsGroundFloor.xml") }, { 1, Assets.Open("dcsFloor1.xml") } }, Assets.Open("Rooms.xml")); pf.CurrentFloor = 0; while (true) { if (pf.Ready) { break; } Thread.Sleep(500); } var result = pf.FindPath(new GraphLocatable(609, 457, 1), new GraphLocatable(1256, 80, 0)); setUpUITabs(); }
// Start is called before the first frame update void Awake() { head = GameObject.FindGameObjectWithTag("MainCamera"); text = GetComponent <Text>(); position = head.transform.position; wall = GameObject.FindGameObjectWithTag("Wall"); script = wall.GetComponent <WallCollision>(); }
/// <summary> /// /// </summary> public Server() { this.SystemMessageHandler = new SystemMessage(); this.TextMessageHandler = new TextMessage(); // TODO: Add Ping Message Handler Construction // TODO: Add Operator Message Handler Construction this.ZoneBorderHandler = new WallCollision(); }
private void TurnIfWall(Collider other, bool dodgeEntering) { if (!enabled) { return; } WallCollision wallCollision = other.GetComponent <WallCollision>(); if (wallCollision == null) { return; } if (wallCollision.KillOnEnter() == dodgeEntering) { bool turnLeft = Random.Range(0, 2) == 0; playerMovement.Turn(turnLeft); } }
/// <summary> /// </summary> /// <param name="c"> /// </param> private void CheckWallCollision(ICharacter c) { WallCollisionResult wcr = WallCollision.CheckCollision(c.Coordinates, c.Playfield.Identity.Instance); if (wcr != null) { int destPlayfield = wcr.SecondWall.DestinationPlayfield; if (destPlayfield > 0) { if (Program.DebugZoning) { LogUtil.Debug(wcr.ToString()); } PlayfieldDestination dest = PlayfieldLoader.PFData[destPlayfield].Destinations[wcr.SecondWall.DestinationIndex]; if (Program.DebugZoning) { LogUtil.Debug(dest.ToString()); } float newX = (dest.EndX - dest.StartX) * wcr.Factor + dest.StartX; float newZ = (dest.EndZ - dest.StartZ) * wcr.Factor + dest.StartZ; float dist = WallCollision.Distance(dest.StartX, dest.StartZ, dest.EndX, dest.EndZ); float headDistX = (dest.EndX - dest.StartX) / dist; float headDistZ = (dest.EndZ - dest.StartZ) / dist; newX -= headDistZ * 8; newZ += headDistX * 8; Coordinate destinationCoordinate = new Coordinate(newX, c.RawCoordinates.Y, newZ); this.Teleport( (Character)c, destinationCoordinate, c.RawHeading, new Identity() { Type = IdentityType.Playfield, Instance = destPlayfield }); return; } } }
/// <summary> /// </summary> /// <param name="self"> /// </param> /// <param name="caller"> /// </param> /// <param name="target"> /// </param> /// <param name="arguments"> /// </param> /// <returns> /// </returns> public override bool Execute( INamedEntity self, IEntity caller, IInstancedEntity target, MessagePackObject[] arguments) { if (arguments.Count() != 3) { return(false); } uint arg1 = arguments[1].AsUInt32(); int toPlayfield = arguments[2].AsInt32(); byte destinationIndex = (byte)(arg1 >> 16); PlayfieldData pfd = PlayfieldLoader.PFData[toPlayfield]; PlayfieldDestination pfDestination = pfd.Destinations[destinationIndex]; float newX = (pfDestination.EndX - pfDestination.StartX) * 0.5f + pfDestination.StartX; float newZ = (pfDestination.EndZ - pfDestination.StartZ) * 0.5f + pfDestination.StartZ; float dist = WallCollision.Distance( pfDestination.StartX, pfDestination.StartZ, pfDestination.EndX, pfDestination.EndZ); float headDistX = (pfDestination.EndX - pfDestination.StartX) / dist; float headDistZ = (pfDestination.EndZ - pfDestination.StartZ) / dist; newX -= headDistZ * 4; newZ += headDistX * 4; Coordinate destCoordinate = new Coordinate(newX, pfDestination.EndY, newZ); ((ICharacter)self).Teleport( destCoordinate, ((ICharacter)self).Heading, new Identity() { Type = IdentityType.Playfield, Instance = toPlayfield }); return(true); }
// Start is called before the first frame update void Start() { wc = new WallCollision(); }
public void WallCollider() { WallCollision?.Invoke(); }
protected virtual void OnWallCollision(int points) { WallCollision?.Invoke(points); }
/// <summary> /// TODO: Add a Description of what this Class does.. -Looks at someone else- /// </summary> /// <param name="packet"></param> /// <param name="client"></param> public static void Read(byte[] packet, Client client) { PacketWriter packetWriter = new PacketWriter(); PacketReader packetReader = new PacketReader(packet); Header header = packetReader.PopHeader(); packetReader.PopByte(); byte moveType = packetReader.PopByte(); Quaternion heading = packetReader.PopQuat(); AOCoord coordinates = packetReader.PopCoord(); // TODO: Find out what these (tmpInt) are and name them int tmpInt1 = packetReader.PopInt(); int tmpInt2 = packetReader.PopInt(); int tmpInt3 = packetReader.PopInt(); packetReader.Finish(); if (!client.Character.DoNotDoTimers) { WallCollision.LineSegment teleportPlayfield = WallCollision.WallCollisionCheck( coordinates.x, coordinates.z, client.Character.PlayField); if (teleportPlayfield.ZoneToPlayfield >= 1) { Quaternion newHeading; CoordHeading coordHeading = WallCollision.GetCoord(teleportPlayfield, coordinates.x, coordinates.z, coordinates); if (teleportPlayfield.Flags != 1337 && client.Character.PlayField != 152 || Math.Abs(client.Character.Coordinates.y - teleportPlayfield.Y) <= 2 || teleportPlayfield.Flags == 1337 && Math.Abs(client.Character.Coordinates.y - teleportPlayfield.Y) <= 6) { client.Teleport(coordHeading.Coordinates, coordHeading.Heading, teleportPlayfield.ZoneToPlayfield); Program.zoneServer.Clients.Remove(client); } return; } if (client.Character.Stats.LastConcretePlayfieldInstance.Value != 0) { Doors correspondingDoor = DoorHandler.DoorinRange( client.Character.PlayField, client.Character.Coordinates, 1.0f); if (correspondingDoor != null) { correspondingDoor = DoorHandler.FindCorrespondingDoor(correspondingDoor, client.Character); client.Character.Stats.LastConcretePlayfieldInstance.Value = 0; AOCoord aoc = correspondingDoor.Coordinates; aoc.x += correspondingDoor.hX * 3; aoc.y += correspondingDoor.hY * 3; aoc.z += correspondingDoor.hZ * 3; client.Teleport(aoc, client.Character.Heading, correspondingDoor.playfield); Program.zoneServer.Clients.Remove(client); return; } } } client.Character.RawCoord = coordinates; client.Character.RawHeading = heading; client.Character.UpdateMoveType(moveType); /* Start NV Heading Testing Code * Yaw: 0 to 360 Degrees (North turning clockwise to a complete revolution) * Roll: Not sure, but is always 0 cause we can't roll in AO * Pitch: 90 to -90 Degrees (90 is nose in the air, 0 is level, -90 is nose to the ground) */ /* Comment this line with a '//' to enable heading testing * client.SendChatText("Raw Headings: X: " + client.Character.heading.x + " Y: " + client.Character.heading.y + " Z:" + client.Character.heading.z); * * client.SendChatText("Yaw: " + Math.Round(180 * client.Character.heading.yaw / Math.PI) + " Degrees"); * client.SendChatText("Roll: " + Math.Round(180 * client.Character.heading.roll / Math.PI) + " Degrees"); * client.SendChatText("Pitch: " + Math.Round(180 * client.Character.heading.pitch / Math.PI) + " Degrees"); * /* End NV Heading testing code */ /* start of packet */ packetWriter.PushByte(0xDF); packetWriter.PushByte(0xDF); /* packet type */ packetWriter.PushShort(10); /* unknown */ packetWriter.PushShort(1); /* packet length (writer takes care of this) */ packetWriter.PushShort(0); /* server ID */ packetWriter.PushInt(3086); /* receiver (Announce takes care of this) */ packetWriter.PushInt(0); /* packet ID */ packetWriter.PushInt(0x54111123); /* affected dynel identity */ packetWriter.PushIdentity(50000, client.Character.Id); /* ? */ packetWriter.PushByte(0); /* movement type */ packetWriter.PushByte(moveType); /* Heading */ packetWriter.PushQuat(heading); /* Coordinates */ packetWriter.PushCoord(coordinates); // see reading part for comment packetWriter.PushInt(tmpInt1); packetWriter.PushInt(tmpInt2); packetWriter.PushInt(tmpInt3); byte[] reply = packetWriter.Finish(); Announce.Playfield(client.Character.PlayField, reply); if (Statels.StatelppfonEnter.ContainsKey(client.Character.PlayField)) { foreach (Statels.Statel s in Statels.StatelppfonEnter[client.Character.PlayField]) { if (s.onEnter(client)) { return; } if (s.onTargetinVicinity(client)) { return; } } } }
// Creating a new wall element public Tile(Texture2D texture, WallCollision collision) { Texture = texture; Collision = collision; }
public override void ViewDidLoad() { base.ViewDidLoad(); // For accelerometer readings motionManager = new CMMotionManager(); motionManager.AccelerometerUpdateInterval = 0.01; // 100Hz //To handle long presses and bring up path start/end menu var longPressManager = new UILongPressGestureRecognizer(); //Graph loading code //Graph loading code var assembly = Assembly.GetExecutingAssembly(); var asset = assembly.GetManifestResourceStream("Navigator.iOS.Resources.dcsfloorWideDoors.xml"); var asset2 = assembly.GetManifestResourceStream("Navigator.iOS.Resources.dcsFloor1.xml"); var assetSci = assembly.GetManifestResourceStream("Navigator.iOS.Resources.ConFloor.xml"); pf = new Pathfinding.Pathfinding(new Dictionary <int, Stream>() { { 0, assembly.GetManifestResourceStream("Navigator.iOS.Resources.dcsfloorWideDoors.xml") }, { 1, assembly.GetManifestResourceStream("Navigator.iOS.Resources.dcsFloor1.xml") }, { 2, assembly.GetManifestResourceStream("Navigator.iOS.Resources.ConFloor.xml") } }, assembly.GetManifestResourceStream("Navigator.iOS.Resources.Rooms.xml")); pf.CurrentFloor = 0; while (true) { if (pf.Ready) { break; } Thread.Sleep(500); } //set up the search bar and prediction box SearchBar.TintColor = UIColor.White; UITextView.AppearanceWhenContainedIn(typeof(UISearchBar)).BackgroundColor = UIColor.White; UITextView.AppearanceWhenContainedIn(typeof(UISearchBar)).TintColor = UIColor.White; UITextField.AppearanceWhenContainedIn(typeof(UISearchBar)).BackgroundColor = UIColor.White; UITextField.AppearanceWhenContainedIn(typeof(UISearchBar)).TintColor = UIColor.White; var shadowView = new UIView(SearchPredictionTable.Frame); shadowView.BackgroundColor = UIColor.White; shadowView.Layer.ShadowColor = UIColor.DarkGray.CGColor; shadowView.Layer.ShadowOpacity = 1.0f; shadowView.Layer.ShadowRadius = 6.0f; shadowView.Layer.ShadowOffset = new System.Drawing.SizeF(0f, 3f); shadowView.Layer.ShouldRasterize = true; shadowView.Layer.MasksToBounds = false; Add(shadowView); var blur = UIBlurEffect.FromStyle(UIBlurEffectStyle.Dark); topblurView = new UIVisualEffectView(blur) { Frame = new RectangleF(0, 0, (float)View.Frame.Width, 90) }; bottomblurView = new UIVisualEffectView(blur) { Frame = new RectangleF(0, (float)View.Frame.Height - 70, (float)View.Frame.Width, 70) }; View.Add(topblurView); View.Add(bottomblurView); View.BringSubviewToFront(SearchPredictionTable); View.BringSubviewToFront(returnButton); View.BringSubviewToFront(SearchBar); View.BringSubviewToFront(directionsButton); var searchController = new CustomSearchController(this, SearchBar, SearchPredictionTable, shadowView, pf.Rooms); //var directionsController = new CustomDirectionsController (this, directionsTable, pf.Rooms); floorPlanGraph = Graph.Load(asset); floorplanWallCol = UIImage.FromBundle("Images/dcsfloorWideDoors.png"); wallCollImg = floorplanWallCol; col = new Collision(floorPlanGraph, new StepDetector()); ((Collision)col).WallCol = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg)); wallColTest = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg)); pathView = new PathView(wallColTest, this); col.SetLocation(707.0f, 677.0f); col.PassHeading(90); col.PositionChanged += HandleStepsTaken; //Container for floorplan and any overlaid images var container = new UIView(); //Will contain floorplan images floorplanImageView = new UIImageView(); //Load floorplan images floorplanImageNoGrid = UIImage.FromBundle("Images/FinalDcsFloor1.png"); floorplanImageWithGrid = UIImage.FromBundle("Images/dcsFloorWideDoorsGrid.png"); floorplanFirstFloorNoGrid = UIImage.FromBundle("Images/final2ndFloorDisplay.png"); floorplanSci = UIImage.FromBundle("Images/ConFloorGrid"); floorplanFirstFloorWallCol = UIImage.FromBundle("Images/dcsFloor1.png"); //Initiate the location arrow locationArrow = new LocationArrowImageView(); locationArrow.ScaleFactor = floorplanView.ZoomScale; pathView.ScaleFactor = floorplanView.ZoomScale; setStartPoint(690.0f, 840.0f, this.floor); //Set sizes for floorplan view and path view floorplanView.ContentSize = floorplanImageNoGrid.Size; pathView.Frame = new CGRect(new CGPoint(0, 0), floorplanImageNoGrid.Size); //Add subviews to the container (including pathview and floorplanview) container.AddSubview(floorplanImageView); container.AddSubview(locationArrow); floorplanImageView.AddSubview(pathView); changeFloorPlanImage(floorplanImageView, floorplanImageNoGrid); container.SizeToFit(); //Adjust scrolling and zooming properties for the floorplanView floorplanView.MaximumZoomScale = 1f; floorplanView.MinimumZoomScale = .25f; floorplanView.AddSubview(container); floorplanView.ViewForZoomingInScrollView += (UIScrollView sv) => { return(floorplanImageView); }; //Variables needed to convert device acceleration to world z direction acceleration double accelX = 0, accelY = 0, accelZ = 0; //Scale location arrow and paths when zooming the floorplan floorplanView.DidZoom += (sender, e) => { locationArrow.ScaleFactor = floorplanView.ZoomScale; pathView.ScaleFactor = floorplanView.ZoomScale; }; floorplanView.DraggingStarted += (sender, e) => { handleAnimate(topblurView, bottomblurView, true); }; var tapGestureRecognizer = new UITapGestureRecognizer(); tapGestureRecognizer.NumberOfTapsRequired = 1; tapGestureRecognizer.AddTarget(() => { handleAnimate(topblurView, bottomblurView, false); }); floorplanView.AddGestureRecognizer(tapGestureRecognizer); //LongPressManager will cause the path input menu to appear after a stationary long press longPressManager.AllowableMovement = 0; longPressManager.AddTarget(() => handleLongPress(longPressManager, floorPlanGraph)); floorplanView.AddGestureRecognizer(longPressManager); //the location manager handles the phone heading locationManager = new CLLocationManager(); locationManager.DesiredAccuracy = CLLocation.AccuracyBest; locationManager.HeadingFilter = 1; locationManager.UpdatedHeading += HandleUpdatedHeading; locationManager.StartUpdatingHeading(); //Another testing button returnButton.TouchUpInside += delegate { returnToMenu(); }; directionsButton.TouchUpInside += delegate { if (!initStep) { //Pass acceleremoter values to the collision class motionManager.StartAccelerometerUpdates(NSOperationQueue.CurrentQueue, (data, error) => { accelX = data.Acceleration.X * 9.8; accelY = data.Acceleration.Y * 9.8; accelZ = Math.Sqrt(Math.Pow(accelX, 2) + Math.Pow(accelY, 2) + Math.Pow(data.Acceleration.Z * 9.8, 2)); col.PassSensorReadings(CollisionSensorType.Accelometer, accelX, accelY, accelZ); //displayAccelVal((float)accelZ); }); directionsButton.SetTitle("Change Floor", UIControlState.Normal); initStep = true; } else if (floor == 0) { Console.Out.WriteLine("Changing to floor 1 "); floor = 1; changeFloorPlanImage(floorplanImageView, floorplanFirstFloorNoGrid); setStartPoint(447.0f, 850.0f, this.floor, false); wallCollImg = floorplanFirstFloorWallCol; col = new Collision(floorPlanGraph, new StepDetector()); ((Collision)col).WallCol = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg)); wallColTest = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg)); pathView = new PathView(wallColTest, this); col.SetLocation(447, 850); col.PositionChanged += HandleStepsTaken; } else if (floor == 1) { Console.Out.WriteLine("Changing to floor 0 "); floor = 0; changeFloorPlanImage(floorplanImageView, floorplanImageNoGrid); setStartPoint(486.0f, 980.0f, this.floor, false); wallCollImg = floorplanWallCol; col = new Collision(floorPlanGraph, new StepDetector()); ((Collision)col).WallCol = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg)); wallColTest = new WallCollision((x, y) => GetPixelColor(new PointF(x, y), wallCollImg)); pathView = new PathView(wallColTest, this); col.SetLocation(486, 980); col.PositionChanged += HandleStepsTaken; } else { floor = 0; } }; }