public bool CanMove(Vector direction) { Vector nextPos = Position + direction; Vector boundingBoxPos = new Vector(nextPos.X, nextPos.Y + 16); CollideObject newbox = new CollideObject(boundingBoxPos, 16, 16); return(!CtxFarm.CollideCollection.IsCollide(newbox)); }
public Player(Farm ctxFarm) { CtxFarm = ctxFarm ?? throw new ArgumentNullException(nameof(ctxFarm)); Position = new Vector(1280 / 2, 720 / 2); // divise par 2 pour centrer le joueur dans la view de la gameloop. A changer Life = FarmOptions.DefaultPlayerLife; Speed = FarmOptions.DefaultPlayerMaxSpeed; Inventory = new List <IBuilding>(); Vector boundingBoxPos = new Vector(Position.X, Position.Y - 16); BoundingBox = new CollideObject(boundingBoxPos, 16, 16); }
public Pnj(Farm ctxFarm, float xCoord, float yCoord) { if (xCoord <= 0) { throw new ArgumentOutOfRangeException(nameof(xCoord)); } if (yCoord <= 0) { throw new ArgumentOutOfRangeException(nameof(yCoord)); } CtxFarm = ctxFarm ?? throw new ArgumentNullException(nameof(ctxFarm)); Position = new Vector(xCoord, yCoord); Life = FarmOptions.DefaultPlayerLife; Speed = FarmOptions.DefaultPlayerMaxSpeed; Vector boundingBoxPos = new Vector(Position.X, Position.Y - 16); BoundingBox = new CollideObject(boundingBoxPos, 16, 16); }