public void Update(GameTime gameTime, bool cutScene, int newGameState) { Player.Update(gameTime, cutScene); CheckActive(); if (!cutScene) { if (isActive && gameMode.BetweenLevelsTimer.IsFinished) { UpdateSpawnHandlers(gameTime); } if (newGameState != EventOperator.CUT_SCENE_STATE) { gameMode.Update(gameTime); } ProgressGame(gameTime); } Drops.Update(gameTime); Enemies.Update(gameTime); Projectiles.Update(gameTime); HandleAllCollisions(); }
public void Update(Time dt) { Sprite.Update(dt);//animation Projectiles.Update(dt); _shootTime += dt; Vector2f pos = Position; Vector2f vel = Velocity; vel.Y += _gravity; Velocity = vel; pos.X += Direction * Velocity.X * dt.AsSeconds(); pos.Y += Velocity.Y * dt.AsSeconds(); Position = pos; if (Position.Y >= 768 - (Size.Y / 2.0f)) { Position = new Vector2f(Position.X, 768 - (Size.Y / 2.0f)); Velocity = new Vector2f(Velocity.X, 0); if (Jumping) { Velocity = new Vector2f(Velocity.X, 0); Jumping = false; } } if (Position.X < 0) { Position = new Vector2f(0, Position.Y); //Velocity = new Vector2f(0, Velocity.Y); } else if (Position.X >= 1366 + Size.X) { Position = new Vector2f(1366 + Size.X, Position.Y); //Velocity = new Vector2f(0, Velocity.Y); } }
public override void Simulate() { try { if (!DedicatedServer) { EntityControlUpdate(); CameraMatrix = Session.Camera.WorldMatrix; CameraPos = CameraMatrix.Translation; PlayerPos = Session.Player?.Character?.WorldAABB.Center ?? Vector3D.Zero; } if (GameLoaded) { DsUtil.Start("ai"); AiLoop(); DsUtil.Complete("ai", true); DsUtil.Start("charge"); if (ChargingWeapons.Count > 0) { UpdateChargeWeapons(); } DsUtil.Complete("charge", true); DsUtil.Start("acquire"); if (AcquireTargets.Count > 0) { CheckAcquire(); } DsUtil.Complete("acquire", true); DsUtil.Start("shoot"); if (ShootingWeapons.Count > 0) { ShootWeapons(); } DsUtil.Complete("shoot", true); } if (!DedicatedServer && !WheelUi.WheelActive && !InMenu) { UpdateLocalAiAndCockpit(); if (UiInput.PlayerCamera && ActiveCockPit != null) { TargetSelection(); } } if (FragmentsNeedingEntities.Count > 0) { Projectiles.PrepFragmentEntities(); } DsUtil.Start("projectiles"); Projectiles.Update(); DsUtil.Complete("projectiles", true); DsUtil.Start("network1"); if (WeaponsToSync.Count > 0) { Proccessor.Proccess(); } DsUtil.Complete("network1", true); /* * if (!DedicatedServer) * { * //PTask = MyAPIGateway.Parallel.StartBackground(Projectiles.Update); * if (WeaponsToSync.Count > 0) NTask = MyAPIGateway.Parallel.StartBackground(Proccessor.Proccess); * } */ } catch (Exception ex) { Log.Line($"Exception in SessionSim: {ex}"); } }