public GameBlock(GameModel parent, BlockType type, Position position, string scriptName = null) : base(position) { if (scriptName != null) { this.scriptName = Constants.SCRIPT_BLOCK_PREFIX + scriptName; } if (type == BlockType.OUT_OF_BOUNDS) { throw new Exception("Can't set blocktype to OUT_OF_BOUNDS!"); } else if (type == BlockType.EMPTY) { throw new Exception("Can't set blocktype to EMPTY!"); } this.type = type; this.parent = parent; }
/// <summary> /// /// </summary> /// <param name="moveOffset"></param> /// <param name="startTime"></param> /// <returns>True if the moving was initiated and false if already moving OR /// the destination position was already occupied</returns> public bool MoveOffsetIfNotAlreadyMoving(Position moveOffset, long startTime) { if (!moving && this.ParentMap().WorldMatrix.beginMoveModel(this, Position + moveOffset)) { moving = true; begunMovingAt = startTime; this.moveOffset = moveOffset; return true; } return false; }
/// <summary> /// /// </summary> /// <param name="destination">An absolute Position</param> /// <param name="gameTime"></param> /// <returns>True if the character (is now|will soon) start walking towards the destination</returns> public bool WalkTo(Position destination, GameTime gameTime) { Position start = Position; if (moving) { start += moveOffset; } PathCheckpoints = Engine.Physics.FindPath(this, start, destination); return checkIfDoneMoving(gameTime); }
public SaveBlock(Position position, BlockType type, string script) : this(position) { this.Type = type; this.Script = script; }
public SaveBlock(Position position) { this.position = position; }
protected void drawBlock(Texture2D image, BoundingBoxInt boundingBox, Color color, Position pos, float depthOffset = 0) { float depth = boundingBox.getRelativeDepthOf(pos); Vector2 projCoords = CoordinateTransform.ObjectToProjectionSpace(pos); spriteBatch.Draw(image, projCoords + Constants.blockDrawOffset, null, color, 0, Vector2.Zero, 1, SpriteEffects.None, (depth + depthOffset) / Wrapper.Camera.Zoom); }