Exemplo n.º 1
0
    public StatusScreen init(StarSystem starSystem, ItemDescriptor itemDescriptor)
    {
        this.starSystem     = starSystem;
        this.itemDescriptor = itemDescriptor;

        onPlanetSurface = starSystem == null;

        shipData   = transform.Find("Ship Data").GetComponent <ShipData>().init(onPlanetSurface);
        playerData = transform.Find("Player Data").GetComponent <PlayerData>().init();

        innerInit(transform.Find("Inventory").GetComponent <Inventory>().init(Inventory.InventoryType.INVENTORY), "Inventory");

        playerBtn = transform.Find("Player Button").GetComponent <Button>().init();
        perksBtn  = transform.Find("Perks Button").GetComponent <Button>().init();
        shipBtn   = transform.Find("Ship Button").GetComponent <Button>().init();
        repairBtn = transform.Find("Repair Button").GetComponent <Button> ().init(true);
        cabinBtn  = transform.Find("Cabin Button").GetComponent <Button>().init();
        closeBtn  = transform.Find("Close Button").GetComponent <Button>().init();

        perksView = transform.Find("Perks View").GetComponent <PerksView>().init();
        cabin     = transform.Find("Cabin").GetComponent <Cabin>().init(this);

        background = transform.Find("Background").GetComponent <SpriteRenderer>();
        background.gameObject.SetActive(true);

        inventory.setCapacity(shipData.hullType.getStorageCapacity());

        close(false);

        return(this);
    }
Exemplo n.º 2
0
        private void Goto(string command, string[] args)
        {
            if (!Context.IsMainPlayer)
            {
                Monitor.Log("You must be the server to do that");
                return;
            }


            if (args.Length < 1)
            {
                return;
            }

            string farmerName = args[0];

            Monitor.Log($"Attempting to warp to {farmerName}'s house");

            foreach (Farmer player in Game1.getAllFarmers())
            {
                if (player.Name.ToLower() == farmerName.ToLower())
                {
                    Console.WriteLine($"Found a match: {player.Name}, ID={player.UniqueMultiplayerID}");
                    Cabin cabin = CabinHelper.FindCabinInside(player);

                    Game1.warpFarmer(cabin.uniqueName.Value, cabin.warps[0].X, cabin.warps[0].Y - 1, 0);                    //Does this work when the cabin is upgraded?
                    return;
                }
            }
        }
