Call() public method

public Call ( ) : object[]
return object[]
示例#1
0
 public static void NetworkDecodeRecv(NetworkPeerLua peer, string msgName, MemoryStream stream, LuaFunction func)
 {
     if (_decodeRecvMethod != null)
     {
         if (stream == null)
         {
             _decodeRecvMethod.Call(peer, msgName, null, func);
         }
         else
         {
             _decodeRecvMethod.Call(peer, msgName, new PBStreamReader(stream.ToArray()), func);
         }
     }
 }
示例#2
0
文件: Util.cs 项目: tallitia/YYScript
    public static void AddChangeEvent(GameObject go, int id, LuaInterface.LuaFunction func)
    {
        Slider slider = go.GetComponent <Slider>();

        if (slider != null)
        {
            slider.onValueChanged.AddListener((value) => {
                func.Call(slider, id, value);
            });
            return;
        }

        Toggle toggle = go.GetComponent <Toggle>();

        if (toggle != null)
        {
            toggle.onValueChanged.AddListener((value) => {
                func.Call(toggle, id, value);
            });
            return;
        }

        InputField input = go.GetComponent <InputField>();

        if (input != null)
        {
            input.onValueChanged.AddListener((value) => {
                func.Call(input, id, value);
            });
        }

        ScrollRect scroll = go.GetComponent <ScrollRect>();

        if (scroll != null)
        {
            scroll.onValueChanged.AddListener((value) => {
                func.Call(scroll, id, value);
            });
        }
        Dropdown dropdown = go.GetComponent <Dropdown>();

        if (dropdown != null)
        {
            dropdown.onValueChanged.AddListener((value) => {
                func.Call(scroll, id, value);
            });
        }
    }
示例#3
0
 /// <summary>
 /// 添加lua单机事件
 /// </summary>
 public static void AddClick(GameObject go, System.Object luafuc)
 {
     UIEventListener.Get(go).onClick += delegate(GameObject o) {
         LuaInterface.LuaFunction func = (LuaInterface.LuaFunction)luafuc;
         func.Call();
     };
 }
        IEnumerator OnCreatePanel(string name, LuaFunction func = null)
        {
            yield return StartCoroutine(Initialize());

            string assetName = name + "Panel";
            // Load asset from assetBundle.
            string abName = name.ToLower() + AppConst.ExtName;
            AssetBundleAssetOperation request = ResourceManager.LoadAssetAsync(abName, assetName, typeof(GameObject));
            if (request == null) yield break;
            yield return StartCoroutine(request);

            // Get the asset.
            GameObject prefab = request.GetAsset<GameObject>();

            if (Parent.FindChild(name) != null || prefab == null) {
                yield break;
            }
            GameObject go = Instantiate(prefab) as GameObject;
            go.name = assetName;
            go.layer = LayerMask.NameToLayer("Default");
            go.transform.SetParent(Parent);
            go.transform.localScale = Vector3.one;
            go.transform.localPosition = Vector3.zero;
            go.AddComponent<LuaBehaviour>();

            if (func != null) func.Call(go);
            Debug.LogWarning("CreatePanel::>> " + name + " " + prefab);
        }
    void Start()
    {
        lua = new LuaState();
        lua.Start();
        lua.DoString(script, "AccessingArray.cs");

        int[] array = { 1, 2, 3, 4, 5};
        func = lua.GetFunction("TestArray");

        func.BeginPCall();
        func.Push(array);
        func.PCall();
        double arg1 = func.CheckNumber();
        string arg2 = func.CheckString();
        bool arg3 = func.CheckBoolean();
        Debugger.Log("return is {0} {1} {2}", arg1, arg2, arg3);
        func.EndPCall();

        //转换一下类型,避免可变参数拆成多个参数传递
        object[] objs = func.Call((object)array);

        if (objs != null)
        {
            Debugger.Log("return is {0} {1} {2}", objs[0], objs[1], objs[2]);
        }

        lua.CheckTop();
    }
示例#6
0
 /// <summary>
 /// 添加单击事件
 /// </summary>
 public void AddClick(GameObject go, LuaFunction luafunc) {
     if (go == null) return;
     UIEventListener.Get(go).onClick = delegate(GameObject o) {
         luafunc.Call(go);
         buttons.Add(luafunc);
     };
 }
示例#7
0
 public static void ClassCallMethod(string className, string methodName, GameObject go)
 {
     if (_callMethod != null)
     {
         _callMethod.Call(className, methodName, go);
     }
 }
示例#8
0
    public override void OnDistanceChanged(float dt)
    {
        if (_CamCtrlMode == CTRL_MODE.FIX25D)
        {
            return;
        }

        _IsModeChangeRecover = false;
        _IsSkillRecover      = false;
        _IsMoveToDest        = false;

        float dist = _DistOffset + dt * CamConfig.CamRollSensitivity;

        if (!InputManager.Instance.IsMultiDragingStarted && dist < CamConfig.CamMinOffsetDist && Mathf.Abs(dt) >= 0.25f)
        {
            if (_Enter_Near_Cam_Lua_Func == null)
            {
                _Enter_Near_Cam_Lua_Func = LuaScriptMgr.Instance.GetLuaFunction("TryEnterNearCam");
            }

            if (_Enter_Near_Cam_Lua_Func != null)
            {
                _Enter_Near_Cam_Lua_Func.Call();    //尝试进入近景模式
                return;
            }
        }

        _IsDistChangeByForce = true;
        _DistOffset          = _DistOffsetDest = Mathf.Clamp(dist, CamConfig.CamMinOffsetDist, _CurMaxDistOffset);
        _CurHeightOffset     = GetHeightOffsetByDistOffset(_DistOffset);
    }
