Ejemplo n.º 1
0
        public static void DrawTimeGrid(grid g, int y)
        {
            int    h, m;
            int    x;
            string buff;

            x = Configuration.STATION_WIDTH + Configuration.KM_WIDTH;
            g.DrawLine(x, Configuration.HEIGHT, x + 23 * 120 + 59 * 2, Configuration.HEIGHT, 0);
            for (h = 0; h < 24; ++h)
            {
                for (m = 0; m < 60; ++m)
                {
                    if ((m % 10) != 0)
                    {
                    }
                    else
                    {
                        g.DrawLine(
                            x + h * 120 + m * 2, 20,
                            x + h * 120 + m * 2, Configuration.HEIGHT,
                            m != 0 ? 6 : 0);
                    }
                }
            }

            for (h = 0; h < 24; ++h)
            {
                buff = String.Format(wxPorting.T("%2d:00"), h);
                g.DrawText1(x + h * 120, 10, buff, false);
            }
        }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     MG   = TerrainGenerator.gameObject.GetComponent <MeshGenerator>();
     GD   = GridScript.gameObject.GetComponent <grid>();
     PS   = Pathfinding.gameObject.GetComponent <pathfinding>();
     CTTR = Trackchnager.gameObject.GetComponent <ChangeTextureToRoad>();
 }
Ejemplo n.º 3
0
        private void DrawStations(grid g)
        {
            Track t;
            int   y = Configuration.HEADER_HEIGHT;

            Globals.nstations = 0;
            for (t = Globals.layout; t != null && Globals.nstations < 100; t = t.next)
            {
                if (!t.isstation || string.IsNullOrEmpty(t.station))
                {
                    continue;
                }
                Globals.stations[Globals.nstations++] = t;
                Globals.DrawTimeGrid(g, y);
                g.DrawText1(0, y - 10, t.station, false);
                g.DrawLine(Configuration.STATION_WIDTH + Configuration.KM_WIDTH, y,
                           Configuration.STATION_WIDTH + Configuration.KM_WIDTH + 24 * 120, y, 0);
                y += Configuration.Y_DIST;
            }
            if (Globals.nstations == 0)
            {
                g.DrawText1(10, 10, wxPorting.L("Sorry, this feature is not available on this scenario."), false);
                g.DrawText1(10, 25, wxPorting.L("No station was found on the layout."), false);
            }
        }
Ejemplo n.º 4
0
 private void txtGrids_Validating(object sender, CancelEventArgs e)
 {
     SetError(txtGrids, string.Empty);
     _plant.grid.Clear();
     button2.Enabled = true;
     if (txtGrids.Text.Trim() == string.Empty)
     {
         return;
     }
     //if(!_plantBLL.addGrids(_plant, txtGrids.Text.Trim()))
     //{
     //    SetError(txtGrids, "Girdiğiniz kareler doğru değildi. Her kareyi sadece virgül ile ayırın. (C5,A2,A3 gibi)");
     //    _plant.grid.Clear();
     //    button2.Enabled = false;
     //}
     foreach (var item in txtGrids.Text.Split(','))
     {
         grid grd = _plantBLL.findGrid(item);
         if (grd != null)
         {
             _plant.grid.Add(grd);
         }
         else
         {
             SetError(txtGrids, "Girdiğiniz kareler doğru değildi. Her kareyi sadece virgül ile ayırın. (C5,A2,A3 gibi)");
             _plant.grid.Clear();
             button2.Enabled = false;
         }
     }
 }
Ejemplo n.º 5
0
        public Image DrawGrid(grid grid)
        {
            int maxRows = grid.maxRows;
            int maxCols = grid.maxColumns;

            var image = new Image <Rgba32>(maxRows, maxCols);


            for (int row = 0; row < maxRows; row++)
            {
                for (int column = 0; column < maxCols; column++)
                {
                    pixel pixelToDraw = grid.getPixel(row, column);
                    if (pixelToDraw.isAlive())
                    {
                        image[row, column] = Rgba32.White;
                    }
                    else
                    {
                        image[row, column] = Rgba32.Black;
                    }
                }
            }

            return(image);
        }
Ejemplo n.º 6
0
        public IHttpActionResult Putgrid(int id, grid grid)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != grid.sequencial)
            {
                return(BadRequest());
            }

            db.Entry(grid).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!gridExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 7
