/// <summary> /// Move the box in the current moveDir. /// </summary> /// <param name="renderContext"></param> /// <param name="moveDir"></param> /// <param name="movementAmount"></param> public void Move(RenderContext renderContext, GameConstants.DIRECTION moveDir, float movementAmount) { facingDirection = moveDir; //Rotate(0f, -90f, 0f); //No need to rotate moving platform to set its direction Vector3 newPosition; Vector3 PositionChange; //Get position change depending on direction if(moveDir == LEFT) PositionChange = new Vector3(-movementAmount, 0, 0); else if (moveDir == RIGHT) PositionChange = new Vector3(movementAmount, 0, 0); else if (moveDir == UP) PositionChange = new Vector3(0, movementAmount, 0); else// if (moveDir == DOWN) PositionChange = new Vector3(0, -movementAmount, 0); newPosition = Position + PositionChange; currDistance += movementAmount; Translate(newPosition); //if player is on the platform, move the player just as much as the platform does if (PlayerOnPlatform) { Vector3 newPlayerPosition = renderContext.Player.Position + PositionChange; renderContext.Player.Translate(newPlayerPosition); } }
public LaserTurret(int column, int row, bool turretOn, GameConstants.POINTDIR direction) : base(column, row) { // Load and position,rotate model based on level builder direction base.Model = GameplayScreen._models["Turret"]; this.direction = direction; SetVerticalOffset(20); // set turret to on state this.turretOn = turretOn; // collision handling base.isCollidable = true; UpdateBoundingBox(base.Model, Matrix.CreateTranslation(base.Position), true, true); base.HitboxHeightOffset = -5; }
public EnemySonar(Vector2 position, GameConstants.POINTDIR direction, Enemy sourceEnemy) : base(position) { active = true; this.direction = direction; isCollidable = false; this.sourceEnemy = sourceEnemy; base.Model = GameplayScreen._models["projectile"]; // hitbox for collision //UpdateBoundingBox(base.Model, Matrix.CreateTranslation(base.Position), false, false); SetVerticalOffset(-20); SetDirection(); base.HitboxHeight = 40; base.HitboxWidth = 300; //base.HitboxWidthOffset = 48; base.HitboxHeightOffset = 20; }
public LaserProjectile(int column, int row, GameConstants.POINTDIR direction) : base(column, row) { base.Model = GameplayScreen._models["projectile"]; Scale(1.9f, 3f, 3f); //Rotate(0f, 0f, 90f); //SetVerticalOffset(); //SetHorizontalOffset(30); active = true; this.direction = direction; isCollidable = false ; SetDirection(); // hitbox for collision UpdateBoundingBox(base.Model, Matrix.CreateTranslation(base.Position), false, false); soundEffects = new SoundEffectPlayer(this); //set up sound soundEffects.LoadSound("LaserWhirLoop", GameplayScreen._sounds["LaserWhirLoop"]); soundEffects.PlayAndLoopSound("LaserWhirLoop"); }