Exemplo n.º 1
0
        private void AddObjectToPool(GameObject go)
        {
            if (go == null)
            {
                return;
            }

            if (!availableObjStack.Contains(go))
            {
                availableObjStack.Push(go);
                go.SetActive(false);
                go.transform.SetParent(LuaHelper.GetPoolManager().PoolRootObject, false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加悬停事件
        /// </summary>
        /// <param name="go"></param>
        /// <param name="luafunc"></param>
        public void AddHovor(GameObject go, LuaFunction luafunc)
        {
            if (go == null || luafunc == null)
            {
                return;
            }
            AddEventListener(go.name, "onhovor", luafunc);
            UIEventListener.Get(go).onHover = delegate(GameObject o, bool isOver)
            {
                if (!LuaHelper.GetPanelManager().CanOpenPanel() || PreLoadingScene.inPreloading)
                {
                    return;
                }

                luafunc.Call(go, isOver);
            };
        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加滚动事件
        /// </summary>
        /// <param name="go"></param>
        /// <param name="luafunc"></param>
        public void AddScroll(GameObject go, LuaFunction luafunc)
        {
            if (go == null || luafunc == null)
            {
                return;
            }
            AddEventListener(go.name, "onscroll", luafunc);
            UIEventListener.Get(go).onScroll = delegate(GameObject o, float delta)
            {
                if (!LuaHelper.GetPanelManager().CanOpenPanel() || PreLoadingScene.inPreloading)
                {
                    return;
                }

                luafunc.Call(go, delta);
            };
        }
Exemplo n.º 4
0
        /// <summary>
        /// 添加拖动out事件
        /// </summary>
        /// <param name="go"></param>
        /// <param name="luafunc"></param>
        public void AddDrop(GameObject go, LuaFunction luafunc)
        {
            if (go == null || luafunc == null)
            {
                return;
            }
            AddEventListener(go.name, "ondrop", luafunc);
            UIEventListener.Get(go).onDrop = delegate(GameObject o, GameObject dropGo)
            {
                if (!LuaHelper.GetPanelManager().CanOpenPanel() || PreLoadingScene.inPreloading)
                {
                    return;
                }

                luafunc.Call(go, dropGo);
            };
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加选择事件
        /// </summary>
        /// <param name="go"></param>
        /// <param name="luafunc"></param>
        public void AddSelect(GameObject go, LuaFunction luafunc)
        {
            if (go == null || luafunc == null)
            {
                return;
            }
            AddEventListener(go.name, "onselect", luafunc);
            UIEventListener.Get(go).onSelect = delegate(GameObject o, bool selected)
            {
                if (!LuaHelper.GetPanelManager().CanOpenPanel() || PreLoadingScene.inPreloading)
                {
                    return;
                }

                luafunc.Call(go, selected);
            };
        }
Exemplo n.º 6
0
        /// <summary>
        /// 添加按下事件
        /// </summary>
        /// <param name="go"></param>
        /// <param name="luafunc"></param>
        public void AddPress(GameObject go, LuaFunction luafunc)
        {
            if (go == null || luafunc == null)
            {
                return;
            }
            AddEventListener(go.name, "onpress", luafunc);
            UIEventListener.Get(go).onPress = delegate(GameObject o, bool isPressed)
            {
                if (!LuaHelper.GetPanelManager().CanOpenPanel() || PreLoadingScene.inPreloading)
                {
                    return;
                }

                ExtendEventDeal(go, "onpress");
                luafunc.Call(go, isPressed);
            };
        }
Exemplo n.º 7
0
        /// <summary>
        /// 添加拖动开始事件
        /// </summary>
        /// <param name="go"></param>
        /// <param name="luafunc"></param>
        public void AddDragStart(GameObject go, LuaFunction luafunc)
        {
            if (go == null || luafunc == null)
            {
                return;
            }
            AddEventListener(go.name, "ondragstart", luafunc);
            UIEventListener.Get(go).onDragStart = delegate(GameObject o)
            {
                if (!LuaHelper.GetPanelManager().CanOpenPanel() || PreLoadingScene.inPreloading)
                {
                    return;
                }

                ExtendEventDeal(go, "ondragstart");
                luafunc.Call(go);
            };
        }
Exemplo n.º 8
0
 public static void InputFunctionDown(int type)
 {
     if (GameGOW.Get().BattleMgr.m_bIsInBattle == false)
     {
         return;
     }
     if (Network.gamemode == BattleType.AI_1v1)
     {
         int index = GameGOW.Get().BattleMgr.m_iCurrentRoundPlayerIndex;
         int id    = GameGOW.Get().BattleMgr.m_stBattleInfo.m_listPlayers[index].m_iPlayerUID;
         if (Network.playerid == id && Network.Attacking == 0)
         {
             Network.BombEnergy = LuaHelper.GetSkillInfo2("ENERGY", 100 + SkillManager.CurrentSkillId);
             int Energy = LuaHelper.GetSetEnergy(-1);
             LuaHelper.GetSetEnergy(Energy - (int)Network.BombEnergy);
             Network.Moving    = true;
             Network.Attacking = 1;
             var m_pCharacterLogic = GameGOW.Get().BattleMgr.m_pCurrentPlayer;
             m_pCharacterLogic.OnFunctionKeyDown(type);
         }
     }
     else if (Network.NetworkMode == true)
     {
         int index = GameGOW.Get().BattleMgr.m_iCurrentRoundPlayerIndex;
         int id    = GameGOW.Get().BattleMgr.m_stBattleInfo.m_listPlayers[index].m_iPlayerUID;
         if (Network.playerid == id && Network.Attacking == 0)
         {
             Network.BombEnergy = LuaHelper.GetSkillInfo2("ENERGY", 100 + SkillManager.CurrentSkillId);
             int Energy = LuaHelper.GetSetEnergy(-1);
             LuaHelper.GetSetEnergy(Energy - (int)Network.BombEnergy);
             Network.Moving    = true;
             Network.Attacking = 1;
             var m_pCharacterLogic = GameGOW.Get().BattleMgr.m_pCurrentPlayer;
             m_pCharacterLogic.OnFunctionKeyDown(type);
         }
     }
     else
     {
         var m_pCharacterLogic = GameGOW.Get().BattleMgr.m_pCurrentPlayer;
         m_pCharacterLogic.OnFunctionKeyDown(type);
     }
 }
Exemplo n.º 9
0
        public static void ShakeScreenEffect(GameObject go, bool isShakeCamera, float shakeTime, float shakeDelta)
        {
            ShakeCamera shakeCamera;

            if (!isShakeCamera)
            {
                Transform parent = LuaHelper.GetPrefabLoader().Parent;
                shakeCamera = parent.GetComponent <ShakeCamera>();
                if (shakeCamera == null)
                {
                    shakeCamera = parent.gameObject.AddComponent <ShakeCamera>();
                }
            }
            else
            {
                shakeCamera = go.GetComponent <ShakeCamera>();
                if (shakeCamera == null)
                {
                    shakeCamera = go.AddComponent <ShakeCamera>();
                }
            }
            shakeCamera.SetShakeParams(isShakeCamera, shakeTime, shakeDelta);
        }
Exemplo n.º 10
0
        public static GameObject CreatePrefab(Transform parent, string path, string name)
        {
            try {
                int num = 0;
                for (int i = 6; i < name.Length; i++)
                {
                    num = num * 10 + name[i] - '0';
                }
                GameObject template = AppFacade.ResManager.GetRes <GameObject>(path);
                GameObject go       = GameObject.Instantiate(template) as GameObject;
                go.name = name;
                go.transform.SetParent(parent, false);
                go.transform.GetChild(1).GetComponent <Text>().text = Network.Friend_list[num].name;

                Toggle tgl = go.transform.GetChild(0).GetComponent <Toggle>();
                tgl.onValueChanged.AddListener(
                    delegate(bool isOn) {
                    Lua_set_string("Lua_Find_Friend", Get_Friend_Name(num));
                }
                    );
                if (LuaHelper.Get_Friend_Status(num) == 1)
                {
                    go.transform.GetChild(2).GetComponent <Text>().text = "在线";
                    ChangeTextColor(go.transform.GetChild(2), 0f, 255f, 119f, 255f);
                }
                else
                {
                    go.transform.GetChild(2).GetComponent <Text>().text = "离线";
                    ChangeTextColor(go.transform.GetChild(2), 51f, 68f, 119f, 255f);
                }

                string headpath = "Sprites/head" + (LuaHelper.Get_Friend_Sex(num)).ToString();
                LoadSprite(go.transform.GetChild(0).GetChild(0).gameObject, headpath);

                //好友列表微信头像
                if (Network.Friend_list[num].wxLogin)
                {
                    setFriendHead(go.transform.GetChild(0).GetChild(0).gameObject, Network.Friend_list[num].wxHead);
                }

                GameObject invite_btn = go.transform.GetChild(3).gameObject;
                if (LuaHelper.Get_Friend_Status(num) != 1)
                {
                    invite_btn.SetActive(false);
                }
                //invite_btn.SetActive(false);//出包暂时隐藏
                Button invite = invite_btn.GetComponent <Button>();
                invite.onClick.AddListener(
                    delegate() {
                    Network.Invitation_name = Get_Friend_Name(num);
                    EventDispatcher.DispatchEvent("EventInvitationFriendConfirm", null, null);
                    //Network.Send_Invitation_Friend(Get_Friend_Name(num));
                    LOG.Log("heheda");
                }
                    );

                return(go);
            } catch (Exception e) {
                LOG.Log(e.Message);
                LOG.Log(e.StackTrace);
            }
            return(null);
        }
Exemplo n.º 11
0
        IEnumerator OnExtractResource()
        {
            string dataPath = Util.DataPath;         //数据目录
            string resPath  = Util.AppContentPath(); //游戏包资源目录

            if (Directory.Exists(dataPath))
            {
                Directory.Delete(dataPath, true);
            }
            Directory.CreateDirectory(dataPath);

            string infile  = resPath + "files.txt";
            string outfile = dataPath + "files.txt";

            if (File.Exists(outfile))
            {
                File.Delete(outfile);
            }

            string message = "正在解包文件:>files.txt";

            Debug.Log(infile);
            Debug.Log(outfile);
            if (Application.platform == RuntimePlatform.Android)
            {
                WWW www = new WWW(infile);
                yield return(www);

                if (www.isDone)
                {
                    File.WriteAllBytes(outfile, www.bytes);
                }
                yield return(0);
            }
            else
            {
                File.Copy(infile, outfile, true);
            }
            yield return(new WaitForEndOfFrame());

            //释放所有文件到数据目录
            string[] files  = File.ReadAllLines(outfile);
            int      cnt    = 0;
            float    length = files.Length;

            foreach (var file in files)
            {
                string[] fs = file.Split('|');
                infile  = resPath + fs[0]; //
                outfile = dataPath + fs[0];

                message = "正在解包文件:>" + fs[0];
                Debug.Log("正在解包文件:>" + infile);
                LuaHelper.SetLoading("正在解包文件(不会消耗流量)" + ++cnt + "/" + length, cnt / length);
                facade.SendMessageCommand(NotiConst.UPDATE_MESSAGE, message);

                string dir = Path.GetDirectoryName(outfile);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                if (Application.platform == RuntimePlatform.Android)
                {
                    WWW www = new WWW(infile);
                    yield return(www);

                    if (www.isDone)
                    {
                        File.WriteAllBytes(outfile, www.bytes);
                    }
                    yield return(0);
                }
                else
                {
                    if (File.Exists(outfile))
                    {
                        File.Delete(outfile);
                    }
                    File.Copy(infile, outfile, true);
                }
                yield return(new WaitForEndOfFrame());
            }
            message = "解包完成!!!";
            LuaHelper.SetLoading("资源解压完成!!!", 1);
            facade.SendMessageCommand(NotiConst.UPDATE_MESSAGE, message);
            yield return(new WaitForSeconds(0.1f));

            message = string.Empty;
            //释放完成,开始启动更新资源
            StartCoroutine(OnUpdateResource());
        }
Exemplo n.º 12
0
        /// <summary>
        /// 启动更新下载,这里只是个思路演示,此处可启动线程下载更新
        /// </summary>
        IEnumerator OnUpdateResource()
        {
            if (!AppConst.UpdateMode)
            {
                OnResourceInited();
                yield break;
            }
            LuaHelper.SetLoading("正在检测更新", 0);
            string dataPath = Util.DataPath;  //数据目录
            string url      = AppConst.WebUrl;
            string message  = string.Empty;
            string random   = DateTime.Now.ToString("yyyymmddhhmmss");
            string listUrl  = url + "files.txt?v=" + random;

            Debug.LogWarning("LoadUpdate---->>>" + listUrl);

            WWW www = new WWW(listUrl); yield return(www);

            if (www.error != null)
            {
                OnUpdateFailed(string.Empty);
                yield break;
            }
            if (!Directory.Exists(dataPath))
            {
                Directory.CreateDirectory(dataPath);
            }
            File.WriteAllBytes(dataPath + "files.txt", www.bytes);
            string filesText = www.text;

            string[] files = filesText.Split('\n');

            int packgeSize            = 0;
            int loadSize              = 0;
            List <PackgeInfo> packges = new List <PackgeInfo>();

            for (int i = 0; i < files.Length; i++)
            {
                if (string.IsNullOrEmpty(files[i]))
                {
                    continue;
                }
                string[] keyValue  = files[i].Split('|');
                string   f         = keyValue[0];
                int      size      = int.Parse(keyValue[2]);
                string   localfile = (dataPath + f).Trim();
                string   path      = Path.GetDirectoryName(localfile);
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string fileUrl   = url + f + "?v=" + random;
                bool   canUpdate = !File.Exists(localfile);
                if (!canUpdate)
                {
                    string remoteMd5 = keyValue[1].Trim();
                    string localMd5  = Util.md5file(localfile);
                    canUpdate = !remoteMd5.Equals(localMd5);
                    if (canUpdate)
                    {
                        File.Delete(localfile);
                    }
                }
                if (canUpdate)     //本地缺少文件
                {
                    packgeSize += size;
                    packges.Add(new PackgeInfo()
                    {
                        size = size, fileUrl = fileUrl, localfile = localfile
                    });
                }
            }

            float  rate      = 1024;
            string dw        = "kb";
            float  downSpeed = 0;

            if (packgeSize > 10485760)
            {
                dw   = "mb";
                rate = 1048576;
            }
            float startTime = Time.time;

            foreach (var item in packges)
            {
                message = "downloading>>" + item.fileUrl;
                facade.SendMessageCommand(NotiConst.UPDATE_MESSAGE, message);
                #region 注释

                /*
                 * www = new WWW(fileUrl); yield return www;
                 * if (www.error != null) {
                 *  OnUpdateFailed(path);   //
                 *  yield break;
                 * }
                 * File.WriteAllBytes(localfile, www.bytes);
                 */
                //这里都是资源文件,用线程下载
                #endregion
                BeginDownload(item.fileUrl, item.localfile);
                while (!(IsDownOK(item.localfile)))
                {
                    float load = loadSize + downSpeed * (Time.time - startTime); // 预测下载进度
                    if (load > (loadSize + item.size))
                    {
                        load = item.size;
                    }
                    if (load < loadSize)
                    {
                        load = loadSize;
                    }
                    float fill = load / packgeSize;
                    Debug.Log(load / rate);
                    Debug.Log(packgeSize / rate);
                    Debug.Log(dw);
                    Debug.Log(fill * 100);

                    string state = string.Format("更新中   {3:F}%   {0:F}{2}/{1:F}{2}", load / rate, packgeSize / rate, dw, fill * 100);
                    LuaHelper.SetLoading(state, fill);
                    yield return(new WaitForEndOfFrame());
                }
                loadSize += item.size;
                downSpeed = loadSize / (Time.time - startTime); // 记录文件下载速度
            }
            yield return(new WaitForEndOfFrame());

            LuaHelper.Loading.SetActive(false);
            message = "更新完成!!";
            LuaHelper.SetLoading("更新完成!!", 0, false);
            facade.SendMessageCommand(NotiConst.UPDATE_MESSAGE, message);

            OnResourceInited();
        }
Exemplo n.º 13
0
 public static bool GetCanTouch()
 {
     return(LuaHelper.GetPrefabLoader().GetEventSystem.enabled);
 }
Exemplo n.º 14
0
 public static void SetCanTouch(bool isEnabled)
 {
     LuaHelper.GetPrefabLoader().GetEventSystem.enabled = isEnabled;
 }
Exemplo n.º 15
0
 //反注册热更新列表
 void OnDisable()
 {
     LuaHelper.GetInstance().CallLuaFunction("ProjectHotFix", "UnRegister_HotFix");
 }
Exemplo n.º 16
0
 public void ReceiveInfoStartRuning()
 {
     LuaHelper.GetInstance().DoString("require 'StartGame'");
 }
Exemplo n.º 17
0
 void Start()
 {
     LuaHelper.GetInstance().DoString("require 'StartGame'");
 }