0
    public void buildStartBase()      // creates start place
    {
        putGround(mapProgressPosition, mapNum);
        drawSecondaryVisualEffects(mapProgressPosition, mapNum);
        drawThirdVisualEffects(mapProgressPosition, mapNum);
        putFances(mapProgressPosition, mapNum);

        Vector2 mapCorner = mapProgressPosition + new Vector2(-(mapSize.x - 1) / 2, (mapSize.y - 1) / 2) * step;

        g = new grid [(int)mapSize.y, (int)mapSize.x];

        for (int i = 0; i < mapSize.y; i++)
        {
            for (int c = 0; c < mapSize.x; c++)
            {
                g [i, c] = new grid(mapCorner + new Vector2(c, -i) * step, false);
            }
        }

        bool putBuilding = steps % environments [mapNum].buildingDensity == 0 ? true : false;

        putRoad(new Vector2(0, 0));
        putRoad(new Vector2(lineHeight, 0));

        building b = environments [mapNum].getBuilding();

        for (int i = 0; i < mapSize.y; i++)
        {
            GameObject newFance = Instantiate(b.side, g[i, 0].position - Vector2.right * step / 2 - new Vector2(10, 0), Quaternion.Euler(0, 0, randomSight())) as GameObject;
            newFance.GetComponent <barrierBehaviour>().health = Mathf.Infinity;
        }

        makeStep();
        drawMap();
    }
Ejemplo n.º 8
0
    void Start()
    {
        GD = GridScript.gameObject.GetComponent <grid>();
        TB = TBS.gameObject.GetComponent <TrackBuilder>();

        Mat = GetComponent <Renderer>().material;
    }
Ejemplo n.º 9
0
 public cell(grid <cell> Grid, int x, int y)
 {
     alive_status = false;
     this.Grid    = Grid;
     this.x       = x;
     this.y       = y;
 }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            int x = 100;
            int y = 100;
            int percentageLiving = 75;

            grid MyGrid = new grid(x, y);

            MyGrid.initiateGrid(percentageLiving);

            DrawingClass drawing = new DrawingClass();
            Image        gif     = drawing.DrawGrid(MyGrid);

            int iteration = 0;

            while (iteration < 1000)
            {
                MyGrid.UpdateGrid();
                iteration++;
                Console.WriteLine(iteration);

                Image newImage = drawing.DrawGrid(MyGrid);
                gif.Frames.InsertFrame(iteration, newImage.Frames.RootFrame);
            }
            gif.Save("result.gif");
        }
Ejemplo n.º 11
0
        public static void DrawTimeGrid1(grid g, int y)
        {
            int    h, m;
            int    x;
            string buff;

            x = Configuration.STATION_WIDTH1 + Configuration.KM_WIDTH1;
            for (h = 0; h < 24; ++h)
            {
                for (m = 0; m < 60; ++m)
                {
                    if ((m % 10) != 0)
                    {
                        g.DrawLine(
                            x + h * 240 + m * 4, y - 2,
                            x + h * 240 + m * 4, y + 2,
                            0);
                    }
                    else
                    {
                        g.DrawLine(
                            x + h * 240 + m * 4, 20,
                            x + h * 240 + m * 4, 1000,
                            m != 0 ? 1 : 0);
                    }
                }
            }

            for (h = 0; h < 24; ++h)
            {
                buff = String.Format(wxPorting.T("%2d:00"), h);
                g.DrawText1(x + h * 240, 10, buff, false);
            }
        }
Ejemplo n.º 12
0
 private void Start()
 {
     grid      = FindObjectOfType <grid>();
     xPosition = transform.position.x;
     yPosition = transform.position.y;
     col       = Mathf.RoundToInt((xPosition - grid.startPosition.x) / grid.offset.x);
     row       = Mathf.RoundToInt((yPosition - grid.startPosition.y) / grid.offset.y);
 }
