using ScriptingSystem; using System; // Main script class, which must inherit from GameScript and have the same name of the script. public class Class1 : GameScript { //The entry point of the script, You can add any intialization code here public void Init(MWorld world, MActor actor, MMatrix transform) { } //This function will be called each frame for any updating code public void Tick() { } } //This our simple actor class which will be inherited from the other script public class MyActor : MActor { //The actor class constructor needs a world public MyActor(MWorld world) : base(world) { //Create a new instance for the actor model MyModel = new MModel(); //Load box.xml to it MyModel.Load("Box.xml", false); } //This function will be called each frame for any updating code public override void Tick() { //Change the actor location according to the Sin wave on the Y axis Location.y = (float)Math.Sin(Environment.TickCount) * 5; } }
using ScriptingSystem; using System; //Use code from Class1.cs using Class1.cs; //Our derived actor from MyActor public class MyActor1 : MyActor { public MyActor1(MWorld world) : base(world) { } public override void Tick() { //Move the actor on the X axis here Location.x = (float)Math.Sin(Environment.TickCount) * 10; base.Tick(); } } //Our Main class, note that it has the same name as the script. public class Class2 : GameScript { //MyActor1 member MyActor1 testActor; public void Init(MWorld world, MActor actor, MMatrix transform) { //Intialize a new instance from MyActor1 testActor = new MyActor1(world); } public void Tick() { } }