private void Start() { _grid = FindObjectOfType <GridSystem>(); _menuManager = FindObjectOfType <MenuManager>(); _menuManager.OnStartGame += StartGame; _menuManager.OnRestartGame += RestartGame; _menuManager.OnCoinEvent += AddLife; _iniPos = transform.position; _grid.gameObject.GetComponent <CoinGenerator>().SetTarget(transform); _grid.gameObject.GetComponent <ObstaclesGenerator>().SetTarget(transform); if (_grid.Grid == null) { _grid.GenInfHexGrid(); var grid = (InfiniteHexGrid)_grid.Grid; GetY = grid.YGraph; } var ray = new Ray(transform.position, Vector3.down); _gr = _grid.Grid.GetPos(ray); SetPos(); transform.position = _position; _grid.GenMesh(_grid.Grid.SelectRegion(_gr, ViewArea, false)); _metronome = FindObjectOfType <Metronome>(); _metronome.Beat += Beat; }
/// <summary> /// Deletes a grid from its database. /// </summary> /// <param name="grid">The grid to be copied.</param> /// <param name="force"> /// If false, the grid is only deleted if it is not in use. /// If true, the deletion will be forced. /// </param> public static void Delete(this IGridInfo grid, bool force = false) { // Only ask for confirmation of unsafe deletion. if (force == false) { Console.WriteLine("Grid: " + grid.ToString()); Console.Write("The grid will be removed, even if it is in use by a session. Do you wish to proceed? [y/n]: "); string line = Console.ReadLine(); if (line.ToLower().Equals("y")) { grid.Database.Controller.DeleteGrid(grid, false); Console.WriteLine("Grid " + grid.ID.ToString() + " deleted."); } else { Console.WriteLine("Grid delete canceled."); } } else { // Don't need to ask for confirmation of safe delete. bool outcome = grid.Database.Controller.DeleteGrid(grid, true); if (outcome == true) { Console.WriteLine("Grid " + grid.ID.ToString() + " deleted."); } else { Console.WriteLine("Grid was not deleted. Probably still in use by a session."); } } }
public void CreateFromGrid_GeneratesTheCorrectGridSquareInfos() { //Arrange var grid = ArrangeGrid(); //Act IGridInfo gridInfo = _factory.CreateFromGrid(grid); //Assert Assert.That(gridInfo, Is.Not.Null, "No instance of a class that implements IGridInfo is returned."); for (var i = 0; i < gridInfo.Squares.Length; i++) { GridSquareInfo[] squareInfoRow = gridInfo.Squares[i]; for (var j = 0; j < squareInfoRow.Length; j++) { GridSquareInfo squareInfo = squareInfoRow[j]; IGridSquare matchingSquare = grid.Squares[i, j]; Assert.That(squareInfo.NumberOfBombs, Is.EqualTo(matchingSquare.NumberOfBombs), $"Number of bombs for square info at [{i}][{j}] is not correct."); Assert.That(squareInfo.Status, Is.EqualTo(matchingSquare.Status), $"Status for square info at [{i}][{j}] is not correct."); } } }
public override List <IGridInfo> SelectRegion(IGridInfo gr, int size, bool removeCenter) { var lst = new List <IGridInfo>() { gr }; for (int j = 0, m = size; j < m; j++) { for (int k = 0, o = lst.Count; k < o; k++) { for (int i = 0, n = _dirs.Length / 2; i < n; i++) { var tmp = GetPos(lst[k].x + _dirs[i + (lst[k].y % 2) * n].x, lst[k].y + _dirs[i + (lst[k].y % 2) * n].y); if (tmp != null && !tmp.isBlocked && !lst.Contains(tmp)) { lst.Add(tmp); } } } } if (removeCenter) { lst.Remove(gr); } return(lst); }
/// <summary> /// loads the grid identified by <paramref name="uid"/> from the /// given <paramref name="database"/> /// </summary> /// <param name="uid">The unique identifier of the grid.</param> /// <param name="database"> /// The database that is associated with the grid. /// </param> /// <returns> /// The loaded grid /// </returns> public IGrid LoadGrid(Guid uid, IDatabaseInfo database) { IGridInfo gridInfo = LoadGridInfo(uid, database); IGrid grid = LoadGridData((IGrid)gridInfo); return(grid); }
public override List <IGridInfo> SelectRegion(IGridInfo gr, int size, bool removeCenter) { var lst = new List <IGridInfo>() { gr }; for (int j = 0, m = size; j < m; j++) { for (int k = 0, o = lst.Count; k < o; k++) { for (int i = 0, n = _dirs.Length / 2; i < n; i++) { var posX = lst[k].x + _dirs[i + (Math.Abs(lst[k].y) % 2) * n].x; var posY = lst[k].y + _dirs[i + (Math.Abs(lst[k].y) % 2) * n].y; var tmp = GetPos( posX, posY ); if (tmp != null && !tmp.isBlocked && !lst.Exists(x => x.x == tmp.x && x.y == tmp.y)) { lst.Add(tmp); } } } } if (removeCenter) { lst.Remove(gr); } return(lst); }
private void GetPos(bool over = false) { if (_eventSys.IsPointerOverGameObject()) { return; } var mouse = Input.mousePosition; _lastPos = mouse; mouse.z = _cam.nearClipPlane; var pos = _grid.GetMousePos(mouse); if (pos == _lastGridPos && over) { return; } _lastGridPos = pos; if (_lastGridPos != null) { if (GridPop != null) { GridPop(_lastGridPos, over); } Debug.LogError("Turn Manager, needs to receive this response"); // _turnManager.GridSetInput(_lastGridPos, over); } }
/// <summary> /// See <see cref="IGrid.Equals(IGridInfo)"/> /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(IGridInfo other) { if (other == null) { return(false); } return(this.ID.Equals(other.ID)); }
/// <summary> /// Retrieves the directory where the plots for the selected /// <paramref name="grid"/> are stored. /// </summary> /// <param name="grid"> /// The selected grid. /// </param> /// <remarks> /// Should work on any System. /// </remarks> public static string GetExportDirectory(IGridInfo grid) { string path = Path.Combine( Utils.GetExportOutputPath(), StandardFsDriver.GridsDir, grid.ID.ToString()); return(path); }
/// <summary> /// Experimental /// </summary> /// <param name="grid"></param> public static void Save(this IGridInfo grid) { if (grid is GridCommons) { GridCommons realGrid = (GridCommons)grid; grid.Database.Controller.DBDriver.SaveGrid(realGrid); } else { throw new NotImplementedException(); } }
public void ShowArrow(IGridInfo grid, Vector3 dir) { HideArrows(); _arrows[0].transform.position = grid.worldPos + dir; _arrows[0].transform.LookAt(grid.worldPos + dir * 2, Vector3.up); _arrows[0].SetActive(true); }
/// <summary> /// Retrieves the write time of a physical file associated with an /// IGridInfo object. /// </summary> /// <param name="grid">The grid in question.</param> /// <returns>The last time the file has been written to disk.</returns> public static DateTime GetGridFileWriteTime(IGridInfo grid) { string gridFolderPath = Path.Combine( grid.Database.Path, StandardFsDriver.GridsDir); string gridFileName = grid.ID.ToString() + ".grid"; string gridFilePath = Path.Combine(gridFolderPath, gridFileName); return(File.GetLastWriteTime(gridFilePath)); }
public ActionResult Index(IGridInfo grid) { var index = new Index { CallbackUrl = grid.Url, PagingInfo = grid.PagingInfo }; return(Display(index)); }
public void DrawPath(IGridInfo start, IGridInfo end) { var path = GetPath(start, end); _pathDrawer.positionCount = path.Count; for (int i = 0; i < path.Count; i++) { _pathDrawer.SetPosition(i, path[i].worldPos + Vector3.up * 0.5f); } }
private void EndGame() { _menuManager.EndGame(); var ray = new Ray(_iniPos, Vector3.down); _gr = _grid.Grid.GetPos(ray); SetPos(); transform.position = _iniPos; }
/// <summary> /// Determines the mesh size of a given <paramref name="gridInfo"/> /// based on <see cref="GridData.CellData.h_maxGlobal"/>. /// </summary> /// <param name="gridInfo">A grid</param> /// <returns> /// A (heuristic) measure for the mesh size of /// <paramref name="gridInfo"/>. /// </returns> public static double GetMeshSize(this IGridInfo gridInfo) { if (gridInfo is GridProxy) { gridInfo = gridInfo.Cast<GridProxy>().RealGrid; } GridCommons grid = gridInfo as GridCommons; if (!(grid is GridCommons)) { throw new ArgumentException("Only works for grids of type 'GridCommons'"); } return new GridData(grid).Cells.h_maxGlobal; }
/// <summary> /// Creates a plotting instruction with default configuration options. /// </summary> /// <param name="grid"> /// The grid to be plotted. /// </param> public GridExportInstruction(IGridInfo grid) { this.Grid = grid; // because hacks work. (TODO) IFileSystemDriver fsdrv = new StandardFsDriver(grid.Database.Path); dbDriver = new DatabaseDriver(fsdrv); GridCommons gridComm = dbDriver.LoadGrid(grid.ID, grid.Database); GridDat = new GridData(gridComm); }
public void FinishedStartup() { if (!m_enabled) { return; } IGridInfo gridInfo = m_registry.RequestModuleInterface <IGridInfo> (); if (gridInfo != null) { gridInfo.AgentAppearanceURI = ServiceURI; } }
public void FinishedStartup() { _server = _registry.RequestModuleInterface <ISimulationBase>().GetHttpServer(0); if (_server != null) { _server.AddHTTPHandler("GridTexture", OnHTTPGetTextureImage); _registry.RegisterModuleInterface <IWebHttpTextureService>(this); } IGridInfo gridInfo = _registry.RequestModuleInterface <IGridInfo>(); _gridNick = gridInfo != null ? gridInfo.GridName : "No Grid Name Available, please set this"; }
public void FinishedStartup() { _server = _registry.RequestModuleInterface <ISimulationBase> ().GetHttpServer(0); if (_server != null) { _server.AddStreamHandler(new GenericStreamHandler("GET", "/index.php?method=GridTexture", OnHTTPGetTextureImage)); _server.AddStreamHandler(new GenericStreamHandler("GET", "/index.php?method=AvatarTexture", OnHTTPGetAvatarImage)); _registry.RegisterModuleInterface <IWebHttpTextureService> (this); } IGridInfo gridInfo = _registry.RequestModuleInterface <IGridInfo> (); _gridNick = gridInfo != null ? gridInfo.GridName : "No Grid Name Available, please set this"; }
private void RestartGame() { Debug.Log(_iniPos); transform.position = _iniPos; var ray = new Ray(transform.position, Vector3.down); _gr = _grid.Grid.GetPos(ray); SetPos(); _grid.GenMesh(_grid.Grid.SelectRegion(_gr, ViewArea, false)); StartGame(); }
public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, Framework.Services.UserInfo pinfo, GridRegion destination, List <InventoryFolderBase> invSkel, FriendInfo[] friendsList, IInventoryService invService, ILibraryService libService, string where, string startlocation, Vector3 position, Vector3 lookAt, List <InventoryItemBase> gestures, GridRegion home, IPEndPoint clientIP, string AdultMax, string AdultRating, ArrayList eventValues, ArrayList eventNotificationValues, ArrayList classifiedValues, string seedCap, IConfigSource source, string DisplayName, string cofversion, IGridInfo info) : this() { m_source = source; m_gridInfo = info; SeedCapability = seedCap; FillOutInventoryData(invSkel, libService, invService); FillOutActiveGestures(gestures); CircuitCode = (int)aCircuit.CircuitCode; Lastname = account.LastName; Firstname = account.FirstName; this.DisplayName = DisplayName; AgentID = account.PrincipalID; SessionID = aCircuit.SessionID; SecureSessionID = aCircuit.SecureSessionID; BuddList = ConvertFriendListItem(friendsList); StartLocation = where; AgentAccessMax = AdultMax; AgentAccess = AdultRating; AgentRegionAccess = AgentRegionAccess; AOTransition = AOTransition; AgentFlag = AgentFlag; eventCategories = eventValues; eventNotifications = eventNotificationValues; classifiedCategories = classifiedValues; COFVersion = cofversion; FillOutHomeData(pinfo, home); LookAt = string.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z); FillOutRegionData(aCircuit, destination); login = "******"; ErrorMessage = ""; ErrorReason = LoginResponseEnum.OK; }
public void FinishedStartup() { if (_enabled) { IGridInfo gridInfo = Registry.RequestModuleInterface <IGridInfo>(); GridName = gridInfo.GridName; if (PagesMigrator.RequiresInitialUpdate()) { PagesMigrator.ResetToDefaults(); } if (SettingsMigrator.RequiresInitialUpdate()) { SettingsMigrator.ResetToDefaults(); } } }
/// <summary> /// Plotting of an grid with dummy data, /// Driver interface for the <see cref="BoSSS.Solution.Tecplot.Tecplot"/> functionality. /// </summary> static public void PlotGrid(string filename, IGridInfo grdInfo) { if (grdInfo is IGridData gdata) { PlotGrid(filename, gdata); } else { Console.WriteLine("Initializing gird..."); var dbi = grdInfo.Database; var drv = dbi.Controller.DBDriver; var grd = drv.LoadGrid(grdInfo.ID, dbi); var gdat = grd.iGridData; Console.WriteLine("done."); PlotGrid(filename, gdat); } }
/// <summary> /// Retrieves all sessions using a particular <paramref name="grid"/>. /// </summary> /// <param name="grid">The grid in question.</param> /// <returns>A collection of sessions using the grid.</returns> public IEnumerable <ISessionInfo> GetSessionInfos(IGridInfo grid) { IList <ISessionInfo> gridSessions = new List <ISessionInfo>(); // Sweep all sessions to find the sessions using the grid foreach (ISessionInfo session in Sessions) { foreach (IGridInfo sessionGrid in GetGridInfos(session)) { if (grid.ID.Equals(sessionGrid.ID)) { gridSessions.Add(session); } } } return(gridSessions); }
public void CreateFromGrid_ConvertsTheSquareMatrixOfTheGridToAJaggedArray() { //Arrange var grid = ArrangeGrid(); //Act IGridInfo gridInfo = _factory.CreateFromGrid(grid); //Assert Assert.That(gridInfo, Is.Not.Null, "No instance of a class that implements IGridInfo is returned."); Assert.That(gridInfo.Size, Is.EqualTo(grid.Size), "The Size should be the same as the Size of the grid."); Assert.That(gridInfo.Squares.Length, Is.EqualTo(grid.Size), "The Squares should have a length equal to the size of the grid."); foreach (var squareInfoRow in gridInfo.Squares) { Assert.That(squareInfoRow.Length, Is.EqualTo(grid.Size), "Each row of squares should have a length equal to the size of the grid."); } }
public void FinishedStartup() { if (!m_enabled) { return; } IGridServerInfoService serverInfo = m_registry.RequestModuleInterface <IGridServerInfoService>(); if (serverInfo != null) { serverInfo.AddURI("MapAPIService", MapServiceAPIURL); } IGridInfo gridInfo = m_registry.RequestModuleInterface <IGridInfo>(); if (gridInfo != null) { gridInfo.GridMapTileURI = MapServiceURL; } }
private void DrawGrid(IGridInfo gr, Color color, CompareFunction ztest = CompareFunction.Always) { var cl = Handles.color; Handles.color = color; var z = Handles.zTest; Handles.zTest = ztest; var sqr = gr.GetEdges(); for (int i = 0, n = sqr.Length; i < n; i++) { Handles.DrawLine(sqr[i], sqr[(i + 1) % n]); } Handles.color = cl; Handles.zTest = z; }
public void TestSafelyDeleteGrid() { databaseWithFiles.Controller.CopySession(databaseWithFiles.Controller.Sessions.First(), emptyDatabase); IGridInfo grd = emptyDatabase.Controller.Sessions.First().GetGrids().First(); Assert.IsFalse( emptyDatabase.Controller.DeleteGrid(grd), // Delete operation fails: no files will be changed "Deleted grid in use by at least one session."); emptyDatabase.Controller.DeleteSession(emptyDatabase.Controller.Sessions.First()); // after the session is deleted, the grid should be successfully removed Assert.IsTrue( emptyDatabase.Controller.DeleteGrid(grd), "Removal of unused grid unsuccessful."); Assert.IsTrue( CountAllFiles(emptyDatabase.Path) == 0, "Files remain in a database that should be empty"); }
/// <summary> /// Grids info. /// </summary> /// <returns>The info.</returns> /// <param name="args">Arguments.</param> OSDMap GridInfo(string [] args) { var response = new OSDMap(); var gridInfo = new OSDMap(); //Add our grid service URIs IGridInfo gridInfoService = m_registry.RequestModuleInterface <IGridInfo> (); if (gridInfoService != null) { var localInfo = gridInfoService.GetGridInfoHashtable(); foreach (string key in localInfo.Keys) { gridInfo.Add(key, (string)localInfo [key]); } } response ["GridInfo"] = gridInfo; return(response); }
public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, Framework.Services.UserInfo pinfo, GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, IInventoryService invService, ILibraryService libService, string where, string startlocation, Vector3 position, Vector3 lookAt, List<InventoryItemBase> gestures, GridRegion home, IPEndPoint clientIP, string AdultMax, string AdultRating, ArrayList eventValues, ArrayList eventNotificationValues, ArrayList classifiedValues, string seedCap, IConfigSource source, string DisplayName, string cofversion, IGridInfo info) : this() { m_source = source; m_gridInfo = info; SeedCapability = seedCap; FillOutInventoryData(invSkel, libService, invService); FillOutActiveGestures(gestures); CircuitCode = (int) aCircuit.CircuitCode; Lastname = account.LastName; Firstname = account.FirstName; this.DisplayName = DisplayName; AgentID = account.PrincipalID; SessionID = aCircuit.SessionID; SecureSessionID = aCircuit.SecureSessionID; BuddList = ConvertFriendListItem(friendsList); StartLocation = where; AgentAccessMax = AdultMax; AgentAccess = AdultRating; eventCategories = eventValues; eventNotifications = eventNotificationValues; classifiedCategories = classifiedValues; COFVersion = cofversion; FillOutHomeData(pinfo, home); LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z); FillOutRegionData(aCircuit, destination); login = "******"; ErrorMessage = ""; ErrorReason = LoginResponseEnum.OK; }