示例#9
0
    public static KeyValuePair <bool, object> InjectMethod(string name, params object[] args)
    {
        if (notHave.ContainsKey(name))
        {
            return(notHaveFix);
        }
        DynamicScript.lua.DoFile("hotFix");
        string selectFName = name;

        if (DynamicScript.lua.IsFuncExists(selectFName))
        {
            LuaInterface.LuaFunction selectF = DynamicScript.lua.GetLuaFunction(selectFName);
            object[] result = selectF.Call(args);
            object   ret    = null;
            if (result != null && result.Length > 0)
            {
                ret = (object)result[0];
            }
            return(new KeyValuePair <bool, object>(true, ret));
        }
        else
        {
            notHave.Add(name, true);
        }
        return(notHaveFix);
    }
示例#10
0
    private void SetAwards(Dictionary <uint, uint> awards)
    {
        while (_bonus_grid.transform.childCount > 0)
        {
            NGUITools.Destroy(_bonus_grid.transform.GetChild(0).gameObject);
        }
        if (awards.Count <= 0)
        {
            return;
        }
        foreach (KeyValuePair <uint, uint> award in awards)
        {
            GameObject   item   = GameSystem.Instance.mClient.mUIManager.CreateUI("Prefab/GUI/GoodsIconConsume", _bonus_grid.transform);
            LuaComponent luacom = item.GetComponent <LuaComponent>();
            //UIAtlas _atlas = ResourceLoadManager.Instance.GetResources("Atlas/icon/iconGoods") as UIAtlas;
            //UISprite sprite = item.transform.FindChild("Icon").GetComponent<UISprite>();
            //sprite.atlas = _atlas;
            //string spriteName = string.Empty;
            //if (award.Key == GlobalConst.DIAMOND_ID)
            //    sprite.spriteName = "com_property_diamond2";
            //else if (award.Key == GlobalConst.GOLD_ID)
            //    sprite.spriteName = "com_property_gold2";
            //else if (award.Key == GlobalConst.TEAM_EXP_ID)
            //    sprite.spriteName = "com_property_exp";

            //sprite.spriteName += "_edged";
            LuaInterface.LuaFunction func = luacom.table["SetData"] as LuaInterface.LuaFunction;
            func.Call(new object[] { luacom.table, (int)(award.Key), (int)(award.Value), false });
            //item.GetComponentInChildren<UISprite>().spriteName = sprite.spriteName;
            item.GetComponentInChildren <UISprite>().depth = 10;
            //item.GetComponentInChildren<UILabel>().text = "+" + award.Value;
            item.GetComponentInChildren <UILabel>().depth = 10;
        }
        _bonus_grid.Reposition();
    }
示例#11
0
        /// <summary>
        /// ������壬������Դ������
        /// </summary>
        /// <param name="type"></param>
        public void CreatePanel(string name, LuaFunction func = null)
        {
            string assetName = name + "Panel";
            string abName = name.ToLower() + AppConst.ExtName;

            ResManager.LoadPrefab(abName, assetName, delegate(UnityEngine.Object[] objs) {
                if (objs.Length == 0) return;
                // Get the asset.
                GameObject prefab = objs[0] as GameObject;

                if (Parent.FindChild(name) != null || prefab == null) {
                    return;
                }
                GameObject go = Instantiate(prefab) as GameObject;
                go.name = assetName;
                go.layer = LayerMask.NameToLayer("Default");
                go.transform.SetParent(Parent);
                go.transform.localScale = Vector3.one;
                go.transform.localPosition = Vector3.zero;
                go.AddComponent<LuaBehaviour>();

                if (func != null) func.Call(go);
                Debug.LogWarning("CreatePanel::>> " + name + " " + prefab);
            });
        }
示例#12
0
	public static Delegate UnityEngine_Events_UnityAction(LuaFunction func)
	{
		UnityEngine.Events.UnityAction d = () =>
		{
			func.Call();
		};
		return d;
	}
示例#13
0
 public static Delegate Action(LuaFunction func)
 {
     Action d = () =>
     {
         func.Call();
     };
     return d;
 }
示例#14
0
文件: Util.cs 项目: tallitia/YYScript
    public static void AddSpineEvent(GameObject go, LuaInterface.LuaFunction func)
    {
        SkeletonGraphic com = go.GetComponent <SkeletonGraphic>();

        com.AnimationState.Complete += delegate {
            func.Call();
        };
    }
