void OnMouseDown() { PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl> (); if (pc.drawLine) { RaycastHit hit; Ray ray = GameObject.Find("Flycam").camera.ScreenPointToRay(Input.mousePosition); if (collider.Raycast(ray, out hit, Mathf.Infinity)) { if (!point1active) { point1 = hit.point; point1active = true; } else if (!point2active) { point2 = hit.point; VectorLine.SetCamera(GameObject.Find("Flycam").camera); myLine = VectorLine.SetLine3D(Color.red, new Vector3[] { point1, point2 }); myLine.lineWidth = 3.0f; point2active = true; lineCrossed = 0; pc.lineDrawn(); } else { removeLine(); } } } }
// Update is called once per frame void Update() { if (point1active && !point2active) { RaycastHit hit; Ray ray = GameObject.Find("Flycam").GetComponent <Camera>().ScreenPointToRay(Input.mousePosition); if (GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity)) { VectorLine.Destroy(ref myLine_tmp); VectorLine.SetCamera(GameObject.Find("Flycam").GetComponent <Camera>()); myLine_tmp = VectorLine.SetLine3D(Color.red, new Vector3[] { point1, hit.point }); myLine_tmp.lineWidth = 3.0f; } } else { VectorLine.Destroy(ref myLine_tmp); if (point1active && point2active) { PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl>(); for (int i = 0; i < crossings.Count; i++) { if (crossings[i] < pc.current_time - 1) { crossings.RemoveAt(i); } } } } }
static void Main() { //Program entrypoint IUPnPConfigFactory sinkfact = new SinkFactory(); IUPnPConfigFactory sourceFact = new SourceFactory(); UPnP sink = new UPnP(sinkfact.CreatePackage()); UPnP source = new UPnP(sourceFact.CreatePackage()); IPlayqueueHandler pqhandl = new PlayqueueHandler(); PlaybackControl PlayCtrl = new PlaybackControl(sink, pqhandl); DBHandle dbHandle = new DBHandle(source, pqhandl); AbstractFileSenderServer Fserver = new FileSenderServer.FileSenderServer(); Console.WriteLine ("=============================================================="); Console.WriteLine ("Welcome to the HiPi Server solution"); Console.WriteLine ("All UPnP devices SHOULD work, but that's probably not the case"); Console.WriteLine ("Feel free to get our Windows application to get all features"); Console.WriteLine ("Enjoy! ;)"); Console.WriteLine ("=============================================================="); Console.Read(); }
void UpdateSecond() { if (activeEntry > -1) { FundamentalDiagram fd = GameObject.Find("FundamentalDiagram").GetComponent <FundamentalDiagram> (); fd.removeFundamentalDiagram(); PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl> (); float tx = ((float)(pc.current_time / pc.total_time)) * diagramPosition.width + diagramPosition.x; timeIndicator.points2 = new Vector2[] { new Vector2(tx, diagramPosition.y - 2), new Vector2(tx, diagramPosition.y + 8 + diagramPosition.height) }; timeIndicator.depth = 100; timeIndicator.Draw(); Vector2[] dp = dataPoints.points2; try { dp[((int)pc.current_time) - 1] = new Vector2(diagramPosition.x + diagramPosition.width * ((float)(pc.current_time / pc.total_time)), diagramPosition.y + Mathf.Min(1.0f, (infos[activeEntry].value / infos[activeEntry].maxValue)) * diagramPosition.height); dataPoints.points2 = dp; dataPoints.Draw(); } catch (System.IndexOutOfRangeException) { } } }
public void lineCross(float speed) { PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl> (); crossings.Insert(0, pc.current_time); crossingSpeed = (crossingSpeed * lineCrossed + speed) / (lineCrossed + 1); lineCrossed++; }
public void addPedestrianPosition(PedestrianPosition p) { positions.Add(p); PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl>(); if (p.getTime() > pc.total_time) { pc.total_time = p.getTime(); } }
public void removeLine() { point1active = false; point2active = false; PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl>(); VectorLine.Destroy(ref myLine); pc.drawLine = false; lineCrossed = 0; crossingSpeed = 0.0f; crossings = new List <decimal>(); }
public TestCasePlaybackControl() { var playback = new PlaybackControl { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(200, 100) }; playback.Beatmap.Value = new TestWorkingBeatmap(new Beatmap()); Add(playback); }
void Start() { gameObject.AddComponent <BoxCollider>(); transform.Rotate(0, 90, 0); myColor = new Color(Random.value, Random.value, Random.value); GetComponentInChildren <Renderer>().materials[1].color = myColor; addTile(); it = GameObject.Find("InfoText").GetComponent <InfoText>(); pl = GameObject.Find("PedestrianLoader").GetComponent <PedestrianLoader>(); pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl>(); r = GetComponentInChildren <Renderer>() as Renderer; gl = GameObject.Find("GeometryLoader").GetComponent <GeometryLoader>(); gp = gl.groundplane; }
private void InitializePlaybackControl() { // add playback controls control _playbackControl = new PlaybackControl(); _playbackControl.Dock = DockStyle.Fill; PlaybackControlsPanel.Controls.Add(_playbackControl); _playbackControl.PlayEvent += new UltraPlayerController.View.Events.Delegates.ActionEventHandler(OnPlaybackPlay); _playbackControl.PauseEvent += new UltraPlayerController.View.Events.Delegates.ActionEventHandler(OnPlaybackPause); _playbackControl.ResumeEvent += new UltraPlayerController.View.Events.Delegates.ActionEventHandler(OnPlaybackResume); _playbackControl.PreviousTrackEvent += new UltraPlayerController.View.Events.Delegates.ActionEventHandler(OnPlaybackPrevious); _playbackControl.NextTrackEvent += new UltraPlayerController.View.Events.Delegates.ActionEventHandler(OnPlaybackNext); _playbackControl.StopEvent += new UltraPlayerController.View.Events.Delegates.ActionEventHandler(OnPlaybackStop); _playbackControl.SeekEvent += new UltraPlayerController.View.Events.Delegates.IntegerValueActionEventHandler(OnPlaybackSeek); _playbackControl.VolumeEvent += new UltraPlayerController.View.Events.Delegates.IntegerValueActionEventHandler(OnPlaybackVolume); }
private void InitializePlaybackControl() { // add playback controls control _playbackControl = new PlaybackControl(); _playbackControl.Dock = DockStyle.Fill; PlaybackControlsPanel.Controls.Add(_playbackControl); _playbackControl.PlayEvent += new Delegates.ActionEventHandler(OnPlaybackPlay); _playbackControl.PauseEvent += new Delegates.ActionEventHandler(OnPlaybackPause); _playbackControl.ResumeEvent += new Delegates.ActionEventHandler(OnPlaybackResume); _playbackControl.StopEvent += new Delegates.ActionEventHandler(OnPlaybackStop); _playbackControl.VolumeEvent += new Delegates.IntegerValueActionEventHandler(OnPlaybackVolume); _playbackControl.SeekEvent += new Delegates.IntegerValueActionEventHandler(OnPlaybackSeek); // disable next/previous controls _playbackControl.DisableNextPrevious(); }
private void load() { var clock = new EditorClock { IsCoupled = false }; Dependencies.CacheAs(clock); var playback = new PlaybackControl { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(200, 100) }; Beatmap.Value = CreateWorkingBeatmap(new Beatmap()); Child = playback; }
private void load() { var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; Dependencies.CacheAs <IAdjustableClock>(clock); Dependencies.CacheAs <IFrameBasedClock>(clock); var playback = new PlaybackControl { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(200, 100) }; Beatmap.Value = new TestWorkingBeatmap(new Beatmap(), Clock); Child = playback; }
public void createPedestrians() { PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl> (); positions = positions.OrderBy(x => x.getID()).ThenBy(y => y.getTime()).ToList <PedestrianPosition>(); SortedList currentList = new SortedList(); population = new int[(int)pc.total_time + 1]; for (int i = 0; i < positions.Count; i++) { currentList.Add(positions[i].getTime(), positions[i]); population[(int)positions[i].getTime()]++; if ((i == (positions.Count - 1) || positions[i].getID() != positions[i + 1].getID()) && currentList.Count > 0) { GameObject p = (GameObject)Instantiate(Resources.Load("Pedestrian")); p.transform.parent = null; p.GetComponent <Pedestrian>().setPositions(currentList); p.GetComponent <Pedestrian>().setID(positions[i].getID()); pedestirans.Add(p); currentList.Clear(); } } }
// Use this for initialization void Start() { pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl> (); }
private void drawDiagram(Rect position) { diagram = true; FundamentalDiagram fd = GameObject.Find("FundamentalDiagram").GetComponent <FundamentalDiagram> (); if (fd.fundamental) { fd.removeFundamentalDiagram(); } diagramPosition = position; diagramLines = new List <VectorLine> (); PedestrianLoader pl = GameObject.Find("PedestrianLoader").GetComponent <PedestrianLoader> (); float maxSpeed = float.MinValue; float maxDensity = float.MinValue; List <Vector2> points = new List <Vector2> (); foreach (GameObject p in pl.pedestirans) { Pedestrian ped = p.GetComponent <Pedestrian>(); Renderer r = ped.GetComponentInChildren <Renderer>() as Renderer; if (r.enabled) { float speed = ped.getSpeed(); float density = ped.getDensity(); maxSpeed = Mathf.Max(speed, maxSpeed); maxDensity = Mathf.Max(density, maxDensity); points.Add(new Vector2(speed, density)); } } for (int i = 0; i < points.Count; i++) { points[i] = new Vector2(points[i].x * position.width / maxSpeed + position.x, points[i].y * position.height / maxDensity + position.y); } PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl> (); //data points VectorPoints.SetCamera(GameObject.Find("Flycam").camera); Vector2[] dp = new Vector2[(int)pc.total_time]; for (int i = 0; i < dp.Length; i++) { dp[i] = new Vector2(position.x + position.width * ((float)(i / pc.total_time)), position.y); } dataPoints = VectorLine.SetLine(Color.white, dp); dataPoints.depth = 99; dataPoints.Draw(); diagramLines.Add(dataPoints); //frame VectorLine line = VectorLine.SetLine(new Color(1f, 1f, 1f, 0.5f), new Vector2[] { new Vector2(position.x - 6, position.y - 2), new Vector2(position.x - 6, position.y + 9 + position.height), new Vector2(position.x + 5 + position.width, position.y + 9 + position.height), new Vector2(position.x + 5 + position.width, position.y - 2), new Vector2(position.x - 6, position.y - 2) }); line.depth = 2; line.Draw(); diagramLines.Add(line); int maxTime = (int)pc.total_time; //lines xLabels = new List <Label> (); float scaleFactor = 10f; int numberOfLines = (int)(maxTime * (1 / scaleFactor)); if (numberOfLines > 0) { for (int i = 1; i <= numberOfLines; i++) { float hx = position.x + i * (position.width / (maxTime * (1 / scaleFactor))); line = VectorLine.SetLine(new Color(1f, 1f, 1f, 0.5f), new Vector2[] { new Vector2(hx, position.y - 2), new Vector2(hx, position.y + 8 + position.height) }); line.depth = 1; line.Draw(); diagramLines.Add(line); xLabels.Add(new Label(new Rect(Screen.width - position.x - position.width + hx - 44, Screen.height - position.y, 28, 28), "" + i * scaleFactor)); } } float tx = ((float)(pc.current_time / pc.total_time)) * position.width + position.x; timeIndicator = VectorLine.SetLine(Color.red, new Vector2[] { new Vector2(tx, position.y - 2), new Vector2(tx, position.y + 8 + position.height) }); //background line = VectorLine.SetLine(new Color(0, 0, 0, 0.7f), new Vector2[] { new Vector2(position.x - 6, position.y + (position.height + 6) / 2), new Vector2(position.x + position.width + 6, position.y + (position.height + 6) / 2) }); line.lineWidth = position.height + 12; line.Draw(); diagramLines.Add(line); }
void OnGUI() { PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl> (); PedestrianLoader pl = GameObject.Find("PedestrianLoader").GetComponent <PedestrianLoader> (); GeometryLoader gl = GameObject.Find("GeometryLoader").GetComponent <GeometryLoader> (); Groundplane gp = gl.groundplane; infos = new List <Entry> (); string text = ""; string minutes = Mathf.Floor((float)pc.current_time / 60).ToString("00");; string seconds = ((float)pc.current_time % 60).ToString("00");; text += "current time: " + minutes + ":" + seconds + "\n"; if (pl.population != null) { infos.Add(new Entry("population", "", pl.population[(int)pc.current_time], 0, true, pl.pedestirans.Count)); } if (gp.point1active && gp.point2active) { infos.Add(new Entry("line length", "m", Vector3.Distance(gp.point1, gp.point2), 2, false, 0)); infos.Add(new Entry("line crossings", "", gp.lineCrossed, 0, true, pl.pedestirans.Count)); infos.Add(new Entry("line flow", "/s", gp.crossings.Count, 0, true, 10.0f)); infos.Add(new Entry("avg. crossing speed", "m/s", gp.crossingSpeed, 2, true, 3.0f)); infos.Add(new Entry("current flow", "/ms", gp.crossings.Count / Vector3.Distance(gp.point1, gp.point2), 2, true, 3.0f)); } if (pc.tileColoringMode == TileColoringMode.TileColoringSpeed) { infos.Add(new Entry("current speed", "m/s", currentValue(currentSpeed), 2, true, 3.0f)); infos.Add(new Entry("min. speed", "m/s", minSpeed, 2, false, 3.0f)); infos.Add(new Entry("max. speed", "m/s", maxSpeed, 2, false, 3.0f)); } else { maxSpeed = float.MinValue; minSpeed = float.MaxValue; } if (pc.tileColoringMode == TileColoringMode.TileColoringDensity) { infos.Add(new Entry("current density", "/m²", currentValue(currentDensity), 2, true, 3.0f)); infos.Add(new Entry("min. density", "/m²", minDenstiy, 2, false, 5.0f)); infos.Add(new Entry("max. density", "/m²", maxDensity, 2, false, 5.0f)); } else { maxDensity = float.MinValue; minDenstiy = float.MaxValue; crossings = 0; } for (int i = 0; i < infos.Count; i++) { Entry e = infos[i]; text += infos[i].name + ": " + System.Math.Round(e.value, e.decimals) + e.unit + "\n"; if (e.graphable) { if (GUI.Toggle(new Rect(Screen.width * (transform.position.x) - 20, Screen.height * (1 - transform.position.y) - (15 * (infos.Count - i) + 17), 100, 15), i == activeEntry, "") && i != activeEntry) { removeDiagram(); activeEntry = i; Rect position = new Rect(30, 30, 400, 300); position.x = Screen.width - position.x - position.width; drawDiagram(position); } } } guiText.text = text; if (diagram) { GUI.Label(new Rect(diagramPosition.x, Screen.height - diagramPosition.y - diagramPosition.height - 30, diagramPosition.width, 30), infos[activeEntry].name); GUI.Label(new Rect(diagramPosition.x - 15, Screen.height - diagramPosition.y, 30, 30), "[s]"); GUI.Label(new Rect(diagramPosition.x - 35, Screen.height - diagramPosition.y - diagramPosition.height - 10, 30, 30), System.Math.Round(infos[activeEntry].maxValue, infos[activeEntry].decimals) + ""); if (infos[activeEntry].unit != "") { GUI.Label(new Rect(diagramPosition.x - 35, Screen.height - diagramPosition.y - diagramPosition.height - 30, 30, 30), "[" + infos[activeEntry].unit + "]"); } } }
public Editor() { EditorMenuBar menuBar; TimeInfoContainer timeInfo; SummaryTimeline timeline; PlaybackControl playback; Children = new[] { new Container { Name = "Screen container", RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = 40, Bottom = 60 }, Child = screenContainer = new Container { RelativeSizeAxes = Axes.Both, Masking = true } }, new Container { Name = "Top bar", RelativeSizeAxes = Axes.X, Height = 40, Child = menuBar = new EditorMenuBar { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, RelativeSizeAxes = Axes.Both, Items = new[] { new MenuItem("File") { Items = new[] { new EditorMenuItem("Export", MenuItemType.Standard, exportBeatmap), new EditorMenuItemSpacer(), new EditorMenuItem("Exit", MenuItemType.Standard, Exit) } } } } }, new Container { Name = "Bottom bar", Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, Height = 60, Children = new Drawable[] { bottomBackground = new Box { RelativeSizeAxes = Axes.Both }, new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Vertical = 5, Horizontal = 10 }, Child = new GridContainer { RelativeSizeAxes = Axes.Both, ColumnDimensions = new[] { new Dimension(GridSizeMode.Absolute, 220), new Dimension(), new Dimension(GridSizeMode.Absolute, 220) }, Content = new[] { new Drawable[] { new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Right = 10 }, Child = timeInfo = new TimeInfoContainer { RelativeSizeAxes = Axes.Both }, }, timeline = new SummaryTimeline { RelativeSizeAxes = Axes.Both, }, new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = 10 }, Child = playback = new PlaybackControl { RelativeSizeAxes = Axes.Both }, } }, } }, } } }, }; timeInfo.Beatmap.BindTo(Beatmap); timeline.Beatmap.BindTo(Beatmap); playback.Beatmap.BindTo(Beatmap); menuBar.Mode.ValueChanged += onModeChanged; }
private void load(OsuColour colours) { // TODO: should probably be done at a RulesetContainer level to share logic with Player. var sourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock(); clock = new EditorClock(Beatmap, beatDivisor) { IsCoupled = false }; clock.ChangeSource(sourceClock); dependencies.CacheAs <IFrameBasedClock>(clock); dependencies.CacheAs <IAdjustableClock>(clock); dependencies.Cache(beatDivisor); EditorMenuBar menuBar; TimeInfoContainer timeInfo; SummaryTimeline timeline; PlaybackControl playback; Children = new[] { new Container { Name = "Screen container", RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = 40, Bottom = 60 }, Child = screenContainer = new Container { RelativeSizeAxes = Axes.Both, Masking = true } }, new Container { Name = "Top bar", RelativeSizeAxes = Axes.X, Height = 40, Child = menuBar = new EditorMenuBar { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, RelativeSizeAxes = Axes.Both, Items = new[] { new MenuItem("File") { Items = new[] { new EditorMenuItem("Export", MenuItemType.Standard, exportBeatmap), new EditorMenuItemSpacer(), new EditorMenuItem("Exit", MenuItemType.Standard, Exit) } } } } }, new Container { Name = "Bottom bar", Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, Height = 60, Children = new Drawable[] { bottomBackground = new Box { RelativeSizeAxes = Axes.Both }, new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Vertical = 5, Horizontal = 10 }, Child = new GridContainer { RelativeSizeAxes = Axes.Both, ColumnDimensions = new[] { new Dimension(GridSizeMode.Absolute, 220), new Dimension(), new Dimension(GridSizeMode.Absolute, 220) }, Content = new[] { new Drawable[] { new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Right = 10 }, Child = timeInfo = new TimeInfoContainer { RelativeSizeAxes = Axes.Both }, }, timeline = new SummaryTimeline { RelativeSizeAxes = Axes.Both, }, new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = 10 }, Child = playback = new PlaybackControl { RelativeSizeAxes = Axes.Both }, } }, } }, } } }, }; timeInfo.Beatmap.BindTo(Beatmap); timeline.Beatmap.BindTo(Beatmap); playback.Beatmap.BindTo(Beatmap); menuBar.Mode.ValueChanged += onModeChanged; bottomBackground.Colour = colours.Gray2; }