Exemplo n.º 1
0
        private void AddWearableController(WearableItem wearable)
        {
            if (wearable == null)
            {
                return;
            }
            switch (wearable.category)
            {
            case Categories.EYES:
                eyesController = new FacialFeatureController(wearable, eyeMaterial);
                break;

            case Categories.EYEBROWS:
                eyebrowsController = new FacialFeatureController(wearable, eyebrowMaterial);
                break;

            case Categories.MOUTH:
                mouthController = new FacialFeatureController(wearable, mouthMaterial);
                break;

            case Categories.BODY_SHAPE:
                break;

            default:
                var wearableController = new WearableController(wearable, bodyShapeController.id);
                wearableControllers.Add(wearable, wearableController);
                break;
            }
        }
Exemplo n.º 2
0
        public IEnumerator FailsGracefully()
        {
            //Arrange
            WearableItem unexistentWearableItem = new WearableItem
            {
                representations = new [] { new WearableItem.Representation
                                           {
                                               mainFile = "NothingHere",
                                               contents = new [] { new ContentServerUtils.MappingPair {
                                                                       file = "NothingHere", hash = "NothingHere"
                                                                   } },
                                               bodyShapes = new [] { WearableLiterals.BodyShapes.FEMALE, WearableLiterals.BodyShapes.MALE }
                                           } }
            };
            WearableController wearable = new WearableController(unexistentWearableItem);

            toCleanUp.Add(wearable);

            //Act
            bool succeeded = false;
            bool failed    = false;

            RendereableAssetLoadHelper.LoadingType cacheLoadingType = RendereableAssetLoadHelper.loadingType;
            RendereableAssetLoadHelper.loadingType = RendereableAssetLoadHelper.LoadingType.ASSET_BUNDLE_ONLY;
            wearable.Load(WearableLiterals.BodyShapes.FEMALE, wearableHolder, x => succeeded = true, x => failed = true);
            yield return(new WaitUntil(() => succeeded || failed));

            RendereableAssetLoadHelper.loadingType = cacheLoadingType;

            //Assert
            Assert.IsFalse(succeeded);
            Assert.IsTrue(failed);
        }
Exemplo n.º 3
0
        private void ProcessWearable(string wearableId)
        {
            var wearable = ResolveWearable(wearableId);

            if (wearable == null)
            {
                return;
            }

            switch (wearable.category)
            {
            case WearableLiterals.Categories.EYES:
                eyesController = new FacialFeatureController(wearable, bodyShapeController.bodyShapeType);
                break;

            case WearableLiterals.Categories.EYEBROWS:
                eyebrowsController = new FacialFeatureController(wearable, bodyShapeController.bodyShapeType);
                break;

            case WearableLiterals.Categories.MOUTH:
                mouthController = new FacialFeatureController(wearable, bodyShapeController.bodyShapeType);
                break;

            case WearableLiterals.Categories.BODY_SHAPE:
                break;

            default:
                var wearableController = new WearableController(ResolveWearable(wearableId), bodyShapeController.id);
                wearablesController.Add(wearableId, wearableController);
                wearableController.Load(transform, OnWearableLoadingSuccess, OnWearableLoadingFail);
                break;
            }
        }
Exemplo n.º 4
0
        public IEnumerator SetAnimatorBonesProperly()
        {
            //Arrange
            SkinnedMeshRenderer skinnedMeshRenderer = CreateTestGameObject("_SMR_Holder").AddComponent <SkinnedMeshRenderer>();

            skinnedMeshRenderer.rootBone = CreateTestGameObject("_rootBone").transform;
            skinnedMeshRenderer.bones    = new Transform[5];
            for (var i = 0; i < skinnedMeshRenderer.bones.Length; i++)
            {
                skinnedMeshRenderer.bones[i] = CreateTestGameObject($"_rootBone_{i}").transform;
            }
            catalog.TryGetValue(SUNGLASSES_ID, out WearableItem wereableItem);
            WearableController wearable = new WearableController(wereableItem);

            toCleanUp.Add(wearable);
            wearable.Load(WearableLiterals.BodyShapes.FEMALE, wearableHolder, null, null);
            yield return(new WaitUntil(() => wearable.isReady));

            //Act
            wearable.SetAnimatorBones(skinnedMeshRenderer);

            //Assert
            SkinnedMeshRenderer wearableSMR = wearable.assetContainer.GetComponentInChildren <SkinnedMeshRenderer>();

            Assert.AreEqual(skinnedMeshRenderer.rootBone, wearableSMR.rootBone);
            for (int index = 0; index < wearableSMR.bones.Length; index++)
            {
                Assert.AreEqual(skinnedMeshRenderer.bones[index], wearableSMR.bones[index]);
            }
        }
