private static void CreateCottages(AppDbContext context) { var cottageData = System.IO.File.ReadAllText("Data/SeedingData/Cottages.json"); var cottagesFromFile = JsonConvert.DeserializeObject <List <CottageData> >(cottageData); cottagesFromFile.ForEach(c => { var cottage = new Cottage { Name = c.Name, NoOfBedrooms = c.NoOfBedrooms, MaxGuests = c.MaxGuests, Location = c.Location, Description = c.Description }; var regionForCottage = context.Regions.FirstOrDefault(r => r.Name == c.Region); regionForCottage.Cottages.Add(cottage); cottage.Region = regionForCottage; // cottage.Region = regionForCottage; context.Add(cottage); }); context.SaveChanges(); }
/** * <summary> * Updates the cottage interface, if any selected * </summary> */ public void UpdateCottageUI(Cottage cottage) { if (cottage == null) { //Disable buttons for (int i = 0; i < cottageList.Length; i++) { cottageList[i].IsVisible = false; } } else { List <WorldObject> people = cottage.GetPeople(); //Enable buttons for each person for (int i = 0; i < people.Count; i++) { WorldObject wo = people[i]; cottageList[i].Text = string.Format("{0}: {1} - {2}/{3}", i + 1, wo.GetWoName(), wo.GetHealth(), wo.GetMaxHealth()); cottageList[i].IsVisible = true; } //Disable the rest of buttons for (int i = people.Count; i < cottageList.Length; i++) { cottageList[i].IsVisible = false; } } }
public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var booking = await _context.Booking.FindAsync(id); var bookingId = _context.Booking .FirstOrDefault(m => m.BookingId == id); //Hämta id från stuga där booking id = id Booking cottageBooking = (from m in _context.Booking where m.BookingId == id select m).SingleOrDefault(); var cottageId = cottageBooking.CottageId; //Hämtar stugans pris Cottage cottagePrice = (from m in _context.Cottage where m.CottageId == cottageId select m).SingleOrDefault(); ViewData["cottageprice"] = cottagePrice.Price; ViewData["cottageid"] = cottageId; if (booking == null) { return(NotFound()); } return(View(booking)); }
public async Task <IActionResult> AddCottage([FromForm] CottageAddUpdateDto cottageAddUpdateDto) { Cottage cottageToAdd = _mapper.Map <Cottage>(cottageAddUpdateDto); var cottageRegion = await _repo.GetRegionById(cottageAddUpdateDto.RegionId); cottageToAdd.Region = cottageRegion; var userIdFromClaims = User.Claims.FirstOrDefault().Value; if (Int32.TryParse(userIdFromClaims, out int currentUser)) { cottageToAdd.ModifiedBy = currentUser; } else { cottageToAdd.ModifiedBy = 0; } _repo.Add <Cottage>(cottageToAdd); var cottageAddedSuccess = await _repo.Commit(); if (!cottageAddedSuccess) { return(StatusCode(500)); } if (cottageAddUpdateDto.PhotoFile != null) { var photoUrl = await SavePhoto(cottageAddUpdateDto.PhotoFile, cottageToAdd.Id, cottageToAdd.Name); if (!String.IsNullOrEmpty(photoUrl)) { cottageToAdd.Photo = photoUrl; } } //add cottage owner entitie(s) List <CottageOwner> cottageOwners = cottageAddUpdateDto.OwnerIds.Select(o => new CottageOwner { CottageId = cottageToAdd.Id, OwnerId = o }).ToList(); _repo.AddCottageOwners(cottageOwners); var cottageOwnersAdded = await _repo.Commit(); if (!cottageOwnersAdded) { return(StatusCode(500)); } return(CreatedAtRoute("GetCottageById", new { id = cottageToAdd.Id }, new { id = cottageToAdd.Id })); }
public async Task <IActionResult> Create([Bind("BookingId,UserId,DateArrival,DateLeaving,TotalPrice")] Booking booking, int id) { if (ModelState.IsValid) { // Räknar ut antal dagar baserat på datumen som har valts int days = (booking.DateLeaving.Date - booking.DateArrival.Date).Days; var cottage = await _context.Cottage .FirstOrDefaultAsync(m => m.CottageId == booking.CottageId); //Pris för aktuell stuga var cottagePrice = Convert.ToInt32(Request.Form["price"]); int TotalPrice = cottagePrice; //Pris baserat på hur många dagar som väljs if (days > 2 && days <= 4) { TotalPrice = cottagePrice + 1000; } else if (days > 4 && days <= 8) { TotalPrice = cottagePrice + 2000; } else if (days > 8) { TotalPrice = cottagePrice + 3000; } //Lagrar värde för totalpris innan lagring i databas booking.TotalPrice = TotalPrice; booking.CottageId = id; //Tilldelar bokningen till den användare som är inloggad var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); booking.UserId = userId; //Bokningsstatus för stugan ändras till bokad Cottage bookingResult = (from p in _context.Cottage where p.CottageId == id select p).SingleOrDefault(); bookingResult.IsBooked = true; _context.Add(booking); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //Visar information om stugan InfoCottage(id); return(View(booking)); }
private void AddImages(ref Cottage cottage, List <IFormFile> images) { foreach (var i in images) { cottage.ImageGroup.Images.Add(new Image() { ImagePath = @"\images\" + i.FileName }); } }
public async Task CreateCottageAsync(Cottage input) { var cottage = new Cottage { Title = input.Title, Description = input.Description, CostPerDay = input.CostPerDay }; await _context.Cottages.AddAsync(cottage); await _context.SaveChangesAsync(); }
private void ExitCottage(object sender, IncomingMessage receivedMessage) { Entity cottage = networkedScene.EntityManager.Find(receivedMessage.ReadString()); if (cottage != null && !cottage.IsDisposed) { Cottage cot = cottage.FindComponent <Cottage>(); int number = receivedMessage.ReadInt32(); if (cot != null && !cot.UnderConstruction()) { LayerTile aux = Map.map.GetTileByMapCoordinates(receivedMessage.ReadInt32(), receivedMessage.ReadInt32()); cot.ExitPerson(number, aux); } } }
static void Main() { Cottage cottage = new Cottage(); cottage.CottageInfo(); Flat flat = new Flat(); flat.FlatInfo(); Mansion mansion = new Mansion(); mansion.MansionInfo(); Console.ReadLine(); }
public void Reset() { VictoryPoints = 0; Money = 0; NumberOfRounds = 0; ResidualMoney = 0; RemainingBonusActions = 0; Round = 1; Hand = new Hand(); VineDeck = new Deck <VineCard>(Hand, _vineCards); OrderDeck = new Deck <OrderCard>(Hand, _orderCards); AutomaDeck = new Deck <AutomaCard>(Hand, _automaCards); SummerVisitorDeck = new Deck <VisitorCard>(Hand, _visitorCards.Where(p => p.Season == Season.Summer)); WinterVisitorDeck = new Deck <VisitorCard>(Hand, _visitorCards.Where(p => p.Season == Season.Winter)); Yoke = new Yoke(_eventAggregator); Trellis = new Trellis(_eventAggregator); Cottage = new Cottage(_eventAggregator); Windmill = new Windmill(_eventAggregator); Irigation = new Irigation(_eventAggregator); LargeCellar = new LargeCellar(_eventAggregator); TastingRoom = new TastingRoom(_eventAggregator); MediumCellar = new MediumCellar(_eventAggregator); Field1 = new Field(_eventAggregator, 5); Field2 = new Field(_eventAggregator, 6); Field3 = new Field(_eventAggregator, 7); Grande = new Grande(_eventAggregator); NeutralWorker = new Worker(_eventAggregator); _workers = new List <Worker>(); for (var i = 0; i < 5; i++) { _workers.Add(new Worker(_eventAggregator)); } InitializeGrapes(out _redGrapes, GrapeColor.Red); InitializeGrapes(out _whiteGrapes, GrapeColor.White); InitializeWines(out _redWines, WineType.Red, 9); InitializeWines(out _whiteWines, WineType.White, 9); InitializeWines(out _blushWines, WineType.Blush, 6); InitializeWines(out _sparklingWines, WineType.Sparkling, 3); }
public ModifyCottageForm(Cottage c) { //Used to import cottage data to form InitializeComponent(); RegionUtils.PopulateCBRegion(cbModifyCottageRegion); lblModifyCottageID.Text = c.CottageID.ToString(); cbModifyCottageRegion.Text = RegionUtils.RegionIndexToName(c.RegionID); tbModifyCottagePostNum.Text = c.Postal; tbModifyCottageName.Text = c.Name; tbModifyCottageStreet.Text = c.Address; nudModifyCottageCapacity.Value = c.Capacity; cbModifyCottageEquipment.Text = c.Equipment; nudModifyCottagePrice.Value = (int)c.Price; tbModifyCottageDescription.Text = c.Description; }
public bool CanAct(WorldObject other) { bool res = other != null && !other.IsDestroyed(); if (res) { Cottage cottage = other.Owner.FindComponent <Cottage>(); LayerTile l1 = Map.map.GetTileByWorldPosition(cottage.wo.GetCenteredPosition()); LayerTile l2 = Map.map.GetTileByWorldPosition(wo.GetCenteredPosition()); res = !cottage.UnderConstruction() && cottage.GetCount() < cottage.maxOccupation && !cottage.GetPeople().Contains(wo) && wo.player == cottage.wo.player && Map.map.Adjacent(l1, l2) && (wo.GetAction() == ActionEnum.Exit || wo.GetAction() == ActionEnum.Idle); } return(res); }
public void ExitCottage(LayerTile cottage, LayerTile exit) { if (Map.map.GetWorldObject(cottage.X, cottage.Y) != null) { this.cottage = Map.map.GetWorldObject(cottage.X, cottage.Y).Owner.FindComponent <Cottage>(); } nextTile = exit; currentTile = cottage; Map.map.SetTileOccupied(nextTile.X, nextTile.Y, true); if (wo.animation != null) { wo.animation.Cancel(); } wo.transform.Position = currentTile.LocalPosition; wo.animation = new WaveEngine.Components.GameActions.MoveTo2DGameAction(Owner, nextTile.LocalPosition, TimeSpan.FromSeconds(wo.genericSpeed)); wo.animation.Run(); wo.SetAction(ActionEnum.Exit); }
public Island(int offset, IEnumerable <Player> players, Save saveFile) { _saveFile = saveFile; _offset = offset; Name = new Utilities.AcString(saveFile.ReadByteArray(offset + IslandName, 6), saveFile.SaveType).Trim(); Id = saveFile.ReadUInt16(offset + IslandId, true); TownName = new Utilities.AcString(saveFile.ReadByteArray(offset + TownNameOffset, 6), saveFile.SaveType).Trim(); TownId = saveFile.ReadUInt16(offset + TownIdOffset, true); var identifier = saveFile.ReadUInt16(offset - 0x2214, true); foreach (var player in players) { if (player != null && player.Data.Identifier == identifier) { Owner = player; } } BuriedDataArray = saveFile.ReadByteArray(offset + BuriedData, 0x40); Items = new WorldItem[2][]; for (var acre = 0; acre < 2; acre++) { Items[acre] = new WorldItem[0x100]; var i = 0; foreach (var itemId in saveFile.ReadUInt16Array(offset + WorldData + acre * 0x200, 0x100, true)) { Items[acre][i] = new WorldItem(itemId, i % 256); SetBuried(Items[acre][i], acre, BuriedDataArray, saveFile.SaveType); i++; } } Cabana = new Cottage(offset + CottageData, saveFile); FlagPattern = new Pattern(offset + FlagData, 0, saveFile); Islander = new Villager(offset + IslanderData, 0, saveFile); Purchased = IsPurchased(); IslandLeftAcreIndex = saveFile.ReadByte(offset + IslandLeftAcreData); IslandRightAcreIndex = saveFile.ReadByte(offset + IslandRightAcreData); }
public Island(int Offset, Player[] Players, Save SaveFile) { this.SaveFile = SaveFile; this.Offset = Offset; Name = new ACSE.Classes.Utilities.ACString(SaveFile.ReadByteArray(Offset + IslandName, 6), SaveFile.Save_Type).Trim(); Id = SaveFile.ReadUInt16(Offset + IslandId, true); TownName = new ACSE.Classes.Utilities.ACString(SaveFile.ReadByteArray(Offset + TownNameOffset, 6), SaveFile.Save_Type).Trim(); TownId = SaveFile.ReadUInt16(Offset + TownIdOffset, true); ushort Identifier = SaveFile.ReadUInt16(Offset - 0x2214, true); foreach (Player Player in Players) { if (Player != null && Player.Data.Identifier == Identifier) { Owner = Player; } } BuriedDataArray = SaveFile.ReadByteArray(Offset + BuriedData, 0x40, false); Items = new WorldItem[2][]; for (int Acre = 0; Acre < 2; Acre++) { Items[Acre] = new WorldItem[0x100]; int i = 0; foreach (ushort ItemId in SaveFile.ReadUInt16Array(Offset + WorldData + Acre * 0x200, 0x100, true)) { Items[Acre][i] = new WorldItem(ItemId, i % 256); SetBuried(Items[Acre][i], Acre, BuriedDataArray, SaveFile.Save_Type); i++; } } Cabana = new Cottage(Offset + CottageData, SaveFile); FlagPattern = new Pattern(Offset + FlagData, 0, SaveFile); Islander = new Villager(Offset + IslanderData, 0, SaveFile); IslandLeftAcreIndex = SaveFile.ReadByte(Offset + IslandLeftAcreData); IslandRightAcreIndex = SaveFile.ReadByte(Offset + IslandRightAcreData); }
public async Task <IActionResult> UpdateCottage(int id, [FromForm] CottageAddUpdateDto cottageAddUpdateDto) { Cottage cottageToUpdate = await _repo.GetCottageById(id, false, false); cottageToUpdate.NoOfBedrooms = cottageAddUpdateDto.NoOfBedrooms; cottageToUpdate.MaxGuests = cottageAddUpdateDto.MaxGuests; cottageToUpdate.Location = cottageAddUpdateDto.Location; cottageToUpdate.Description = cottageAddUpdateDto.Description; cottageToUpdate.ModifiedDate = DateTime.Now; var userIdFromClaims = User.Claims.FirstOrDefault().Value; if (Int32.TryParse(userIdFromClaims, out int currentUser)) { cottageToUpdate.ModifiedBy = currentUser; } else { cottageToUpdate.ModifiedBy = 0; } if (cottageAddUpdateDto.PhotoFile != null) { var photoUrl = await SavePhoto(cottageAddUpdateDto.PhotoFile, cottageToUpdate.Id, cottageToUpdate.Name); if (!String.IsNullOrEmpty(photoUrl)) // photo saved successfully { cottageToUpdate.Photo = photoUrl; } } var cottageUpdateSuccess = await _repo.Commit(); if (!cottageUpdateSuccess) { return(StatusCode(500)); } return(NoContent()); }
public override void VisitBuilding(int a, int b) { base.VisitBuilding(a, b); if (Origin.AmountStored == 0) { return; } House house = world.Map.GetBuildingAt(a, b).GetComponent <House>(); if (house == null) { return; } Cottage cottage = (Cottage)Origin; Node itemData = Enums.GetItemData(cottage.product); SellItem(house, itemData.x, (ItemType)itemData.y, (int)cottage.AmountStored); }
public async Task <IActionResult> Create([Bind("CottageId,Name,Price,NumberOfGuest,AnimalsAllowed,Description,IsBooked,Photo")] CottageCreateViewModel cottageModel) { if (ModelState.IsValid) { //Kod för bilduppladdning string cottageFileName = null; if (cottageModel.Photo != null) { //Mapp där bilderna lagras string imagesFolder = Path.Combine(hostingEnvironment.WebRootPath, "img/cottageimg"); //Filnamn cottageFileName = Guid.NewGuid().ToString() + "_" + cottageModel.Photo.FileName; //Sökväg till bild string filePath = Path.Combine(imagesFolder, cottageFileName); //Kopierar över till server cottageModel.Photo.CopyTo(new FileStream(filePath, FileMode.Create)); } //Lägger till alla värden Cottage newCottage = new Cottage { Name = cottageModel.Name, Price = cottageModel.Price, NumberOfGuest = cottageModel.NumberOfGuest, AnimalsAllowed = cottageModel.AnimalsAllowed, Description = cottageModel.Description, IsBooked = cottageModel.IsBooked, PhotoPath = cottageFileName }; _context.Add(newCottage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }
public void EnterCottage(WorldObject cot) { if (CanAct(cot)) { Cottage cottage = cot.Owner.FindComponent <Cottage>(); LayerTile l1 = Map.map.GetTileByWorldPosition(cottage.wo.GetCenteredPosition()); LayerTile l2 = Map.map.GetTileByWorldPosition(wo.GetCenteredPosition()); cottage.SetCount(cottage.GetCount() + 1); nextTile = l1; currentTile = l2; this.cottage = cottage; Trace.WriteLine(cottage.GetCount()); wo.SetAction(ActionEnum.Enter); if (wo.animation != null) { wo.animation.Cancel(); } wo.animation = new WaveEngine.Components.GameActions.MoveTo2DGameAction(Owner, l1.LocalPosition, TimeSpan.FromSeconds(wo.genericSpeed)); wo.animation.Run(); } }
public async Task <IActionResult> SubmitCottageForm(List <IFormFile> images, CottageFormViewModel vm) { var cottage = new Cottage() { Description = vm.Cottage.Description, ImageGroup = new ImageGroup(), IsVisibleToClient = true, Name = vm.Cottage.Name, PricePerNight = vm.Cottage.PricePerNight }; cottage.ImageGroup.Images = new List <Image>(); WriteImages(images); AddImages(ref cottage, images); await _cottageRepository.AddAysnc(cottage); await _cottageRepository.SaveAsync(); return(RedirectToAction("Index", "Admin")); }
public async Task <IActionResult> DeleteConfirmed(int id) { //Kod för att ändra bokningsstatus Booking cottageBooking = (from m in _context.Booking where m.BookingId == id select m).SingleOrDefault(); var cottageId = cottageBooking.CottageId; Cottage bookingResult = (from m in _context.Cottage where m.CottageId == cottageId select m).SingleOrDefault(); //Bokningsstatus ändrad bookingResult.IsBooked = false; var booking = await _context.Booking.FindAsync(id); _context.Booking.Remove(booking); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
static void Main(string[] args) { var cottage = new Cottage ( 300, 320, 7, 2013, 12, 900000 ); var apartment = new Apartment( 100, 30, 3, 1998, 25, 43000 ); var townhouse = new Townhouse (3000, 240, 10, 2016, 3, 1200000 ); var calculator = new InsuranceСalculator(); Console.WriteLine($"{nameof(cottage)} : {calculator.GetInsurance(cottage):F2}"); Console.WriteLine($"{nameof(apartment)} : {calculator.GetInsurance(apartment):F2}"); Console.WriteLine($"{nameof(townhouse)} : {calculator.GetInsurance(townhouse):F2}"); Console.ReadKey(); }
protected override void Update(TimeSpan gameTime) { if (wo.networkedScene.isHost) { if (wo.GetAction() == ActionEnum.Enter) { LayerTile tile = Map.map.GetTileByWorldPosition(wo.GetCenteredPosition()); if (tile == nextTile) { if (cottage != null && !cottage.IsDestroyed()) { cottage.AddPerson(wo); cottage = null; if (Map.map.GetWorldObject(currentTile.X, currentTile.Y) == null || Map.map.GetWorldObject(currentTile.X, currentTile.Y).IsTraversable(wo)) { //This is common execution path. however, if we came from a water tile because the bridge was destroyed //this should not, and do not, run, effectively not setting the water tile to false, which is not right Map.map.SetTileOccupied(currentTile.X, currentTile.Y, false); Map.map.SetMobile(currentTile.X, currentTile.Y, null); } //nullify coordinates so when destroyed wont set anything free wo.SetX(-1); wo.SetY(-1); nextTile = null; currentTile = null; cottage = null; wo.SetAction(ActionEnum.Inside); } else { ExitCottage(nextTile, currentTile); } } } else if (wo.GetAction() == ActionEnum.Exit) { Map map = Map.map; LayerTile tile = Map.map.GetTileByWorldPosition(wo.GetCenteredPosition()); if (tile == nextTile) { if (map.GetWorldObject(nextTile.X, nextTile.Y) != null && !map.GetWorldObject(nextTile.X, nextTile.Y).IsTraversable(wo)) { if (cottage != null && !cottage.IsDestroyed()) { //If we found water, return back EnterCottage(cottage.wo); } else { //If we found water and the cottage is destroyed, back luck wo.Destroy(); } } else { Map.map.SetMobile(nextTile.X, nextTile.Y, wo); if (tile.LocalPosition == wo.transform.Position) { wo.Stop(); nextTile = null; currentTile = null; cottage = null; } } } } } }
public BookableCottageViewModel() { Cottage = new Cottage(); }
private Holiday CreateHolidayFromPendingBooking(PendingBooking pendingBooking, Cottage cottage, Customer customer, PaymentIntent paymentIntent) { var holiday = new Holiday { Customer = customer, Cottage = cottage, NumberOfAdults = pendingBooking.NumberOfAdults, NumberOfChildren = pendingBooking.NumberOfChildren, NumberOfInfants = pendingBooking.NumberOfInfants, FirstNight = pendingBooking.ArrivalDate, LastNight = pendingBooking.LeavingDate, TotalCost = pendingBooking.TotalCost, CreatedBy = pendingBooking.CreatedBy }; holiday.DepositPaid = paymentIntent.AmountReceived / 100; if (holiday.DepositPaid == holiday.TotalCost) { holiday.PaymentStatus = PaymentStatus.PaidInFull; } else { holiday.PaymentStatus = PaymentStatus.DepositPaid; } _repo.Add <Holiday>(holiday); return(holiday); }
/** * <summary> * Assumes selectedWO is not null. Checks all posible actions between selectedWO and any of the mouse tile WOs * </summary> */ private void HandleAction() { //We can't do anything if we are moving (you'd better not modify that) if (!selectedWO.IsActionBlocking()) { ui.ClearActionButtons(); //As always, when handling actions we must save the instances at the moment //If you remove this lines, when a person tries to exit a cottage, for example, //the tile for exit will be the currentTile below the button at the moment it is pressed (which will probably be null), and not the tile that was selected WorldObject currentWO = null; WorldObject currentMobile = null; LayerTile currentTile = this.currentTile; if (fog == null || fog.IsVisible(currentTile.X, currentTile.Y)) { currentWO = this.currentWO; currentMobile = this.currentMobile; } else if (fog.IsPartiallyVisible(currentTile.X, currentTile.Y)) { currentWO = fog.GetRevealedWO(currentTile.X, currentTile.Y); } foreach (ActionBehavior act in selectedWO.allActions) { if (act.CanShowButton(currentMobile)) { ui.AddAction(act.GetCommandName(currentMobile), () => HandleMovementAction(currentMobile, currentTile, act)); } if (act.CanShowButton(currentWO)) { ui.AddAction(act.GetCommandName(currentWO), () => HandleMovementAction(currentWO, currentTile, act)); } } if (selectedWO.IsMobile()) { //A button to move if "we see" the tile is free if ((currentWO == null || currentWO.IsTraversable(selectedWO)) && (currentMobile == null || currentMobile.IsTraversable(selectedWO))) { ui.AddAction("Move", () => CalculatePathDStar(selectedWO, currentTile)); } } Cottage cottage = selectedWO.Owner.FindComponent <Cottage>(); if (cottage != null) { for (int i = 0; i < cottage.GetPeople().Count; i++) { //Careful with event handlers, actions in loops, because the i variable wont work int aux = i; WorldObject peopleInside = cottage.GetPeople()[aux]; if ((currentMobile == null || currentMobile.IsTraversable(peopleInside)) && (currentWO == null || currentWO.IsTraversable(peopleInside))) { ui.AddAction(string.Format("Exit cottage {0}: {1}", aux + 1, cottage.GetPeople()[aux].GetWoName()), () => SendExit(aux + 1, currentTile)); } } } if (ui.actions.Count == 1) { //if there is only an action, we directly execute it ui.ExecuteAction(0); } else if (ui.actions.Count > 1) { for (int i = 0; i < ui.actions.Count; i++) { //Careful with event handlers, actions in loops, because the i variable wont work int aux = i; if (i >= ui.buttons.Count) { //We have less buttons than actions, create a new one ui.CreateActionButton(); } ui.UpdateActionButton(aux); } ui.optionsAlreadyShown = true; lastActionTile = currentTile; WaveServices.Layout.PerformLayout(Owner.Scene); } } }
protected override void Update(TimeSpan gameTime) { if (!active || !isLocalPlayer) { return; } currentTile = Map.map.GetTileByWorldPosition(GetMousePosition()); //If the wo is inside other (p.e: a cottage) we deselect it if (selectedWO != null && (selectedWO.GetAction() == ActionEnum.Inside || selectedWO.IsDestroyed())) { selectedWO = null; SendSelect(selectedWO); ui.ClearActionButtons(); lastActionTile = null; } if (ui.MouseOverGUI()) { return; } //If we are selecting something we own if (selectedWO != null && !selectedWO.IsDestroyed() && selectedWO.player == this) { if (currentTile != null) { currentMobile = Map.map.GetMobile(currentTile.X, currentTile.Y); currentWO = Map.map.GetWorldObject(currentTile.X, currentTile.Y); //If we are not creating a path if (!readingTiles && selectedWO.IsMobile()) { //But we want to start a new path if (keysBehavior.IsCommandExecuted(CommandEnum.StartPath)) { if (!selectedWO.IsActionBlocking() && map.Adjacent(currentTile, map.GetTileByWorldPosition(selectedWO.GetCenteredPosition()))) { //Start path readingTiles = true; path.Add(Map.map.GetTileByWorldPosition(selectedWO.GetCenteredPosition())); } } } if (readingTiles && keysBehavior.IsCommandExecuted(CommandEnum.AddTile)) { AddTile(); } if (readingTiles && keysBehavior.IsCommandExecuted(CommandEnum.FinishPath)) { //Right button no longer pressed, set path MovementBehavior per = selectedWO.Owner.FindComponent <MovementBehavior>(); if (path.Count > 2 && per != null) { SendPath(path); } readingTiles = false; path.Clear(); } if (keysBehavior.IsCommandExecuted(CommandEnum.ActInTile)) { readingTiles = false; path.Clear(); if (ui.optionsAlreadyShown && currentTile == lastActionTile && selectedWO.IsMobile() && !selectedWO.IsActionBlocking()) { for (int i = 0; i < ui.actions.Count; i++) { if (ui.actions[i].text == "Move") { ui.actions[i].buttonAction(null, null); break; } } lastActionTile = null; } else { HandleAction(); } } //Shortcuts for vicious ones if (keysBehavior.IsCommandExecuted(CommandEnum.Chop)) { Chop(); } if (keysBehavior.IsCommandExecuted(CommandEnum.Fight)) { Fight(); } if (keysBehavior.IsCommandExecuted(CommandEnum.Build)) { Build(); } if (keysBehavior.IsCommandExecuted(CommandEnum.Heal)) { Heal(); } if (keysBehavior.IsCommandExecuted(CommandEnum.Train)) { Train(); } //Cottage shortcuts Cottage cottage = selectedWO.Owner.FindComponent <Cottage>(); if (cottage != null) { if (keysBehavior.IsCommandExecuted(CommandEnum.CottageOne)) { SendExit(1, currentTile); } if (keysBehavior.IsCommandExecuted(CommandEnum.CottageTwo)) { SendExit(2, currentTile); } if (keysBehavior.IsCommandExecuted(CommandEnum.CottageThree)) { SendExit(3, currentTile); } if (keysBehavior.IsCommandExecuted(CommandEnum.CottageFour)) { SendExit(4, currentTile); } if (keysBehavior.IsCommandExecuted(CommandEnum.CottageFive)) { SendExit(5, currentTile); } if (keysBehavior.IsCommandExecuted(CommandEnum.CottageSix)) { SendExit(6, currentTile); } } //Update cottage info any ui.UpdateCottageUI(cottage); } if (keysBehavior.IsCommandExecuted(CommandEnum.Stop)) { SendStop(selectedWO); } if (keysBehavior.IsCommandExecuted(CommandEnum.Destroy)) { Destroy(); } } //Select if (keysBehavior.IsCommandExecuted(CommandEnum.Select)) { lastActionTile = null; Select(); } }
public void SetFromClone(GameState clone) { VictoryPoints = clone.VictoryPoints; Money = clone.Money; NumberOfRounds = clone.NumberOfRounds; ResidualMoney = clone.ResidualMoney; RemainingBonusActions = clone.RemainingBonusActions; Round = clone.Round; Hand.SetFromClone(clone.Hand, Entities); VineDeck.SetFromClone(clone.VineDeck, Entities); OrderDeck.SetFromClone(clone.OrderDeck, Entities); AutomaDeck.SetFromClone(clone.AutomaDeck, Entities); SummerVisitorDeck.SetFromClone(clone.SummerVisitorDeck, Entities); WinterVisitorDeck.SetFromClone(clone.WinterVisitorDeck, Entities); Yoke.SetFromClone(clone.Yoke, Entities); Trellis.SetFromClone(clone.Trellis, Entities); Cottage.SetFromClone(clone.Cottage, Entities); Windmill.SetFromClone(clone.Windmill, Entities); Irigation.SetFromClone(clone.Irigation, Entities); LargeCellar.SetFromClone(clone.LargeCellar, Entities); TastingRoom.SetFromClone(clone.TastingRoom, Entities); MediumCellar.SetFromClone(clone.MediumCellar, Entities); Field1.SetFromClone(clone.Field1, Entities); Field2.SetFromClone(clone.Field2, Entities); Field3.SetFromClone(clone.Field3, Entities); Grande.SetFromClone(clone.Grande, Entities); NeutralWorker.SetFromClone(clone.NeutralWorker, Entities); for (var i = 0; i < 5; i++) { _workers[i].SetFromClone(clone.Workers.ElementAt(i), Entities); } for (int i = 0; i < 9; i++) { _redGrapes[i].SetFromClone(clone._redGrapes[i], Entities); } for (int i = 0; i < 9; i++) { _whiteGrapes[i].SetFromClone(clone._whiteGrapes[i], Entities); } for (int i = 0; i < 9; i++) { _redWines[i].SetFromClone(clone._redWines[i], Entities); } for (int i = 0; i < 9; i++) { _whiteWines[i].SetFromClone(clone._whiteWines[i], Entities); } for (int i = 0; i < 6; i++) { _blushWines[i].SetFromClone(clone._blushWines[i], Entities); } for (int i = 0; i < 3; i++) { _sparklingWines[i].SetFromClone(clone._sparklingWines[i], Entities); } }
public GameState Clone() { var gameState = new GameState(); gameState.VictoryPoints = VictoryPoints; gameState.Money = Money; gameState.NumberOfRounds = NumberOfRounds; gameState.ResidualMoney = ResidualMoney; gameState.RemainingBonusActions = RemainingBonusActions; gameState.Round = Round; gameState.Hand = Hand.Clone() as Hand; gameState.VineDeck = VineDeck.Clone(); gameState.OrderDeck = OrderDeck.Clone(); gameState.AutomaDeck = AutomaDeck.Clone(); gameState.SummerVisitorDeck = SummerVisitorDeck.Clone(); gameState.WinterVisitorDeck = WinterVisitorDeck.Clone(); gameState.Yoke = Yoke.Clone() as Yoke; gameState.Trellis = Trellis.Clone() as Trellis; gameState.Cottage = Cottage.Clone() as Cottage; gameState.Windmill = Windmill.Clone() as Windmill; gameState.Irigation = Irigation.Clone() as Irigation; gameState.LargeCellar = LargeCellar.Clone() as LargeCellar; gameState.TastingRoom = TastingRoom.Clone() as TastingRoom; gameState.MediumCellar = MediumCellar.Clone() as MediumCellar; gameState.Field1 = Field1.Clone() as Field; gameState.Field2 = Field2.Clone() as Field; gameState.Field3 = Field3.Clone() as Field; gameState.Grande = Grande.Clone() as Grande; gameState.NeutralWorker = NeutralWorker.Clone() as Worker; gameState._workers = new List <Worker>(); for (var i = 0; i < 5; i++) { gameState._workers.Add(_workers[i].Clone() as Worker); } gameState._redGrapes = new List <Grape>(); foreach (var redGrape in _redGrapes) { gameState._redGrapes.Add(redGrape.Clone() as Grape); } gameState._whiteGrapes = new List <Grape>(); foreach (var whiteGrape in _whiteGrapes) { gameState._whiteGrapes.Add(whiteGrape.Clone() as Grape); } gameState._redWines = new List <Wine>(); foreach (var redWine in _redWines) { gameState._redWines.Add(redWine.Clone() as Wine); } gameState._whiteWines = new List <Wine>(); foreach (var whiteWine in _whiteWines) { gameState._whiteWines.Add(whiteWine.Clone() as Wine); } gameState._blushWines = new List <Wine>(); foreach (var blushWine in _blushWines) { gameState._blushWines.Add(blushWine.Clone() as Wine); } gameState._sparklingWines = new List <Wine>(); foreach (var sparklingWine in _sparklingWines) { gameState._sparklingWines.Add(sparklingWine.Clone() as Wine); } return(gameState); }
public static ICottage GetCottage() { ICottage cottage = new Cottage(rand.Next().ToString(), rand.Next(), rand.Next(), GetFlat(), GetFlats()); return(cottage); }