Ejemplo n.º 13
0
        public ActionResult DeleteConfirmed(int id)
        {
            grid grid = db.grid.Find(id);

            db.grid.Remove(grid);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 14
0
 // Start is called before the first frame update
 void Start()
 {
     ourgrid = FindObjectOfType <grid>();
     targetX = (int)transform.position.x;
     targetY = (int)transform.position.y;
     row     = targetY;
     column  = targetX;
 }
Ejemplo n.º 15
0
	void Awake()
	{
		if (instance==null)
			instance=this;
		else if (instance!=this)
			Destroy(gameObject);
		//DontDestroyOnLoad(gameObject);		
	}
Ejemplo n.º 16
0
 public void moveto(grid target)
 {
     ((piece)temp_piece.GetComponent(typeof(piece))).moveto(target.transform.position);
     occupied = false;
     GetComponent <Renderer>().material = original_material;
     B.next     = 1 - B.next;
     temp_piece = null;
 }
Ejemplo n.º 17
0
 public void Init(int _x, int _y, Vector3 _pos, Quaternion _rot, grid _grid, grid.PieceType _type)      //Sets the pieces location
 {
     x    = _x;
     y    = _y;
     pos  = _pos;
     rot  = _rot;
     Grid = _grid;
     type = _type;
 }
Ejemplo n.º 18
0
        public override void Refresh()
        {
            grid g = Globals.tgraph_grid;

            g.Clear();
            DrawStations(g);
            DrawTrains(g);
            base.Refresh();
        }
Ejemplo n.º 19
0
        public override void Refresh()
        {
            grid g = late_graph_grid;

            g.Clear();
            DrawTimeGrid(g, 0);
            DrawTrains(g);
            base.Refresh();
        }
Ejemplo n.º 20
0
        private void DrawTrains(grid g)
        {
            //Train	t;
            //TrainStop ts;
            //Track	trk;
            //int	indx;
            //int	x, y;
            //int	nx, ny;

            //for(t = Globals.schedule; t != null; t = t.next) {
            //  if(t.days != 0 && Globals.run_day != 0 && (t.days & Globals.run_day) == 0)
            //  continue;
            //    x = y = -1;
            //    for(trk = Globals.layout; trk != null; trk = trk.next) {
            //  if(trk.type == trktype.TRACK && trk.isstation &&
            //        Globals.samestation(trk.station, t.entrance))
            //      break;
            //    }
            //    if(trk != null && (indx = Globals.graphstation(trk.station)) >= 0) {
            //      Globals.graph_xy(indx, t.timein, out x, out y);
            //  if(String.IsNullOrEmpty(t.waitfor) == false) {
            //    Train parent = Globals.findTrainNamed(t.waitfor);
            //      if(parent != null) {
            //        Globals.graph_xy(indx, parent.timeout, out nx, out ny);
            //    Globals.time_to_time(g, x, y, nx, ny, t.type);
            //    Globals.addSegment(t, x, nx, y, parent.timeout, t.timein, parent);
            //      }
            //  }
            //    }
            //    for(ts = t.stops; ts != null; ts = ts.next) {
            //  indx = Globals.graphstation(ts.station);
            //  if(indx < 0)
            //      continue;
            //  Globals.graph_xy(indx, ts.arrival, out nx, out ny);
            //  Globals.graph_xy(indx, ts.departure, out x, out y);
            //  Globals.time_to_time(g, nx, ny, x, y, t.type);
            //  Globals.addSegment(t, nx, x, y, ts.arrival, ts.departure, 0);
            //    }
            //    if(String.IsNullOrEmpty(t.stock) == false) {
            //      for(trk = Globals.layout; trk != null; trk = trk.next) {
            //      if(trk.type == trktype.TRACK && trk.isstation &&
            //            Globals.samestation(trk.station, t.exit))
            //    break;
            //  }
            //      if(trk && (indx = Globals.graphstation(trk.station)) >= 0) {
            //        Train child = Globals.findTrainNamed(t.stock);
            //      if(child != null) {
            //        Globals.graph_xy(indx, t.timeout, out x, out y);
            //        Globals.graph_xy(indx, child.timein, out nx, out ny);
            //        Globals.time_to_time(g, x, y, nx, ny, t.type);
            //        Globals.addSegment(child, x, nx, y, t.timeout, child.timein, t);
            //      }
            //  }
            //    }
            //}
        }
Ejemplo n.º 21
0
        public IHttpActionResult Getgrid(int id)
        {
            grid grid = db.grid.Find(id);

            if (grid == null)
            {
                return(NotFound());
            }

            return(Ok(grid));
        }
Ejemplo n.º 22
0
    // Start is called before the first frame update
    void Start()
    {
        mygrid = FindObjectOfType <grid>();
        mygrid.GetComponent <grid>().generateGrid();
        _allTiles = mygrid.GetComponent <grid>().allTiles;

        playerTilePos = new Vector2Int(2, 3);
        playerTile    = _allTiles[playerTilePos.x, playerTilePos.y];
        //myPlayer.transform.GetChild(0).transform.GetChild(0).transform.position = new Vector2(playerTile.transform.position.x + 0.05f, playerTile.transform.position.y - 0.05f);
        moves = 6;
    }
Ejemplo n.º 23
0
    private void Start()
    {
        CellGrid       = new grid <cell>(gridXsize, gridYsize, cellSize, transform.position, (grid <cell> g, int x, int y) => new cell(g, x, y));
        Time.timeScale = 0f;

        /* CellGrid.GetValue(9, 9).become_alive();
         * CellGrid.GetValue(10, 9).become_alive();
         * CellGrid.GetValue(11, 9).become_alive();
         * CellGrid.GetValue(11, 10).become_alive();
         * CellGrid.GetValue(10, 11).become_alive();*/
    }
 private void OnValidate()
 {
     placementGrid = FindObjectOfType <grid>();
     totalWeight   = 0;
     towersDrafted = false;
     foreach (Possible t in towers)
     {
         totalWeight += t.weight;
     }
     Inventory = this.GetComponent <SpawnedTowers>();
 }
Ejemplo n.º 25
0
        public LateGraphView(Window parent)
            : base(parent, (int)wxID_ANY, new Point(0, 0), new Size(Configuration.XMAX * 2 + Configuration.STATION_WIDTH + Configuration.KM_WIDTH, Configuration.YMAX))
        {
            EVT_PAINT(new wx.EventListener(OnPaint));

            SetScrollbars(1, 1, Configuration.XMAX * 2 + Configuration.STATION_WIDTH + Configuration.KM_WIDTH, Configuration.YMAX);
            grid g = new grid(this, Configuration.XMAX * 2 + Configuration.STATION_WIDTH + Configuration.KM_WIDTH, Configuration.YMAX);

            late_graph_grid = g;
            g.Clear();
        }
Ejemplo n.º 26
0
        public GraphView(Window parent)
            : base(parent, wxID_ANY, new Point(0, 0), new wxSize(Configuration.XMAX * 4 + Configuration.STATION_WIDTH1 + Configuration.KM_WIDTH1, Configuration.YMAX))
        {
            EVT_PAINT(new wx.EventListener(OnPaint));

            SetScrollbars(1, 1, Configuration.XMAX * 4 + Configuration.STATION_WIDTH1 + Configuration.KM_WIDTH1, Configuration.YMAX);
            grid g = new grid(this, Configuration.XMAX * 4 + Configuration.STATION_WIDTH1 + Configuration.KM_WIDTH1, Configuration.YMAX);

            Globals.tgraph_grid = g;
            g.Clear();
        }
Ejemplo n.º 27
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     //DontDestroyOnLoad(gameObject);
 }
