private int getObstacleYOffset(Obstacle obstacle) { int yOffset = obstacle.Height; switch (obstacle.Type) { case ObstacleType.HILL: yOffset -= 2; break; case ObstacleType.HOLE: yOffset -= 34; break; case ObstacleType.SLIDE: yOffset += 50; break; case ObstacleType.WALL: yOffset += 0; break; } return yOffset; }
private Obstacle createObstacle(ObstacleType obsType) { Obstacle newObs = new Obstacle(); int newWidth = 0; Texture2D obstacleTexture = null; switch (obsType) { case ObstacleType.HOLE: obstacleTexture = getRandomHoleTexture(); break; case ObstacleType.HILL: obstacleTexture = getRandomHillTexture(); break; case ObstacleType.SLIDE: obstacleTexture = getRandomSlideTexture(); break; case ObstacleType.WALL: obstacleTexture = getRandomWallTexture(); newObs.AnimateOnDeath = true; newWidth = 100; break; } if (obstacleTexture != null) { if (obsType != ObstacleType.NULL) { newObs.Type = obsType; } newObs.Texture = obstacleTexture; newObs.Color = ColorHandler.getCurrentColor(); if (newWidth == 0) { newWidth = newObs.Texture.Width; } newObs.Width = newWidth; newObs.Height = newObs.Texture.Height; newObs.Move(obstacleCreationPointX, obstacleCreationPointY); newObs.AnimationSpeed = obstacleAnimSpeed; newObs.Speed = 2.5f; newObs.LayerDepth = 0.1f; newObs.Active = true; newObs.ReadyToAnimate = false; newObs.StayAtFrame = false; if (newObs.AnimateOnDeath != true) { newObs.AnimateOnDeath = false; } obstacleSprites.Add(newObs); } else { newObs = null; } return newObs; }