Exemplo n.º 3
0
        public static async Task Initialize(IServiceProvider serviceProvider)
        {
            var context = serviceProvider.GetRequiredService <AppDbContext>();

            if (context.Students.Any())
            {
                return;
            }
            var userManager = serviceProvider.GetService <UserManager <IdentityUser> >();
            //var roleManager = serviceProvider.GetService<RoleManager<IdentityRole>>();

            var adminId = await EnsureRole(userManager, "$Password1", "*****@*****.**");

            int studentCount = 8;
            var cab          = new Cabin
            {
                Name           = "Unassigned",
                Gender         = Gender.Other,
                BedCount       = int.MaxValue,
                BedsRegistered = studentCount
            };
            await context.Cabins.AddAsync(cab);

            await context.SaveChangesAsync();

            await SeedDb(context, userManager);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutCabin(int id, Cabin cabin)
        {
            if (id != cabin.Id)
            {
                return(BadRequest());
            }

            _context.Entry(cabin).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CabinExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 5
0
        private void txt_Cabin_Search_Name_TextChanged(object sender, EventArgs e)
        {
            NakyvatMokit.Clear();
            SQL    s     = new SQL();
            string query = "SELECT * FROM mokki";


            if (txt_Cabin_Search_Name.Text != null)
            {
                query = "SELECT * FROM mokki where mokki.mokkinimi LIKE '%" + txt_Cabin_Search_Name.Text + "%'";
            }


            List <DataRow> dataa2 = s.SQLiteQuery_DataRowList(query);

            foreach (DataRow i in dataa2)
            {
                Cabin c = new Cabin(
                    Convert.ToInt32(i[0].ToString()), // <-> i["mokki_id"]
                    Convert.ToInt32(i[1].ToString()),
                    i[2].ToString(),
                    i[3].ToString(),
                    i[4].ToString(),
                    i[5].ToString(),
                    Convert.ToInt32(i[6].ToString()),
                    i[8].ToString(),
                    Convert.ToInt32(i[7].ToString())
                    );
                NakyvatMokit.Add(c);
            }
        }
Exemplo n.º 6
0
        private static void CheckCampersCouncelour()
        {
            using (CampSleepawayContext context = new CampSleepawayContext())
            {
                //======
                // Ask for Next of kin info
                string bigfirstname = MenuUtils.AskForString("Vad heter målsmannen i förnamn?");
                string biglastname  = MenuUtils.AskForString("Vad heter målsmannen i efternamn?");
                // Query data from next of kin

                NextOfKin nextOfKin = (from nextOfKins in context.NextOfKins
                                       where nextOfKins.FirstName == bigfirstname &&
                                       nextOfKins.LastName == biglastname
                                       select nextOfKins).FirstOrDefault();
                context.Entry(nextOfKin).Collection(c => c.Campers).Load();

                int      campersCount     = nextOfKin.Campers.Count();
                string[] campersFirstName = new string[campersCount];
                string[] campersLastName  = new string[campersCount];
                int[]    camperIds        = new int[campersCount];
                int      i = 0;
                foreach (var campersInQuery in nextOfKin.Campers)
                {
                    campersFirstName[i] = campersInQuery.FirstName;
                    campersLastName[i]  = campersInQuery.LastName;
                    camperIds[i]        = campersInQuery.CamperId;
                    i++;
                }
                // Checks out and prints all the campers of the next of kin.
                int choice = MenuUtils.AlternetivesMenu(0, campersFirstName, "Vilken unge vill du hämta?");

                //var camperQuery = (from camper in context.Campers
                //                   where camper.LastName == campersLastName[choice] &&
                //                   camper.FirstName == campersFirstName[choice]
                //                   select camper.Cabin).ToList();
                string camperFirstName = campersFirstName[choice];
                string camperLastName  = campersLastName[choice];
                int    camperId        = camperIds[choice];
                //======

                string camperName  = MenuUtils.AskForString("Vad heter parveln i förnamn?");
                var    camperQuery = (from camper in context.Campers
                                      where camper.CamperId == camperId
                                      select camper.Cabin).ToList();


                // visa info om valda kabin
                Cabin cabinInfo = camperQuery[0];
                context.Entry(cabinInfo).Reference(c => c.Counselor).Load();
                if (cabinInfo.Counselor != null)
                {
                    Console.WriteLine($"\nGruppledarens namn: {cabinInfo.Counselor.FirstName}");
                }
                else
                {
                    Console.WriteLine("Hittade ingen råggivare till den kamparen");
                }
            }
            MenuUtils.PauseUntilFeedback("Tryck en knapp för att fortsätta");
        }
Exemplo n.º 7
0
 public PilotFacade()
 {
     _cabin  = new Cabin();
     _engine = new Engine();
     _wings  = new Wings();
     _pa     = new PublicAnnouncement();
 }
Exemplo n.º 8
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(idTextBox.Text))
            {
                MessageBox.Show("There is no item found");
                return;
            }
            DialogResult dr = MessageBox.Show("Are you sure to delete row?", "Confirmation Message", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                Cabin aCabin = new Cabin();
                aCabin.Id = Convert.ToInt32(idTextBox.Text);
                string message = aCabinManager.DeleteCabin(aCabin);

                //string message = aCabinManager.DeleteCabin(aCabin);
                MessageBox.Show(message);
                ResetAllData();
                PopulateCabinListView();
            }
            else
            {
                //Nothing to do
            }
        }
