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); } }); } }
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); } }); } }
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); } }
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); } }
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 }); } } }); } }
public static void Clear(ILuaExecuter executer) { if (GiantVoiceToLua.giantVoice != null) { GiantVoiceToLua.giantVoice.Clear(); } }
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() : "")); } }
public static void LuaCloseWindow(ILuaExecuter executer) { var parameters = executer.PopParameters(); var window = parameters[0] as IWindow; if (null != window) { window.Close(); } }
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]); } }
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(); } }
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]); } }
public static void LuaClearOptions(ILuaExecuter executor) { var parameters = executor.PopParameters(); var dropdown = parameters[0] as IDropDown; if (null != dropdown) { dropdown.ClearOptions(); } }
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]); } }
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(); } }
public static void LuaGetKeyboardType(ILuaExecuter executer) { var parameters = executer.PopParameters(); var input = parameters[0] as IInputField; if (null != input) { executer.PushResult(input.KeyboardType); } }
public static void LuaGetUserData(ILuaExecuter executer) { var parameters = executer.PopParameters(); var element = parameters[0] as IElement; if (null != element) { executer.PushResult(element.UserData); } }
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]); } }
public static void LuaSetUserData(ILuaExecuter executer) { var parameters = executer.PopParameters(); var element = parameters[0] as IElement; if (null != element) { element.UserData = parameters[1]; } }
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])); } }
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]; } }
public static void LuaScrollToTop(ILuaExecuter executer) { var parameters = executer.PopParameters(); var scrollView = parameters[0] as IScrollView; if (null != scrollView) { scrollView.ScrollToTop(); } }
public static void LuaMoveToLast(ILuaExecuter executer) { var parameters = executer.PopParameters(); var element = parameters[0] as IElement; if (null != element) { element.MoveToLast(); } }
public static void LuaPauseSpriteAnimation(ILuaExecuter executer) { var parameters = executer.PopParameters(); var img = parameters[0] as IImageAnimation; if (null != img) { img.Pause(); } }
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]))); } }
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]); } }
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); } }
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); } }
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)); } }
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; } }
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); } }