コード例 #1
0
        public static void RegisterPlayVoiceFunction(ILuaExecuter executer)
        {
            var parameters         = executer.PopParameters();
            var playVoiceComponent = parameters[0] as IGiantVoicePlayer;
            var voiceId            = parameters[1].ToString();

            if (null != playVoiceComponent && null != voiceId)
            {
                var playSuccessfulHandler = parameters.Length > 2 ? parameters[2] : null;
                var playFailHandler       = parameters.Length > 3 ? parameters[3] : null;
                playVoiceComponent.RegisterPlay(voiceId,
                                                delegate() {
                    if (null != playSuccessfulHandler)
                    {
                        executer.Call(playSuccessfulHandler);
                    }
                },
                                                delegate(string error)
                {
                    if (null != playFailHandler)
                    {
                        executer.Call(playFailHandler, error);
                    }
                });
            }
        }
コード例 #2
0
        public static void RegisterCancelRecordFunction(ILuaExecuter executer)
        {
            var parameters        = executer.PopParameters();
            var recordVoiceButton = parameters[0] as IGiantVoiceRecorder;

            if (null != recordVoiceButton)
            {
                var cancelSuccessfulHandler = parameters.Length > 1 ? parameters[1] : null;
                var cancelFailHandler       = parameters.Length > 2 ? parameters[2] : null;
                recordVoiceButton.RegisterCancel(
                    delegate() {
                    if (null != cancelSuccessfulHandler)
                    {
                        executer.Call(cancelSuccessfulHandler);
                    }
                },
                    delegate(string error)
                {
                    if (null != cancelFailHandler)
                    {
                        executer.Call(cancelFailHandler, error);
                    }
                });
            }
        }
コード例 #3
0
        public static void LuaSetSpriteAnimation(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var img        = parameters[0] as IImageAnimation;

            if (null != img && null != parameters[1])
            {
                ILuaTable spriteTb  = parameters[1] as ILuaTable;
                string[]  spritesTb = spriteTb.ToArray() as string[];
                List <SpriteLoadingInformation> spriteLoadingInformatonList = new List <SpriteLoadingInformation>();
                for (int i = 0; i < spritesTb.Length; i++)
                {
                    var spriteLoadingInformation = new SpriteLoadingInformation();
                    var spriteInfo      = spritesTb[i];
                    var spriteInfoArray = spriteInfo.Split('|');
                    if (spriteInfoArray.Length < 2)
                    {
                        continue;
                    }
                    spriteLoadingInformation.path = spriteInfoArray[0];
                    spriteLoadingInformation.name = spriteInfoArray[1];
                    spriteLoadingInformatonList.Add(spriteLoadingInformation);
                }
                var framesPerSecond = parameters.Length > 2 && null != parameters[2] ? Convert.ToInt32(parameters[2]) : 10;
                img.SetSpriteAnimation(spriteLoadingInformatonList, framesPerSecond);
            }
        }
コード例 #4
0
        public static void OnEvent(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var eventId    = parameters[0].ToString();
            var luaTable   = parameters[1] as ILuaTable;
            var map        = luaTable.ToMap();
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            /*Dictionary<object, object>.Enumerator enumerator = map.GetEnumerator();
             * while(enumerator.MoveNext())
             * {
             *  dictionary.Add(enumerator.Current.Key.ToString(), enumerator.Current.Value.ToString());
             * }*/
            foreach (var v in map)
            {
                object o;
                if (v.Value is ILuaString)
                {
                    o = v.Value.ToString();
                }
                else
                {
                    o = v.Value;
                }
                dictionary.Add(v.Key.ToString(), o);
            }
            if (GameAnalyticsToLua.gameAnalytics != null)
            {
                GameAnalyticsToLua.gameAnalytics.OnEvent(eventId, dictionary);
            }
        }
コード例 #5
0
ファイル: UISystemToLua.cs プロジェクト: Hengle/Unity3D-1
        public static void LuaCreateWindowAsync(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var manager    = parameters[0] as IUISystem;

            if (null != manager && null != parameters[1] && null != parameters[2])
            {
                var path     = parameters[1].ToString();
                var layer    = Convert.ToInt32(parameters[2]);
                var callback = parameters[3];
                var target   = (parameters.Length > 4 ? parameters[4] : null);
                manager.CreateWindowAsync(path, layer, window =>
                {
                    if (null != callback)
                    {
                        if (null == target)
                        {
                            executer.Call(callback, new object[] { window });
                        }
                        else
                        {
                            executer.Call(callback, new object[] { target, window });
                        }
                    }
                });
            }
        }
コード例 #6
0
ファイル: GiantVoiceToLua.cs プロジェクト: Hengle/Unity3D-1
 public static void Clear(ILuaExecuter executer)
 {
     if (GiantVoiceToLua.giantVoice != null)
     {
         GiantVoiceToLua.giantVoice.Clear();
     }
 }
コード例 #7
0
ファイル: ImageToLua.cs プロジェクト: Hengle/Unity3D-1
        public static void LuaSetSprite(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var img        = parameters[0] as IImage;

            if (null != img && null != parameters[1])
            {
                img.SetSprite(parameters[1].ToString(), (parameters.Length > 2 && null != parameters[2] ? parameters[2].ToString() : ""));
            }
        }
コード例 #8
0
ファイル: WindowToLua.cs プロジェクト: Hengle/Unity3D-1
        public static void LuaCloseWindow(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var window     = parameters[0] as IWindow;

            if (null != window)
            {
                window.Close();
            }
        }