示例#15
0
 /// <summary>
 /// 添加单击事件
 /// </summary>
 public void AddClick(GameObject go, LuaFunction luafunc) {
     if (go == null) return;
     buttons.Add(luafunc);
     go.GetComponent<Button>().onClick.AddListener(
         delegate() {
             luafunc.Call(go);
         }
     );
 }
 /// <summary>
 /// 添加单击事件
 /// </summary>
 public void AddClick(string button, LuaFunction luafunc) {
     Transform to = trans.Find(button);
     if (to == null) return;
     GameObject go = to.gameObject;
     UIEventListener.Get(go).onClick = delegate(GameObject o) {
         luafunc.Call(go);
         buttons.Add(luafunc);
     };
 }
    public static Uobject LoadAsset(string path, System.Type type, string ext, LuaInterface.LuaFunction callBack = null)
    {
        Uobject obj = null;

        if (assetObjDic.TryGetValue(path, out obj))
        {
            assetNumDic[path]++;
            if (callBack != null)
            {
                callBack.Call(obj);
            }

            return(obj);
        }

        if (AssetConfig.UseAssetBundle)
        {
        }
        else
        {
#if UNITY_EDITOR
            obj = AssetDatabase.LoadAssetAtPath(path + ext, type);
            if (obj == null && ext == ".png")
            {
                Debug.LogError("load png-->jpg");
                obj = AssetDatabase.LoadAssetAtPath(path + ".jpg", type);
            }
#endif
        }
        if (obj)
        {
            assetNumDic.Add(path, 1);
            assetObjDic.Add(path, obj);
            if (callBack != null)
            {
                callBack.Call(obj);
            }
        }
        else
        {
            Debug.LogError("load asset fail  ---path: " + path);
        }
        return(obj);
    }
示例#18
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="eachFn"></param>
 public static void ForeachChild(GameObject parent, LuaFunction eachFn)
 {
     Transform pr=parent.transform;
     int count = pr.childCount;
     Transform child = null;
     for (int i = 0; i < count; i++)
     {
         child = pr.GetChild(i);
         eachFn.Call(i, child.gameObject);
     }
 }
示例#19
0
    void ShowAwardsAcquire(List <KeyValueData> awards)
    {
        LuaComponent luaCom = UIManager.Instance.CreateUI("Prefab/GUI/GoodsAcquirePopup").GetComponent <LuaComponent>();

        LuaInterface.LuaFunction setGoodsData = luaCom.table["SetGoodsData"] as LuaInterface.LuaFunction;
        foreach (KeyValueData award in awards)
        {
            setGoodsData.Call(new object[] { luaCom.table, award.id, award.value });
        }
        UIManager.Instance.BringPanelForward(luaCom.gameObject);
    }
示例#20
0
文件: Util.cs 项目: tallitia/YYScript
    public static void CallLuaFunction <T1, T2, T3>(string name, T1 arg1, T2 arg2, T3 arg3)
    {
        LuaManager manager = MainGame.GetManager <LuaManager>();

        LuaInterface.LuaFunction func = manager.GetFunction(name);
        if (func != null)
        {
            func.Call <T1, T2, T3>(arg1, arg2, arg3);
            func.Dispose();
            func = null;
        }
    }
示例#21
0
文件: Util.cs 项目: tallitia/YYScript
    public static void CallLuaFunction(string name)
    {
        LuaManager manager = MainGame.GetManager <LuaManager>();

        LuaInterface.LuaFunction func = manager.GetFunction(name);
        if (func != null)
        {
            func.Call();
            func.Dispose();
            func = null;
        }
    }
示例#22
0
        public static CharacterBaseInfo CreateCharacterBaseInfo(HeroInfo heroInfo)
        {
            CharacterBaseInfo characterInfo = new CharacterBaseInfo()
            {
                baseId   = (uint)heroInfo.heroData.id,
                hitId    = heroInfo.heroData.hitId,
                skillId1 = heroInfo.heroData.skillId1,
                skillId2 = heroInfo.heroData.skillId2,
                //passiveId1 = heroInfo.heroData.passiveId1,
                passiveIdDic = new Dictionary <int, int>(),
                passiveId2   = heroInfo.heroData.passiveId2,
                instanceID   = heroInfo.instanceID,
                HP           = (int)heroInfo.heroData.HP,
                maxHP        = heroInfo.heroData.HP,
                floatable    = heroInfo.heroData.floatable,
                speed        = (int)heroInfo.heroData.speed,
                roleType     = heroInfo.heroData.roleType,
                roleInfo     = heroInfo
            };

            if (characterInfo.hitId != 0)
            {
                characterInfo.hitSkillInfo = new SkillInfo(characterInfo.hitId);
                characterInfo.hitSkillInfo.characterInstanceId = heroInfo.instanceID;
            }
            if (characterInfo.skillId1 != 0)
            {
                characterInfo.skillInfo1 = new SkillInfo(characterInfo.skillId1);
                characterInfo.skillInfo1.characterInstanceId = heroInfo.instanceID;
            }
            if (characterInfo.skillId2 != 0)
            {
                characterInfo.skillInfo2 = new SkillInfo(characterInfo.skillId2);
                characterInfo.skillInfo2.characterInstanceId = heroInfo.instanceID;
            }
            if (characterInfo.roleInfo.advanceLevel > characterInfo.roleInfo.heroData.starMin)
            {
                characterInfo.dlevel = (uint)characterInfo.roleInfo.advanceLevel - characterInfo.roleInfo.heroData.starMin;
            }
            if (heroInfo.heroData.passiveId1 > 0)
            {
                characterInfo.passiveIdDic.Add((int)heroInfo.heroData.passiveId1, 1);
                string luaFile = "user/skill/passive_skill_" + heroInfo.heroData.passiveId1;
                //if (Lua.Model.LuaData.ExistLuaFile(luaFile))
                LuaScriptMgr.Instance.DoFile(luaFile);
            }
            LuaInterface.LuaFunction initFunc = PassiveSkillController.instance.GetPassiveSkillLuaFunction(PassiveSkillController.INIT_CHARACTER_DATAS, (int)characterInfo.baseId);
            if (initFunc != null)
            {
                initFunc.Call(characterInfo.instanceID);
            }
            return(characterInfo);
        }
