public IEnumerator SetTheCorrectMaterialWhenLoadingMultipleTimes() { avatarModel = AvatarShapeTestHelpers.GetTestAvatarModel("test", "TestAvatar.json"); avatarShape.avatarRenderer.ApplyModel(avatarModel, null, null); avatarShape.avatarRenderer.ApplyModel(avatarModel, null, null); avatarShape.avatarRenderer.ApplyModel(avatarModel, null, null); bool lastUpdateIsDone = false; avatarShape.avatarRenderer.ApplyModel(avatarModel, () => lastUpdateIsDone = true, null); yield return(new DCL.WaitUntil(() => lastUpdateIsDone)); var wearableControllers = AvatarRenderer_Mock.GetWearableMockControllers(avatarShape.avatarRenderer); List <Material> materials = new List <Material>(); foreach (var wearableControllerMock in wearableControllers.Values) { if (wearableControllerMock.category == WearableLiterals.Categories.EYES || wearableControllerMock.category == WearableLiterals.Categories.EYEBROWS || wearableControllerMock.category == WearableLiterals.Categories.MOUTH) { continue; } materials.AddRange(wearableControllerMock.myAssetContainer.GetComponentsInChildren <Renderer>().SelectMany(x => x.materials).ToList()); } Assert.IsTrue(materials.All(x => x.shader.name == "DCL/Toon Shader")); }
public ActionResult Create([Bind(Include = "Id," + "Name," + "Description," + "Uri," + "")] AvatarModel data) { try { if (ModelState.IsValid) { if (data == null) { return(RedirectToAction("Error", new { route = "Home", action = "Error" })); } if (string.IsNullOrEmpty(data.Id)) { return(View(data)); } avatarBackend.Create(data); return(RedirectToAction("Index")); } // Send back for edit return(View(data)); } catch { return(RedirectToAction("Error", new { route = "Home", action = "Error" })); } }
public static HashSet <int> GetModelOfFXs(int modelID) { ResourceManager.InitModelData(); AvatarModel avatarModel = DataReader <AvatarModel> .Get(modelID); if (avatarModel == null) { string text = "AvatarModel表找不到数据, id = " + modelID; UIManagerControl.Instance.ShowToastText(text); return(null); } if (ResourceManager.m_modelFxs.ContainsKey(avatarModel.action)) { return(ResourceManager.m_modelFxs.get_Item(avatarModel.action)); } string text2 = string.Concat(new object[] { "Tools/PreprocessBeforeBuild, model数据索引中没有找到特效key, key = ", avatarModel.action, ", modelId = ", modelID }); UIManagerControl.Instance.ShowToastText(text2); return(null); }
private IEnumerator loadRenderGameObjects(DCustomEquipment[] outfit, AvatarAnimationFrame avatarFrame) { if (avatarInstance != null) { continueAvatarRender = false; cleanupRenderObjects(); yield return(null); } while (lightingRig != null && !lightingRig.IsReady) { yield return(null); } AssetRequest <GameObject> assetRequest = null; try { assetRequest = Content.LoadAsync(uiAvatarPrefabContentKey); } catch (Exception ex) { Log.LogError(this, $"Could not load UI Avatar penguin asset {uiAvatarPrefabContentKey.Key}. Message: {ex.Message}"); } if (assetRequest != null) { yield return(assetRequest); avatarInstance = UnityEngine.Object.Instantiate(assetRequest.Asset); DCustomOutfit avatarOutfit = default(DCustomOutfit); avatarOutfit.Equipment = outfit; avatarImageSet = false; continueAvatarRender = true; AvatarModel avatarModel = avatarInstance.GetComponent <AvatarModel>(); yield return(AvatarRenderer.RenderOutfit(beakColor: avatarModel.BeakColor, bellyColor: avatarModel.BellyColor, bodyColor: useBodyColor ? bodyColor : avatarModel.BodyColor, outfit: avatarOutfit, cameraData: imageBuilderCameraData, avatarGO: avatarInstance, onProcessModel: onProcessAnimationFrame, animationFrame: avatarFrame)); } }
protected override IEnumerator SetUp() { yield return(base.SetUp()); avatarModel = new AvatarModel() { name = " test", hairColor = Color.white, eyeColor = Color.white, skinColor = Color.white, bodyShape = WearableLiterals.BodyShapes.FEMALE, wearables = new List <string>() { } }; AvatarTestHelpers.CreateTestCatalog(); var avatarShape = AvatarTestHelpers.CreateAvatarShape(scene, avatarModel); yield return(new DCL.WaitUntil(() => avatarShape.everythingIsLoaded, 20)); avatarRenderer = avatarShape.avatarRenderer; animator = avatarRenderer.animator; }
public ActorModel JustCreateUIModel(int uid, int modelId, AvatarModel dataAM, bool model_active, string model_layer, Vector2 offsetlocalPos) { ActorModel actorModel = ModelPool.Instance.Get(modelId); if (actorModel == null) { return(null); } this.m_models.set_Item(uid, actorModel); actorModel.ModelType = ActorModelType.UI; actorModel.ModelLayer = model_layer; NavMeshAgent component = actorModel.GetComponent <NavMeshAgent>(); if (component != null) { component.set_enabled(false); } ModelDisplayManager.RefreshInitLocalPosition(actorModel, offsetlocalPos); actorModel.get_transform().set_localEulerAngles(new Vector3(0f, dataAM.modelProjRotateRevise, 0f)); actorModel.get_transform().set_localScale(Vector3.get_one() * dataAM.scale); actorModel.ShowShadow(false, modelId); actorModel.ChangeToIdle(); actorModel.get_gameObject().SetActive(model_active); return(actorModel); }
private void PreloadModel(ResWeight.ResType type) { if (ResWeight.IsLoadFinished(type)) { this.JustLoadNextResource(ResWeight.ResType.none); return; } using (HashSet <int> .Enumerator enumerator = LoadingRes.m_load_modelIds.GetEnumerator()) { while (enumerator.MoveNext()) { int current = enumerator.get_Current(); AvatarModel avatarModel = DataReader <AvatarModel> .Get(current); if (avatarModel == null) { this.LoadSuccessWithCheck(type); } else { AssetManager.LoadAssetWithPool(avatarModel.path, delegate(bool isSuccess) { this.LoadSuccessWithCheck(type); }); } } } }
internal AvatarModel GetAndRemoveModel() { AvatarModel pam = Model; Model = null; return(pam); }
protected T SetGameObject(GameObject obj, int guid) { if (obj.get_transform().get_parent() != this.root) { obj.get_transform().set_parent(this.root.get_transform()); } obj.SetActive(false); T t = obj.AddUniqueComponent <T>(); t.resGUID = guid; t.InstanceID = t.GetInstanceID(); t.GameObjectID = obj.GetInstanceID(); t.pool = this; this.Pools.Add(t); if (!(t is ActorFX)) { if (!(t is ActorFXSpine)) { obj.SetActive(true); } } if (t is ActorParent && DataReader <AvatarModel> .Contains(guid)) { AvatarModel avatarModel = DataReader <AvatarModel> .Get(guid); obj.get_transform().set_localScale(Vector3.get_one() * avatarModel.scale); obj.get_transform().set_localPosition(Vector3.get_zero()); obj.GetComponentsInChildren <Animator>(true)[0].set_cullingMode((avatarModel.alwaysVisible <= 0) ? 1 : 0); (t as ActorParent).IsLockModelDir = (avatarModel.lockDirection == 1); } return(t); }
public void CleanupAvatar() { StopLoadingCoroutines(); eyebrowsController?.CleanUp(); eyebrowsController = null; eyesController?.CleanUp(); eyesController = null; bodyShapeController?.CleanUp(); bodyShapeController = null; using (var iterator = wearableControllers.GetEnumerator()) { while (iterator.MoveNext()) { iterator.Current.Value.CleanUp(); } } wearableControllers.Clear(); model = null; isLoading = false; OnFailEvent = null; OnSuccessEvent = null; }
public void Controller_Avatar_Create_Post_Valid_Should_Return_Index_Page() { // Arrange AvatarController controller = new AvatarController(); var data = new AvatarModel { Description = "description", Id = "abc", Name = "Name", Uri = "picture" }; // Act var result = (RedirectToRouteResult)controller.Create(data); // Assert Assert.AreEqual("Index", result.RouteValues["action"], TestContext.TestName); // No need to check the route, Assert.AreEqual("Avatar", result.RouteValues["route"], TestContext.TestName); // Check that the item is created var resultAvatar = AvatarBackend.Instance.Read("abc"); Assert.AreEqual(data.Id, resultAvatar.Id, TestContext.TestName); // Reset the Avatars AvatarBackend.Instance.Reset(); }
public void ApplyModel(AvatarModel model, Action onSuccess, Action onFail) { this.model = model; Action onSuccessWrapper = null; Action onFailWrapper = null; onSuccessWrapper = () => { onSuccess?.Invoke(); this.OnSuccessEvent -= onSuccessWrapper; }; onFailWrapper = () => { onFail?.Invoke(); this.OnFailEvent -= onFailWrapper; }; this.OnSuccessEvent += onSuccessWrapper; this.OnFailEvent += onFailWrapper; isLoading = false; StopLoadingCoroutines(); if (this.model == null) { ResetAvatar(); this.OnSuccessEvent?.Invoke(); return; } isLoading = true; loadCoroutine = CoroutineStarter.Start(LoadAvatar()); }
protected void GetAsyncModel(Transform root, int modelID, Action callback) { AvatarModel avatarModelData = DataReader <AvatarModel> .Get(modelID); if (avatarModelData == null) { return; } this.asyncModelIDs.Add(GameObjectLoader.Instance.Get(avatarModelData.path, delegate(GameObject obj) { if (obj == null) { Debug.LogError(string.Format("马上联系左总,GameObjectLoader.Instance.Get拿到空值,路径是{0}", avatarModelData.path)); return; } obj.SetActive(true); obj.set_name(modelID.ToString()); root.set_localScale(Vector3.get_one() * avatarModelData.scale); UGUITools.ResetTransform(obj.get_transform(), root); Animator[] componentsInChildren = obj.GetComponentsInChildren <Animator>(true); if (componentsInChildren.Length > 0) { componentsInChildren[0].set_cullingMode((avatarModelData.alwaysVisible <= 0) ? 1 : 0); AssetManager.AssetOfControllerManager.SetController(componentsInChildren[0], modelID, false); } if (callback != null) { callback.Invoke(); } })); }
public ActionResult Delete([Bind(Include = "Id," + "Name," + "Description," + "Uri," + "Level," + "")] AvatarModel data) { if (!ModelState.IsValid) { // Send back for edit return(View(data)); } if (data == null) { // Send to Error Page return(RedirectToAction("Error", new { route = "Home", action = "Error" })); } if (string.IsNullOrEmpty(data.Id)) { // Send back for Edit return(View(data)); } avatarBackend.Delete(data.Id); return(RedirectToAction("Index")); }
public ActionResult GetUserBlock(string userName) { try { User user = dr.UsersLogic.GetUserByUserName(userName); if (user != null) { UserModel userModel = user; Avatar avatar = dr.AvatarsLogic.GetUserAvatar(userModel.UserAvatarId); if (avatar == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } AvatarModel avatarModel = avatar; ViewBag.Avatar = avatarModel; return(this.PartialView(userModel)); } else { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } } catch (Exception) { return(this.View("~/Views/Shared/Error.cshtml")); } }
public void UpdateFromModel() { //to be destroyed? bool toBeDestroyed = false; if (Model != null) { foreach (CastedCard cc in Model.Effects) { if (cc.Params.ContainsKey(CastedCardParamType.Destroy)) { toBeDestroyed = true; } } } if (Model != null && (Model.ActualHealth <= 0 || toBeDestroyed)) { //is dead _Model.GetMyHero().Minions.Remove(_Model); _Model = null; } AvatarModel heroModel = Model != null?Model.GetMyHero() : null; PanelAvatarCard.GetComponent <PanelAvatarCard>().PreviewModel(heroModel, Model, PanelMinigame.Me.ActualTurnModel.IsItYourMinion(Model) || PanelMinigame.Me.ActualTurnModel == heroModel); }
protected override IEnumerator SetUp() { yield return(SetUp_SceneController()); yield return(SetUp_CharacterController()); if (avatarShape == null) { avatarModel = new AvatarModel() { name = " test", hairColor = Color.white, eyeColor = Color.white, skinColor = Color.white, bodyShape = WearableLiterals.BodyShapes.FEMALE, wearables = new List <string>() { } }; catalog = AvatarTestHelpers.CreateTestCatalogLocal(); avatarShape = AvatarTestHelpers.CreateAvatarShape(scene, avatarModel); yield return(new DCL.WaitUntil(() => avatarShape.everythingIsLoaded, 20)); } }
public static IEnumerator RenderOutfit(DCustomOutfit outfit, Color beakColor, Color bodyColor, Color bellyColor, ImageBuilderCameraData cameraData, GameObject avatarGO, Func <ModelRenderer, bool> onProcessModel, AvatarAnimationFrame animationFrame = null) { AvatarModel avatarModel = avatarGO.GetComponent <AvatarModel>(); avatarModel.BeakColor = beakColor; avatarModel.BodyColor = bodyColor; avatarModel.BellyColor = bellyColor; avatarModel.ClearAllEquipment(); avatarModel.ApplyOutfit(outfit); AvatarView avatarView = avatarGO.GetComponent <AvatarView>(); yield return(new WaitUntil(() => avatarView.IsReady)); ModelRendererConfig renderConfig = new ModelRendererConfig(avatarGO.transform, cameraData.ModelOffset, new Vector2(cameraData.IconSize, cameraData.IconSize)); avatarGO.transform.Rotate(cameraData.ModelRotation); renderConfig.FieldOfView = cameraData.FieldOfView; ModelRenderer modelRenderer = new ModelRenderer(renderConfig); modelRenderer.RotateCamera(cameraData.CameraRotation); if (animationFrame != null) { Animator component = avatarGO.GetComponent <Animator>(); component.Play(animationFrame.StateName, animationFrame.Layer, animationFrame.Time); } do { yield return(null); }while (onProcessModel(modelRenderer)); }
void Start() { this.player = (Player)GameObject.FindGameObjectWithTag("Player").GetComponent("Player"); this.eventService = (EventService)this.gameObject.GetComponent("EventService"); this.eventService.successResponseHandler = new WebService.SuccessResponseHandler(this.HandleSendEventsSuccess); this.roomService = (RoomService)this.gameObject.GetComponent("RoomService"); if (PlayerPrefs.HasKey("avatar")) { Debug.Log(PlayerPrefs.GetString("avatar")); AvatarModel avatar = JsonMapper.ToObject <AvatarModel>(PlayerPrefs.GetString("avatar")); if (avatar != null) { this.player.AvatarId = avatar.avatar_id; this.player.Name = avatar.label; this.player.XP = avatar.GetAttributeValue("xp"); this.player.HP = avatar.GetAttributeValue("hp"); } } else { Debug.LogWarning("Started game with no avatar data."); } if (this.roomId != 0) { this.roomService.successResponseHandler = new WebService.SuccessResponseHandler(this.PopulateRoomContainers); this.roomService.GetRoom(this.roomId); } }
public void RefreshUI(MemberResume member) { if (!this.isInit) { this.InitUI(); } this.UpdateTeamChatTip(null); this.m_memberResume = member; if (this.m_headIcon != null) { AvatarModel avatarModel = DataReader <AvatarModel> .Get(DataReader <RoleCreate> .Get((int)member.career).modle); ResourceManager.SetSprite(this.m_headIcon, GameDataUtils.GetIcon(avatarModel.icon)); } base.FindTransform("num").GetComponent <Text>().set_text(member.hp + string.Empty); base.FindTransform("NameLab").GetComponent <Text>().set_text(member.name); base.FindTransform("LevelLab").GetComponent <Text>().set_text("Lv." + member.level.ToString()); ResourceManager.SetSprite(this.m_spVIPLevel1, GameDataUtils.GetNumIcon10(member.vipLv, NumType.Yellow_light)); ResourceManager.SetSprite(this.m_spVIPLevel2, GameDataUtils.GetNumIcon1(member.vipLv, NumType.Yellow_light)); if (member.roleId == TeamBasicManager.Instance.MyTeamData.LeaderID) { this.m_leaderIcon.get_gameObject().SetActive(true); } else { this.m_leaderIcon.get_gameObject().SetActive(false); } base.FindTransform("InFightingStatusIcon").get_gameObject().SetActive(member.inFighting); }
private void UpdatePlayerStatus(AvatarModel model) { // Remove the player status if the userId changes if (playerStatus != null && (playerStatus.id != model.id || playerStatus.name != model.name)) { DataStore.i.player.otherPlayersStatus.Remove(playerStatus.id); } if (string.IsNullOrEmpty(model?.id)) { return; } bool isNew = false; if (playerStatus == null) { playerStatus = new PlayerStatus(); isNew = true; } playerStatus.id = model.id; playerStatus.name = model.name; playerStatus.isTalking = model.talking; playerStatus.worldPosition = entity.gameObject.transform.position; if (isNew) { DataStore.i.player.otherPlayersStatus.Add(playerStatus.id, playerStatus); } }
protected List <Vector3> SetCityFakeDropWaitingPosition(int typeID, Vector3 originPos) { List <Vector3> list = new List <Vector3>(); Monster monster = DataReader <Monster> .Get(typeID); if (monster == null) { return(list); } AvatarModel avatarModel = DataReader <AvatarModel> .Get(monster.model); if (monster == null) { return(list); } if (avatarModel.flopAngle == 0) { return(list); } int num = Random.Range(0, 360); for (float num2 = 0f; num2 < 360f; num2 += (float)avatarModel.flopAngle) { float num3 = (float)avatarModel.flopRange * 0.01f * 0.5f + Random.get_value() * (float)avatarModel.flopRange * 0.01f * 0.5f; Vector3 vector = originPos + Quaternion.Euler(0f, (float)num + num2, 0f) * Vector3.get_forward() * num3; list.Add(vector); } return(list); }
private static void CameraSettingOfActorModel(Camera cameraRT, AvatarModel dataAM, float modelOffset) { if (dataAM.camProjRotRevise.get_Count() >= 2) { ModelDisplayManager.CameraSettingOfActorModel(cameraRT, new Vector3(0f, dataAM.camProjRotRevise.get_Item(0), dataAM.camProjRotRevise.get_Item(1)), dataAM.camProjPosRevise, modelOffset); } }
internal void Preview(AvatarModel hero, AvatarModel targetModel, WhereAmI whereAmI) { Card tmp = targetModel != null ? targetModel.Card : null; PreviewCard(hero, tmp, whereAmI); string effectsText = ""; if (targetModel != null) { if (targetModel.Effects.Count > 0) { effectsText += "\n effects: "; } foreach (CastedCard cc in targetModel.Effects) { effectsText += "( "; foreach (KeyValuePair <CastedCardParamType, int> kvp in cc.Params) { effectsText += kvp.Key + ": " + kvp.Value + ","; } effectsText += "),"; } } TextDescription.GetComponent <Text>().text = tmp != null?(tmp.Describe(hero) + effectsText):""; }
public static AvatarModel GetPlayerAM() { if (ModelDisplayManager.PlayerAM == null) { ModelDisplayManager.PlayerAM = DataReader <AvatarModel> .Get(EntityWorld.Instance.EntSelf.FixModelID); } return(ModelDisplayManager.PlayerAM); }
public static AvatarModel GetTestAvatarModel(string name, string fileName) { var avatarjson = File.ReadAllText(Utils.GetTestAssetsPathRaw() + "/Avatar/" + fileName); AvatarModel model = JsonUtility.FromJson <AvatarModel>(avatarjson); model.name = name; return(model); }
public void Models_AvatarModel_Default_Instantiate_Should_Pass() { // Act var result = new AvatarModel(); // Assert Assert.IsNotNull(result, TestContext.TestName); }
internal AvatarModel Cast(AvatarModel castingOn, Card c) { Hand.Remove(c); //minion if (c.CardPersistency == CardPersistency.Minion) { if (castingOn != null && !c.Params.ContainsKey(ParamType.ReplaceExisting)) { //can not cast minion on other minion throw new Exception("Casting card: " + c.Name + " on " + castingOn.Card.Name + " this can not happen"); } AvatarModel owner = GetMyHero(); if (c.Params.ContainsKey(ParamType.ReplaceExisting)) { owner = castingOn.GetMyHero(); owner.Minions.Remove(castingOn); PanelMinigame.Me.AnimationRequests.Add(new AnimationRequestStruct(this, AnimationRequest.ReplaceMinionOn, castingOn)); } else { PanelMinigame.Me.AnimationRequests.Add(new AnimationRequestStruct(this, AnimationRequest.PutMinionOnTile, castingOn)); } castingOn = new AvatarModel(c, true, owner); //minions will be a flat structure. there is no need for deep one. owner.Minions.Add(castingOn); } //is null for totemic might. where the actual spell does nothing, the battlecry throws totem if (castingOn != null) { //check if there is already an effect like this and marked to remove. we will unmark it bool foundTheSame = false; foreach (CastedCard cc in castingOn.Effects) { if (cc.Card == c && cc.MarkedToRemove) { cc.MarkedToRemove = false; foundTheSame = true; break; } } if (!foundTheSame) { CastedCard castedCard = new CastedCard(this, castingOn, c); if (c.CardPersistency != CardPersistency.Instant && castedCard.Params.Count > 0) { Debug.Log("Casting " + c.Name + " on " + castingOn.Card.Name); castingOn.Effects.Add(castedCard); } //because of healing this has to be after adding castedCard to effect. (max health update then healing) castedCard.DealInstants(this, castingOn); } } return(castingOn); }
public static AvatarShape CreateAvatarShape(ParcelScene scene, AvatarModel model) { GLTFSceneImporter.budgetPerFrameInMilliseconds = float.MaxValue; DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene); AvatarShape shape = TestHelpers.EntityComponentCreate <AvatarShape, AvatarModel>(scene, entity, model, CLASS_ID_COMPONENT.AVATAR_SHAPE); TestHelpers.SetEntityTransform(scene, entity, new Vector3(0, 0, 0), Quaternion.identity, Vector3.one); return(shape); }
public void Awake() { if (Model == null) { Model = GetComponent <AvatarModel>(); } Model.PartChanged += model_PartChanged; Model.OutfitSet += model_OutfitSet; }