private void InitItemList()
        {
            GameObject itemObj;

            foreach (var id in itemIdList)
            {
                var itemInfo = ItemMgr.Instance.GetItem(id);
                itemObj = MemoryMgr.InstantiateGameObject(UiPath.Image_ItemUI, this.itemList);
                Assert.IsTrue(itemObj);


                var avator = itemObj.transform.Find("Image_ItemAvator");
                if (avator == null)
                {
                    throw new Exception("avator is null");
                }
                var image = avator.GetComponent <Image>();
                if (image == null)
                {
                    throw new Exception("Image is null");
                }
                image.sprite =
                    MemoryMgr.GetSourceFromResources <Sprite>(itemInfo.SpritePath);
                itemObj.transform.Find("Tmp_Price").GetComponent <TextMeshProUGUI>().text = itemInfo.Price.ToString();

                this.items.Add(itemObj);
            }
        }
        private void OnTouchItem(Slot slot)
        {
            var item = ItemMgr.Instance.GetItem(slot.itemUi.itemId);

            this.itemInfoUi.Set(slot.itemUi.itemId, slot.transform.position);
            this.itemInfoUi.Show();
            this.moreInfoTextObj.GetComponent <Text>().text = item.ToString();
            var sprite = MemoryMgr.GetSourceFromResources <Sprite>(item.SpritePath);

            Assert.IsTrue(sprite);
            this.moreInfoSpriteObj.GetComponent <Image>().sprite = sprite;
        }
Example #3
0
        /// <summary>
        /// 实例化UI物体,加图片,为变量itemImage,itemNum赋值
        /// </summary>
        private void FillSlot()
        {
            if (this == null)
            {
                throw new Exception("????????????");
            }

            this.itemUi.obj = MemoryMgr.InstantiateGameObject(UiName.Image_ItemUI, transform);
            this.itemImage  = this.itemUi.obj.GetComponent <Image>();
            Assert.IsTrue(this.itemImage);
            this.itemImage.sprite = MemoryMgr.GetSourceFromResources <Sprite>(this.itemUi.SpritePath);
            this.itemNum          = this.itemUi.obj.GetComponentInChildren <Text>();
            Assert.IsTrue(this.itemNum);
        }
Example #4
0
        private void InitItemList()
        {
            GameObject itemObj;

            foreach (var id in itemIdList)
            {
                itemObj = MemoryMgr.InstantiateGameObject(DirPath.LittleUiDir + this.itemDataPath, this.itemList);
                Assert.IsTrue(itemObj);
                var itemInfo = ItemMgr.GetItem <AbstractCommodity>(id);
                itemObj.transform.Find("Image_ItemAvator").GetComponent <Image>().sprite =
                    MemoryMgr.GetSourceFromResources <Sprite>(itemInfo.SpritePath);
                itemObj.transform.Find("Tmp_Price").GetComponent <TextMeshProUGUI>().text = itemInfo.price.ToString();

                this.items.Add(itemObj);
            }
        }
Example #5
0
        /// <summary>
        /// 播放指定名字的背景音乐
        /// </summary>
        /// <param name="name"></param>
        public void PlayBgm(string name)
        {
            if (!enableBgmAudio)
            {
                return;
            }

            var clip = MemoryMgr.GetSourceFromResources <AudioClip>(name);

            if (clip == null)
            {
                Debug.Log("音效获取失败:" + name);
                return;
            }

            BgmAudioSource.clip   = clip;
            BgmAudioSource.loop   = true;
            BgmAudioSource.volume = 1;
            BgmAudioSource.Play();
        }
Example #6
0
        /// <summary>
        /// 播放指定名字音效
        /// </summary>
        /// <param name="name"></param>
        public void PlayEffect(string name)
        {
            if (!enableEffectAudio)
            {
                return;
            }

            var clip = MemoryMgr.GetSourceFromResources <AudioClip>(name);

            if (clip == null)
            {
                Debug.Log("音效获取失败:" + name);
                return;
            }

            var audioSource = GetAudioSource();

            audioSource.clip = clip;
            audioSource.loop = false;
            audioSource.Play();
        }
 /// <summary>
 /// 在指定位置播放音效
 /// </summary>
 /// <param CharacterName="audioName"></param>
 /// <param CharacterName="position"></param>
 public void PlayEffect(string audioPath, Vector3 position)
 {
     AudioSource.PlayClipAtPoint(MemoryMgr.GetSourceFromResources <AudioClip>(audioPath), position);
 }