// Serialization public void RegisterGrid(IMapGrid grid) { if (GridIDMap.ContainsKey(grid.Index)) { throw new InvalidOperationException(); } Grids.Add(grid); GridIDMap.Add(grid.Index, GridIDMap.Count); }
public void ajax_rsp_assign_grid(String GridName, Object GridObj) { try { Grids.Add(((IGxJSONAble)GridObj).GetJSONObject()); } catch (Exception ex) { GXLogging.Error(log, "ajax_rsp_assign_grid error", ex); } }
public void UpdateAABB() { var startPos = Grids.First().PositionComp.GetPosition(); var box = new BoundingBoxD(startPos, startPos); foreach (var aabb in Grids.Select(g => g.PositionComp.WorldAABB)) { box.Include(aabb); } WorldAABB = box; }
private void CreateObserverTab() { Grids.Add("Observer", Resources["LoadObserverTemplate"] as Grid); Border border = Grids["Observer"].Children[0] as Border; if (!(border?.Child is Grid innerGrid)) { return; } ((Grid)innerGrid.Children[1]).Children.Add(_manager.GetGameLoadGrid()); ((Button)innerGrid.Children[3]).Click += (sender, arg) => { GameScroll.Content = Grids["Menu"]; }; }
private void CreateSaveMapTab() { Grids.Add("SaveMap", Resources["SaveMapTemplate"] as Grid); Border border = Grids["SaveMap"].Children[0] as Border; if (!(border?.Child is Grid innerGrid)) { return; } ((Grid)innerGrid.Children[1]).Children.Add(_manager.GetMapSaveGrid()); ((Button)innerGrid.Children[3]).Click += (sender, arg) => GameScroll.Content = Grids["Admin"]; }
private int[,] RotatePattern(int[,] pattern, int angle) { (int width, int depth) = Grids.Dim(pattern); int[,] rotatedPattern = Grids.Blank(pattern); foreach ((int countW, int countD) in Itr.Iteration(width, depth)) { rotatedPattern[countD, width - countW - 1] = pattern[countW, countD]; } return(rotatedPattern); }
public void LoadGrid(int ID, bool LoadNearPlayer) { if (!PerformMainChecks(false)) { return; } if (!PlayersHanger.LoadGrid(ID, out IEnumerable <MyObjectBuilder_CubeGrid> Grids, out GridStamp Stamp)) { Log.Error($"Loading grid {ID} failed for {IdentityID}!"); Chat.Respond("Loading grid failed! Report this to staff and check logs for more info!"); return; } if (!PlayersHanger.CheckLimits(Stamp, Grids)) { return; } if (!CheckEnemyDistance(Config.LoadType, Stamp.GridSavePosition)) { return; } if (!RequireLoadCurrency(Stamp)) { return; } PluginDependencies.BackupGrid(Grids.ToList(), IdentityID); Vector3D SpawnPos = DetermineSpawnPosition(Stamp.GridSavePosition, PlayerPosition, out bool KeepOriginalPosition, LoadNearPlayer); if (!CheckDistanceToLoadPoint(SpawnPos)) { return; } ParallelSpawner Spawner = new ParallelSpawner(Grids, Chat, !KeepOriginalPosition, SpawnedGridsSuccessful); Log.Info("Attempting Grid Spawning @" + SpawnPos.ToString()); if (Spawner.Start(KeepOriginalPosition, SpawnPos)) { Chat?.Respond("Spawning Complete!"); PlayersHanger.RemoveGridStamp(Stamp); } else { Chat?.Respond("An error occured while spawning the grid!"); } }
public IEnumerable <Cell> BoardCellsWithValues() { for (int i = 0; i < Grids.GetLength(0); i++) { for (int j = 0; j < Grids.GetLength(1); j++) { if (CellBoard[i, j] != null) { yield return(CellBoard[i, j]); } } } }
private List <LogicalPosition> GetNeighbors(LogicalPosition from, HashSet <LogicalPosition> visited) { List <LogicalPosition> NeighBors = new List <LogicalPosition>(); LogicalPosition[] sides = { new LogicalPosition(from.X - 1, from.Y), new LogicalPosition(from.X, from.Y - 1), new LogicalPosition(from.X + 1, from.Y), new LogicalPosition(from.X, from.Y + 1) }; foreach (LogicalPosition position in sides) { if (Grids.ContainsKey(position) && !visited.Contains(position)) { NeighBors.Add(position); } } return(NeighBors); }
internal void PositionClosed(TradeResult tradeResult) { if (tradeResult.IsSuccessful) { Grids.Where(x => x.Status == TradeStatus.Active && x.RobotPosition.Id == tradeResult.Position.Id).All(x => { x.Reset(); return(true); }); if (Grids.All(x => x.Status == TradeStatus.Inactive)) { Reset(); } } }
internal void PendingOrderCancelled(TradeResult tradeResult) { if (tradeResult.IsSuccessful) { Grids.Where(x => x.Status == TradeStatus.Pending && x.RobotPendingOrder.Id == tradeResult.PendingOrder.Id).All(x => { x.Reset(); return(true); }); if (Grids.All(x => x.Status == TradeStatus.Inactive)) { Reset(); } } }
public void Render(int centerTileX, int centerTileY) { if (IsTiled) { var wmoProgram = ShaderProgramCache.Instance.Get("wmo"); var view = Matrix4.Mult(Game.Camera.View, Game.Camera.Projection); var cameraDirection = Game.Camera.Forward; wmoProgram.Use(); wmoProgram.UniformMatrix4("projection_view", false, ref view); wmoProgram.UniformVector3("camera_direction", ref cameraDirection); const int MAX_CHUNK_DISTANCE = 1; /// Debugging lock (Grids) { foreach (var grid in Grids) { if (grid.Value != null && Math.Abs(grid.Value.X - centerTileX) > MAX_CHUNK_DISTANCE && Math.Abs(grid.Value.Y - centerTileY) > MAX_CHUNK_DISTANCE) { grid.Value.Unload(); } } for (var i = centerTileY - MAX_CHUNK_DISTANCE; i <= centerTileY + MAX_CHUNK_DISTANCE; ++i) { for (var j = centerTileX - MAX_CHUNK_DISTANCE; j <= centerTileX + MAX_CHUNK_DISTANCE; ++j) { if (!Grids.ContainsKey(PackTile(j, i))) { LoadTile(j, i); } } } foreach (var mapGrid in Grids.Values) { if (mapGrid == null || !(Math.Abs(centerTileX - mapGrid.X) <= MAX_CHUNK_DISTANCE && Math.Abs(centerTileY - mapGrid.Y) <= MAX_CHUNK_DISTANCE)) { continue; } mapGrid.Render(); } } } //else //GlobalModel.Render(); }
internal void InitializeGrids() { double LastUpperEstimatedPricing = 0; double LastUnderEstimatedPricing = 0; if (c == null) { return; } double lotSize = (double)c.GridParameters.LotSize; OriginalAsk = robot.Symbol.Ask; OriginalBid = robot.Symbol.Bid; Grids.Clear(); ActiveSince = robot.Time; UpperGroundStartingPoint = robot.ShiftPrice(OriginalAsk, (int)c.GridParameters.Intervals.Starting); UnderGroundStartingPoint = robot.ShiftPrice(OriginalBid, -Math.Abs((int)c.GridParameters.Intervals.Starting)); GridSize = Math.Abs((int)c.GridParameters.Size); for (int i = 0; i < GridSize; i++) { LastUpperEstimatedPricing = i == 0 ? UpperGroundStartingPoint : robot.ShiftPrice(LastUpperEstimatedPricing, Math.Abs((int)c.GridParameters.Intervals.Grid)); //robot.Print("EstimatedPricing-Upper: {0} at {1}", LastUpperEstimatedPricing.ToString(), i.ToString()); var UpperGrid = new Grid() { Side = GridSide.UpperGround, OrderType = c.GridParameters.OrderType, LotSize = lotSize, EstimatedPricing = LastUpperEstimatedPricing, SideIndex = i }; Grids.Add(UpperGrid); LastUnderEstimatedPricing = i == 0 ? UnderGroundStartingPoint : robot.ShiftPrice(LastUnderEstimatedPricing, -Math.Abs((int)c.GridParameters.Intervals.Grid)); //robot.Print("EstimatedPricing-Under: {0} at {1}", LastUnderEstimatedPricing.ToString(), i.ToString()); var UnderGrid = new Grid() { Side = GridSide.UnderGround, OrderType = c.GridParameters.OrderType, LotSize = lotSize, EstimatedPricing = LastUnderEstimatedPricing, SideIndex = i }; Grids.Add(UnderGrid); } }
// Start is called before the first frame update void Start() { if (tamplates == null) { tamplates = this; } Grids newGrid = new Grids(); CurrentGrid = new GridMapping(); newGrid.grid = CurrentGrid; GridList.Add(newGrid); Debug.Log(Tamplates.tamplates.CurrentGrid.storage.Count); }
void GameEnd() { isGameEnd = true; Tile[] allTile = FindObjectsOfType <Tile>(); Grids grid = FindObjectOfType <Grids>(); finalScoreText.text = "Final score : " + playerScore.ToString(); grid.gameObject.SetActive(false); foreach (Tile tile in allTile) { tile.gameObject.SetActive(false); } GameEndPanel.SetActive(true); }
internal void CloseCycle() { //close all positions Grids.Where(x => x.Status == TradeStatus.Active).OrderBy(x => x.RobotPosition.NetProfit).All(x => { robot.ClosePositionAsync(x.RobotPosition, PositionClosed); return(true); }); //close all pending orders Grids.Where(x => x.Status == TradeStatus.Pending).All(x => { robot.CancelPendingOrderAsync(x.RobotPendingOrder, PendingOrderCancelled); return(true); }); }
private void CreateSaveGameTab() { Grids.Add("SaveGame", Resources["SaveGameTemplate"] as Grid); Border border = Grids["SaveGame"].Children[0] as Border; if (!(border?.Child is Grid innerGrid)) { return; } ((Grid)innerGrid.Children[1]).Children.Add(_manager.GetGameSaveGrid()); ((Button)innerGrid.Children[3]).Click += (sender, arg) => { GameScroll.Content = Grids["GameMap"]; ChangeDisplayMode(true); }; }
// Use this for initialization void Awake() { ins = this; Transform = transform; rect = new Rectangle(0, 0, Width, Height); bornRect = new Rectangle(1, 7, Width - 1, Height - 7); grids = new Grids(Width, Height); grounds = new SpriteRenderer[Height, Width]; trackerList = new List <Tracker>(); trackerHash = new Dictionary <string, Tracker>(); joystick.OnTouchMove += OnJoystickMove; // joystick.enabled = false; }
private void AddGrids(Side side) { int countTo = 0, x = 0, y = 0, xI = 0, yI = 0; switch (side) { case Side.Down: countTo = Math.Abs(TopLeft.X) + BottomRight.X + 1; x = TopLeft.X; y = BottomRight.Y + 1; xI = 1; BottomRight = new LogicalPosition(BottomRight.X, BottomRight.Y + 1); break; case Side.Left: countTo = Math.Abs(TopLeft.Y) + BottomRight.Y + 1; x = TopLeft.X - 1; y = TopLeft.Y; yI = 1; TopLeft = new LogicalPosition(TopLeft.X - 1, TopLeft.Y); break; case Side.Right: countTo = Math.Abs(TopLeft.Y) + BottomRight.Y + 1; x = BottomRight.X + 1; y = TopLeft.Y; yI = 1; BottomRight = new LogicalPosition(BottomRight.X + 1, BottomRight.Y); break; case Side.Up: countTo = Math.Abs(TopLeft.X) + BottomRight.X + 1; x = TopLeft.X; y = TopLeft.Y - 1; xI = 1; TopLeft = new LogicalPosition(TopLeft.X, TopLeft.Y - 1); break; default: throw new ArgumentOutOfRangeException(nameof(side)); } for (int count = 0; count < countTo; count++, x += xI, y += yI) { LogicalPosition position = new LogicalPosition(x, y); Grids.Add(position, new Grid(position)); } }
static public void delConnectionModel(int Id) { int i = 0; if (Grids.Count == 0) { return; } do { if (Grids[i].Id == Id) { Grids.Remove(Grids[i]); continue; } }while (++i < Grids.Count); }
// To user friedly model, like put 'Male' ou 'Femalle' otherwise 1 or 2 // And another expansions static public void addConnectionModel(int Id, List <GridAdminViewer_Result> Grid) { List <GridViewer_Result> l = new List <GridViewer_Result>(); if (Grid.Count > 0) { var gender = new _ddlGenderId(); var city = new _ddlCityId(); var region = new _ddlRegionId(); var purchase = new _ddlLastPurchase(); var classification = new _ddlClassificationId(); var user = new _ddlUserId(); foreach (var g in Grid) { GridViewer_Result g0 = new GridViewer_Result(); g0.Id = g.Id; g0.Name = g.Name; g0.Phone = g.Phone; g0.GenderId = g.GenderId; g0.CityId = g.CityId; g0.RegionId = g.RegionId; g0.LastPurchase = g.LastPurchase; g0.ClassificationId = g.ClassificationId; g0.UserId = g.UserId; l.Add(g0); gender.add_ddlGenderId(g.GenderId); city.add_ddlCityId(g.CityId.GetValueOrDefault()); region.add_ddlRegionId(g.RegionId.GetValueOrDefault()); purchase.add_ddlLastPurchase(g.LastPurchase.GetValueOrDefault()); classification.add_ddlClassificationId(g.ClassificationId.GetValueOrDefault()); user.add_ddlUserId(g.UserId.GetValueOrDefault()); } var model = new connectionModels ( Id, l, gender.get_ddlGenderId(), city.get_ddlCityId(), region.get_ddlRegionId(), purchase.get_ddlLastPurchase(), classification.get_ddlClassificationId(), user.get_ddlUserId() ); Grids.Add(model); } }
public MazeGen(GameObject g, LevelEditor l) { t = l.transform; wallobj = g; for (int i = 0; i < sizeX; i++) { grids[i] = new Grids[sizeY]; } for (int i = 0; i < sizeX; i++) { for (int j = 0; j < sizeY; j++) { grids[i][j] = new Grids(i, j); } } enemyobj = Resources.Load <GameObject>("Prefabs/Enemy"); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> public void LoadContent(ContentManager content) { //load four sets of stuff for (int i = 0; i < 4; i++) { //load four grids Grids.Add(new TextureInfo(content.Load <Texture2D>("grid"))); //add four 0's for their levels Levels.Add(0); } GridColors.Add(Color.Red); GridColors.Add(Color.Yellow); GridColors.Add(Color.DarkGreen); GridColors.Add(Color.Blue); }
private void CacheSpawns() { MedicalRooms.Clear(); CryoChambers.Clear(); foreach (var block in Grids.SelectMany(x => x.GetFatBlocks())) { if (block is MyMedicalRoom medical) { MedicalRooms.Add(medical); } else if (block is MyCryoChamber cryo) { CryoChambers.Add(cryo); } } }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } PlayerPrefs.DeleteAll(); esagoniInGriglia = new List <GameObject>(); esagoniSelezionati = new List <GameObject>(); inError = false; griglia = DatiGioco.GrigliaDiGioco; DatiGioco.PercorsoSoluzioneDaSuggerire = new List <string>(); txtCoins.text = DatiGioco.user.Money.ToString(); }
Cor GetXY(Grids g) { Cor result = new Cor(); for (int i = 0; i < colNum; i++) { for (int j = 0; j < rowNum; j++) { if (allGrids[i, j] == g) { result.x = i; result.y = j; return(result); } } } return(result); }
private bool IsGridsOutOfRenge(int x, int y) { if (x < 0 || y < 0) { return(true); } if (Grids.GetLength(0) <= x) { return(true); } if (Grids.GetLength(1) <= y) { return(true); } return(false); }
internal static int[,] Flatten(int[,] grid, int flat) { (int width, int depth) = Grids.Dim(grid); int[,] result = new int[width, depth]; foreach ((int countW, int countD) in Itr.Iteration(width, depth)) { if (grid[countW, countD] != flat) { result[countW, countD] = 1; } else { result[countW, countD] = 0; } } return(result); }
public void Render(int centerTileX, int centerTileY) { const int MAX_CHUNK_DISTANCE = 1; /// Debugging var terrainProgram = ShaderProgramCache.Instance.Get("terrain"); var projModelView = Matrix4.Mult(Game.Camera.View, Game.Camera.Projection); var cameraDirection = Game.Camera.Forward; terrainProgram.Use(); terrainProgram.UniformMatrix4("modelViewProjection", false, ref projModelView); terrainProgram.UniformVector3("camera_direction", ref cameraDirection); lock (Grids) { foreach (var grid in Grids) { if (grid.Value != null && Math.Abs(grid.Value.X - centerTileX) > MAX_CHUNK_DISTANCE && Math.Abs(grid.Value.Y - centerTileY) > MAX_CHUNK_DISTANCE) { grid.Value.Unload(); } } for (var i = centerTileY - MAX_CHUNK_DISTANCE; i <= centerTileY + MAX_CHUNK_DISTANCE; ++i) { for (var j = centerTileX - MAX_CHUNK_DISTANCE; j <= centerTileX + MAX_CHUNK_DISTANCE; ++j) { if (!Grids.ContainsKey(PackTile(j, i))) { LoadTile(j, i); } } } foreach (var mapGrid in Grids.Values) { if (mapGrid != null && Math.Abs(centerTileX - mapGrid.X) <= MAX_CHUNK_DISTANCE && Math.Abs(centerTileY - mapGrid.Y) <= MAX_CHUNK_DISTANCE) { mapGrid.Render(); } } } }
public void LoadTile(int tileX, int tileY) { var gridHash = PackTile(tileX, tileY); if (Grids.ContainsKey(gridHash)) { return; } // Placeholder until loaded. Grids[gridHash] = null; Task.Factory.StartNew(() => { var gridLoader = new VMapTileLoader(Directory, MapID, tileX, tileY); if (gridLoader.FileExists) { lock (Grids) Grids[gridHash] = gridLoader; } }); }