/// <summary> /// Update /// </summary> public void Update(GameTime gameTime, World w) { pos = physics.Position; bool wallCollision = false; if(state != DumbCopState.FALL || state != DumbCopState.GET_UP || state != DumbCopState.HIT){ wallCollision = testWallCollide(); } if(!wallCollision){ updateState(); } movement.Look(ref physics); physics.UpdatePosition(gameTime.ElapsedGameTime.TotalSeconds, out pos); physics.UpdateOrientation(gameTime.ElapsedGameTime.TotalSeconds); if (state == DumbCopState.HIT) { if (pos.X < Game1.world.streaker.Position.X) { draw.SpriteEffect = SpriteEffects.None; } else { draw.SpriteEffect = SpriteEffects.FlipHorizontally; } } else if (physics.Orientation > 0) { draw.SpriteEffect = SpriteEffects.None; } else if (physics.Orientation < 0) { draw.SpriteEffect = SpriteEffects.FlipHorizontally; } draw.Update(gameTime); if (draw.animComplete && (state == DumbCopState.FALL || state == DumbCopState.GET_UP)) { draw.GoToPrevFrame(); } base.Update(gameTime); }
/// <summary> /// Update /// </summary> public void Update(GameTime gameTime, World w) { pos = physics.Position; bool wallCollision = false; if (state != SmartCopState.FALL || state != SmartCopState.GET_UP || state != SmartCopState.HIT) { wallCollision = testWallCollide(); } if (!wallCollision) { updateState(gameTime); } if (closest == this) { closestDistSq = (Game1.world.streaker.ComponentPhysics.Position - physics.Position).LengthSquared(); } else { float distSq = (Game1.world.streaker.ComponentPhysics.Position - physics.Position).LengthSquared(); if (distSq < closestDistSq) { closest = this; closestDistSq = distSq; } } movement.Look(ref physics); physics.UpdatePosition(gameTime.ElapsedGameTime.TotalSeconds, out pos, this); physics.UpdateOrientation(gameTime.ElapsedGameTime.TotalSeconds); if (state == SmartCopState.HIT) { if (pos.X < Game1.world.streaker.Position.X) { draw.SpriteEffect = SpriteEffects.None; } else { draw.SpriteEffect = SpriteEffects.FlipHorizontally; } } else if (physics.Orientation > 0) { draw.SpriteEffect = SpriteEffects.None; } else if (physics.Orientation < 0) { draw.SpriteEffect = SpriteEffects.FlipHorizontally; } draw.Update(gameTime); if (draw.animComplete && (state == SmartCopState.FALL || state == SmartCopState.GET_UP)) { draw.GoToPrevFrame(); } if (draw.animComplete && state == SmartCopState.HIT && Math.Abs(Game1.world.streaker.Position.X - pos.X) <= HIT_DISTANCE_X && Math.Abs(Game1.world.streaker.Position.Y - pos.Y) <= HIT_DISTANCE_Y) { Game1.world.streaker.GetHit(); playSound("Hit"); } base.Update(gameTime); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { SoundManager.GetInstance().LoadContent(Content); SoundManager.GetInstance().PlaySong("Level"); reset = false; graphics.PreferredBackBufferWidth = SCREEN_WIDTH; graphics.PreferredBackBufferHeight = SCREEN_HEIGHT; #if(!DEBUG) this.graphics.IsFullScreen = true; #endif graphics.ApplyChanges(); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); spriteFont = Content.Load<SpriteFont>("Fonts/Game Over"); FontManager fontMan = FontManager.getInstance(); fontMan.addFont("GameOver", spriteFont); fontMan.addFont("AchieveTitle", Content.Load<SpriteFont>("Fonts/AchievementTitle")); fontMan.addFont("AchieveText", Content.Load<SpriteFont>("Fonts/AchievementText")); SpriteDatabase.loadSprites(Content); Texture2D blank = new Texture2D(GraphicsDevice, 1, 1); blank.SetData(new[] { Color.White }); SpriteDatabase.AddAnimation(new Animation("blank", blank, 1, 1, 1, 0, 1)); //Create World world = new World(); world.LoadMap("level.txt"); Texture2D level = SpriteDatabase.GetAnimation("level_1").Texture; Camera.MaxX = level.Width; Camera.MaxY = level.Height; Camera.Target = world.streaker; Camera.Scale = 1f; Debugger.getInstance(); //Hud Texture2D banner = Content.Load<Texture2D>("Hud/banner"); Texture2D notorietyBar = Content.Load<Texture2D>("Hud/notorietyBar"); Texture2D notorietyMeter = Content.Load<Texture2D>("Hud/notorietyMeter"); Texture2D gameOverText = Content.Load<Texture2D>("Hud/gameOverText"); Texture2D superFlashIcon = Content.Load<Texture2D>("Hud/superFlashButton"); HUD.getInstance().loadContent(banner, notorietyBar, notorietyMeter, spriteFont, blank, gameOverText, superFlashIcon); IsMouseVisible = true; mainMenu.LoadContent(Content.Load<Texture2D>("Menu")); }
public static void LoadContentReset() { NPC.copsWhoSeeTheStreaker = 0; SmartCop.closest = null; SmartCop.closestDistSq = float.MaxValue; SmartCop.StreakerSeen = false; foreach (Trigger trigger in world.map.triggers) { trigger.clearTriggered(); } AchievementManager.getInstance().Reset(); DataManager.GetInstance().Reset(); elapsedTime = 0.0f; world = new World(); world.LoadMap("level.txt"); Texture2D level = SpriteDatabase.GetAnimation("level_1").Texture; //Reset data in datamanager SoundManager.GetInstance().PlaySong("Level"); Camera.Target = world.streaker; }
/// <summary> /// Update /// </summary> public void Update(GameTime gameTime, World w) { pos = physics.Position; bool wallCollision = false; if (state ==RoboCopState.HIT) { if (pos.X < Game1.world.streaker.Position.X) { draw.SpriteEffect = SpriteEffects.None; } else { draw.SpriteEffect = SpriteEffects.FlipHorizontally; } } else if (state != RoboCopState.HIT) { wallCollision = testWallCollide(); } if (!wallCollision) { updateState(gameTime); } movement.Look(ref physics); physics.UpdatePosition(gameTime.ElapsedGameTime.TotalSeconds, out pos); physics.UpdateOrientation(gameTime.ElapsedGameTime.TotalSeconds); if (physics.Orientation > 0) { draw.SpriteEffect = SpriteEffects.None; } else if (physics.Orientation < 0) { draw.SpriteEffect = SpriteEffects.FlipHorizontally; } draw.Update(gameTime); if (draw.animComplete && state == RoboCopState.HIT && Math.Abs(Game1.world.streaker.Position.X - pos.X) <= HIT_DISTANCE_X && Math.Abs(Game1.world.streaker.Position.Y - pos.Y) <= HIT_DISTANCE_Y) { Game1.world.streaker.GetHit(); Game1.world.streaker.ResolveCollision(this); } base.Update(gameTime); }
/// <summary> /// Update /// </summary> public void Update(GameTime gameTime, World w) { pos = physics.Position; updateState(w); movement.Look(ref physics); physics.UpdatePosition(gameTime.ElapsedGameTime.TotalSeconds, out pos); physics.UpdateOrientation(gameTime.ElapsedGameTime.TotalSeconds); if (physics.Orientation > 0) { draw.SpriteEffect = SpriteEffects.None; } else if (physics.Orientation < 0) { draw.SpriteEffect = SpriteEffects.FlipHorizontally; } draw.Update(gameTime); if (draw.animComplete && (state == PedestrianState.FALL || state == PedestrianState.GET_UP)) { draw.GoToPrevFrame(); } if (fleePoints) { fleePointsTime += gameTime.ElapsedGameTime.Milliseconds; if (fleePointsTime >= fleePointsTimeout) { fleePointsTime = 0; DataManager.GetInstance().IncreaseScore(DataManager.Points.FleeProximity, true, physics.Position.X, physics.Position.Y - 64); } } base.Update(gameTime); }
private void updateState(World w) { IsVisible(Game1.world.streaker.Position, out canSee, out canReach); fleePoints = false; //-------------------------------------------------------------------------- // DEFAULT BEHAVIOR TRANSITIONS --> Before aware of streaker //-------------------------------------------------------------------------- if (behavior == PedestrianBehavior.DEFAULT) { if (Vector2.Distance(w.streaker.Position, pos) < detectRadius && canSee) { playSound("Exclamation"); behavior = PedestrianBehavior.AWARE; transitionToState(PedestrianState.FLEE); } } //-------------------------------------------------------------------------- // AWARE BEHAVIOR TRANSITION --> Knows about streaker //-------------------------------------------------------------------------- else if (behavior == PedestrianBehavior.AWARE) { if (Vector2.Distance(w.streaker.Position, pos) < detectRadius && canSee) fleePoints = true; else fleePoints = false; if (Vector2.Distance(w.streaker.Position, pos) > detectRadius) { behavior = PedestrianBehavior.DEFAULT; transitionToState(PedestrianState.WANDER); } } //-------------------------------------------------------------------------- // COLLIDE BEHAVIOR TRANSITION //-------------------------------------------------------------------------- else if (behavior == PedestrianBehavior.KNOCKEDUP) { switch (state) { case PedestrianState.FALL: if (draw.animComplete) { SoundManager.GetInstance().PlaySound("Common", "Fall", w.streaker.Position, Position); transitionToState(PedestrianState.GET_UP); } break; case PedestrianState.GET_UP: if (draw.animComplete && Vector2.Distance(w.streaker.Position, pos) < detectRadius) { behavior = PedestrianBehavior.AWARE; transitionToState(PedestrianState.FLEE); } else if (draw.animComplete && Vector2.Distance(w.streaker.Position, pos) >= detectRadius) { behavior = PedestrianBehavior.DEFAULT; transitionToState(PedestrianState.WANDER); } break; } } //-------------------------------------------------------------------------- // CHAR STATE --> ACTION //-------------------------------------------------------------------------- switch (state) { case PedestrianState.STATIC: movement.Stop(ref physics); break; case PedestrianState.WANDER: movement.Wander(ref physics); break; case PedestrianState.FLEE: movement.SetTarget(w.streaker.ComponentPhysics.Position); movement.Flee(ref physics); break; case PedestrianState.PATH: //TO DO break; case PedestrianState.FALL: movement.Stop(ref physics); break; case PedestrianState.GET_UP: movement.Stop(ref physics); break; default: break; } if (!fleePoints) fleePointsTime = 500; }