示例#23
0
 /// <summary>
 /// 添加单击事件
 /// </summary>
 public void AddClick(string button, LuaFunction luafunc)
 {
     Transform to = trans.Find(button);
     if (to == null) return;
     buttons.Add(luafunc);
     GameObject go = to.gameObject;
     go.GetComponent<Button>().onClick.AddListener(
         delegate() {
             luafunc.Call(go);
         }
     );
 }
示例#24
0
 /// <summary>
 /// 执行Lua函数
 /// </summary>
 /// <param name="fun">函数名</param>
 /// <param name="pa">参数列表</param>
 /// <returns></returns>
 public object ExecuteFunc(string fun, params object[] pa)
 {
     LuaInterface.LuaFunction fff = pLuaVM.GetFunction(fun);
     object[] obj = fff.Call(pa);
     if (obj != null)
     {
         return(obj[0]);
     }
     else
     {
         return(null);
     }
 }
示例#25
0
        /// <summary>
        /// 添加单击事件
        /// </summary>
        public void AddClick(GameObject go, LuaFunction luafunc) {
            if (go == null || luafunc == null) return;
			if (buttons.ContainsKey (go.name)) {
				Debug.LogWarning ("Already Registered :" + go.name + " click event");
				RemoveClick (go);
			}
            buttons.Add(go.name, luafunc);
            go.GetComponent<Button>().onClick.AddListener(
                delegate() {
                    luafunc.Call(go);
                }
            );
        }
示例#26
0
 public void ShowSpecifiedUI(string strUIName, uint param)
 {
     if (UICallList.ContainsKey(strUIName))
     {
         UICallList[strUIName](param);
     }
     else
     {
         LuaInterface.LuaTable    topPanelMgr   = LuaScriptMgr.Instance.GetLuaTable("TopPanelManager");
         LuaInterface.LuaFunction funcShowPanel = topPanelMgr["ShowPanel"] as LuaInterface.LuaFunction;
         funcShowPanel.Call(new object[] { topPanelMgr, strUIName, param });
     }
 }
示例#27
0
 public bool CallFunction(int index)
 {
     if (index < dataList.Count)
     {
         if (dataList[index].GetType() == typeof(LuaInterface.LuaFunction))
         {
             LuaInterface.LuaFunction f = (LuaInterface.LuaFunction)dataList[index];
             f.Call();
             return(true);
         }
     }
     return(false);
 }
示例#28
0
 public void CallLuaFunction(LuaFunction func, Object[] args)
 {
     try
     {
         if (args != null)
         {
             func.Call(args);
         }
         else
         {
             func.Call();
         }
         m_luaState.DoString("io.flush()");
     }
     catch (LuaException e)
     {
         PrintError(e);
     }
     catch (Exception e)
     {
         PrintError(e);
     }
 }
示例#29
0
    void OnDestroy()
    {
        if (info.funcOnDestroy != null)
        {
            info.funcOnDestroy.Call(table);
        }

        table.Release();
        table = null;

        LuaInterface.LuaTable    topPanelMgr  = LuaScriptMgr.Instance.GetLuaTable("TopPanelManager");
        LuaInterface.LuaFunction SetLuaComNil = topPanelMgr["SetLuaComNil"] as LuaInterface.LuaFunction;
        SetLuaComNil.Call(new object[] { topPanelMgr, info.scriptName });
    }
    public void LoadUI(string pkg, string pageName, LuaInterface.LuaFunction gfunc = null)
    {
#if ASYNC_MODE
        UIPackage.CreateObjectAsync(pkg, pageName, delegate(GObject obj)
        {
            Debug.Log("异步加载打开");
            if (gfunc != null)
            {
                gfunc.Call <GObject>(obj);
                gfunc.Dispose();
                gfunc = null;
            }
        });
#else
        Debug.Log("同步加载打开");
        GObject obj = UIPackage.CreateObject(pkg, pageName);
        if (gfunc != null)
        {
            gfunc.Call <GObject>(obj);
            gfunc.Dispose();
            gfunc = null;
        }
#endif
    }
示例#31
0
        IEnumerator OnLoadAsset(string abname, string assetName, LuaFunction func) {
            // Load asset from assetBundle.
            string abName = abname.ToLower() + AppConst.ExtName;
            AssetBundleAssetOperation request = ResourceManager.LoadAssetAsync(abName, assetName, typeof(GameObject));
            if (request == null) yield break;
            yield return StartCoroutine(request);

            // Get the asset.
            GameObject prefab = request.GetAsset<GameObject>();
            if (func != null) {
                func.Call(prefab);
                func.Dispose();
                func = null;
            }
        }