コード例 #9
0
ファイル: ToggleToLua.cs プロジェクト: Hengle/Unity3D-1
        public static void LuaSetOn(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var toggle     = parameters[0] as IToggle;

            if (null != toggle && null != parameters[1])
            {
                toggle.On = Convert.ToBoolean(parameters[1]);
            }
        }
コード例 #10
0
        public static void LuaSetText(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var label      = parameters[0] as ILabel;

            if (null != label && null != parameters[1])
            {
                label.Text = parameters[1].ToString();
            }
        }
コード例 #11
0
        public static void LuaSetFontSize(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var label      = parameters[0] as ILabel;

            if (null != label && null != parameters[1])
            {
                label.FontSize = Convert.ToInt32(parameters[1]);
            }
        }
コード例 #12
0
        public static void LuaClearOptions(ILuaExecuter executor)
        {
            var parameters = executor.PopParameters();
            var dropdown   = parameters[0] as IDropDown;

            if (null != dropdown)
            {
                dropdown.ClearOptions();
            }
        }
コード例 #13
0
ファイル: TogglesToLua.cs プロジェクト: Hengle/Unity3D-1
        public static void LuaSetToggleOn(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var toggles    = parameters[0] as IToggles;

            if (null != toggles && null != parameters[1])
            {
                toggles.ToggleOn = Convert.ToInt32(parameters[1]);
            }
        }
コード例 #14
0
        public static void LuaSetText(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var input      = parameters[0] as IInputField;

            if (null != input && null != parameters[1])
            {
                input.Text = parameters[1].ToString();
            }
        }
コード例 #15
0
        public static void LuaGetKeyboardType(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var input      = parameters[0] as IInputField;

            if (null != input)
            {
                executer.PushResult(input.KeyboardType);
            }
        }
コード例 #16
0
        public static void LuaGetUserData(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var element    = parameters[0] as IElement;

            if (null != element)
            {
                executer.PushResult(element.UserData);
            }
        }
コード例 #17
0
ファイル: SliderToLua.cs プロジェクト: Hengle/Unity3D-1
        public static void LuaSetValue(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var slider     = parameters[0] as ISlider;

            if (null != slider && null != parameters[1])
            {
                slider.Value = Convert.ToSingle(parameters[1]);
            }
        }
コード例 #18
0
        public static void LuaSetUserData(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var element    = parameters[0] as IElement;

            if (null != element)
            {
                element.UserData = parameters[1];
            }
        }
コード例 #19
0
        public static void LuaMoveTo(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var element    = parameters[0] as IElement;

            if (null != element && null != parameters[1])
            {
                element.MoveTo(Convert.ToInt32(parameters[1]));
            }
        }
コード例 #20
0
        public static void LuaSetVisible(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var element    = parameters[0] as IElement;

            if (null != element && null != parameters[1])
            {
                element.Visible = (bool)parameters[1];
            }
        }
コード例 #21
0
        public static void LuaScrollToTop(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var scrollView = parameters[0] as IScrollView;

            if (null != scrollView)
            {
                scrollView.ScrollToTop();
            }
        }
コード例 #22
0
        public static void LuaMoveToLast(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var element    = parameters[0] as IElement;

            if (null != element)
            {
                element.MoveToLast();
            }
        }
コード例 #23
0
        public static void LuaPauseSpriteAnimation(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var img        = parameters[0] as IImageAnimation;

            if (null != img)
            {
                img.Pause();
            }
        }
コード例 #24
0
        public static void LuaGetItems(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var scrollView = parameters[0] as IScrollView;

            if (null != scrollView && null != parameters[1])
            {
                executer.PushResult(scrollView.GetItems(Convert.ToInt32(parameters[1])));
            }
        }
コード例 #25
0
        public static void LuaSetKeyboardType(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var input      = parameters[0] as IInputField;

            if (null != input && null != parameters[1])
            {
                input.KeyboardType = Convert.ToInt32(parameters[1]);
            }
        }
コード例 #26
0
        public static void SetVoiceBarLength(ILuaExecuter executer)
        {
            var parameters         = executer.PopParameters();
            var playVoiceComponent = parameters[0] as IGiantVoicePlayer;
            var length             = Convert.ToSingle(parameters[1]);

            if (null != playVoiceComponent && 0 != length)
            {
                playVoiceComponent.SetVoiceBarLength(length);
            }
        }
コード例 #27
0
        public static void LuaAddOption(ILuaExecuter executor)
        {
            var parameters = executor.PopParameters();
            var dropdown   = parameters[0] as IDropDown;

            if (null != dropdown && null != parameters[1])
            {
                var option = parameters[1].ToString();
                dropdown.AddOption(option);
            }
        }
コード例 #28
0
        public static void LuaGetOption(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var dropdown   = parameters[0] as IDropDown;

            if (null != dropdown && null != parameters[1])
            {
                var index = Convert.ToInt32(parameters[1]);
                executer.PushResult(dropdown.GetOption(index));
            }
        }
コード例 #29
0
        public static void LuaSetInteractable(ILuaExecuter executer)
        {
            var parameters   = executer.PopParameters();
            var button       = parameters[0] as IButton;
            var interactable = Convert.ToBoolean(parameters[1]);

            if (null != button)
            {
                button.Interactable = interactable;
            }
        }
コード例 #30
0
ファイル: ImageToLua.cs プロジェクト: Hengle/Unity3D-1
        public static void LuaSetSpriteAtlas(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var img        = parameters[0] as IImage;

            if (null != img && null != parameters[1] && null != parameters[2])
            {
                var defaultPath = parameters.Length > 3 && null != parameters[3] ? parameters[3].ToString() : "";
                img.SetSpriteAtlas(parameters[1].ToString(), parameters[2].ToString(), defaultPath);
            }
        }