Ejemplo n.º 1
0
    void Start()
    {
        print("Normal_Start");

        GameMgr.Instance.PlayerPos = this.PlayerPos;

        if (enableMiniMap)
        {
            MemoryMgr.InstantiateGameObject(DirPath.LittleUiDir + UiName.Image_MiniMap, GlobalVar.G_Canvas.transform);
        }

        if (!string.IsNullOrEmpty(UiPanelName))
        {
            PanelMgr.PushPanel(UiPanelName);
            if (UiPanelName == PanelName.battlePanel)
            {
                CEventCenter.BroadMessage(Message.M_RankAwake, 0, 0);
            }
        }

        if (creatTestPeople)
        {
            new TestPerson("Test", DirPath.GameObjectDir + GameObjectName.TestPerson, EnemyPos);
        }
    }
Ejemplo n.º 2
0
 protected override void Awake()
 {
     base.Awake();
     //实现从文件夹读取所有文件
     MemoryMgr.LoadAssetFromResourceDir <AudioClip>(typeof(AudioName), "Audio/", (name, audio) =>
                                                    audioclips.Add(name, audio));
 }
        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);
            }
        }
Ejemplo n.º 4
0
 private void Awake()
 {
     print("Normal_Awake");
     if (GameObject.FindGameObjectsWithTag("GameController").Length <= 0)
     {
         MemoryMgr.InstantiateGameObject(DirPath.GameObjectDir + GameObjectName.GameMgr);
     }
 }
 protected AbstractSpriteObj(string path, Vector3 pos, Transform parent = null)
 {
     obj = MemoryMgr.Instantiate(path, pos, Quaternion.identity, parent);
     if (obj == null)
     {
         throw new Exception("子弹生成失败");
     }
     MainLoop.Instance.AddUpdateFunc(Update);
 }
        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;
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        void Start()
        {
            if (enableMiniMap)
            {
                MemoryMgr.InstantiateGameObject(UiPath.Image_MiniMapBackGround,
                                                GlobalVar.G_Canvas.transform);
            }


            if (PanelUiAsset != null)
            {
                PanelAssetMgr.PushPanel(PanelUiAsset);
            }
            CEventCenter.BroadMessage(Message.M_RankAwake, 0, 0);
        }
Ejemplo n.º 9
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);
            }
        }
        public AbstractPerson(BaseCharacterInfo characterInfo, Vector3 pos, Transform parent = null)
        {
            this.characterInfoInfo = characterInfo;

            this.obj = MemoryMgr.InstantiateGameObject(characterInfo.prefabPath.Path, pos, Quaternion.identity, parent);
            this.Hp  = characterInfo.maxHp;

            //添加事件监听
            OnAddListener();

            //开始每帧Update
            MainLoop.Instance.AddUpdateFunc(Update);

            //记录每个实例
            instanceList.Add(this);
        }
Ejemplo n.º 11
0
        public AbstractPerson(string name, string prefabPath, Vector3 pos, List <string> skillTypes = null, Transform parent = null)
        {
            //初始化默认属性
            this.name             = name;
            this.InputOk          = true;
            this.IsConst          = false;
            this.IgnoreHitback    = false;
            this.DefaultConstTime = 0;

//            Debug.Log("TestPerson_PrefabPath:"+ prefabPath);
            this.obj = MemoryMgr.InstantiateGameObject(prefabPath, pos, Quaternion.identity, parent);


            allSkillNames = skillTypes;
            //初始化技能
            if (skillTypes != null)
            {
                foreach (var str in skillTypes)
                {
                    //skillDic.Add(str, SkillTriggerMgr.skillInstanceDic[str]);
                    skills.Add(SkillTriggerMgr.skillInstanceDic[str]);
                }
            }

            if (skillTypes != null)
            {
                this.maxRealSkillCount = skillTypes.Count - this.BaseSkillCount;
            }
            else
            {
                this.maxRealSkillCount = 0;
            }

            //添加基本攻击效果
            this.OnAttackListRefresh += AddBaseAttackEffects;
            //添加事件监听
            OnAddListener();

            //开始每帧Update
            MainLoop.Instance.AddUpdateFunc(Update);

            //记录每个实例
            instanceList.Add(this);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 创建窗体
        /// </summary>
        /// <returns></returns>
        protected virtual void Create(string path)
        {
            m_sResName = path;

            if (m_TransFrom)
            {
                Debug.LogError("Window Create Error Exist");
                return;
            }

            if (string.IsNullOrEmpty(m_sResName))
            {
                Debug.LogError("Windows Create Error ResName is empty");
                return;
            }

            if (GlobalVar.G_Canvas == null)
            {
                throw new Exception("你忘了初始化GlobalVar.G_Canvas");
            }

            var canvas = GlobalVar.G_Canvas.transform;

            if (null == canvas)
            {
                throw new Exception("画布获取失败");
            }

            var obj = MemoryMgr.InstantiateGameObject(m_sResName, canvas);

            if (obj == null)
            {
                Debug.LogError("Window Create Error LoadRes WindowName = " + m_sResName);
                return;
            }

            m_TransFrom = obj.transform;

            m_TransFrom.gameObject.SetActive(false);

            InitWindow();
        }
Ejemplo n.º 13
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();
        }
Ejemplo n.º 14
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();
        }
Ejemplo n.º 15
0
 public long ReserveMemory(long Size, long Align)
 {
     return(MemoryMgr.Reserve(Size, Align));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 在指定位置播放音效
 /// </summary>
 /// <param CharacterName="audioName"></param>
 /// <param CharacterName="position"></param>
 public void PlayEffect(string audioPath, Vector3 position)
 {
     AudioSource.PlayClipAtPoint(MemoryMgr.GetSourceFromResources <AudioClip>(audioPath), position);
 }
Ejemplo n.º 17
0
 public long GetCpuAddr(long Position)
 {
     return(MemoryMgr.GetCpuAddr(Position));
 }
Ejemplo n.º 18
0
 public long MapMemory(long CpuAddr, long GpuAddr, long Size)
 {
     return(MemoryMgr.Map(CpuAddr, GpuAddr, Size));
 }
Ejemplo n.º 19
0
 public long ReserveMemory(long GpuAddr, long Size, long Align)
 {
     return(MemoryMgr.Reserve(GpuAddr, Size, Align));
 }