コード例 #1
0
        public async Task IzbrisiSilos(int idSilos)
        {
            Silos silos = await Context.Silos.FindAsync(idSilos);

            Context.Remove(silos);
            await Context.SaveChangesAsync();
        }
コード例 #2
0
        public async Task <IActionResult> AzurirajSilos(int idFabrika, [FromBody] Silos silos)
        {
            var xy = Context.Silos.Where(p => p.Fabrika.ID == idFabrika && p.Oznaka == silos.Oznaka).FirstOrDefault();

            if (Context.Silos.Any(p => p.Fabrika.ID == idFabrika && p.Oznaka == silos.Oznaka))
            {
                Silos si = Context.Silos.Where(p => p.Fabrika.ID == idFabrika && p.Oznaka == silos.Oznaka).FirstOrDefault();

                if ((Int32.Parse(si.TrenutnaKolicina) + Int32.Parse(silos.TrenutnaKolicina)) < Int32.Parse(si.Kapacitet))
                {
                    int kolicina = Int32.Parse(si.TrenutnaKolicina) + Int32.Parse(silos.TrenutnaKolicina);
                    si.TrenutnaKolicina = kolicina.ToString();

                    Context.Update <Silos>(si);
                    await Context.SaveChangesAsync();

                    return(Ok());
                }
                else
                {
                    return(StatusCode(406));
                }
            }
            else
            {
                return(BadRequest(new { Oznaka = xy?.Oznaka }));
            }
        }
コード例 #3
0
        public async Task UpisiSilos(int idFabrika, [FromBody] Silos silos)
        {
            Fabrika fr = await Context.Fabrika.FindAsync(idFabrika);

            silos.Fabrika = fr;
            Context.Silos.Add(silos);
            await Context.SaveChangesAsync();
        }
コード例 #4
0
    //Current Cash level is updated
    void Update()
    {
        CashDisplayer.text = Cash.ToString() + '$';
        TimeSinceStart    += Time.deltaTime;
        string minutes = Mathf.Floor(TimeSinceStart / 60).ToString("00");
        string seconds = Mathf.Floor(TimeSinceStart % 60).ToString("00");

        TimeDisplayer.text   = minutes + ":" + seconds;            //Mathf.FloorToInt(Time.time).ToString();
        SupplyDisplayer.text = (CellFactory.cellCount + "/" + Silos.getAvailableBuildings());
    }
コード例 #5
0
ファイル: Startup.cs プロジェクト: vlatko019/Web2020
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, PekaraDbContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });

            var Fabrika = new Fabrika()
            {
                Naziv = "Pajina fabrika"
            };

            var Silos1 = new Silos()
            {
                Fabrika      = Fabrika,
                Kapacitet    = 1000,
                Oznaka       = "Pajin prvi silos",
                TrenKolicina = 420
            };

            var Silos2 = new Silos()
            {
                Fabrika      = Fabrika,
                Kapacitet    = 2000,
                Oznaka       = "Pajin drugi silos",
                TrenKolicina = 1080
            };

            context.Silosi.Add(Silos1);
            context.Silosi.Add(Silos2);
            context.Fabrike.Add(Fabrika);

            Fabrika = new Fabrika()
            {
                Naziv = "Pajina fabrika 2"
            };

            Silos1 = new Silos()
            {
                Fabrika      = Fabrika,
                Kapacitet    = 1000,
                Oznaka       = "Pajin prvi silos 2",
                TrenKolicina = 420
            };

            Silos2 = new Silos()
            {
                Fabrika      = Fabrika,
                Kapacitet    = 2000,
                Oznaka       = "Pajin drugi silos 2",
                TrenKolicina = 1080
            };

            context.Silosi.Add(Silos1);
            context.Silosi.Add(Silos2);
            context.Fabrike.Add(Fabrika);

            context.SaveChanges();
        }
コード例 #6
0
    void Update()
    {
        if (switch1)
        {
            switch1 = false;
            CellFactory.cellCount  = 0;
            ScoreCore.cellCount    = new int[5];
            ScoreCore.cellCount[0] = 0;
            ScoreCore.Prices[0]    = 8 * ScoreCore.cellCount[0];
            ScoreCore.Prices[2]    = 6 * ScoreCore.cellCount[2];
            ScoreCore.Prices[3]    = 3 * ScoreCore.cellCount[3];
            ScoreCore.Prices[4]    = 8 * ScoreCore.cellCount[4];
            Camera.main.GetComponent <ScoreCore>().PriceDisplayers[0].text = ScoreCore.Prices[0].ToString() + "$";
            Camera.main.GetComponent <ScoreCore>().PriceDisplayers[2].text = ScoreCore.Prices[2].ToString() + "$";
            Camera.main.GetComponent <ScoreCore>().PriceDisplayers[3].text = ScoreCore.Prices[3].ToString() + "$";
            Camera.main.GetComponent <ScoreCore>().PriceDisplayers[4].text = ScoreCore.Prices[4].ToString() + "$";
        }

        //While holding LMB, object follows the mouse position
        if (IsSelected)
        {
            ObjectFollowsMouse(gameObject);
        }

        //When LMB is relesed, (drag ends)  do the following
        if (IsSelected && Input.GetMouseButtonUp(0))
        {
            IsSelected = false;
            Vector2 WorldPos = Camera.main.ScreenToWorldPoint(new Vector2(Input.mousePosition.x, Input.mousePosition.y));

            Vector2Int hPos = Cell.getHexCoords(WorldPos, 55f / 64f);



            //Checking if position is occupied and if player has enough cash to build the cell
            if ((Factory.Find(hPos) == null && ScoreCore.Cash >= ScoreCore.Prices[SpawnedIdentifier] && grassFactory.Find(hPos).buildable) && Input.mousePosition.y > Camera.main.pixelWidth / 7 && Silos.getAvailableBuildings() > CellFactory.cellCount) // > (Camera.main.pixelHeight/10)
            {
                CellFactory.cellCount++;

                ScoreCore.cellCount[SpawnedIdentifier]++;

                Factory.Add(hPos, SpawnedIdentifier);
                GameObject.Instantiate(Resources.Load <GameObject>("BuildParticles") as GameObject, Cell.getGlobalCoords(Cell.getHexCoords(WorldPos, 55f / 64f), 55f / 64f), Quaternion.identity);

                //Charging for purchase
                ScoreCore.Cash -= ScoreCore.Prices[SpawnedIdentifier];

                //Debug.Log(ScoreCore.cellCount[0]);

                //Increase Price of thebuilding built
                ScoreCore.Prices[0] = 8 * ScoreCore.cellCount[0];
                ScoreCore.Prices[2] = 6 * ScoreCore.cellCount[2];
                ScoreCore.Prices[3] = 3 * ScoreCore.cellCount[3];
                ScoreCore.Prices[4] = 8 * ScoreCore.cellCount[4];

                Camera.main.GetComponent <ScoreCore>().PriceDisplayers[0].text = ScoreCore.Prices[0].ToString() + "$";
                Camera.main.GetComponent <ScoreCore>().PriceDisplayers[2].text = ScoreCore.Prices[2].ToString() + "$";
                Camera.main.GetComponent <ScoreCore>().PriceDisplayers[3].text = ScoreCore.Prices[3].ToString() + "$";
                Camera.main.GetComponent <ScoreCore>().PriceDisplayers[4].text = ScoreCore.Prices[4].ToString() + "$";

                Debug.Log($"Info cell: {CellFactory.cellCount}");
            }



            //Returning the draggable to origin position
            gameObject.transform.localPosition = ReturnPosition;
        }
    }