Example #1
0
        /// <summary>
        /// 報酬追加
        /// </summary>
        /// <param name="loots"></param>
        /// <returns></returns>
        private AsyncSubject <Unit> AddLoots(List <LootItemStruct> loots)
        {
            AsyncSubject <Unit> subject = new AsyncSubject <Unit>();

            ObservableUtils.Timer(loots.Count * 100 + 400).Subscribe(_ =>
            {
                subject.OnNext(Unit.Default);
                subject.OnCompleted();
            });
            foreach (var(loot, index) in loots.Select((x, i) => (x, i)))
            {
                var pos        = new Vector3(-500, -90 - (index * 60), 0);
                var itemObject = Object.Instantiate((GameObject)Resources.Load("Prefabs/GUI/ResultItem"),
                                                    Vector3.zero, Quaternion.identity, _itemTransform);
                itemObject.transform.localPosition            = pos;
                itemObject.GetComponent <CanvasGroup>().alpha = 0;
                var sprite = ItemDictionary.GetLootSprite(loot);
                //var sprite = AssetDatabase.LoadAssetAtPath<Sprite>("Assets/Resources/Sprites/Items/" + item.imageData.spritePath);
                itemObject.transform.Find("Icon").GetComponent <Image>().sprite = sprite;
                var text = ItemDictionary.GetText(loot);
                itemObject.transform.Find("Text").GetComponent <Text>().text             = text;
                itemObject.transform.Find("Text").GetComponent <Text>().color            = ItemDictionary.GetColor(loot.ItemId);
                itemObject.transform.Find("Type").GetComponent <TextMeshProUGUI>().text  = ItemDictionary.GetCategoryName(loot.ItemId);
                itemObject.transform.Find("Type").GetComponent <TextMeshProUGUI>().color =
                    ItemDictionary.GetColor(loot.ItemId);
                ObservableUtils.Timer(100 * index).Subscribe(_ =>
                {
                    itemObject.transform.DOLocalMoveX(0, 0.4f).Play();
                    itemObject.transform.GetComponent <CanvasGroup>().DOFade(1f, 0.4f).Play();
                });
            }
            return(subject);
        }
Example #2
0
        /// <summary>
        /// 獲得したアイテムを表示する
        /// </summary>
        /// <param name="loots"></param>
        public void AddLootImages(List <LootItemStruct> loots)
        {
            var lootTransform = Modal.transform.Find("Content/LootItems");

            loots.ForEach(loot =>
            {
                var lootObject = Object.Instantiate(
                    (GameObject)Resources.Load("Prefabs/Modal/DungeonEvent/Parts/LootItem"), lootTransform);
                lootObject.GetComponent <Image>().sprite = ItemDictionary.GetLootSprite(loot);
            });
        }