//evidenzio l'oggetto selezionato public static void highlightFurniture(Furniture furniture, bool show = true) { GameObject[] border = new GameObject[10]; if (furniture is Construction) { Construction c = furniture as Construction; border[0] = c.border; } else if (furniture is HouseRoom) { HouseRoom hr = furniture as HouseRoom; border = hr.GetBorder; } else { border[0] = furniture.border; } for (var i = 0; i < border.Length; i++) { if (border[i]) { border[i].SetActive((show) ? true : false); } } }
void SomeFunction() { List <Room> rooms = new List <Room>(); List <Forniture> fornitures = new List <Forniture>(); //house House _house = new House(); _house.position = new Position(fixcenter.transform.position.x, fixcenter.transform.position.y, fixcenter.transform.position.z); _house.rotation = new Rotation(fixcenter.transform.rotation.x, fixcenter.transform.rotation.y, fixcenter.transform.rotation.z); _house.scale = new Scale(fixcenter.transform.localScale.x, fixcenter.transform.localScale.y, fixcenter.transform.localScale.z); for (var i = 0; i < fixcenter.transform.childCount; i++) { List <Wall> walls = new List <Wall>(); //evito la stanza 0 perche è un default da non contare //evito il player if (fixcenter.transform.GetChild(i).name == "RoomHide" || fixcenter.transform.GetChild(i).name == "Player") { continue; } //prendo tutte le stanze evitando il player ed ulteriori oggetti if (fixcenter.transform.GetChild(i).GetComponent <HouseRoom>()) { HouseRoom currentRoom = fixcenter.transform.GetChild(i).GetComponent <HouseRoom>(); //room Room _room = new Room(); _room.name = currentRoom.name; _room.position = new Position(currentRoom.transform.position.x, currentRoom.transform.position.y, currentRoom.transform.position.z); _room.rotation = new Rotation(currentRoom.transform.rotation.x, currentRoom.transform.rotation.y, currentRoom.transform.rotation.z); _room.scale = new Scale(currentRoom.transform.localScale.x, currentRoom.transform.localScale.y, currentRoom.transform.localScale.z); //floor Floor _floor = new Floor(); _floor.name = currentRoom.floor.name; _floor.position = new Position(currentRoom.floor.transform.position.x, currentRoom.floor.transform.position.y, currentRoom.floor.transform.position.z); _floor.rotation = new Rotation(currentRoom.floor.transform.rotation.x, currentRoom.floor.transform.rotation.y, currentRoom.floor.transform.rotation.z); _floor.scale = new Scale(currentRoom.floor.transform.localScale.x, currentRoom.floor.transform.localScale.y, currentRoom.floor.transform.localScale.z); _floor.inside = currentRoom.floor.inside.transform.GetComponent <Renderer>().material.mainTexture.name; _floor.outside = currentRoom.floor.outside.transform.GetComponent <Renderer>().material.mainTexture.name; //roof Roof _roof = new Roof(); _roof.name = currentRoom.roof.name; _roof.position = new Position(currentRoom.roof.transform.position.x, currentRoom.roof.transform.position.y, currentRoom.roof.transform.position.z); _roof.rotation = new Rotation(currentRoom.roof.transform.rotation.x, currentRoom.roof.transform.rotation.y, currentRoom.roof.transform.rotation.z); _roof.scale = new Scale(currentRoom.roof.transform.localScale.x, currentRoom.roof.transform.localScale.y, currentRoom.roof.transform.localScale.z); _roof.inside = currentRoom.roof.transform.GetComponent <Renderer>().material.mainTexture.name; _roof.outside = null; //topleftpillar Column _topleft = new Column(); _topleft.left = currentRoom.topLeft.GetleftColor(); _topleft.right = currentRoom.topLeft.GetrightColor(); //toprightpillar Column _topright = new Column(); _topright.left = currentRoom.topRight.GetleftColor(); _topright.right = currentRoom.topRight.GetrightColor(); //bottomleftpillar Column _bottomleft = new Column(); _bottomleft.left = currentRoom.bottomLeft.GetleftColor(); _bottomleft.right = currentRoom.bottomLeft.GetrightColor(); //bottomrightpillar Column _bottomright = new Column(); _bottomright.left = currentRoom.bottomRight.GetleftColor(); _bottomright.right = currentRoom.bottomRight.GetrightColor(); foreach (Construction con in currentRoom.walls) { if (con) { Wall _wall = new Wall(); _wall.name = con.name; _wall.position = new Position(con.transform.localPosition.x, con.transform.localPosition.y, con.transform.localPosition.z); _wall.rotation = new Rotation(con.transform.localEulerAngles.x, con.transform.localEulerAngles.y, con.transform.localEulerAngles.z); _wall.scale = new Scale(con.transform.localScale.x, con.transform.localScale.y, con.transform.localScale.z); //se il muro corrente è Whole o Door if (con.name == "Whole" || con.name == "Door" || con.name == "Window") { //creo un array con il numero di muri inside del muro corrente _wall.insides = new string[4]; //scorro i child dentro insides e salvo il colore for (var k = 0; k < con.transform.FindChild("insides").childCount; k++) { _wall.insides[k] = con.transform.FindChild("insides").GetChild(k).transform.GetComponent <Renderer>().material.mainTexture.name; } //creo un array con il numero di muri outside del muro corrente _wall.outsides = new string[4]; //scorro i child alla ricerca degli outside ed inside e salvo il colore for (var k = 0; k < con.transform.FindChild("outsides").childCount; k++) { _wall.outsides[k] = con.transform.FindChild("outsides").GetChild(k).transform.GetComponent <Renderer>().material.mainTexture.name; } } else { _wall.inside = con.inside.transform.GetComponent <Renderer>().material.mainTexture.name; _wall.outside = con.outside.transform.GetComponent <Renderer>().material.mainTexture.name; } //salvo la direction del muro _wall.direction = con.Direction.ToString(); //aggiungo il muro alla lista walls.Add(_wall); } } //setto il pavimento _room.floor = _floor; //setto il soffitto _room.roof = _roof; //setto i muri _room.walls = walls; //setto i pilastri _room.topleftpillar = _topleft; _room.toprightpillar = _topright; _room.bottomleftpillar = _bottomleft; _room.bottomrightpillar = _bottomright; //aggiungo la stanza in una lista rooms.Add(_room); } //prendo i vari oggetti else if (!fixcenter.transform.GetChild(i).GetComponent <HouseRoom>()) { Furniture currentfurniture = fixcenter.transform.GetChild(i).GetComponent <Furniture>(); Forniture _forniture = new Forniture(); _forniture.name = currentfurniture.name; _forniture.position = new Position(currentfurniture.transform.position.x, currentfurniture.transform.position.y, currentfurniture.transform.position.z); _forniture.rotation = new Rotation(currentfurniture.transform.rotation.x, currentfurniture.transform.rotation.y, currentfurniture.transform.rotation.z); _forniture.scale = new Scale(currentfurniture.transform.localScale.x, currentfurniture.transform.localScale.y, currentfurniture.transform.localScale.z); //aggiungo forniture alla lista fornitures.Add(_forniture); } } _house.rooms = rooms; _house.fornitures = fornitures; //cambio solo i parametri d'aggiornare tipo l'orario dell'ultima modifica e le pos rot scale dei vari oggetti currentproject.lastchanges_date = DateTime.Now.ToString(); currentproject.house = _house; }
public static void SeedHouses(ApplicationDbContext context) { House Nova = new House { HouseName = "Nova", Opens = new TimeSpan(06, 00, 00), Closes = new TimeSpan(23, 00, 00) }; House Lang = new House { HouseName = "Långhuset", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Teknik = new House { HouseName = "Teknikhuset", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Gymnastik = new House { HouseName = "Gymnastikhuset", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Forum = new House { HouseName = "Forumhuset", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Prisma = new House { HouseName = "Prismahuset", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Bilbergska = new House { HouseName = "Bilbergska", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Test = new House { HouseName = "Test", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; context.Houses.AddRange(new[] { Nova, Lang, Teknik, Gymnastik, Forum, Prisma, Bilbergska, Test }); context.SaveChanges(); HouseRoom N2037 = new HouseRoom { Id = "N2037", HouseId = Nova.Id, Projector = true, WhiteBoard = true }; HouseRoom L111 = new HouseRoom { Id = "L1112", HouseId = Lang.Id, Projector = true, WhiteBoard = true }; HouseRoom T133 = new HouseRoom { Id = "T133", HouseId = Teknik.Id, Projector = true, WhiteBoard = true }; HouseRoom G108 = new HouseRoom { Id = "G108", HouseId = Gymnastik.Id, Projector = false, WhiteBoard = true }; HouseRoom F138 = new HouseRoom { Id = "F138", HouseId = Forum.Id, Projector = true, WhiteBoard = true }; HouseRoom P104 = new HouseRoom { Id = "P104", HouseId = Prisma.Id, Projector = false, WhiteBoard = true }; HouseRoom B187 = new HouseRoom { Id = "B187", HouseId = Bilbergska.Id, Projector = false, WhiteBoard = false }; context.Rooms.AddRange(new[] { N2037, L111, T133, G108, F138, P104, B187 }); context.SaveChanges(); AvailableTimes Time1 = new AvailableTimes { RoomId = N2037.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time2 = new AvailableTimes { RoomId = L111.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time3 = new AvailableTimes { RoomId = T133.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time4 = new AvailableTimes { RoomId = G108.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time5 = new AvailableTimes { RoomId = F138.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time6 = new AvailableTimes { RoomId = P104.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time7 = new AvailableTimes { RoomId = B187.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; context.FreeIntervals.AddRange(new[] { Time1, Time2, Time3, Time4, Time5, Time6, Time7 }); context.SaveChanges(); }
// Use this for initialization void Start() { //prendo la lista di item del menu d'arredi items = FurnitureMenu.instance.items; token = SharedVariables.token; currentproject = SharedVariables.currentproject; currentprojectname.text = currentproject.name; //appena caricato il progetto la variabile canLoad la setto false LoadAllProjects.canLoad = false; /* WebClient wc = new WebClient(); * wc.Headers["Content-Type"] = "application/json"; * wc.Headers["Authorization"] = token; * byte[] reply = wc.DownloadData(address + "/api/" + SharedVariables.user._id + "/projects/" + currentproject._id); * string r = System.Text.Encoding.ASCII.GetString(reply); * Project project = JsonMapper.ToObject<Project>(r);*/ if (currentproject.house == null) { return; } //rooms for (var i = 0; i < currentproject.house.rooms.Count; i++) { //room //non faccio il foreach perchè qualsiasi stanza dovrò generare dovrò partire da RoomPrefab GameObject room = null; room = Instantiate(RoomPrefab, fixcenter.transform, false); room.transform.position = new Vector3(currentproject.house.rooms[i].position.x, currentproject.house.rooms[i].position.y, currentproject.house.rooms[i].position.z); room.transform.rotation = new Quaternion(currentproject.house.rooms[i].rotation.x, currentproject.house.rooms[i].rotation.y, currentproject.house.rooms[i].rotation.z, room.transform.rotation.w); room.transform.localScale = new Vector3(currentproject.house.rooms[i].scale.x, currentproject.house.rooms[i].scale.y, currentproject.house.rooms[i].scale.z); room.name = currentproject.house.rooms[i].name; //deve rimanere dopo il for perchè nel for assegno il svalore di room HouseRoom currentroom = room.GetComponent <HouseRoom>(); //roof currentroom.roof.name = currentproject.house.rooms[i].roof.name; currentroom.roof.transform.position = new Vector3(currentproject.house.rooms[i].roof.position.x, currentproject.house.rooms[i].roof.position.y, currentproject.house.rooms[i].roof.position.z); currentroom.roof.transform.rotation = new Quaternion(currentproject.house.rooms[i].roof.rotation.x, currentproject.house.rooms[i].roof.rotation.y, currentproject.house.rooms[i].roof.rotation.z, currentroom.roof.transform.rotation.w); currentroom.roof.transform.localScale = new Vector3(currentproject.house.rooms[i].roof.scale.x, currentproject.house.rooms[i].roof.scale.y, currentproject.house.rooms[i].roof.scale.z); foreach (Sprite s in PatternsManager._sprites) { //il soffitto prende solo la texture inside perchè l'outside non esiste if (s.name == currentproject.house.rooms[i].roof.inside) { currentroom.roof.GetComponent <Renderer>().material.mainTexture = s.texture; } } //floor currentroom.floor.name = currentproject.house.rooms[i].floor.name; currentroom.floor.transform.position = new Vector3(currentproject.house.rooms[i].floor.position.x, currentproject.house.rooms[i].floor.position.y, currentproject.house.rooms[i].floor.position.z); currentroom.floor.transform.rotation = new Quaternion(currentproject.house.rooms[i].floor.rotation.x, currentproject.house.rooms[i].floor.rotation.y, currentproject.house.rooms[i].floor.rotation.z, currentroom.floor.transform.rotation.w); currentroom.floor.transform.localScale = new Vector3(currentproject.house.rooms[i].floor.scale.x, currentproject.house.rooms[i].floor.scale.y, currentproject.house.rooms[i].floor.scale.z); foreach (Sprite s in PatternsManager._sprites) { if (s.name == currentproject.house.rooms[i].floor.inside) { currentroom.floor.inside.GetComponent <Renderer>().material.mainTexture = s.texture; } if (s.name == currentproject.house.rooms[i].floor.outside) { currentroom.floor.outside.GetComponent <Renderer>().material.mainTexture = s.texture; } } //pillars foreach (Sprite s in PatternsManager._sprites) { //topleft if (s.name == currentproject.house.rooms[i].topleftpillar.left) { currentroom.topLeft.SetleftColor(s.texture); } if (s.name == currentproject.house.rooms[i].topleftpillar.right) { currentroom.topLeft.SetrightColor(s.texture); } //topright if (s.name == currentproject.house.rooms[i].toprightpillar.left) { currentroom.topLeft.SetleftColor(s.texture); } if (s.name == currentproject.house.rooms[i].toprightpillar.right) { currentroom.topLeft.SetrightColor(s.texture); } //bottomleft if (s.name == currentproject.house.rooms[i].bottomleftpillar.left) { currentroom.bottomLeft.SetleftColor(s.texture); } if (s.name == currentproject.house.rooms[i].bottomleftpillar.right) { currentroom.bottomLeft.SetrightColor(s.texture); } //bottomright if (s.name == currentproject.house.rooms[i].bottomrightpillar.left) { currentroom.bottomRight.SetleftColor(s.texture); } if (s.name == currentproject.house.rooms[i].bottomrightpillar.right) { currentroom.bottomRight.SetrightColor(s.texture); } } //walls for (var j = 0; j < currentproject.house.rooms[i].walls.Count; j++) { //scorro la lista degli item per verificare il nome ed instanziare l'oggetto esatto for (var z = 0; z < items.Count; z++) { //controllo che l'item dentro la lista sia di tipo Construction perchè la lista presenta oggetti di diverso tipo if (items[z].name == currentproject.house.rooms[i].walls[j].name && items[z] is Construction) { GameObject wall = Instantiate(items[z].gameObject, room.transform, false); wall.transform.localPosition = new Vector3(currentproject.house.rooms[i].walls[j].position.x, currentproject.house.rooms[i].walls[j].position.y, currentproject.house.rooms[i].walls[j].position.z); wall.transform.eulerAngles = new Vector3(currentproject.house.rooms[i].walls[j].rotation.x, currentproject.house.rooms[i].walls[j].rotation.y, currentproject.house.rooms[i].walls[j].rotation.z); wall.transform.localScale = new Vector3(currentproject.house.rooms[i].walls[j].scale.x, currentproject.house.rooms[i].walls[j].scale.y, currentproject.house.rooms[i].walls[j].scale.z); wall.name = currentproject.house.rooms[i].walls[j].name; if (wall.name == "Whole" || wall.name == "Door" || wall.name == "Window") { for (var k = 0; k < wall.transform.FindChild("insides").childCount; k++) { foreach (Sprite s in PatternsManager._sprites) { if (s.name == currentproject.house.rooms[i].walls[j].insides[k]) { wall.transform.FindChild("insides").GetChild(k).GetComponent <Renderer>().material.mainTexture = s.texture; } } } for (var k = 0; k < wall.transform.FindChild("outsides").childCount; k++) { foreach (Sprite s in PatternsManager._sprites) { if (s.name == currentproject.house.rooms[i].walls[j].outsides[k]) { wall.transform.FindChild("outsides").GetChild(k).GetComponent <Renderer>().material.mainTexture = s.texture; } } } } else { foreach (Sprite s in PatternsManager._sprites) { if (s.name == currentproject.house.rooms[i].walls[j].inside) { wall.GetComponent <Construction>().inside.GetComponent <Renderer>().material.mainTexture = s.texture; } if (s.name == currentproject.house.rooms[i].walls[j].outside) { wall.GetComponent <Construction>().outside.GetComponent <Renderer>().material.mainTexture = s.texture; } } } wall.GetComponent <Construction>().Direction = (Construction.Directions)Enum.Parse(typeof(Construction.Directions), currentproject.house.rooms[i].walls[j].direction); //aggiungo i muri nella stanza //assegno il muro nella sua posizione in base al nome if (wall.GetComponent <Construction>().Direction == Construction.Directions.Front) { currentroom.front = wall.GetComponent <Construction>(); } else if (wall.GetComponent <Construction>().Direction == Construction.Directions.Back) { currentroom.back = wall.GetComponent <Construction>(); } else if (wall.GetComponent <Construction>().Direction == Construction.Directions.Left) { currentroom.left = wall.GetComponent <Construction>(); } else if (wall.GetComponent <Construction>().Direction == Construction.Directions.Right) { currentroom.right = wall.GetComponent <Construction>(); } currentroom.walls[j] = wall.GetComponent <Construction>(); } } } } //fornitures for (var k = 0; k < currentproject.house.fornitures.Count; k++) { //scorro la lista degli item per verificare il nome ed instanziare l'oggetto esatto foreach (Furniture i in items) { //controllo che l'item dentro la lista non sia di tipo HouseRoom 0 Construction perchè la lista presenta oggetti di diverso tipo if (i is HouseRoom || i is Construction) { continue; } if (i.name == currentproject.house.fornitures[k].name) { GameObject forniture = Instantiate(i.gameObject, fixcenter.transform, false); forniture.transform.position = new Vector3(currentproject.house.fornitures[k].position.x, currentproject.house.fornitures[k].position.y, currentproject.house.fornitures[k].position.z); forniture.transform.rotation = new Quaternion(currentproject.house.fornitures[k].rotation.x, currentproject.house.fornitures[k].rotation.y, currentproject.house.fornitures[k].rotation.z, forniture.transform.rotation.w); forniture.transform.localScale = new Vector3(currentproject.house.fornitures[k].scale.x, currentproject.house.fornitures[k].scale.y, currentproject.house.fornitures[k].scale.z); forniture.name = currentproject.house.fornitures[k].name; } } } }
//public static byte[] setInitializerProfilePicture(string endPath) { // // Setting default avatar for all profiles // string path = AppDomain.CurrentDomain.BaseDirectory + endPath; // FileStream file = new FileStream(path, FileMode.Open); // byte[] avatar = null; // using (var binary = new BinaryReader(file)) { // avatar = binary.ReadBytes((int)file.Length); // } // return avatar; //} public static void SeedHouses(ApplicationDbContext context) { // Create the users UserStore <ApplicationUser> store = new UserStore <ApplicationUser>(context); UserManager <ApplicationUser> manager = new UserManager <ApplicationUser>(store); House Nova = new House { HouseName = "Nova", Opens = new TimeSpan(06, 00, 00), Closes = new TimeSpan(23, 00, 00) }; House Lang = new House { HouseName = "Långhuset", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Teknik = new House { HouseName = "Teknikhuset", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Gymnastik = new House { HouseName = "Gymnastikhuset", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Forum = new House { HouseName = "Forumhuset", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Prisma = new House { HouseName = "Prismahuset", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Bilbergska = new House { HouseName = "Bilbergska", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; House Test = new House { HouseName = "Test", Opens = new TimeSpan(00, 00, 00), Closes = new TimeSpan(23, 59, 59) }; context.Houses.AddRange(new[] { Nova, Lang, Teknik, Gymnastik, Forum, Prisma, Bilbergska, Test }); context.SaveChanges(); HouseRoom N2037 = new HouseRoom { Id = "N2037", HouseId = Nova.Id, Projector = true, WhiteBoard = true }; HouseRoom L111 = new HouseRoom { Id = "L1112", HouseId = Lang.Id, Projector = true, WhiteBoard = true }; HouseRoom T133 = new HouseRoom { Id = "T133", HouseId = Teknik.Id, Projector = true, WhiteBoard = true }; HouseRoom G108 = new HouseRoom { Id = "G108", HouseId = Gymnastik.Id, Projector = false, WhiteBoard = true }; HouseRoom F138 = new HouseRoom { Id = "F138", HouseId = Forum.Id, Projector = true, WhiteBoard = true }; HouseRoom P104 = new HouseRoom { Id = "P104", HouseId = Prisma.Id, Projector = false, WhiteBoard = true }; HouseRoom B187 = new HouseRoom { Id = "B187", HouseId = Bilbergska.Id, Projector = false, WhiteBoard = false }; context.Rooms.AddRange(new[] { N2037, L111, T133, G108, F138, P104, B187 }); context.SaveChanges(); AvailableTimes Time1 = new AvailableTimes { RoomId = N2037.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time2 = new AvailableTimes { RoomId = L111.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time3 = new AvailableTimes { RoomId = T133.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time4 = new AvailableTimes { RoomId = G108.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time5 = new AvailableTimes { RoomId = F138.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time6 = new AvailableTimes { RoomId = P104.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; AvailableTimes Time7 = new AvailableTimes { RoomId = B187.Id, From = new TimeSpan(09, 00, 00), To = new TimeSpan(10, 00, 00) }; context.FreeIntervals.AddRange(new[] { Time1, Time2, Time3, Time4, Time5, Time6, Time7 }); context.SaveChanges(); //ApplicationUser eliasU = new ApplicationUser { // UserName = "******", // Email = "*****@*****.**", //}; //manager.Create(eliasU, "password"); //ApplicationUser nicoU = new ApplicationUser { // UserName = "******", // Email = "*****@*****.**" //}; //manager.Create(nicoU, "password"); //ApplicationUser oskarU = new ApplicationUser { // UserName = "******", // Email = "*****@*****.**" //}; //manager.Create(oskarU, "password"); //ApplicationUser randomU = new ApplicationUser { // UserName = "******", // Email = "*****@*****.**" //}; //manager.Create(randomU, "password"); //ApplicationUser corazonU = new ApplicationUser { // UserName = "******", // Email = "*****@*****.**" //}; //manager.Create(corazonU, "password"); //ApplicationUser andreasU = new ApplicationUser { // UserName = "******", // Email = "*****@*****.**" //}; //manager.Create(andreasU, "password"); //ApplicationUser mathiasU = new ApplicationUser { // UserName = "******", // Email = "*****@*****.**" //}; //manager.Create(mathiasU, "password"); //ApplicationUser lightU = new ApplicationUser { // UserName = "******", // Email = "*****@*****.**" //}; //manager.Create(lightU, "password"); //ApplicationUser hakU = new ApplicationUser { // UserName = "******", // Email = "*****@*****.**" //}; //manager.Create(hakU, "password"); //ApplicationUser alfonsU = new ApplicationUser { // UserName = "******", // Email = "*****@*****.**" //}; //manager.Create(alfonsU, "password"); //// Define friendships //FriendModels friends1 = new FriendModels { // UserId = nicoU.Id, // FriendId = oskarU.Id, // FriendCategory = category1.Id //}; //FriendModels friends2 = new FriendModels { // UserId = nicoU.Id, // FriendId = eliasU.Id, // FriendCategory = category2.Id //}; //FriendModels friends3 = new FriendModels { // UserId = eliasU.Id, // FriendId = corazonU.Id, // FriendCategory = category3.Id //}; //FriendModels friends4 = new FriendModels { // UserId = oskarU.Id, // FriendId = randomU.Id, // FriendCategory = category1.Id //}; //FriendModels friends5 = new FriendModels { // UserId = oskarU.Id, // FriendId = alfonsU.Id, // FriendCategory = category1.Id //}; //FriendModels friends6 = new FriendModels { // UserId = eliasU.Id, // FriendId = lightU.Id, // FriendCategory = category1.Id //}; //FriendModels friends7 = new FriendModels { // UserId = andreasU.Id, // FriendId = eliasU.Id, // FriendCategory = category1.Id //}; //FriendModels friends8 = new FriendModels { // UserId = nicoU.Id, // FriendId = hakU.Id, // FriendCategory = category1.Id //}; //context.Friends.AddRange(new[] { friends1, friends2, friends3, friends4, friends5, friends6, friends7, friends8 }); // Add friendships //context.SaveChanges(); }
void GenerateUI() { foreach (Furniture item in items) { Transform t = null; Furniture newItem = null; //decido il container in cui andrà l'item da istanziare in base al tipo di oggetto if (item is Construction) { newItem = item.GetComponent <Construction>(); t = Constructions_container.transform; } else if (item is HouseRoom) { newItem = item.GetComponent <HouseRoom>(); t = Rooms_container.transform; } else { newItem = item.GetComponent <Furniture>(); t = Interios_container.transform; } GameObject go = Instantiate(itemPrefab, t, false); go.transform.FindChild("Text").GetComponent <Text>().text = newItem.name; go.transform.FindChild("Image").GetComponent <Image>().sprite = newItem.icon; go.GetComponent <Button>().onClick.AddListener(() => { //se l'item corrente è di tipo construction if (item is Construction) { //se c'è un 'oggetto selezionato di tipo construction cambia quel muro con questo se no evito d'istanziarlo if (SelectFurniture.currentFurniture is Construction) { GameObject _go = Instantiate(item.gameObject, SelectFurniture.currentFurniture.transform.parent, false); _go.transform.localRotation = SelectFurniture.currentFurniture.transform.localRotation; _go.transform.localPosition = SelectFurniture.currentFurniture.transform.localPosition; //prendo solo la parte prima dei (clone) e la assegno come nome _go.name = _go.name.Split('(')[0]; //salvo in in una variabile l'oggetto che poi distruggerò GameObject _lastWall = SelectFurniture.currentFurniture.gameObject; //deseleziono l'oggetto corrente SelectFurniture._DeselectFurniture(); //seleziono il nuovo oggetto SelectFurniture._SelectFurniture(_go.GetComponent <Construction>()); /////////////////////////////// //_go.transform.GetComponent<Construction>().name = _lastWall.transform.GetComponent<Construction>().name; //la stanza corrente HouseRoom hr = _go.transform.parent.GetComponent <HouseRoom>(); for (int i = 0; i < hr.walls.Length; i++) { //trovo nell'array la posizione del vecchio muro per metterci al suo posto il nuovo muro if (hr.walls[i].gameObject.Equals(_lastWall)) { hr.walls[i] = _go.transform.GetComponent <Construction>(); if (hr.walls[i].Direction == Construction.Directions.Left) { hr.left = _go.transform.GetComponent <Construction>(); //imposto la direction del muro che sto cambiando con la direction del muro vecchio _go.transform.GetComponent <Construction>().Direction = Construction.Directions.Left; } else if (hr.walls[i].Direction == Construction.Directions.Right) { hr.right = _go.transform.GetComponent <Construction>(); //imposto la direction del muro che sto cambiando con la direction del muro vecchio _go.transform.GetComponent <Construction>().Direction = Construction.Directions.Right; } else if (hr.walls[i].Direction == Construction.Directions.Front) { hr.front = _go.transform.GetComponent <Construction>(); //imposto la direction del muro che sto cambiando con la direction del muro vecchio _go.transform.GetComponent <Construction>().Direction = Construction.Directions.Front; } else if (hr.walls[i].Direction == Construction.Directions.Back) { hr.back = _go.transform.GetComponent <Construction>(); //imposto la direction del muro che sto cambiando con la direction del muro vecchio _go.transform.GetComponent <Construction>().Direction = Construction.Directions.Back; } } } //distruggo l'oggetto precedente Destroy(_lastWall); return; } else { return; } } GameObject obj = Instantiate(item.gameObject, house.transform); Furniture f = null; Vector3 pos = Vector3.zero; if (newItem is HouseRoom) { pos = roomPrefab.transform.position; f = obj.GetComponent <HouseRoom>(); } else if (newItem is Construction) { f = obj.GetComponent <Construction>(); } else { pos = new Vector3(roomPrefab.transform.position.x, roomPrefab.transform.position.y + 0.5f, roomPrefab.transform.position.z); f = obj.GetComponent <Furniture>(); } obj.transform.position = pos; obj.transform.rotation = obj.transform.rotation; //seleziono l'oggetto corrente SelectFurniture._SelectFurniture(f); }); } }