示例#32
0
 private void SetOnLoadCallBack(LuaInterface.LuaFunction luaCall)
 {
     if (_FxObject != null)
     {
         if (luaCall != null)
         {
             luaCall.Call(gameObject);
             luaCall.Release();
         }
     }
     else
     {
         _OnCreateLuaCB = luaCall;
     }
 }
	// Use this for initialization
	void Start () {
        LuaScriptMgr mgr = new LuaScriptMgr();
        
        mgr.DoString(script);

        // Get the function object
        func = mgr.GetLuaFunction("luaFunc");

        //有gc alloc
        object[] r = func.Call(123456);        
        print(r[0]);

        // no gc alloc
        int num = CallFunc();
        print(num);
	}
示例#34
0
    // 返回脚本实际存在的函数情况来决定是否调用其函数
    public static bool[] ClassHasMethod(string className)
    {
        var methodExistsStatus = new bool[(int)CellLuaClass.MethodName.Max];

        if (_hasMethod != null)
        {
            var ret = _hasMethod.Call(className)[0] as LuaInterface.LuaTable;

            for (int i = 0; i < ret.Length; i++)
            {
                methodExistsStatus[i] = (bool)ret[i + 1];
            }
        }

        return(methodExistsStatus);
    }
 public static void OnComplete(Tweener tweener, LuaFunction func)
 {
     tweener.OnComplete(() =>
     {
         try
         {
             func.Call();
         }
         catch (Exception e)
         {
             Debug.LogError(e);
         }
         func.Dispose();
         func = null;
     });
 }
示例#36
0
        /// <summary>
        /// 创建面板,请求资源管理器
        /// </summary>
        /// <param name="type"></param>
        public void CreatePanel(string name, LuaFunction func = null) {
            string assetName = name + "Panel";
            GameObject prefab = ResManager.LoadAsset(name, assetName);
            if (Parent.FindChild(name) != null || prefab == null) {
                return;
            }
            GameObject go = Instantiate(prefab) as GameObject;
            go.name = assetName;
            go.layer = LayerMask.NameToLayer("Default");
            go.transform.SetParent(Parent);
            go.transform.localScale = Vector3.one;
            go.transform.localPosition = Vector3.zero;
            go.AddComponent<LuaBehaviour>();

            if (func != null) func.Call(go);
            Debug.LogWarning("CreatePanel::>> " + name + " " + prefab);
        }
示例#37
0
    private void StartPlay()
    {
        _IsPlaying = true;

        gameObject.SetActive(true);
        //If using rectMask2D
        UISFxAreaClip sfx_clip = GetComponent <UISFxAreaClip>();

        if (sfx_clip != null)
        {
            sfx_clip.UpdateFxObject(false);
        }

        if (_Duration <= 0)
        {
            FxDuration fd = _FxObject.GetComponent <FxDuration>();
            if (fd != null)
            {
                _Duration = fd.duration;
            }
        }

        // adapted to the new FX recycle mechanism by LiJian
        _AutoPlayComp = _FxObject.GetComponent <AutoPlayFx>();
        if (_AutoPlayComp == null)
        {
            _AutoPlayComp = _FxObject.AddComponent <AutoPlayFx>();
        }
        _AutoPlayComp.enabled = true;

        if (_Duration > 0)
        {
            Invoke("StopPlay", _Duration);
        }

        //_LastStopTime = Time.time;
#if IN_GAME
        if (_OnCreateLuaCB != null)
        {
            _OnCreateLuaCB.Call(gameObject);
            _OnCreateLuaCB.Release();
            _OnCreateLuaCB = null;
        }
#endif
    }
 public static Tweener TweenFloat(float start, float end, float duration, LuaFunction OnUpdate)
 {
     return DOTween.To(() => start, x =>
     {
         try
         {
             OnUpdate.Call(x);
         }
         catch (Exception e)
         {
             Debug.LogError(e);
         }
     }
     , end, duration).SetEase(Ease.Linear).OnComplete(() =>
     {
         OnUpdate.Dispose();
         OnUpdate = null;
     });
 }
示例#39
0
    // Update is called once per frame
    void Update()
    {
        if (!isPlaying)
        {
            return;
        }

        m_timeTick += Time.deltaTime * m_animData.Speed;
        if (m_timeTick >= GlobalConfig.AnimationSpeed)
        {
            m_timeTick = 0;
            animIndex++;
            if (animIndex >= m_listSprite.Count)
            {
                animIndex = 0;

                if (m_animData.Loop == 0)
                {
                    if (m_animCompleteEvent != null)
                    {
                        m_animCompleteEvent();
                        //m_animCompleteEvent = null;
                        PlayAnimation(m_animData.NextAnim, m_animCompleteEvent);
                    }

                    if (m_animCompleteEventLua != null)
                    {
                        m_animCompleteEventLua.Call();
                        //m_animCompleteEventLua = null;
                        PlayAnimation(m_animData.NextAnim, m_animCompleteEventLua);
                    }
                }
                else
                {
                    m_spriteRenderer.sprite = m_listSprite[animIndex];
                }
            }
            else
            {
                m_spriteRenderer.sprite = m_listSprite[animIndex];
            }
        }
    }