Ejemplo n.º 28
0
    void Start()
    {
        gridcontrol = grid.thisgrid;
        for (int i = 0; i < 10; i++)
        {
            AvailableLines.Add(Instantiate(line));

            //AvailableLines[i].gameObject.SetActive(false);
        }
        lineSegments = new List <LineRenderer>(AvailableLines);
        NewGradient  = lineSegments[0].colorGradient;
    }
Ejemplo n.º 29
0
            private grid getGrid(int x, int y)
            {
                grid g = new grid();

                switch (x)
                {
                case 0:
                case 1:
                case 2:
                    g.x = 0;
                    break;

                case 3:
                case 4:
                case 5:
                    g.x = 3;
                    break;

                case 6:
                case 7:
                case 8:
                    g.x = 6;
                    break;

                default:
                    break;
                }
                switch (y)
                {
                case 0:
                case 1:
                case 2:
                    g.y = 0;
                    break;

                case 3:
                case 4:
                case 5:
                    g.y = 3;
                    break;

                case 6:
                case 7:
                case 8:
                    g.y = 6;
                    break;

                default:
                    break;
                }

                return(g);
            }
Ejemplo n.º 30
0
        public IHttpActionResult Postgrid(grid grid)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.grid.Add(grid);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = grid.sequencial }, grid));
        }
Ejemplo n.º 31
0
 public ActionResult Edit([Bind(Include = "sequencial,piloto_id_piloto,gp_id_gp,posicao")] grid grid)
 {
     if (ModelState.IsValid)
     {
         db.Entry(grid).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.gp_id_gp         = new SelectList(db.gp, "id_gp", "nome", grid.gp_id_gp);
     ViewBag.piloto_id_piloto = new SelectList(db.piloto, "id_piloto", "nome", grid.piloto_id_piloto);
     return(View(grid));
 }
Ejemplo n.º 32
0
    public bool checkVictory(grid g)
    {
        for(int x = 0; x < g.grid_size; ++x)
        {
            for(int y = 0; y < g.grid_size; ++y)
            {
                if(g.m_grid[y,x] == 8)
                {
                    return true;
                }
            }
        }

        return false;
    }
Ejemplo n.º 33
0
 // Use this for initialization
 void Start()
 {
     g = GameMaster.getGrid();
     s = GetComponent<SpriteRenderer>();
 }
Ejemplo n.º 34
0
 void Awake()
 {
     prm = GetComponent<pathRequestManager>();
     mainGrid = GetComponent<grid>();
 }