Exemplo n.º 9
0
        public Lasku(Client asiakas, Cabin mokki, Reservation varaus, Invoice lasku, Service[] palvelut = null)
        {
            InitializeComponent();
            printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
            label_AsiakasID.Text     += " " + asiakas.asiakas_id.ToString();
            labelAsiakas.Text        += " " + asiakas.etunimi + " " + asiakas.sukuimi;
            labelOsoite.Text         += " " + asiakas.lahiosoite;
            labelPostinumero.Text    += " " + asiakas.postinro.ToString();
            labelPostitmp.Text       += " " + asiakas.postitoimipaikka.ToString();

            labelLaskunumero.Text += " " + lasku.lasku_id;
            labelVarausID.Text    += " " + varaus.varaus_id;
            labelPaivamaara.Text  += " " + DateTime.Now.ToShortDateString();

            labelAlue.Text         += " " + mokki.toimintaalue;
            labelVarausOsoite.Text += " " + mokki.katuosoite;

            labellblTulopaiva.Text += " " + UnixTimeStampToDateTime(varaus.varattu_alkupvm).ToShortDateString();
            labelLahtopaiva.Text   += " " + UnixTimeStampToDateTime(varaus.varattu_loppupvm).ToShortDateString();

            label_HintaYoText.Text += " " + mokki.hinta.ToString();

            foreach (Service s in palvelut)
            {
                textBox1.Text += s.nimi + Environment.NewLine;
                textBox_PalveluidenHinta.Text += s.hinta + Environment.NewLine;
            }

            label_LoppusummaText.Text = " " + lasku.summa;
        }
Exemplo n.º 10
0
        public MokkiRaportointi()
        {
            InitializeComponent();

            Mokit = new BindingList <Cabin>();
            List <DataRow> data = new SQL().SQLiteQuery_DataRowList("SELECT * FROM mokki");

            foreach (DataRow i in data)
            {
                Cabin c = new Cabin(
                    Convert.ToInt32(i[0].ToString()), // <-> i["mokki_id"]
                    Convert.ToInt32(i[1].ToString()),
                    i[2].ToString(),
                    i[3].ToString(),
                    i[4].ToString(),
                    i[5].ToString(),
                    Convert.ToInt32(i[6].ToString()),
                    i[8].ToString(),
                    Convert.ToInt32(i[7].ToString())
                    );
                Mokit.Add(c);
            }
            checklist_Cabins.DataSource    = Mokit;
            checklist_Cabins.DisplayMember = "DISPLAYNAME";
        }
Exemplo n.º 11
0
        public async Task <ActionResult <Cabin> > PostCabin(Cabin cabin)
        {
            _context.Cabins.Add(cabin);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCabin", new { id = cabin.Id }, cabin));
        }
Exemplo n.º 12
0
        public async Task <ActionResult <Cabin> > PostCabin([FromBody] Cabin cabin)
        {
            _context.Cabin.Add(cabin);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetCabin), new { id = cabin.Id }, cabin));
        }
        public async Task <ActionResult> Edit(int id, Cabin cabin)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    bool editCabin = await _service.PutCabin(User, id, cabin);

                    if (editCabin)
                    {
                        return(RedirectToAction("Index", new { success = 2 }));
                    }

                    return(View("ErrorPage"));
                }

                // Getting PostalCodes to Dropdownlist
                ViewBag.PostalCodes = await _service.GetPostalCodesSelectListItems();

                if (null == ViewBag.PostalCodes)
                {
                    ViewBag.ErrorMessage = "Tietokannassa ei ole yhtään postinumeroa";
                    return(View("ErrorPage"));
                }
                return(View(cabin));
            }
            catch
            {
                return(View("ErrorPage"));
            }
        }
        public async Task <Cabin> CreateCabin(int portalId, CabinModel cabin)
        {
            IEnumerable <Cabin> existingCabins = await GetCabinsByName(portalId, cabin.Name);

            if (existingCabins.Any())
            {
                throw new Exception("This cabin already exists. Please use another name.");
            }

            Cabin newCabin = new Cabin
            {
                PortalId    = portalId,
                Name        = cabin.Name.Trim(),
                CreatedBy   = cabin.CreatedBy,
                CreatedDate = DateTimeOffset.Now,
                IsActive    = true,
                IsDeleted   = false,
                UpdatedDate = DateTimeOffset.Now
            };

            await Context.Cabins.AddAsync(newCabin);

            await Context.SaveChangesAsync();

            return(newCabin);
        }
