• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Eluant.LuaFunction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Eluant.LuaFunction的典型用法代码示例。如果您正苦于以下问题:C# LuaFunction类的具体用法?C# LuaFunction怎么用?C# LuaFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LuaFunction类属于Eluant命名空间,在下文中一共展示了LuaFunction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PlayMusic

		public void PlayMusic(string track = null, LuaFunction func = null)
		{
			if (!playlist.IsMusicAvailable)
				return;

			var musicInfo = !string.IsNullOrEmpty(track) ? GetMusicTrack(track)
				: playlist.GetNextSong();

			if (func != null)
			{
				var f = func.CopyReference() as LuaFunction;
				onComplete = () =>
				{
					try
					{
						using (f)
							f.Call().Dispose();
					}
					catch (LuaException e)
					{
						Context.FatalError(e.Message);
					}
				};

				playlist.Play(musicInfo, onComplete);
			}
			else
				playlist.Play(musicInfo);
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:29,代码来源:MediaGlobal.cs


示例2: OnAllKilled

        public void OnAllKilled(LuaTable actors, LuaFunction func)
        {
            List<Actor> group = new List<Actor>();
            foreach (var kv in actors)
            {
                Actor actor;
                if (!kv.Value.TryGetClrValue<Actor>(out actor))
                    throw new LuaException("OnAllKilled requires a table of int,Actor pairs. Recieved {0},{1}".F(kv.Key.GetType().Name, kv.Value.GetType().Name));

                group.Add(actor);
            }

            var copy = (LuaFunction)func.CopyReference();
            Action<Actor> OnMemberKilled = m =>
            {
                group.Remove(m);
                if (!group.Any())
                {
                    copy.Call();
                    copy.Dispose();
                }
            };

            foreach (var a in group)
                GetScriptTriggers(a).OnKilledInternal += OnMemberKilled;
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:26,代码来源:TriggerGlobal.cs


示例3: Reinforce

		public Actor[] Reinforce(Player owner, string[] actorTypes, CPos[] entryPath, int interval = 25, LuaFunction actionFunc = null)
		{
			var actors = new List<Actor>();
			for (var i = 0; i < actorTypes.Length; i++)
			{
				var af = actionFunc != null ? actionFunc.CopyReference() as LuaFunction : null;
				var actor = CreateActor(owner, actorTypes[i], false, entryPath[0], entryPath.Length > 1 ? entryPath[1] : (CPos?)null);
				actors.Add(actor);

				var actionDelay = i * interval;
				Action actorAction = () =>
				{
					Context.World.Add(actor);
					for (var j = 1; j < entryPath.Length; j++)
						Move(actor, entryPath[j]);

					if (af != null)
					{
						actor.QueueActivity(new CallFunc(() =>
						{
							af.Call(actor.ToLuaValue(Context));
							af.Dispose();
						}));
					}
				};

				Context.World.AddFrameEndTask(w => w.Add(new DelayedAction(actionDelay, actorAction)));
			}

			return actors.ToArray();
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:31,代码来源:ReinforcementsGlobal.cs


示例4: GetPlayers

		public Player[] GetPlayers(LuaFunction filter)
		{
			return Context.World.Players
				.Where(p =>
				{
					using (var f = filter.Call(p.ToLuaValue(Context)))
						return f.First().ToBoolean();
				}).ToArray();
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:9,代码来源:PlayerGlobal.cs


示例5: Any

        public bool Any(LuaValue[] collection, LuaFunction func)
        {
            foreach (var c in collection)
                using (var ret = func.Call(c))
                using (var result = ret.FirstOrDefault())
                    if (result != null && result.ToBoolean())
                        return true;

            return false;
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:10,代码来源:UtilsGlobal.cs


示例6: ActorsInCircle

		public LuaTable ActorsInCircle(WPos location, WRange radius, LuaFunction filter)
		{
			var actors = context.World.FindActorsInCircle(location, radius)
				.Select(a => a.ToLuaValue(context))
				.Where(a => 
				{
					using (var f = filter.Call(a))
						return f.First().ToBoolean();
				});
			return actors.ToLuaTable(context);
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:11,代码来源:MapGlobal.cs


示例7: GetPlayers

		public LuaTable GetPlayers(LuaFunction filter)
		{
			var players = context.World.Players
				.Select(p => p.ToLuaValue(context))
				.Where(a =>
				{
					using (var f = filter.Call(a))
						return f.First().ToBoolean();
				});

			return players.ToLuaTable(context);
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:12,代码来源:PlayerGlobal.cs


示例8: Any

        public bool Any(LuaTable table, LuaFunction func)
        {
            foreach (var kv in table)
            {
                using (var ret = func.Call(kv.Value))
                {
                    var result = ret.FirstOrDefault();
                    if (result != null && result.ToBoolean())
                        return true;
                }
            }

            return false;
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:14,代码来源:UtilsGlobal.cs


示例9: All

		public bool All(LuaValue[] collection, LuaFunction func)
		{
			foreach (var c in collection)
			{
				using (var ret = func.Call(c))
				{
					var result = ret.FirstOrDefault();
					if (result == null || !result.ToBoolean())
						return false;
				}
			}

			return true;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:14,代码来源:UtilsGlobal.cs


示例10: ActorsInBox

		public Actor[] ActorsInBox(WPos topLeft, WPos bottomRight, LuaFunction filter = null)
		{
			var actors = Context.World.ActorMap.ActorsInBox(topLeft, bottomRight);

			if (filter != null)
			{
				actors = actors.Where(a =>
				{
					using (var f = filter.Call(a.ToLuaValue(Context)))
						return f.First().ToBoolean();
				});
			}

			return actors.ToArray();
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:15,代码来源:MapGlobal.cs


示例11: ActorsInCircle

		public Actor[] ActorsInCircle(WPos location, WDist radius, LuaFunction filter = null)
		{
			var actors = Context.World.FindActorsInCircle(location, radius);

			if (filter != null)
			{
				actors = actors.Where(a =>
				{
					using (var f = filter.Call(a.ToLuaValue(Context)))
						return f.First().ToBoolean();
				});
			}

			return actors.ToArray();
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:15,代码来源:MapGlobal.cs


示例12: AfterDelay

        public void AfterDelay(int delay, LuaFunction func)
        {
            var f = (LuaFunction)func.CopyReference();
            Action doCall = () =>
            {
                try
                {
                    using (f)
                        f.Call().Dispose();
                }
                catch (Exception e)
                {
                    Context.FatalError(e.Message);
                }
            };

            Context.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, doCall)));
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:18,代码来源:TriggerGlobal.cs


示例13: PlayMovieFullscreen

        public void PlayMovieFullscreen(string movie, LuaFunction func = null)
        {
            if (func != null)
            {
                var f = func.CopyReference() as LuaFunction;
                onCompleteFullscreen = () =>
                {
                    try
                    {
                        using (f)
                            f.Call().Dispose();
                    }
                    catch (LuaException e)
                    {
                        Context.FatalError(e.Message);
                    }
                };
            }
            else
                onCompleteFullscreen = () => { };

            Media.PlayFMVFullscreen(world, movie, onCompleteFullscreen);
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:23,代码来源:MediaGlobal.cs


示例14: OnAllKilled

		public void OnAllKilled(Actor[] actors, LuaFunction func)
		{
			var group = actors.ToList();
			var copy = (LuaFunction)func.CopyReference();
			Action<Actor> onMemberKilled = m =>
			{
				try
				{
					group.Remove(m);
					if (!group.Any())
					{
						copy.Call();
						copy.Dispose();
					}
				}
				catch (Exception e)
				{
					Context.FatalError(e.Message);
				}
			};

			foreach (var a in group)
				GetScriptTriggers(a).OnKilledInternal += onMemberKilled;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:24,代码来源:TriggerGlobal.cs


示例15: OnEnteredFootprint

        public int OnEnteredFootprint(CPos[] cells, LuaFunction func)
        {
            // We can't easily dispose onEntry, so we'll have to rely on finalization for it.
            var onEntry = (LuaFunction)func.CopyReference();
            var triggerId = 0;
            Action<Actor> invokeEntry = a =>
            {
                try
                {
                    using (var luaActor = a.ToLuaValue(Context))
                    using (var id = triggerId.ToLuaValue(Context))
                        onEntry.Call(luaActor, id).Dispose();
                }
                catch (Exception e)
                {
                    Context.FatalError(e.Message);
                }
            };

            triggerId = Context.World.ActorMap.AddCellTrigger(cells, invokeEntry, null);

            return triggerId;
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:23,代码来源:TriggerGlobal.cs


示例16: OnProduction

 public void OnProduction(Actor a, LuaFunction func)
 {
     GetScriptTriggers(a).RegisterCallback(Trigger.OnProduction, func, Context);
 }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:4,代码来源:TriggerGlobal.cs


示例17: OnPlayerWon

 public void OnPlayerWon(Player player, LuaFunction func)
 {
     GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnPlayerWon, func, Context);
 }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:4,代码来源:TriggerGlobal.cs


示例18: OnPlayerDiscovered

 public void OnPlayerDiscovered(Player discovered, LuaFunction func)
 {
     GetScriptTriggers(discovered.PlayerActor).RegisterCallback(Trigger.OnPlayerDiscovered, func, Context);
 }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:4,代码来源:TriggerGlobal.cs


示例19: OnPassengerExited

 public void OnPassengerExited(Actor a, LuaFunction func)
 {
     GetScriptTriggers(a).RegisterCallback(Trigger.OnPassengerExited, func, Context);
 }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:4,代码来源:TriggerGlobal.cs


示例20: OnObjectiveFailed

 public void OnObjectiveFailed(Player player, LuaFunction func)
 {
     GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnObjectiveFailed, func, Context);
 }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:4,代码来源:TriggerGlobal.cs



注:本文中的Eluant.LuaFunction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Eme.EmeEntities类代码示例发布时间:2022-05-24
下一篇:
C# Elmah.ExceptionFilterEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap