public void DeactivateValve(Hero gameHero) { if (!AtValve) return; foreach (Trigger trig in valves) { if (!trig.HasTriggered) if (trig.Object.Location.Contains(Helper.VtoP(gameHero.Position))) { int layer = 0; if (trig.Object.Properties.Contains("Layer")) layer = Convert.ToInt16(trig.Object.Properties["Layer"]); if (gameHero.Layer == layer) { trig.HasTriggered = true; if (trig.Object.Properties.Contains("Master")) gameHero.Complete = true; } } } }
public void Update(GameTime gameTime, int waterLevel, Hero gameHero, Map gameMap) { if (ShowingSouls) { soulsAlpha = MathHelper.Lerp(soulsAlpha, 1f, 0.05f); } if (ShowingWater) { waterAlpha = MathHelper.Lerp(waterAlpha, 1f, 0.05f); } //waterLevelHeight = MathHelper.Clamp((1f / ((gameMap.Height * gameMap.TileHeight) - (gameHero.Position.Y-200))) * (float)waterLevel, 0f, 1f); //((float)texHud.Height / (gameHero.Position.Y - 200f)) * (float)waterLevel; waterLevelHeight = MathHelper.Clamp((1f / 700f) * (700f - (((float)(gameMap.TileHeight * gameMap.Height) - (float)waterLevel)-gameHero.Position.Y+200f)), 0f, 1f); //((float)texHud.Height / (gameHero.Position.Y - 200f)) * (float)waterLevel; waterAnimTime += gameTime.ElapsedGameTime.TotalMilliseconds; if (waterAnimTime >= 200) { waterAnimTime = 0; waterAnimFrame = 1 - waterAnimFrame; } if (gameHero.Dead) { ShowingSouls = true; soulsToCenterAmount = MathHelper.Lerp(soulsToCenterAmount, 1f, 0.05f); if (!endPromptsDone) { PromptController.Instance.ClearPrompts(); PromptController.Instance.AddPrompt("dead1", PromptController.PromptType.Text, " ", false, 0, 0); PromptController.Instance.AddPrompt("dead2", PromptController.PromptType.Text, " ", false, 0, 0); PromptController.Instance.AddPrompt("dead3", PromptController.PromptType.Text, "...and one.", false, 0, 4000); PromptController.Instance.AddPrompt("dead4", PromptController.PromptType.Image, "use", false, 0, 8000); endPromptsDone = true; } if (soulsToCenterAmount > 0.98f) ReadyForRestart = true; } if (gameHero.Complete) { ShowingSouls = true; soulsToCenterAmount = MathHelper.Lerp(soulsToCenterAmount, 1f, 0.05f); if (!endPromptsDone) { PromptController.Instance.ClearPrompts(); PromptController.Instance.AddPrompt("comp1", PromptController.PromptType.Text, " ", false, 0, 0); PromptController.Instance.AddPrompt("comp2", PromptController.PromptType.Text, " ", false, 0, 0); PromptController.Instance.AddPrompt("comp3", PromptController.PromptType.Text, "...but Gerde had saved untold numbers", false, 0, 4000); PromptController.Instance.AddPrompt("comp4", PromptController.PromptType.Text, "of her people. She was happy.", false, 0, 4000); PromptController.Instance.AddPrompt("comp5", PromptController.PromptType.Image, "use", false, 0, 8000); endPromptsDone = true; } if (soulsToCenterAmount > 0.98f) ReadyForRestart = true; } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { AudioController.LoadContent(Content); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here gameMap = Content.Load<Map>("map"); gameHud = new Hud(); gameHud.LoadContent(Content); gameTriggerController = new TriggerController(gameMap); gamePromptController = new PromptController(); gamePromptController.LoadContent(Content); blankTex = Content.Load<Texture2D>("blank"); skyGradient = Content.Load<Texture2D>("sky-gradient"); cloudTexture = Content.Load<Texture2D>("cloud-test"); valveTexture = Content.Load<Texture2D>("valve"); int layerCount = 0; foreach (Layer ml in gameMap.Layers) if (ml is TileLayer) layerCount++; LayerDepths = new float[layerCount]; LayerColors = new Color[layerCount]; float scale = 1f; for (int i = 0; i < LayerDepths.Length; i++) { LayerDepths[i] = scale; LayerColors[i] = new Color((1f - (scale * 0.5f)) * 0.4f, (1f - (scale * 0.5f)) * 0.5f, (1f - (scale * 0.5f)) * 0.9f);//Color.White * (scale * 0.5f); if (scale > 0f) scale -= 0.33333f; } gameHero = new Hero(Helper.PtoV((gameMap.GetLayer("Spawn") as MapObjectLayer).Objects[0].Location.Center)); gameHero.LoadContent(Content, GraphicsDevice); gameCamera = new Camera(GraphicsDevice.Viewport, gameMap); gameCamera.Position = gameHero.Position; gameCamera.Target = gameHero.Position; for (scale = 1.5f; scale > -5f; scale -= 0.1f) { Waters.Add(new Water(GraphicsDevice, gameMap, new Rectangle(-GraphicsDevice.Viewport.Bounds.Width, (gameMap.Height * gameMap.TileHeight) - waterLevel, ((gameMap.Width * gameMap.TileWidth) * 2) + GraphicsDevice.Viewport.Bounds.Width, 400 + waterLevel), new Color(50, 128, 255), Color.Black, scale)); } for (scale = 1.5f; scale > -5f; scale -= 0.1f) { Clouds.Add(new Vector4(rand.Next(1920), 1000f, scale, 0f)); } ambient1 = Content.Load<SoundEffect>("sfx/ambient1").CreateInstance(); ambient2 = Content.Load<SoundEffect>("sfx/ambient2").CreateInstance(); water = Content.Load<SoundEffect>("sfx/water").CreateInstance(); ambient1.Volume = 0f; ambient2.Volume = 0f; water.Volume = 0f; ambient1.IsLooped = true; ambient2.IsLooped = true; water.IsLooped = true; ambient1.Play(); ambient2.Play(); water.Play(); }
public void DrawValves(SpriteBatch sb, int layer, Texture2D tex, Color col, bool sil, Hero gameHero) { foreach (Trigger v in valves.Where(valve => Convert.ToInt16(valve.Object.Properties["Layer"]) == layer)) { sb.Draw(tex, v.Position, new Rectangle(gameHero.usingValve?rand.Next(2) * (tex.Width/2):0, sil?tex.Height/2:0,tex.Width/2,tex.Height/2), col, 0f, new Vector2(tex.Width, tex.Height) / 4, 1f, SpriteEffects.None, 0); //v.Position } }
public void Update(GameTime gameTime, Hero gameHero) { foreach (Trigger trig in triggers) { if(!trig.HasTriggered) if (trig.Object.Location.Contains(Helper.VtoP(gameHero.Position))) { int layer = 0; if (trig.Object.Properties.Contains("Layer")) layer = Convert.ToInt16(trig.Object.Properties["Layer"]); if (gameHero.Layer == layer) { trig.HasTriggered = true; ActivateTrigger(Convert.ToInt16(trig.Object.Name)); } } } AtValve = false; foreach (Trigger trig in valves) { if (!trig.HasTriggered) { if (trig.Object.Location.Contains(Helper.VtoP(gameHero.Position))) { int layer = 0; if (trig.Object.Properties.Contains("Layer")) layer = Convert.ToInt16(trig.Object.Properties["Layer"]); if (gameHero.Layer == layer) { AtValve = true; } } } else { trig.Position += trig.Speed; trig.Speed.Y += 0.1f; trig.Speed.X -=0.02f; if (trig.Position.Y > (trig.Object.Location.Y + trig.Object.Location.Height) - 40f) { trig.Speed.Y = -(trig.Speed.Y / 2); trig.Position += trig.Speed; } trig.Speed = Vector2.Clamp(trig.Speed, new Vector2(0, -10f), new Vector2(2f, 10f)); } } }