示例#40
0
        /// <summary>
        /// 创建面板
        /// </summary>
        IEnumerator StartCreatePanel(string name, AssetBundle bundle, LuaFunction func = null) {
            name += "Panel";
            GameObject prefab = Util.LoadAsset(bundle, name);
            yield return new WaitForEndOfFrame();
            if (Parent.FindChild(name) != null || prefab == null) {
                yield break;
            }
            GameObject go = Instantiate(prefab) as GameObject;
            go.name = name;
            go.layer = LayerMask.NameToLayer("Default");
            go.transform.parent = Parent;
            go.transform.localScale = Vector3.one;
            go.transform.localPosition = Vector3.zero;

            yield return new WaitForEndOfFrame();
            go.AddComponent<LuaBehaviour>().OnInit(bundle);

            if (func != null) func.Call(go);
            Debug.Log("StartCreatePanel------>>>>" + name);
        }
    public bool ValidateAcquiringGoods(string arg)
    {
        Transform tm = basePanel.FindChild("GoodsAcquirePopup(Clone)");

        if (tm != null && NGUITools.GetActive(tm.gameObject))
        {
            uint                     goodsID  = uint.Parse(arg);
            LuaComponent             luaCom   = tm.GetComponent <LuaComponent>();
            LuaInterface.LuaFunction func     = (LuaInterface.LuaFunction)luaCom.table["HasGoods"];
            bool                     hasGoods = (bool)(func.Call((double)goodsID)[0]);
            if (hasGoods)
            {
                Debug.Log("Validate goods acquire, true, GoodsID: " + goodsID);
                return(true);
            }
            Debug.Log("Validate goods acquire, false, GoodsID: " + goodsID);
            return(false);
        }
        Debug.Log("Validate goods acquire, false, UI not visible");
        return(false);
    }
 public static void OnComplete(Tweener tweener, LuaFunction func, object self)
 {
     tweener.OnComplete(() =>
     {
         try
         {
             func.Call(self);
         }
         catch (Exception e)
         {
             Debug.LogError(e);
         }
         func.Dispose();
         func = null;
         if (self is LuaTable)
         {
             ((LuaTable)self).Dispose();
             self = null;
         }
     });
 }
示例#43
0
    /// <summary>
    /// 渐变提示框
    /// </summary>
    /// <param name="message"></param>
    /// <param name="parent"></param>
    /// <returns></returns>
    public static LuaComponent ShowTip(string message, Transform parent = null)
    {
        //if (parent == null)
        //    parent = GameSystem.Instance.mClient.mUIManager.m_uiRootBasePanel.transform;
        //GameObject tipWithTweenObj = UIManager.Instance.CreateUI("Prefab/GUI/TipWithTween", parent);
        //TipWithTween tipWithTween = tipWithTweenObj.GetComponent<TipWithTween>();
        //tipWithTween.message = message;
        //Vector3 pos = tipWithTweenObj.transform.localPosition;
        //tipWithTweenObj.transform.localPosition = new Vector3(pos.x, pos.y, -450.0f);
        //tipWithTweenObj.GetComponent<UIPanel>().depth = 5000;
        //return tipWithTween;
        if (parent == null)
        {
            UIManager.Instance.CreateUIRoot();
            parent = UIManager.Instance.m_uiRootBasePanel.transform;
        }
        GameObject popup_message_prefab;

        if (message.Contains("[-]"))
        {
            popup_message_prefab = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/TipWithTween") as GameObject;
        }
        else
        {
            popup_message_prefab = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/PopupMessage") as GameObject;
        }
        GameObject popup_message_obj = CommonFunction.InstantiateObject(popup_message_prefab, parent);
        Vector3    position          = popup_message_obj.transform.localPosition;

        position.z = -500;
        popup_message_obj.transform.localPosition = position;
        LuaComponent popup_message = popup_message_obj.GetComponent <LuaComponent>();

        //popup_message.table.Set("message", message);
        LuaInterface.LuaFunction func = popup_message.table["SetMessage"] as LuaInterface.LuaFunction;
        func.Call(new object[] { popup_message.table, message });
        NGUITools.BringForward(popup_message_obj);

        return(popup_message);
    }
示例#44
0
	void Start () 
    {
        lua = new LuaState();
        lua.Start();
        lua.DoString(script);

        //Get the function object
        func = lua.GetFunction("test.luaFunc");

        if (func != null)
        {
            //有gc alloc
            object[] r = func.Call(123456);
            Debugger.Log(r[0]);

            // no gc alloc
            int num = CallFunc();
            Debugger.Log(num);
        }

        lua.CheckTop();
	}
示例#45
0
		public NamedLuaFunction(LuaFunction function, string theevent, Action<string> logCallback, Lua lua, string name = null)
		{
			_function = function;
			_name = name ?? "Anonymous";
			_event = theevent;
			Lua = lua;
			Guid = Guid.NewGuid();

			_action = delegate
			{
				try
				{
					_function.Call();
				}
				catch (SystemException ex)
				{
					logCallback(
						"error running function attached by the event " +
						_event +
						"\nError message: " +
						ex.Message);
				}
			};
		}