Exemplo n.º 15
0
 public CabinViewModel(Cabin cabin)
 {
     WrappedCabin = cabin;
     IsSelected   = cabin.DefaultSelected;
     RaisePropertyChanged(nameof(WrappedCabin));
     RaisePropertyChanged(nameof(SelectedSchedule));
 }
Exemplo n.º 16
0
        public void CabinTest()
        {
            //a new cabin should not have any personnel
            Cabin cabin = new Cabin(Connector.None, Connector.None, Connector.None, Connector.None);

            Assert.Equal(Personnel.None, cabin.Personnel);

            //set personnel as alien, removing a single personnel should leave the cabin empty
            cabin.Personnel = Personnel.LaserAlien;
            cabin.RemoveSinglePersonnel();
            Assert.Equal(Personnel.None, cabin.Personnel);

            cabin.Personnel = Personnel.EngineAlien;
            cabin.RemoveSinglePersonnel();
            Assert.Equal(Personnel.None, cabin.Personnel);

            //setting personnel as double humans, removing a singl personnel should leave the cabin with 1 human
            cabin.Personnel = Personnel.HumanDouble;
            cabin.RemoveSinglePersonnel();
            Assert.Equal(Personnel.HumanSingle, cabin.Personnel);

            //removing personnel a second times makes it empty again
            cabin.RemoveSinglePersonnel();
            Assert.Equal(Personnel.None, cabin.Personnel);
        }
Exemplo n.º 17
0
        public JsonResult AddgalleryPhoto(int id, string name)
        {
            Cabin model = db.Cabins.FirstOrDefault(a => a.ID == id);

            if (model != null)
            {
                List <CruiseGallery> listDetail = new List <CruiseGallery>();

                var images = new CruiseGallery
                {
                    NameImages = name
                };
                if (string.IsNullOrEmpty(model.Cabingallery))
                {
                    listDetail.Add(images);
                    var addgallery = JsonConvert.SerializeObject(listDetail);
                    model.Cabingallery = addgallery;
                }
                else
                {
                    listDetail = JsonConvert.DeserializeObject <List <CruiseGallery> >(model.Cabingallery);
                    listDetail.Add(images);
                    model.Cabingallery = JsonConvert.SerializeObject(listDetail);
                }
                db.SubmitChanges();
            }
            return(Json(new { success = true }));
        }
Exemplo n.º 18
0
    void DoDoor(int x, int y, GameObject tileGObj, SpriteRenderer sr)
    {
        Cabin cabin_ext = area_filler.cabin_exterior;
        Cabin cabin_int = area_filler.cabin_interior;

        // Give interactable colliders to doors:
        if (sr.sprite.name == "CabExt_Door")
        {
            GameObject intCollider = pool.GetObjectForType("Interactable Tile", true, tileGObj.transform.position);
            intCollider.transform.SetParent(tileGObj.transform);
            intCollider.GetComponent <Tile_Interactable>().Init(tileGObj.transform.position);
            intCollider.GetComponent <Tile_Interactable>().SetDoorParams(1, 2, 5);
        }
        else
        {
            if (x == cabin_int.doorX && y == cabin_int.doorY)
            {
                sr.sprite = spriteMgr.GetSprite("CabInt_Door");
                GameObject intCollider = pool.GetObjectForType("Interactable Tile", true, tileGObj.transform.position);
                intCollider.transform.SetParent(tileGObj.transform);
                intCollider.GetComponent <Tile_Interactable>().Init(tileGObj.transform.position);
                intCollider.GetComponent <Tile_Interactable>().SetDoorParams(0, 23, 25);
            }
        }
    }