Exemplo n.º 5
0
 protected WearableController(WearableController original)
 {
     wearable       = original.wearable;
     loader         = original.loader;
     bodyShapeId    = original.bodyShapeId;
     assetRenderers = original.assetRenderers;
 }
    public void SetItem(Item newItem, InventoryItemController newUiItem)
    {
        item = newItem;
        Sprite sprite = newItem.icon;

        foreach (WearableController wearableController in FindObjectsOfType <WearableController>())
        {
            wearableController.GetComponent <Selectable>().interactable = true;
        }
        foreach (var categorySlot in FindObjectsOfType <CategoryController>())
        {
            categorySlot.GetComponent <Selectable>().interactable = true;
        }
        _itemIcon.sprite = sprite;
        GetComponent <Selectable>().Select();
        ChangingItem = null;
        FindObjectOfType <WeightBarController>().UpdateBar();
        if (uiItem != null)
        {
            uiItem.SetNotInUse();
        }
        uiItem = newUiItem;
        newUiItem.SetInUse();
        //_defaultSprite = image.sprite;
        _image.sprite = _defaultSprite;
    }
Exemplo n.º 7
0
        void OnWearableLoadingFail(WearableController wearableController)
        {
            Debug.LogError($"Avatar: {model.name}  -  Failed loading wearable: {wearableController.id}");
            StopLoadingCoroutines();

            ResetAvatar();
            isLoading = false;
            OnFailEvent?.Invoke();
        }
Exemplo n.º 8
0
        void OnWearableLoadingSuccess(WearableController wearableController)
        {
            if (wearableController == null || model == null)
            {
                Debug.LogWarning($"WearableSuccess was called wrongly: IsWearableControllerNull=>{wearableController == null}, IsModelNull=>{model == null}");
                OnWearableLoadingFail(wearableController, 0);
                return;
            }

            wearableController.SetupDefaultMaterial(defaultMaterial, model.skinColor, model.hairColor);
        }
Exemplo n.º 9
0
        void OnWearableLoadingFail(WearableController wearableController, int retriesCount = MAX_RETRIES)
        {
            if (retriesCount <= 0)
            {
                Debug.LogError($"Avatar: {model.name}  -  Failed loading wearable: {wearableController.id}");
                CleanupAvatar();
                OnFailEvent?.Invoke();
                return;
            }

            wearableController.Load(transform, OnWearableLoadingSuccess, x => OnWearableLoadingFail(x, retriesCount - 1));
        }
    private IEnumerator LoadWearable(string wearableId, string bodyShapeId, Vector3 wearablePosition)
    {
        catalog.TryGetValue(wearableId, out WearableItem wearableItem);
        Assert.NotNull(wearableItem);
        WearableController wearable = new WearableController(wearableItem);

        toCleanUp.Add(wearable);
        bool succeeded = false;
        bool failed    = false;

        wearable.Load(bodyShapeId, CreateTestGameObject(wearable.id, wearablePosition).transform, x => succeeded = true, x => failed = true);
        yield return(new WaitUntil(() => succeeded || failed));

        Assert.IsTrue(succeeded);
        wearable.SetAssetRenderersEnabled(true);
        wearable.SetupDefaultMaterial(avatarMaterial, skinColor, hairColor);
    }
Exemplo n.º 11
0
        public IEnumerator LoadSuccessfully()
        {
            //Arrange
            WearableController wearable = new WearableController(catalog.GetOrDefault(SUNGLASSES_ID), WearableLiterals.BodyShapes.FEMALE);

            toCleanUp.Add(wearable);

            //Act
            bool succeeded = false;
            bool failed    = false;

            wearable.Load(wearableHolder, x => succeeded = true, x => failed = true);
            yield return(new WaitUntil(() => succeeded || failed));

            //Assert
            Assert.IsTrue(succeeded);
            Assert.IsFalse(failed);
        }