示例#46
0
 // Use this for initialization
 void Awake()
 {
     mgr = new LuaScriptMgr();
     luaCache = new Dictionary<string, LuaTable>();
     luaScript = FileHelper.ReadLuaScriptFile(Define.LuaScriptPathRoot + "/" + "main.lua");
     Debug.Log(luaScript);
     object[] ret = mgr.DoString(luaScript);
     LuaTable mainTable = ret[0] as LuaTable;
     awakeFun = mainTable.RawGetFunc("awake");
     startFun = mainTable.RawGetFunc("start");
     updateFun = mainTable.RawGetFunc("update");
     lateUpdateFun = mainTable.RawGetFunc("lateUpdate");
     LuaTable conf = mainTable.rawget("conf") as LuaTable;
     string[] confStr = conf.ToArray<string>();
     for (int i = 0; i < confStr.Length; i++)
     {
         Debug.Log(Define.LuaScriptPathRoot + "/" + confStr[i] + ".lua");
         luaScript = FileHelper.ReadLuaScriptFile(Define.LuaScriptPathRoot + "/" + confStr[i] + ".lua");
         LuaTable retTable = mgr.DoString(luaScript)[0] as LuaTable;
         luaCache.Add(confStr[i], retTable);
     }
         if (awakeFun != null)
             awakeFun.Call();
 }
示例#47
0
    public static LuaComponent ShowPopupMsg(string message, Transform parent       = null,
                                            UIEventListener.VoidDelegate onOKClick = null, UIEventListener.VoidDelegate onCancelClick = null,
                                            string okLabel = null, string cancelLabel = null)
    {
        if (parent == null)
        {
            UIManager.Instance.CreateUIRoot();
            parent = UIManager.Instance.m_uiRootBasePanel.transform;
        }
        if (onCancelClick == null)
        {
            if (okLabel == null)
            {
                okLabel = GetConstString("BUTTON_OK");
            }
            if (cancelLabel == null)
            {
                cancelLabel = "";
            }
        }
        else
        {
            if (okLabel == null)
            {
                okLabel = GetConstString("BUTTON_CONFIRM");
            }
            if (cancelLabel == null)
            {
                cancelLabel = GetConstString("BUTTON_CANCEL");
            }
        }
        GameObject popup_message_prefab;

        if (message.Contains("[-]"))
        {
            popup_message_prefab = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/TipWithTween") as GameObject;
        }
        else
        {
            if (onCancelClick == null)
            {
                popup_message_prefab = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/PopupMessage") as GameObject;
            }
            else
            {
                popup_message_prefab = ResourceLoadManager.Instance.LoadPrefab("Prefab/GUI/PopupMessage1") as GameObject;
            }
        }
        GameObject popup_message_obj = CommonFunction.InstantiateObject(popup_message_prefab, parent);
        Vector3    position          = popup_message_obj.transform.localPosition;

        position.z = -500;
        popup_message_obj.transform.localPosition = position;
        LuaComponent popup_message = popup_message_obj.GetComponent <LuaComponent>();

        //popup_message.table.Set("message", message);
        LuaInterface.LuaFunction func = popup_message.table["SetMessage"] as LuaInterface.LuaFunction;
        func.Call(new object[] { popup_message.table, message, message.Length > 12 });
        popup_message.table.Set("onOKClick", onOKClick);
        popup_message.table.Set("onCancelClick", onCancelClick);
        popup_message.table.Set("okLabel", okLabel);
        popup_message.table.Set("cancelLabel", cancelLabel);
        NGUITools.BringForward(popup_message_obj);
        return(popup_message);
    }
示例#48
0
文件: Util.cs 项目: tallitia/YYScript
 public static void AddSpineListener(SkeletonGraphic com, LuaInterface.LuaFunction func)
 {
     com.AnimationState.Event += (trackIndexs, eventdata) => {
         func.Call(eventdata.data.name);
     };
 }
示例#49
0
 // CP: Fix provided by Ben Bryant for delegates with one param
 // link: http://luaforge.net/forum/message.php?msg_id=9318
 public void handleEvent(object[] args)
 {
     handler.Call(args);
 }
示例#50
0
 public static Action Action(LuaFunction func) {
     Action action = () => {
         func.Call();
     };
     return action;
 }
示例#51
0
 public static UIEventListener.VoidDelegate VoidDelegate(LuaFunction func) {
     UIEventListener.VoidDelegate action = (go) => {
         func.Call(go);
     };
     return action;
 }
示例#52
0
		public int NewForm(int? width = null, int? height = null, string title = null, LuaFunction onClose = null)
		{
			var form = new LuaWinform();
			_luaForms.Add(form);
			if (width.HasValue && height.HasValue)
			{
				form.Size = new Size(width.Value, height.Value);
			}

			form.Text = title;
			form.MaximizeBox = false;
			form.FormBorderStyle = FormBorderStyle.FixedDialog;
			form.Icon = SystemIcons.Application;
			form.Show();

			form.FormClosed += (o, e) =>
			{
				if (onClose != null)
				{
					try
					{
						onClose.Call();
					}
					catch (Exception ex)
					{
						Log(ex.ToString());
					}
				}
			};

			return (int)form.Handle;
		}
示例#53
0
    static IEnumerator CoYield(object o, LuaFunction func)
    {
        if (o is IEnumerator)
        {
            yield return mb.StartCoroutine((IEnumerator)o);
        }
        else
        {
            yield return o;
        }

        func.Call();
    }
示例#54
0
 static IEnumerator CoWaitForSeconds(float sec, LuaFunction func)
 {
     yield return new WaitForSeconds(sec);
     func.Call();
 }