Exemplo n.º 19
0
        public void Post([FromBody] Cabin cabin)
        {
            cabin.ID = Guid.NewGuid();
            var db = new DataManager();

            db.Save(cabin);
        }
Exemplo n.º 20
0
        private static void CabinInfo()
        {
            // hitta alla stugor in i en array
            using (CampSleepawayContext context = new CampSleepawayContext())
            {
                var cabinQuery = (from cabins in context.Cabins
                                  select cabins).ToList();
                string[] cabinNames = new string[cabinQuery.Count];
                for (int i = 0; i < cabinQuery.Count; i++)
                {
                    cabinNames[i] = cabinQuery[i].Name;
                }
                // visa lista över alla stugor
                int choice = MenuLibrary.MenuUtils.AlternetivesMenu(
                    0,
                    cabinNames,
                    "Välj vilken kabin du vill se info om");
                // visa info om valda kabin
                Cabin cabinInfo = cabinQuery[choice];
                context.Entry(cabinInfo).Reference(c => c.Counselor).Load();
                context.Entry(cabinInfo).Collection(c => c.Campers).Load();

                Console.WriteLine($"\nLägerhusets namn: {cabinInfo.Name}");

                if (cabinInfo.Counselor != null)
                {
                    Console.WriteLine($"\nGruppledarens namn: {cabinInfo.Counselor.FirstName}");
                }
                if (cabinInfo.Campers != null)
                {
                    PrintCamperInfo(context, cabinInfo);
                }
            }
            MenuUtils.PauseUntilFeedback("Tryck en knapp för att fortsätta");
        }
Exemplo n.º 21
0
        private static void AddOneCabinWithCampers(CampSleepawayContext context)
        {
            NextOfKin        next       = context.NextOfKins.Find(1);
            List <NextOfKin> nextOfKins = new List <NextOfKin>();

            nextOfKins.Add(next);

            List <Camper> campers = new List <Camper>
            {
                new Camper {
                    FirstName = "Karl", LastName = "Ekman", NextOfKins = nextOfKins
                },
                new Camper {
                    FirstName = "Berit", LastName = "Ekman", NextOfKins = nextOfKins
                },

                new Camper {
                    FirstName = "Lisa", LastName = "Ekdhal", NextOfKins = nextOfKins
                }
            };
            Cabin cabin = context.Cabins.Find(1);

            cabin.Counselor = context.Counselors.Find(2);
            context.Cabins.Add(cabin);
            context.SaveChanges();
        }
        public async Task DeleteCabin(int portalId, int cabinId)
        {
            Cabin dbCabin = await GetCabinById(portalId, cabinId);

            dbCabin.IsActive  = false;
            dbCabin.IsDeleted = true;

            await Context.SaveChangesAsync();
        }
Exemplo n.º 23
0
 public static string ToRow(Cabin cab)
 {
     return("<tr>" +
            $"<td>{cab.CabinName}</td>" +
            $"<td>{cab.Square}</td>" +
            $"<td>{cab.ClassName}</td>" +
            $"<td style=\"height=0px\">{PassengersController.ToTable(cab.Passengers, true)}</td>" +
            "</tr>");
 }
Exemplo n.º 24
0
        private static void AddOneCabin(CampSleepawayContext context)
        {
            Cabin cabin = new Cabin {
                Name = "Moonbase"
            };

            context.Cabins.Add(cabin);
            context.SaveChanges();
        }