Exemplo n.º 12
0
        public IEnumerator UpdateVisibilityProperly_True()
        {
            //Arrange
            WearableController wearable = new WearableController(catalog.GetOrDefault(SUNGLASSES_ID), WearableLiterals.BodyShapes.FEMALE);

            toCleanUp.Add(wearable);
            wearable.Load(wearableHolder, null, null);
            yield return(new WaitUntil(() => wearable.isReady));

            SkinnedMeshRenderer skinnedMeshRenderer = wearable.assetContainer.GetComponentInChildren <SkinnedMeshRenderer>();

            skinnedMeshRenderer.enabled = false;

            //Act
            wearable.UpdateVisibility(new HashSet <string>());

            //Assert
            Assert.IsTrue(skinnedMeshRenderer.enabled);
        }
Exemplo n.º 13
0
                public object Call(Interpreter interpreter, Token token, List <object> arguments)
                {
                    //spawn the item, which contains the tuple's information

                    GameObject go = GameObject.Instantiate(self.gameController.wearablePrefab);

                    WearableController controller = go.GetComponent <WearableController>();
                    WearableTuple      tuple      = self.registeredWearables[(string)arguments[0]];

                    controller.displayName = tuple.displayName;
                    controller.spriteName  = tuple.spriteName;
                    controller.onEquip     = tuple.onEquip;
                    controller.onUnequip   = tuple.onUnequip;
                    controller.positionX   = (int)(double)arguments[1];
                    controller.positionY   = (int)(double)arguments[2];

                    self.gameController.CacheEntity(go);

                    return(new GameObjectWrapper(go));
                }
Exemplo n.º 14
0
        public IEnumerator UpdateVisibilityProperly_False()
        {
            //Arrange
            catalog.TryGetValue(SUNGLASSES_ID, out WearableItem wereableItem);
            WearableController wearable = new WearableController(wereableItem);

            toCleanUp.Add(wearable);
            wearable.Load(WearableLiterals.BodyShapes.FEMALE, wearableHolder, null, null);
            yield return(new WaitUntil(() => wearable.isReady));

            SkinnedMeshRenderer skinnedMeshRenderer = wearable.assetContainer.GetComponentInChildren <SkinnedMeshRenderer>();

            skinnedMeshRenderer.enabled = true;

            //Act
            wearable.UpdateVisibility(new HashSet <string> {
                wearable.wearable.category
            });

            //Assert
            Assert.IsFalse(skinnedMeshRenderer.enabled);
        }
    public void SelectSlot()
    {
        ChangingItem  = this;
        _image.sprite = _slotBeeingSelected;
        var allCategories = FindObjectsOfType <CategoryController>();

        foreach (var categorySlot in allCategories)
        {
            categorySlot.GetComponent <Selectable>().interactable = false;
        }
        var myCategory = allCategories.Where(c => c.category == _category).First();

        myCategory.GetComponent <Selectable>().interactable = true;
        myCategory.SelectCategory();
        myCategory.CategoryPanel.SelectLastSubCategory();
        myCategory.CategoryPanel.ReselectItem();
        foreach (WearableController wearableController in FindObjectsOfType <WearableController>())
        {
            wearableController.GetComponent <Selectable>().interactable = false;
        }
        var selectable = GetComponent <Selectable>();

        selectable.interactable = true;
    }
Exemplo n.º 16
0
 void OnBodyShapeLoadingFail(WearableController wearableController)
 {
     Debug.LogError($"Avatar: {model.name}  -  Failed loading bodyshape: {wearableController.id}");
     CleanupAvatar();
     OnFailEvent?.Invoke();
 }
Exemplo n.º 17
0
 void OnWearableLoadingSuccess(WearableController wearableController)
 {
     wearableController.SetupDefaultMaterial(defaultMaterial, model.skinColor, model.hairColor);
 }
Exemplo n.º 18
0
 protected BodyShapeController(WearableController original) : base(original)
 {
 }
Exemplo n.º 19
0
 public GetSpriteNameCallable(WearableController self)
 {
     this.self = self;
 }
Exemplo n.º 20
0
 public BodyShapeController_Mock(WearableController original) : base(original)
 {
 }
Exemplo n.º 21
0
 public WearableController_Mock(WearableController original) : base(original)
 {
 }
Exemplo n.º 22
0
 public GetDisplayNameCallable(WearableController self)
 {
     this.self = self;
 }