Ejemplo n.º 1
0
            // Serialization
            public void RegisterGrid(IMapGrid grid)
            {
                if (GridIDMap.ContainsKey(grid.Index))
                {
                    throw new InvalidOperationException();
                }

                Grids.Add(grid);
                GridIDMap.Add(grid.Index, GridIDMap.Count);
            }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        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"]; };
        }
Ejemplo n.º 5
0
        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"];
        }
Ejemplo n.º 6
0
    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);
    }
Ejemplo n.º 7
0
        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!");
            }
        }
Ejemplo n.º 8
0
 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]);
             }
         }
     }
 }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
 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();
         }
     }
 }
Ejemplo n.º 11
0
 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();
         }
     }
 }
Ejemplo n.º 12
0
        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();
        }
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
0
    // 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);
    }
Ejemplo n.º 15
0
    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);
    }
Ejemplo n.º 16
0
 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);
     });
 }
Ejemplo n.º 17
0
        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);
            };
        }
Ejemplo n.º 18
0
    // 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;
    }
Ejemplo n.º 19
0
        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));
            }
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        // 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);
            }
        }
Ejemplo n.º 22
0
 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");
 }
Ejemplo n.º 23
0
        /// <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);
        }
Ejemplo n.º 24
0
        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);
                }
            }
        }
Ejemplo n.º 25
0
 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();
 }
Ejemplo n.º 26
0
    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);
    }
Ejemplo n.º 27
0
    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);
    }
Ejemplo n.º 28
0
    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);
    }
Ejemplo n.º 29
0
        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();
                    }
                }
            }
        }
Ejemplo n.º 30
0
        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;
                }
            });
        }