Exemplo n.º 25
0
        public ActionResult PostCabin(Cabin cabin)
        {
            using (var session = NHibernateHelper.OpenSession())
            {
                new NHibernateDAOFactory(session).getCabinDAO().SaveOrUpdate(cabin);
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 26
0
        private void BringBackCabin(string command, string[] args)
        {
            if (!Context.IsMainPlayer)
            {
                Monitor.Log("You must be the server to do that");
                return;
            }

            if (args.Length < 1)
            {
                Monitor.Log("Which player's house?");
                return;
            }

            if (Game1.getFarm() != Game1.player.currentLocation)
            {
                Monitor.Log("You need to be on the farm");
                return;
            }

            string farmerName = args[0];

            Monitor.Log($"Attempting to move {farmerName}'s house back");

            foreach (Farmer player in Game1.getAllFarmers())
            {
                if (player.Name.ToLower() == farmerName.ToLower())
                {
                    Monitor.Log($"Found a match: {player.Name}, ID={player.UniqueMultiplayerID}");

                    Building targetBuilding = CabinHelper.FindCabinOutside(player);
                    Cabin    cabin          = CabinHelper.FindCabinInside(player);
                    if (cabin != null && targetBuilding != null)
                    {
                        targetBuilding.GetType()
                        .GetField("tileX", BindingFlags.Instance | BindingFlags.Public)                           //tileX is readonly
                        .SetValue(targetBuilding, new NetInt(Game1.player.getTileX()));

                        targetBuilding.GetType()
                        .GetField("tileY", BindingFlags.Instance | BindingFlags.Public)                           //tileY is readonly
                        .SetValue(targetBuilding, new NetInt(Game1.player.getTileY() - 1));

                        foreach (var warp in cabin.warps)
                        {
                            warp.TargetX = targetBuilding.humanDoor.X + (int)targetBuilding.tileX.Value;
                            warp.TargetY = targetBuilding.humanDoor.Y + (int)targetBuilding.tileY.Value + 1;
                        }

                        Monitor.Log($"Moved it");
                    }
                    else
                    {
                        Monitor.Log("Could not find the cabin");
                    }
                }
            }
        }
Exemplo n.º 27
0
        public override void OnClicked()
        {
            Console.WriteLine($"Warping to {player.Name}'s cabin");

            Cabin cabin = CabinHelper.FindCabinInside(player);

            Game1.warpFarmer(cabin.uniqueName.Value, cabin.warps[0].X, cabin.warps[0].Y - 1, 0);

            Game1.activeClickableMenu.exitThisMenu(false);
        }
Exemplo n.º 28
0
        private Farmer findOriginalFarmhand(Farmer farmhand)
        {
            Cabin cabin = findCabin(farmhand);

            if (cabin == null)
            {
                return(null);
            }
            return(cabin.getFarmhand().Value);
        }
Exemplo n.º 29
0
        public int DeleteCabin(Cabin aCabin)
        {
            Query   = "DELETE FROM Cabin WHERE Id = " + aCabin.Id;
            Command = new SqlCommand(Query, Connection);
            //Connection.Open();
            int rowAffect = Command.ExecuteNonQuery();

            //Connection.Close();
            return(rowAffect);
        }
Exemplo n.º 30
0
        public string UpdateCabin(Cabin aCabin)
        {
            int isAffect = aCabinGatway.UpdateCabin(aCabin);

            if (isAffect > 0)
            {
                return("Success! cabin has been updated.");
            }
            return("Error! cabin has not been updated.");
        }
Exemplo n.º 31
0
    public static void Main()
    {
        Cabin cabin_1 = new Cabin();
           cabin_1.id = 2;
           cabin_1.name = "Jumbo Suite";
           cabin_1.deckLevel = 1;
           cabin_1.shipId = 1;
           cabin_1.bedCount = 2;

           TravelAgentService agent = new TravelAgentService();

           agent.createCabin(cabin_1);

           Cabin cabin_2 = agent.findCabin(2);
           Console.WriteLine(cabin_2.name);
           Console.WriteLine(cabin_2.deckLevel);
           Console.WriteLine(cabin_2.shipId);
           Console.WriteLine(cabin_2.bedCount);
    }
 /// <remarks/>
 public System.IAsyncResult BegincreateCabin(Cabin Cabin, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("createCabin", new object[] {
                 Cabin}, callback, asyncState);
 }