public void ApplyPost() { var mockUser = University.GetUser("a101"); var stickerType = University.GetStickerTypes(mockUser.Category).FirstOrDefault(); var mockData = new StickerApplication { SelectedType = stickerType.ID.ToString(), Vehicle = new Vehicle { OwnerName = "Test Owner", PlateNumber = "06ZZ1234", RegistrationNumber = "ZZ123456" } }; StickerController controller = new StickerController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockUser).Object, new RouteData(), controller); RedirectToRouteResult result = controller.Apply(mockData) as RedirectToRouteResult; Assert.IsNotNull(result); Assert.AreEqual("1", result.RouteValues["ok"]); Assert.AreEqual("Index", result.RouteValues["action"]); ViewResult indexResult = controller.Index() as ViewResult; Assert.IsNotNull(indexResult); Assert.IsInstanceOfType(indexResult.Model, typeof(List <StickerApplication>)); List <StickerApplication> model = indexResult.Model as List <StickerApplication>; Assert.AreNotEqual(0, model.Count); Assert.AreEqual("06ZZ1234", model.FirstOrDefault().Vehicle.PlateNumber); }
public void ResponseFail() { var mockApproveUser = University.GetUser("e201"); //get Applications StickerController sc = new StickerController(); sc.ControllerContext = new ControllerContext(MockAuthContext(mockApproveUser).Object, new RouteData(), sc); ViewResult indexResult = sc.Index() as ViewResult; Assert.IsNotNull(indexResult); Assert.IsInstanceOfType(indexResult.Model, typeof(List <StickerApplication>)); //find application waiting for payment List <StickerApplication> listModel = indexResult.Model as List <StickerApplication>; Assert.AreNotEqual(0, listModel.Count); StickerApplication application = listModel.Find(m => m.Status == StickerApplicationStatus.WaitingForPayment); Assert.IsNotNull(application); Assert.AreEqual(StickerApplicationStatus.WaitingForPayment, application.Status); //pay PayController controller = new PayController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockApproveUser).Object, new RouteData(), controller); PaymentResponseFail pr = new PaymentResponseFail() { TransId = "TEST-Transaction-002", ReturnOid = application.ID.ToString() + "-TestOrder", mdStatus = 4, Response = "error", ErrMsg = "Test Error Message" }; RedirectToRouteResult result = controller.Fail(pr) as RedirectToRouteResult; Assert.IsNotNull(result); Assert.AreEqual("Pay", result.RouteValues["controller"]); Assert.AreEqual("Index", result.RouteValues["action"]); Assert.AreEqual(application.ID.ToString(), result.RouteValues["Id"]); Assert.IsNotNull(result.RouteValues["hasError"]); //get updated list ViewResult indexResultR = sc.Index() as ViewResult; Assert.IsNotNull(indexResultR); Assert.IsInstanceOfType(indexResultR.Model, typeof(List <StickerApplication>)); List <StickerApplication> listModelR = indexResultR.Model as List <StickerApplication>; Assert.AreNotEqual(0, listModelR.Count); StickerApplication applicationR = listModelR.Find(m => m.ID == application.ID); Assert.IsNotNull(applicationR); Assert.AreEqual(StickerApplicationStatus.WaitingForPayment, applicationR.Status); }
public void ResponseOk() { var mockApproveUser = University.GetUser("e101"); //get Applications StickerController sc = new StickerController(); sc.ControllerContext = new ControllerContext(MockAuthContext(mockApproveUser).Object, new RouteData(), sc); ViewResult indexResult = sc.Index() as ViewResult; Assert.IsNotNull(indexResult); Assert.IsInstanceOfType(indexResult.Model, typeof(List <StickerApplication>)); //find application waiting for payment List <StickerApplication> listModel = indexResult.Model as List <StickerApplication>; Assert.AreNotEqual(0, listModel.Count); StickerApplication application = listModel.Find(m => m.Status == StickerApplicationStatus.WaitingForPayment); Assert.IsNotNull(application); Assert.AreEqual(StickerApplicationStatus.WaitingForPayment, application.Status); //pay PayController controller = new PayController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockApproveUser).Object, new RouteData(), controller); PaymentResponseSuccess pr = new PaymentResponseSuccess() { amount = application.Quota.StickerFee, TransId = "TEST-Transaction-001", ReturnOid = application.ID.ToString() + "-TestOrder", mdStatus = 4, Response = "success" }; RedirectToRouteResult result = controller.Ok(pr) as RedirectToRouteResult; Assert.IsNotNull(result); Assert.AreEqual("Sticker", result.RouteValues["controller"]); Assert.AreEqual("Index", result.RouteValues["action"]); Assert.IsNotNull(result.RouteValues["paymentok"]); //get updated list to be sure application status is not updated ViewResult indexResultR = sc.Index() as ViewResult; Assert.IsNotNull(indexResultR); Assert.IsInstanceOfType(indexResultR.Model, typeof(List <StickerApplication>)); List <StickerApplication> listModelR = indexResultR.Model as List <StickerApplication>; Assert.AreNotEqual(0, listModelR.Count); StickerApplication applicationR = listModelR.Find(m => m.ID == application.ID); Assert.IsNotNull(applicationR); Assert.AreEqual(StickerApplicationStatus.WaitingForDelivery, applicationR.Status); }
public void ApplyGetMethod() { var mockUser = University.GetUser("a101"); StickerController controller = new StickerController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockUser).Object, new RouteData(), controller); ViewResult result = controller.Apply() as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(StickerApplication)); }
public void DetailNotAllowed() { var mockUser = University.GetUser("e100"); StickerController controller = new StickerController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockUser).Object, new RouteData(), controller); ActionResult result = controller.Detail(2); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(HttpUnauthorizedResult)); }
public void IndexFilteredThenApprove() { var mockApproveUser = University.GetUser("o101"); ApproveController controller = new ApproveController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockApproveUser).Object, new RouteData(), controller); //get list ViewResult result = controller.Index("", "", "Test Student11", 1) as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(PagedList <StickerApplication>)); PagedList <StickerApplication> model = result.Model as PagedList <StickerApplication>; Assert.AreEqual(0, model.Where(a => a.Status != StickerApplicationStatus.WaitingForApproval).Count()); Assert.AreEqual(1, model.Count); //approve StickerApplication stickerApplication = model.FirstOrDefault(); List <ApprovementOption> approvementOptions = stickerApplication.GetApprovementOptions(); Assert.AreEqual(2, approvementOptions.Count); ApprovementOption otherOption = approvementOptions.Where(a => a.QuotaID != stickerApplication.Quota.ID).FirstOrDefault(); controller.Approve(stickerApplication.ID, otherOption.QuotaID); //get list result = controller.Index("", "", "Test Student11", 1) as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(PagedList <StickerApplication>)); model = result.Model as PagedList <StickerApplication>; Assert.AreEqual(0, model.Count); //applications index page for user StickerController scontroller = new StickerController { ControllerContext = new ControllerContext(MockAuthContext(University.GetUser(stickerApplication.User.UID)).Object, new RouteData(), controller) }; ViewResult sresult = scontroller.Index() as ViewResult; Assert.IsNotNull(sresult); Assert.IsInstanceOfType(sresult.Model, typeof(List <StickerApplication>)); List <StickerApplication> smodel = sresult.Model as List <StickerApplication>; Assert.AreNotEqual(0, smodel.Count); Assert.AreEqual(StickerApplicationStatus.WaitingForPayment, smodel.FirstOrDefault().Status); }
public void IndexFilteredThenApprove() { var mockDeliverUser = University.GetUser("o102"); DeliverController controller = new DeliverController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockDeliverUser).Object, new RouteData(), controller); //get list ViewResult result = controller.Index("", "", "Test Student13", 1) as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(PagedList <StickerApplication>)); PagedList <StickerApplication> model = result.Model as PagedList <StickerApplication>; Assert.AreEqual(0, model.Where(a => a.Status != StickerApplicationStatus.WaitingForDelivery).Count()); Assert.AreEqual(1, model.Count); //deliver StickerApplication stickerApplication = model.FirstOrDefault(); controller.Deliver(stickerApplication.ID, new Sticker { SerialNumber = 1 }); //get list result = controller.Index("", "", "Test Student13", 1) as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(PagedList <StickerApplication>)); model = result.Model as PagedList <StickerApplication>; Assert.AreEqual(0, model.Count); //applications index page for user StickerController scontroller = new StickerController { ControllerContext = new ControllerContext(MockAuthContext(University.GetUser(stickerApplication.User.UID)).Object, new RouteData(), controller) }; ViewResult sresult = scontroller.Index() as ViewResult; Assert.IsNotNull(sresult); Assert.IsInstanceOfType(sresult.Model, typeof(List <StickerApplication>)); List <StickerApplication> smodel = sresult.Model as List <StickerApplication>; Assert.AreNotEqual(0, smodel.Count); Assert.AreEqual(StickerApplicationStatus.Active, smodel.FirstOrDefault().Status); Assert.AreEqual(1, smodel.FirstOrDefault().Sticker.SerialNumber); }
public void InvalidateSticker() { var mockUser = University.GetUser("o103"); InvalidateController controller = new InvalidateController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockUser).Object, new RouteData(), controller); ViewResult result = controller.Index("", "", "", 1) as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(PagedList <StickerApplication>)); PagedList <StickerApplication> applications = result.Model as PagedList <StickerApplication>; Assert.IsTrue(applications.Count > 0, "No active stickers found"); StickerApplication application = applications.FirstOrDefault(); Assert.IsNotNull(application); Assert.AreEqual(StickerApplicationStatus.Active, application.Status); StickerApplication invalidatedApplication = application; RedirectToRouteResult invalidateResult = controller.Invalidate(application.ID) as RedirectToRouteResult; Assert.AreEqual(1, invalidateResult.RouteValues["success"]); Assert.AreEqual("Index", invalidateResult.RouteValues["action"]); result = controller.Index("", "", "", 1) as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(PagedList <StickerApplication>)); applications = result.Model as PagedList <StickerApplication>; StickerApplication testApplication = applications.FirstOrDefault(a => a.ID == invalidatedApplication.ID); Assert.IsNull(testApplication, "Invalidated sticker still listed as Active"); //applications index page for user StickerController scontroller = new StickerController { ControllerContext = new ControllerContext(MockAuthContext(University.GetUser(invalidatedApplication.User.UID)).Object, new RouteData(), controller) }; ViewResult sresult = scontroller.Index() as ViewResult; Assert.IsNotNull(sresult); Assert.IsInstanceOfType(sresult.Model, typeof(List <StickerApplication>)); List <StickerApplication> smodel = sresult.Model as List <StickerApplication>; Assert.AreNotEqual(0, smodel.Count); Assert.AreEqual(StickerApplicationStatus.Invalidated, smodel.FirstOrDefault().Status); }
public void DetailwithApprovalUser() { var mockUser = University.GetUser("o101"); StickerController controller = new StickerController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockUser).Object, new RouteData(), controller); ViewResult result = controller.Detail(1) as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(StickerApplication)); StickerApplication model = result.Model as StickerApplication; Assert.AreEqual(1, model.ID); }
public void IndexWithDataTest() { var mockUser = University.GetUser("e100"); StickerController controller = new StickerController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockUser).Object, new RouteData(), controller); ViewResult result = controller.Index() as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(List <StickerApplication>)); List <StickerApplication> model = result.Model as List <StickerApplication>; Assert.AreNotEqual(0, model.Count); Assert.AreEqual(1, model.FirstOrDefault().ID); }
private void SetupTabSticker(JewelControl jewel, StoreTab tab) { if (this.parentStoreScreen.IsTabLocked(tab)) { this.HideStickerVisuals(tab); return; } StickerType stickerTypeFromStoreTab = this.GetStickerTypeFromStoreTab(tab); StickerController stickerController = Service.StickerController; StickerVO storeStickerToDisplay = stickerController.GetStoreStickerToDisplay(stickerTypeFromStoreTab); jewel.EndTime = 0; if (storeStickerToDisplay == null) { jewel.Cleanup(); this.HideStickerVisuals(tab); return; } jewel.EndTime = storeStickerToDisplay.EndTime; this.SetupStickerVisuals(tab, storeStickerToDisplay); }
private void SetupCrystalsSticker(JewelControl jewel) { StickerController stickerController = Service.StickerController; StickerVO storeStickerToDisplay = stickerController.GetStoreStickerToDisplay(StickerType.CrystalShop); Lang lang = Service.Lang; bool flag = storeStickerToDisplay != null && this.parentStoreScreen.HasInAppPurchaseItems(); this.parentStoreScreen.GetElement <UXElement>("PanelCrystalsSpecial").Visible = false; this.parentStoreScreen.GetElement <UXElement>("WidgetCrystalsNormal").Visible = true; jewel.EndTime = 0; if (!flag) { jewel.Cleanup(); return; } jewel.EndTime = storeStickerToDisplay.EndTime; string assetName = "storeicon_lg_crystals_special"; string factionBasedTextureAsset = stickerController.GetFactionBasedTextureAsset(storeStickerToDisplay); if (!string.IsNullOrEmpty(factionBasedTextureAsset)) { assetName = factionBasedTextureAsset; } this.parentStoreScreen.GetElement <UXTexture>("TextureCrystalsIconSpecial").LoadTexture(assetName, new Action(this.OnCrystalsSpecialTextureLoaded)); jewel.Text = lang.Get(storeStickerToDisplay.LabelText, new object[0]); string iconAsset = storeStickerToDisplay.IconAsset; bool flag2 = !string.IsNullOrEmpty(iconAsset); if (flag2) { jewel.Icon = iconAsset; } this.parentStoreScreen.GetElement <UXElement>("particlesJewelCrystals").Visible = flag2; if (jewel.TimerLabel != null) { jewel.TimerLabel.TextColor = UXUtils.COLOR_CRYSTALS_EXPIRE_LABEL_NORMAL; CountdownControl countdownControl = new CountdownControl(jewel.TimerLabel, lang.Get("crystal_sale_sticker_expiration_timer", new object[0]), storeStickerToDisplay.EndTime); countdownControl.SetThreshold(GameConstants.CRYSTAL_STORE_SALE_EXPIRATION_TIMER_WARNING, UXUtils.COLOR_CRYSTALS_EXPIRE_LABEL_WARNING); } }
public void IndexWithoutData() { var mockUser = new User() { UID = "e100" }; var mockData = new List <StickerApplication>(); var mockDbSet = new Mock <DbSet <StickerApplication> >().SetupData(mockData); var dbctx = new Mock <DatabaseContext>(); dbctx.Setup(c => c.StickerApplications).Returns(mockDbSet.Object); StickerController controller = new StickerController(dbctx.Object); controller.ControllerContext = new ControllerContext(MockAuthContext(mockUser).Object, new RouteData(), controller); RedirectToRouteResult result = controller.Index() as RedirectToRouteResult; Assert.IsNotNull(result); Assert.AreEqual("action", result.RouteValues.Keys.FirstOrDefault()); Assert.AreEqual("Apply", result.RouteValues.Values.FirstOrDefault()); }
public void ApplyPostForNoMoreSticker() { var mockUser = University.GetUser("e101"); var stickerType = University.GetStickerTypes(mockUser.Category).FirstOrDefault(); var mockData = new StickerApplication { SelectedType = stickerType.ID.ToString(), Vehicle = new Vehicle { OwnerName = "Test Owner", PlateNumber = "06ZZ1234", RegistrationNumber = "ZZ123456" } }; StickerController controller = new StickerController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockUser).Object, new RouteData(), controller); RedirectToRouteResult result = controller.Apply(mockData) as RedirectToRouteResult; Assert.IsNotNull(result); Assert.AreEqual("1", result.RouteValues["nomoresticker"]); Assert.AreEqual("Sticker", result.RouteValues["controller"]); Assert.AreEqual("Index", result.RouteValues["action"]); }
public void ApplyRenew() { var mockUser = University.GetUser("e103"); var stickerType = University.GetStickerTypes(mockUser.Category).FirstOrDefault(); StickerController controller = new StickerController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockUser).Object, new RouteData(), controller); ViewResult result = controller.Index() as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(List <StickerApplication>)); StickerApplication oldApplication = ((List <StickerApplication>)result.Model).FirstOrDefault(); Assert.IsNotNull(oldApplication); Assert.IsTrue(oldApplication.Term.IsExpired); RedirectToRouteResult renewResult = controller.Renew(oldApplication.ID) as RedirectToRouteResult; Assert.AreEqual("1", renewResult.RouteValues["ok"]); Assert.AreEqual("Index", renewResult.RouteValues["action"]); result = controller.Index() as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(List <StickerApplication>)); List <StickerApplication> applications = result.Model as List <StickerApplication>; Assert.AreEqual(2, applications.Count); StickerApplication newApplication = applications.FirstOrDefault(a => a.ID != oldApplication.ID); oldApplication = applications.FirstOrDefault(a => a.ID == oldApplication.ID); Assert.IsFalse(newApplication.Term.IsExpired); Assert.AreEqual(StickerApplicationStatus.Expired, oldApplication.Status); Assert.AreEqual(StickerApplicationStatus.WaitingForApproval, newApplication.Status); }
public void Index() { var mockApproveUser = University.GetUser("e201"); //get Applications StickerController sc = new StickerController(); sc.ControllerContext = new ControllerContext(MockAuthContext(mockApproveUser).Object, new RouteData(), sc); ViewResult indexResult = sc.Index() as ViewResult; Assert.IsNotNull(indexResult); Assert.IsInstanceOfType(indexResult.Model, typeof(List <StickerApplication>)); //find application waiting for payment List <StickerApplication> listModel = indexResult.Model as List <StickerApplication>; Assert.AreNotEqual(0, listModel.Count); StickerApplication application = listModel.Find(m => m.Status == StickerApplicationStatus.WaitingForPayment); Assert.IsNotNull(application); PayController controller = new PayController(); controller.ControllerContext = new ControllerContext(MockAuthContext(mockApproveUser).Object, new RouteData(), controller); ViewResult result = controller.Index(application.ID) as ViewResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result.Model, typeof(PaymentRequest)); PaymentRequest model = result.Model as PaymentRequest; Assert.IsNotNull(model.Application); Assert.IsNotNull(model.Application.Quota); Assert.IsNotNull(model.Application.Quota.StickerFee); Assert.AreEqual(model.Application.Quota.StickerFee, application.Quota.StickerFee); }
void showPlaceHolders(string id, Transform zeroP, ACityAPIDev.StickerInfo[] stickers) { if (id != null) { /*Debug.Log("zeroPpos = " + zeroP.position.x + " " + zeroP.position.y + " " + zeroP.position.z); * Debug.Log("zeroPori = " + zeroP.eulerAngles.x + " " + zeroP.eulerAngles.y + " " + zeroP.eulerAngles.z);*/ GameObject placeHolderParent; placeHolderParent = checkSavedID(id); /*if (pcloud == null) * { * pcloud = GetComponent<plyreader>().GetPointCloud(); * if (pcloud != null) * { * pcloud.transform.position = zeroP.position; * pcloud.transform.rotation = zeroP.rotation; * } * }*/ setTimeForRelocation(PlayerPrefs.GetFloat("TimeForRelocation")); if (placeHolderParent == null) // if it's first time we need to generate a new scene { if (stickers != null) // nothing to do at the empty scene, no objects to create for { GameObject scaleParent = new GameObject("CamParent-" + id); // add 'id' into the name scaleParent.transform.position = arCamCoordinates; placeHolderParent = new GameObject(id); placeHolderParent.transform.position = zeroP.position; placeHolderParent.transform.rotation = zeroP.rotation; activeReco = placeHolderParent; for (int j = 0; j < stickers.Length; j++) { // Placeholders for (int i = 0; i < 4; i++) { GameObject go = Instantiate(dot, placeHolderParent.transform); go.transform.position = stickers[j].positions[i]; placeHoldersDotsLines.Add(go); } // Lines GameObject lineHolder = Instantiate(linePrefab); LineRenderer lr = lineHolder.GetComponent <LineRenderer>(); lr.positionCount = 4; lr.SetPositions(stickers[j].positions); lineHolder.transform.SetParent(placeHolderParent.transform); lr.useWorldSpace = false; placeHoldersDotsLines.Add(lineHolder); // VideoPlayer GameObject temp1 = Instantiate(dot, placeHolderParent.transform); temp1.transform.position = stickers[j].positions[0]; GameObject temp2 = Instantiate(dot, placeHolderParent.transform); temp2.transform.position = new Vector3(stickers[j].positions[1].x, stickers[j].positions[0].y, stickers[j].positions[1].z); GameObject temp3 = Instantiate(dot, placeHolderParent.transform); temp3.transform.position = stickers[j].positions[2]; Vector3 raznp = (stickers[j].positions[0] - stickers[j].positions[2]) / 2; GameObject vp = Instantiate(videoPref, placeHolderParent.transform); vp.transform.position = temp1.transform.position; vp.transform.SetParent(temp1.transform); temp1.transform.LookAt(temp2.transform); vp.transform.position = stickers[j].positions[0] - raznp; vp.transform.localEulerAngles = new Vector3(vp.transform.localEulerAngles.x, vp.transform.localEulerAngles.y + 90, vp.transform.localEulerAngles.z); vp.transform.SetParent(placeHolderParent.transform); vp.transform.localEulerAngles = new Vector3(0, vp.transform.localEulerAngles.y, 0); vp.transform.localScale = (vp.transform.localScale * Vector3.Magnitude(stickers[j].positions[0] - stickers[j].positions[1])); videoDemos.Add(vp); if (stickers[j] != null) // if the sticker object is not failed { bool isVideoSticker = stickers[j].sPath != null && stickers[j].sPath.Contains(".mp4"); bool is3dModel = !isVideoSticker && (stickers[j].type.ToLower().Contains("3d") || // new 3d object format stickers[j].sSubType.Contains("3dobject") || // old 3d object format (stickers[j].sPath != null && stickers[j].sPath.Contains("3dobject")) // oldest 3d object format ); bool is3dModelTransfer = stickers[j].sDescription.ToLower().Contains("transfer") || stickers[j].subType.ToLower().Contains("transfer"); if (isVideoSticker) // if it's a video-sticker { GameObject urlVid = Instantiate(vp, placeHolderParent.transform); VideoPlayer vidos = urlVid.GetComponentInChildren <VideoPlayer>(); vidos.source = VideoSource.Url; vidos.url = stickers[j].sPath; //#if PLATFORM_ANDROID //FixMe: waits AC cert fix // vidos.url = vidos.url.Replace("https://developer.augmented.city", // "http://developer.augmented.city"); //#endif // Debug.Log("VID URL = " + vidos.url); videoURLs.Add(urlVid); } else if (is3dModel || is3dModelTransfer) // 3d object or special navi object { GameObject model = Instantiate(GetComponent <ModelManager>().ABloader, placeHolderParent.transform); string bundleName = stickers[j].sText.ToLower(); if (stickers[j].type.ToLower().Contains("3d")) // is it new format { bundleName = stickers[j].bundleName.ToLower(); if (string.IsNullOrEmpty(bundleName)) { bundleName = stickers[j].sText.ToLower(); // return back to default bundle name as the 'name' } } model.GetComponent <AssetLoader>().ABName = bundleName; model.transform.localPosition = stickers[j].mainPositions; // * acapi.tempScale3d; model.transform.localRotation = new Quaternion( stickers[j].orientations.x, stickers[j].orientations.y, stickers[j].orientations.z, stickers[j].orientations.w); if (stickers[j].sTrajectoryPath.Length > 1) { Trajectory tr = model.GetComponent <Trajectory>(); tr.go = true; tr.acapi = acapi; tr.sTrajectory = stickers[j].sTrajectoryPath; tr.sTimePeriod = stickers[j].sTrajectoryPeriod; tr.sOffset = stickers[j].sTrajectoryOffset; } //Debug.Log(stickers[j].sTrajectoryPath); // TEMP Mover mover = model.GetComponent <Mover>(); mover.setLocked(true); mover.objectId = stickers[j].objectId; if (!stickers[j].vertical || bundleName.Contains("nograv")) { mover.noGravity = true; } if (stickers[j].grounded || bundleName.Contains("quar") || bundleName.Contains("santa") || bundleName.Contains("pavel") || bundleName.Contains("gard")) { mover.landed = true; } /*Debug.Log(j + ". 3dmodel " + stickers[j].sText + " = " + model.transform.localPosition + " model.rot = " + model.transform.localRotation + " stick.ori = " + stickers[j].orientations);*/ if (stickers[j].SModel_scale.Length > 0) { float scale = float.Parse(stickers[j].SModel_scale); model.transform.localScale = new Vector3(scale, scale, scale); } models.Add(model); // store the new just created model } else // other types of objects - info-stickers { GameObject newSticker = null; string checkType = stickers[j].sType.ToLower(); if (checkType.Contains("food") || checkType.Contains("restaurant")) { newSticker = Instantiate(stickerFood, placeHolderParent.transform); } else if (checkType.Contains("place")) { newSticker = Instantiate(stickerPlace, placeHolderParent.transform); } else if (checkType.Contains("shop")) { newSticker = Instantiate(stickerShop, placeHolderParent.transform); } else { newSticker = Instantiate(stickerPref, placeHolderParent.transform); } if (newSticker != null) { newSticker.transform.position = stickers[j].positions[0] - raznp; StickerController sc = newSticker.GetComponent <StickerController>(); sc.setStickerInfo(stickers[j]); stickerObjects.Add(newSticker); // store the new just created info-sticker } } } // if (stickers[j] != null...) Destroy(temp1); Destroy(temp2); Destroy(temp3); } // for (j < stickers.Length) turnOffVideoDemos(videoDemosTurn); turnOffPlaceHolders(toShowPlaceHolders); turnOffStickers(toShowStickers); localizedImage.SetActive(true); placeHolderParent.transform.SetParent(scaleParent.transform); recos.Add(placeHolderParent); // store processed scene into the cache uim.Located(); relocationCompleted = true; } else { Debug.Log("No stickers"); CantLocalize(); } } else // if (placeHolderParent == null) { Transform scaleParentTransform = placeHolderParent.transform.root; //if (needScaling && lastLocalizedRecoId.Contains(id)) {} placeHolderParent.SetActive(true); GameObject tempScaler = new GameObject("TempScaler"); tempScaler.transform.position = arCamCoordinates; GameObject tempBiasVector = new GameObject("TempBiasVector"); tempBiasVector.transform.position = zeroP.position; tempBiasVector.transform.eulerAngles = zeroP.eulerAngles; tempBiasVector.transform.SetParent(tempScaler.transform); tempScaler.transform.localScale = scaleParentTransform.localScale; Translocation(placeHolderParent, tempBiasVector.transform, animationTime); Destroy(tempScaler); Destroy(tempBiasVector); } lastLocalizedRecoId = id; } else // if (id != null) { CantLocalize(); } }
void showPlaceHolders(string id, Transform zeroP, ACityAPIDev.StickerInfo[] stickers) { if (id != null) { Debug.Log("zero = " + zeroP.position.x + " " + zeroP.position.y + " " + zeroP.position.z); Debug.Log("zeroeulerAngles = " + zeroP.eulerAngles.x + " " + zeroP.eulerAngles.y + " " + zeroP.eulerAngles.z); GameObject placeHolderParent; placeHolderParent = checkSavedID(id); if (placeHolderParent == null) { if (stickers != null) { GameObject scaleParent = new GameObject("CamParent-" + id); scaleParent.transform.position = arCamCoordinates; placeHolderParent = new GameObject(id); placeHolderParent.transform.position = zeroP.position; placeHolderParent.transform.rotation = zeroP.rotation; activeReco = placeHolderParent; for (int j = 0; j < stickers.Length; j++) { //Placeholders for (int i = 0; i < 4; i++) { GameObject go = Instantiate(dot, placeHolderParent.transform); go.transform.position = stickers[j].positions[i]; placeHoldersDotsLines.Add(go); } //Lines GameObject lineHolder = Instantiate(linePrefab); LineRenderer lr = lineHolder.GetComponent<LineRenderer>(); lr.positionCount = 4; lr.SetPositions(stickers[j].positions); lineHolder.transform.SetParent(placeHolderParent.transform); lr.useWorldSpace = false; placeHoldersDotsLines.Add(lineHolder); //---VideoPlayer GameObject temp1 = Instantiate(dot, placeHolderParent.transform); temp1.transform.position = stickers[j].positions[0]; GameObject temp2 = Instantiate(dot, placeHolderParent.transform); temp2.transform.position = new Vector3(stickers[j].positions[1].x, stickers[j].positions[0].y, stickers[j].positions[1].z); GameObject temp3 = Instantiate(dot, placeHolderParent.transform); temp3.transform.position = stickers[j].positions[2]; Vector3 raznp = (stickers[j].positions[0] - stickers[j].positions[2]) / 2; GameObject vp = Instantiate(videoPref, placeHolderParent.transform); vp.transform.position = temp1.transform.position; vp.transform.SetParent(temp1.transform); temp1.transform.LookAt(temp2.transform); vp.transform.position = stickers[j].positions[0] - raznp; vp.transform.localEulerAngles = new Vector3(vp.transform.localEulerAngles.x, vp.transform.localEulerAngles.y + 90, vp.transform.localEulerAngles.z); vp.transform.SetParent(placeHolderParent.transform); vp.transform.localEulerAngles = new Vector3(0, vp.transform.localEulerAngles.y, 0); vp.transform.localScale = (vp.transform.localScale * Vector3.Magnitude(stickers[j].positions[0] - stickers[j].positions[1])); videoDemos.Add(vp); if (stickers[j].sPath.Contains("mp4")) { GameObject urlVid = Instantiate(vp, placeHolderParent.transform); VideoPlayer vidos = urlVid.GetComponentInChildren<VideoPlayer>(); vidos.source = VideoSource.Url; vidos.url = stickers[j].sPath; videoURLs.Add(urlVid); } else if (stickers[j].sSubType.Contains("3dobject")||stickers[j].sPath.Contains("3dobject")) { GameObject model = Instantiate(GetComponent<ModelManager>().ABloader, placeHolderParent.transform); string bundleName = stickers[j].sText.ToLower(); model.GetComponent<AssetLoader>().ABName = bundleName; model.transform.localPosition = stickers[j].mainPositions;// * acapi.tempScale3d; model.transform.localPosition = new Vector3(model.transform.localPosition.x,-model.transform.localPosition.y,model.transform.localPosition.z); model.transform.localRotation = new Quaternion(stickers[j].orientations.x, stickers[j].orientations.y, stickers[j].orientations.z, stickers[j].orientations.w); if (stickers[j].sTrajectoryPath.Length > 1) { Trajectory tr = model.GetComponent<Trajectory>(); tr.go = true; tr.acapi = acapi; tr.sTrajectory = stickers[j].sTrajectoryPath; tr.sTimePeriod = stickers[j].sTrajectoryPeriod; tr.sOffset = stickers[j].sTrajectoryOffset; } Debug.Log(stickers[j].sTrajectoryPath); // TEMP Mover mover = model.GetComponent<Mover>(); mover.setLocked(true); mover.objectId = stickers[j].objectId; if (bundleName.Contains("quar") || bundleName.Contains("santa") || bundleName.Contains("pavel") || bundleName.Contains("gard")) { mover.landed = true; } Debug.Log(j+". 3dmodel "+ stickers[j].sText + " = " + model.transform.localPosition + " ROT Quaternion = " + model.transform.localRotation + " stickers[j].orientations = " + stickers[j].orientations); if (stickers[j].SModel_scale.Length>0) model.transform.localScale = new Vector3(float.Parse(stickers[j].SModel_scale), float.Parse(stickers[j].SModel_scale), float.Parse(stickers[j].SModel_scale)); models.Add(model); } else { GameObject newSticker = null; string checkType = stickers[j].sType.ToLower(); if (checkType.Contains("food") || checkType.Contains("restaurant")) newSticker = Instantiate(stickerFood, placeHolderParent.transform); else if (checkType.Contains("place")) newSticker = Instantiate(stickerPlace, placeHolderParent.transform); else if (checkType.Contains("shop")) newSticker = Instantiate(stickerShop, placeHolderParent.transform); else newSticker = Instantiate(stickerPref, placeHolderParent.transform); if (newSticker != null) { newSticker.transform.position = stickers[j].positions[0] - raznp; StickerController sc = newSticker.GetComponent<StickerController>(); sc.setStickerInfo(stickers[j]); stickerObjects.Add(newSticker); } } Destroy(temp1); Destroy(temp2); Destroy(temp3); relocationCompleted = true; } turnOffVideoDemos(videoDemosTurn); turnOffPlaceHolders(toShowPlaceHolders); turnOffStickers(toShowStickers); localizedImage.SetActive(true); placeHolderParent.transform.SetParent(scaleParent.transform); recos.Add(placeHolderParent); uim.Located(); } else { Debug.Log("No stickers"); CantLocalize(); } } else { Transform scaleParentTransform = placeHolderParent.transform.root; placeHolderParent.SetActive(true); GameObject tempScaler = new GameObject("TempScaler"); tempScaler.transform.position = arCamCoordinates; GameObject tempBiasVector = new GameObject("TempBiasVector"); tempBiasVector.transform.position = zeroP.position; tempBiasVector.transform.eulerAngles = zeroP.eulerAngles; tempBiasVector.transform.SetParent(tempScaler.transform); tempScaler.transform.localScale = scaleParentTransform.localScale; Translocation(placeHolderParent, tempBiasVector.transform, animationTime); Destroy(tempScaler); Destroy(tempBiasVector); } lastLocalizedRecoId = id; } else { CantLocalize(); } }