示例#1
0
        public Movement(MovementTemplate template, Actor actor)
        {
            Template = template;
            Actor = actor;

            Animation = template.Animation.Create(actor);
            Event.Register(Animation, Completed, TestContinuation);

            MovementAnimation = new MovementAnimation(actor);
            MovementAnimation.Duration = template.Animation.Duration / template.Speed;

            Completion = template.Completion.Create(actor);
            Event.Register(Completion, Completed, TestMovement);

            timeout = new Animation(0.1);
            Event.Register(timeout, Completed, TestMovement);

            Event.Register(this, Started, TestMovement);
        }
示例#2
0
 public MovementAnimation(Actor actor)
 {
     Actor = actor;
 }
示例#3
0
 public virtual void Load(Loader l, Instruction i)
 {
     switch (i.Type)
     {
         case "name":
             Name = i.String();
             break;
         case "dim":
             int width = i.Int(), height = i.Int(), length = i.Int();
             Dimension = new Dimension3D(width, height, length);
             models = new Model[width, height, length];
             break;
         case "m": // Model
             {
                 Position3D pos = i.Position3D();
                 ModelTemplate mt = Game.Get<ModelTemplate>(i.String());
                 Model m = new Model(mt);
                 AddModel(m, pos);
                 ProcessModelArgs(i, m);
             }
             break;
         case "r": // Range (multiple models)
             {
                 Position3D origin = i.Position3D();
                 Dimension3D dim = i.Dimension3D();
                 ModelTemplate mt = Game.Get<ModelTemplate>(i.String());
                 origin.ForEachInRange(dim, (loc) =>
                 {
                     Model m = new Model(mt);
                     AddModel(m, loc);
                 });
             }
             break;
         case "a": // Actor
             {
                 Position3D pos = i.Position3D();
                 ActorTemplate at = Game.Get<ActorTemplate>(i.String());
                 Actor actor = new Actor(at);
                 AddActor(actor);
                 ProcessModelArgs(i, actor);
             }
             break;
         case "dl": // Directional light
             {
                 Light light = new DirectionalLight(i.Color(), i.Vector3D());
                 Lamp ls = new Lamp(light);
                 AddLamp(ls);
                 if (i.HasNext)
                     namedElements[i.String()] = ls;
             }
             break;
         case "pl": // Point light
             {
                 Light light = new PointLight(i.Color(), i.Point3D());
                 Lamp ls = new Lamp(light);
                 AddLamp(ls);
                 if (i.HasNext)
                     namedElements[i.String()] = ls;
             }
             break;
         case "al": // Ambient light
             {
                 Light light = new AmbientLight(i.Color());
                 Lamp ls = new Lamp(light);
                 AddLamp(ls);
                 if (i.HasNext)
                     namedElements[i.String()] = ls;
             }
             break;
     }
 }
示例#4
0
 public void RemoveActor(Actor actor)
 {
     actors.Remove(actor);
     Children.Remove(actor);
 }
示例#5
0
 public void AddActor(Actor actor)
 {
     actors.Add(actor);
     Children.Add(actor);
 }