添加脚本功能到.NET应用程序 [英] Adding scripting functionality to .NET applications

查看:300
本文介绍了添加脚本功能到.NET应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小游戏在C#编写。它使用一个数据库作为后台。其 一个换式卡牌游戏,我想实现的卡功能的脚本。

I have a little game written in C#. It uses a database as back-end. It's a trading card game, and I wanted to implement the function of the cards as a script.

我的意思是,我实际上有一个接口,的iCard ,其中卡类实现的(公共类Card056状态:iCard )和含有功能是由游戏称为

What I mean is that I essentially have an interface, ICard, which a card class implements (public class Card056 : ICard) and which contains function that are called by the game.

现在,为了使东西维护/ moddable,我想有类每张卡源$ C ​​$ C在数据库中,基本上是在第一次使用编译。所以当我有添加/更改卡,我只是将其添加到数据库中,并告诉我的应用程序更新,无需任何组装的部署(特别是因为我们每个卡,这意味着数百个组件谈论1集)

Now, to make the thing maintainable/moddable, I would like to have the class for each card as source code in the database and essentially compile it on first use. So when I have to add/change a card, I'll just add it to the database and tell my application to refresh, without needing any assembly deployment (especially since we would be talking about 1 assembly per card which means hundreds of assemblies).

这可能吗?从源文件注册一个类,然后实例化,等等。

Is that possible? Register a class from a source file and then instantiate it, etc.

ICard Cards[current] = new MyGame.CardLibrary.Card056();
Cards[current].OnEnterPlay(ref currentGameState);

的语言是C#,但额外的奖金,如果有可能在任何.NET语言编写的脚本。

The language is C#, but extra bonus if it's possible to write the script in any .NET language.

推荐答案

奥列格希洛的C#脚本解决方案(位于code计划)真的是一个伟大的介绍提供脚本能力的应用程序。

Oleg Shilo's C# Script solution (at The Code Project) really is a great introduction to providing script abilities in your application.

有一个不同的方法是考虑专门为脚本建立了一个语言,如 IronRuby的,的 IronPython的 Lua的

A different approach would be to consider a language that is specifically built for scripting, such as IronRuby, IronPython, or Lua.

IronPython和IronRuby的今天两个可用。

IronPython and IronRuby are both available today.

有关以嵌入IronPython的指南阅读 如何嵌入IronPython的脚本支持在现有的应用程序在10个简单的步骤

For a guide to embedding IronPython read How to embed IronPython script support in your existing app in 10 easy steps.

Lua是一种脚本语言中的游戏常用。有一个Lua编译为.NET,可从codePLEX - HTTP://www.$c$cplex.com /诺

Lua is a scripting language commonly used in games. There is a Lua compiler for .NET, available from CodePlex -- http://www.codeplex.com/Nua

这codeBase的是一个伟大的阅读,如果你想了解有关构建编译器在.NET。

That codebase is a great read if you want to learn about building a compiler in .NET.

一个不同的角度完全是尝试 PowerShell的。有嵌入的PowerShell到应用程序的例子不胜枚举 - 这里是关于这一主题的深入项目: <一href="http://$c$c.msdn.microsoft.com/PowerShellTunnel/Wiki/View.aspx?title=PowerShellTunnel%20Reference">Powershell隧道

A different angle altogether is to try PowerShell. There are numerous examples of embedding PowerShell into an application -- here's a thorough project on the topic: Powershell Tunnel

这篇关于添加脚本功能到.NET应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