示例#1
0
 /**
  * <summary>
  * This method swaps places in the map at halfway, then continue to the end of the tile
  * </summary>
  */
 private void SwapPlaces(IGameAction obj)
 {
     if (other.wo.IsDestroyed())
     {
         //If the other was destroyed, release the previous tile and occupy the new
         Map.map.SetMobile(wo.GetX(), wo.GetY(), null);
         Map.map.SetTileOccupied(wo.GetX(), wo.GetY(), false);
         Map.map.SetTileOccupied(otherTile.X, otherTile.Y, true);
     }
     //If we are moving to a non traversable area, like water because the bridge was destroyed, go back.
     if (Map.map.GetWorldObject(otherTile.X, otherTile.Y) != null && !Map.map.GetWorldObject(otherTile.X, otherTile.Y).IsTraversable(this.wo))
     {
         Owner.FindComponent <MovementBehavior>().MoveBack(thisTile, otherTile);
         other     = null;
         otherTile = null;
         thisTile  = null;
     }
     else
     {
         Map.map.SetMobile(otherTile.X, otherTile.Y, wo);
         LayerTile tile      = Map.map.GetTileByMapCoordinates(wo.GetX(), wo.GetY());
         var       animation = new WaveEngine.Components.GameActions.MoveTo2DGameAction(Owner, tile.LocalPosition, TimeSpan.FromSeconds(wo.genericSpeed / 2));
         animation.Completed += Stop;
         animation.Run();
     }
 }
示例#2
0
        //Método para mover al personaje
        public void Move()
        {
            moving = true;
            Map.map.SetTileOccupied(nextTile.X, nextTile.Y, true);

            var animation = new WaveEngine.Components.GameActions.MoveTo2DGameAction(Owner, new Vector2(nextTile.LocalPosition.X, nextTile.LocalPosition.Y), TimeSpan.FromSeconds(3));

            animation.Run();
        }