Exemplo n.º 1
0
 public Position3D Rotate(Direction dir)
 {
     Position3D p = new Position3D();
     p.X = dir.Shift(1) * X + dir.Shift(0) * Z;
     p.Y = 0;
     p.Z = dir.Shift(1) * Z + dir.Shift(3) * X;
     return p;
 }
Exemplo n.º 2
0
 public Position3D Offset(Position3D p)
 {
     return new Position3D(X + p.X, Y + p.Y, Z + p.Z);
 }
Exemplo n.º 3
0
 public bool CanPassThrough(Position3D pos)
 {
     Model b = this[pos];
     return b == null || !b.Template.IsCollidable;
 }
Exemplo n.º 4
0
 public void SetPosition(Position3D pos)
 {
     position = pos;
 }
Exemplo n.º 5
0
 public void AddModel(Model Model, Position3D location)
 {
     PlaceModel(Model, location);
     Children.Add(Model);
 }
Exemplo n.º 6
0
 public void PlaceModel(Model model, Position3D location)
 {
     // Set new location (for visual update)
     model.Position = location;
     // Set new area
     location.ForEachInRange(model.Template.Dimension, (l) =>
     {
         Model m = this[l];
         if (m != null)
         {
             // Remove object being replaced
             RemoveModel(m);
         }
         this[l] = model;
     });
 }
Exemplo n.º 7
0
 public void MoveModelTo(Model model, Position3D location)
 {
     ClearModel(model);
     PlaceModel(model, location);
 }
Exemplo n.º 8
0
 public Model this[Position3D location]
 {
     get { return models[location.X, location.Y, location.Z]; }
     set { models[location.X, location.Y, location.Z] = value; }
 }
Exemplo n.º 9
0
        private bool CanMove()
        {
            if (Actor.Movement == null)
                Actor.Movement = this;
            else if (Actor.Movement != this)
                return false;

            Position3D offset = Template.PositionOffset;
            if (Template.FollowDirection)
                offset = offset.Rotate(Actor.Direction);
            pos = Actor.Position.Offset(offset);

            // TODO: Test actor
            Model m = Game.Scene[pos];
            if (m != null)
            {
                // Raise event whenever there's something ahead
                Event.Raise(m, Model.Collided);
                // Don't go if it collidable (or you will get hit!)
                if (m.Template.IsCollidable)
                    return false;
            }

            dir = Actor.Direction.Offset(Template.DirectionOffset);
            return true;
        }