public Player(Vector2 position,Sprite sprite,ScreenDebuger screenDebuger,ContentManager content,GraphicsDevice graphicsDevice,Level level) { this.content = content; this.screenDebuger = screenDebuger; playerSprite = sprite; this.position = position; playerSprite.Position = this.position; Spawn = position; this.level = level; this.platforms = level.Platforms; random = new Random(); Health = 100; runningAnimation = new Animation(content.Load<Texture2D>("SpriteSheets/running"), position, 100, 100, 8, 150, 1f, true, graphicsDevice); currentAnimation = runningAnimation; }
public void Intialise(List<Platform> platforms,List<Sprite> sprites,KryptonEngine krypton,ContentManager content,GraphicsDevice graphicsDevice, ScreenDebuger screenDebuger, Level level) { if (EntityType == "Player") { Texture2D playerImage = content.Load<Texture2D>("player"); Sprite testSprite = new Sprite(playerImage, new Vector2(0,0), false, krypton); Player aPlayer = new Player(new Vector2(EntityBounds.X, EntityBounds.Y), testSprite,screenDebuger,content,graphicsDevice,level); level.setPlayer(aPlayer); } if (EntityType == "Hazard") { } if (EntityType == "Platform") { TileCollision tileCollision = TileCollision.Platform; if (Properties["CollisionType"] == "Platform") {tileCollision = TileCollision.Platform;} if (Properties["CollisionType"] == "Passable") { tileCollision = TileCollision.Passable; } if (Properties["CollisionType"] == "Impassable") { tileCollision = TileCollision.Impassable; } Platform platform = new Platform(EntityBounds, tileCollision, Convert.ToBoolean(Properties["IsShadowCaster"]), krypton); platforms.Add(platform); } if (EntityType == "Light") { Color color = new Color(); color.R = (byte)Convert.ToInt32(Properties["R"]); color.G = (byte)Convert.ToInt32(Properties["G"]); color.B = (byte)Convert.ToInt32(Properties["B"]); color.A = 255; /* X = EntityBounds.X, Y = EntityBounds.Y, Range = (float)Convert.ToInt32(Properties["Range"]), Intensity = (float)Convert.ToDouble(Properties["Intensity"]), Color = color, ShadowType = ShadowType.Illuminated, Fov = MathHelper.PiOver2 * (float) (0.5) * */ Light2D light = new Light2D { Texture = LightTextureBuilder.CreatePointLight(graphicsDevice, 1024), X = EntityBounds.X, Y = EntityBounds.Y, Range = (float)Convert.ToInt32(Properties["Range"]), Intensity = (float)Convert.ToDouble(Properties["Intensity"]), Color = color, ShadowType = ShadowType.Illuminated, Fov = MathHelper.PiOver2 * (float)Convert.ToDouble(Properties["Fov"]) }; //Optional Properties if(Properties.ContainsKey("Flicker")){ light.Flicker = (bool)Convert.ToBoolean(Properties["Flicker"]);} krypton.Lights.Add(light); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // Make sure to initialize krpyton, unless it has been added to the Game's list of Components krypton.Initialize(); krypton.SpriteBatchCompatablityEnabled = true; krypton.CullMode = CullMode.None; krypton.Bluriness = 3; krypton.AmbientColor = new Color(15, 15, 15); ambiantLight.Initialize(); //ambiantLight.SpriteBatchCompatablityEnabled = true; //ambiantLight.CullMode = CullMode.None; ambiantLight.Bluriness = 0; ambiantLight.AmbientColor = new Color(40, 40, 40); //ambiantLight.AmbientColor = new Color(255, 255, 255); //Sprites list sprites = new List<Sprite>(); //Create camera camera = new Camera2D(GraphicsDevice); //Set vertical scale verticalUnits = GraphicsDevice.Viewport.Height; // TODO: use this.Content to load your game content here level = Content.Load<Level>("Levels/newTest"); level.Intialise(krypton, this.Content, this.GraphicsDevice, this.screenDebuger , sprites); base.Initialize(); }