示例#55
0
 static IEnumerator CoWaitForFixedUpdate(LuaFunction func)
 {
     yield return new WaitForFixedUpdate();
     func.Call();
 }
示例#56
0
 static IEnumerator CoWaitForEndOfFrame(LuaFunction func)
 {
     yield return new WaitForEndOfFrame();
     func.Call();
 }
示例#57
0
        public static CharacterBaseInfo CreateCharacterBaseInfo(PlayerInfo playerInfo)
        {
            CharacterBaseInfo characterInfo = new CharacterBaseInfo()
            {
                baseId       = playerInfo.playerData.Id,
                hitId        = playerInfo.heroData.hitId,
                skillId1     = playerInfo.heroData.skillId1,
                skillId2     = playerInfo.heroData.skillId2,
                passiveIdDic = new Dictionary <int, int>(),
                //passiveId1 = (uint)playerInfo.passiveSkillId,
                //passiveId1Level = (uint)playerInfo.passiveSkillLevel,
                passiveId2     = playerInfo.heroData.passiveId2,
                aeonEffectId   = (uint)playerInfo.summonEffectId,
                aeonSkillLevel = (uint)playerInfo.summonSkillLevel,
                maxAngerValue  = playerInfo.playerData.maxAngry,
                instanceID     = playerInfo.instanceID,
                HP             = (int)playerInfo.heroData.HP,
                maxHP          = (uint)playerInfo.heroData.HP,
                angerValue     = 0,
                speed          = (int)playerInfo.heroData.speed,
                floatable      = true,
                roleType       = playerInfo.heroData.roleType,
                roleInfo       = playerInfo
            };

            if (playerInfo.passiveSkillId > 0)
            {
                characterInfo.passiveIdDic.Add(playerInfo.passiveSkillId, playerInfo.passiveSkillLevel);
            }
            characterInfo.passiveIdDic.AddRange(playerInfo.normalPassiveSkilIdDic);
            if (characterInfo.hitId != 0)
            {
                characterInfo.hitSkillInfo = new SkillInfo(characterInfo.hitId);
                characterInfo.hitSkillInfo.characterInstanceId = playerInfo.instanceID;
            }
            if (characterInfo.skillId1 != 0)
            {
                characterInfo.skillInfo1 = new SkillInfo(characterInfo.skillId1);
                characterInfo.skillInfo1.characterInstanceId = playerInfo.instanceID;
            }
            if (characterInfo.skillId2 != 0)
            {
                characterInfo.skillInfo2 = new SkillInfo(characterInfo.skillId2);
                characterInfo.skillInfo2.characterInstanceId = playerInfo.instanceID;
            }
            if (characterInfo.roleInfo.advanceLevel > characterInfo.roleInfo.heroData.starMin)
            {
                characterInfo.dlevel = (uint)characterInfo.roleInfo.advanceLevel - characterInfo.roleInfo.heroData.starMin;
            }
            string luaFile = "user/skill/passive_skill_" + characterInfo.baseId;

            //if (Lua.Model.LuaData.ExistLuaFile(luaFile))
            LuaScriptMgr.Instance.DoFile(luaFile);
            LuaInterface.LuaFunction initFunc = PassiveSkillController.instance.GetPassiveSkillLuaFunction(PassiveSkillController.INIT_CHARACTER_DATAS, (int)characterInfo.baseId);
            if (initFunc != null)
            {
                initFunc.Call(characterInfo.instanceID);
            }
            if (characterInfo.aeonEffectId > 0)
            {
                LuaInterface.LuaFunction func = PassiveSkillController.instance.GetPassiveSkillLuaFunction(PassiveSkillController.AEON_ID_AND_SKILL_ID, (int)characterInfo.baseId);
                if (func != null)
                {
                    object[] rs = func.Call(characterInfo.aeonEffectId);
                    if (rs.Length > 0)
                    {
                        uint eaonId = 0;
                        uint.TryParse(rs[0].ToString(), out eaonId);
                        uint eaonSkillId = 0;
                        uint.TryParse(rs[1].ToString(), out eaonSkillId);
                        characterInfo.aeonId    = eaonId;
                        characterInfo.aeonSkill = eaonSkillId;

                        if (characterInfo.aeonSkill != 0)
                        {
                            characterInfo.aeonSkillInfo = new SkillInfo(characterInfo.aeonSkill);
                        }
                    }
                }
            }
            if (characterInfo.aeonId == 0)
            {
                characterInfo.aeonId    = (uint)playerInfo.playerData.summonID;
                characterInfo.aeonSkill = (uint)playerInfo.playerData.summonSkillId;
                if (characterInfo.aeonSkill != 0)
                {
                    characterInfo.aeonSkillInfo = new SkillInfo(characterInfo.aeonSkill);
                    characterInfo.aeonSkillInfo.characterInstanceId = playerInfo.instanceID;
                }
            }
            return(characterInfo);
        }
示例#58
0
 /// <summary>
 /// cjson函数回调
 /// </summary>
 /// <param name="data"></param>
 /// <param name="func"></param>
 public static void OnJsonCallFunc(string data, LuaFunction func) {
     Debug.LogWarning("OnJsonCallback data:>>" + data + " lenght:>>" + data.Length);
     if (func != null) func.Call(data);
 }