protected override void OnFixedUpdate(float timeMult) { base.OnFixedUpdate(timeMult); // ToDo: This workaround should be removed if (isStillLoading > 0) { isStillLoading--; if (isStillLoading <= 0) { // TODO const PlayerType playerType = PlayerType.Spaz; client.SendToServer(new LevelReady { Index = localPlayerIndex, PlayerType = playerType }, 3, NetDeliveryMethod.ReliableOrdered, PacketChannels.Main); } } #if DEBUG Hud.ShowDebugText("- Local Player Index: " + localPlayerIndex); Hud.ShowDebugText("- RTT: " + (int)(client.AverageRoundtripTime * 1000) + " ms / Up: " + client.UploadPacketBytes + " / Down: " + client.DownloadPacketBytes); Hud.ShowDebugText("- Last Server Update: " + lastServerUpdateTime); Hud.ShowDebugText("- Remote Objects: " + /*localRemotableActors.Count + " / " +*/ remoteActors.Count); #endif if (players.Count > 0) { //lastUpdate += timeMult; /*if (lastUpdate < 1.4f) { * return; * }*/ //lastUpdate = 0f; long updateTime = (long)(NetTime.Now * 1000); // Send update to server Player player = players[0]; client.SendToServer(new PlayerUpdate { Index = localPlayerIndex, UpdateTime = updateTime, Pos = player.Transform.Pos, Speed = player.Speed, CurrentSpecialMove = player.CurrentSpecialMove, IsVisible = player.IsVisible, IsFacingLeft = player.IsFacingLeft, IsActivelyPushing = player.IsActivelyPushing }, 20, NetDeliveryMethod.Unreliable, PacketChannels.UnorderedUpdates); } }
protected virtual void OnUpdate() { if (ControlScheme.MenuActionHit(PlayerActions.Menu)) { Scene.SwitchTo(new InGameMenu(root, this)); } Hud.ShowDebugText("- FPS: " + Time.Fps.ToString("N0") + " (" + Math.Round(Time.UnscaledDeltaTime * 1000, 1).ToString("N1") + " ms)"); Hud.ShowDebugText(" Diff.: " + difficulty + " | Actors: " + actors.Count.ToString("N0")); Hud.ShowDebugText(" Ambient Light: " + ambientLightCurrent.ToString("0.00") + " / " + ambientLightTarget.ToString("0.00")); Hud.ShowDebugText(" Collisions: " + collisionsCountA + " > " + collisionsCountB + " > " + collisionsCountC); }
protected virtual void OnUpdate() { if (ControlScheme.PlayerActionHit(0, PlayerActions.Menu)) { Scene.SwitchTo(new InGameMenu(root, this)); } #if !DISABLE_CHEATS if (root.EnableCheats && difficulty != GameDifficulty.Multiplayer) { ProcessCheats(); } #endif Hud.ShowDebugText("- FPS: " + Time.Fps.ToString("N0") + " (" + Math.Round(Time.UnscaledDeltaTime * 1000, 1).ToString("N1") + " ms)"); Hud.ShowDebugText(" Diff.: " + difficulty + " | Actors: " + actors.Count.ToString("N0")); Hud.ShowDebugText(" Ambient Light: " + ambientLightCurrent.ToString("0.00") + " / " + ambientLightTarget.ToString("0.00")); Hud.ShowDebugText(" Collisions: " + collisionsCountA + " > " + collisionsCountB + " > " + collisionsCountC); }
private void OnUpdate() { if (currentCarryOver.HasValue) { if (levelChangeTimer > 0) { levelChangeTimer -= Time.TimeMult; } else { root.ChangeLevel(currentCarryOver.Value); currentCarryOver = null; return; } } Vector3 pos = players[0].Transform.Pos; //int tx = (int)(pos.X / 32); //int ty = (int)(pos.Y / 32); int tx = (int)pos.X >> 5; int ty = (int)pos.Y >> 5; // ToDo: Remove this branching #if __ANDROID__ const int ActivateTileRange = 20; #else const int ActivateTileRange = 26; #endif for (int i = 0; i < actors.Count; i++) { if (actors[i].OnTileDeactivate(tx, ty, ActivateTileRange + 2)) { i--; } } eventMap.ActivateEvents(tx, ty, ActivateTileRange); eventMap.ProcessGenerators(); ResolveCollisions(); // Ambient Light Transition if (ambientLightCurrent != ambientLightTarget) { float step = Time.TimeMult * 0.012f; if (MathF.Abs(ambientLightCurrent - ambientLightTarget) < step) { ambientLightCurrent = ambientLightTarget; } else { ambientLightCurrent += step * ((ambientLightTarget < ambientLightCurrent) ? -1 : 1); } } // Weather if (weatherType != WeatherType.None) { Vector3 viewPos = camera.Transform.Pos; for (int i = 0; i < weatherIntensity; i++) { TileMap.DebrisCollisionAction collisionAction; if (weatherOutdoors) { collisionAction = TileMap.DebrisCollisionAction.Disappear; } else { collisionAction = (MathF.Rnd.NextFloat() > 0.7f ? TileMap.DebrisCollisionAction.None : TileMap.DebrisCollisionAction.Disappear); } Vector3 debrisPos = viewPos + MathF.Rnd.NextVector3((LevelRenderSetup.TargetSize.X / -2) - 40, (LevelRenderSetup.TargetSize.Y * -2 / 3), MainPlaneZ, LevelRenderSetup.TargetSize.X + 120, LevelRenderSetup.TargetSize.Y, 0); if (weatherType == WeatherType.Rain) { GraphicResource res = commonResources.Graphics["Rain"]; Material material = res.Material.Res; Texture texture = material.MainTexture.Res; float scale = MathF.Rnd.NextFloat(0.4f, 1.1f); float speedX = MathF.Rnd.NextFloat(2.2f, 2.7f) * scale; float speedY = MathF.Rnd.NextFloat(7.6f, 8.6f) * scale; debrisPos.Z = MainPlaneZ * scale; tileMap.CreateDebris(new TileMap.DestructibleDebris { Pos = debrisPos, Size = res.Base.FrameDimensions, Speed = new Vector2(speedX, speedY), Scale = scale, Angle = MathF.Atan2(speedY, speedX), Alpha = 1f, Time = 180f, Material = material, MaterialOffset = texture.LookupAtlas(res.FrameOffset + MathF.Rnd.Next(res.FrameCount)), CollisionAction = collisionAction }); } else { GraphicResource res = commonResources.Graphics["Snow"]; Material material = res.Material.Res; Texture texture = material.MainTexture.Res; float scale = MathF.Rnd.NextFloat(0.4f, 1.1f); float speedX = MathF.Rnd.NextFloat(-1.6f, -1.2f) * scale; float speedY = MathF.Rnd.NextFloat(3f, 4f) * scale; float accel = MathF.Rnd.NextFloat(-0.008f, 0.008f) * scale; debrisPos.Z = MainPlaneZ * scale; tileMap.CreateDebris(new TileMap.DestructibleDebris { Pos = debrisPos, Size = res.Base.FrameDimensions, Speed = new Vector2(speedX, speedY), Acceleration = new Vector2(accel, -MathF.Abs(accel)), Scale = scale, Angle = MathF.Rnd.NextFloat(MathF.TwoPi), AngleSpeed = speedX * 0.02f, Alpha = 1f, Time = 180f, Material = material, MaterialOffset = texture.LookupAtlas(res.FrameOffset + MathF.Rnd.Next(res.FrameCount)), CollisionAction = collisionAction }); } } } // Active Boss if (activeBoss != null && activeBoss.ParentScene == null) { activeBoss = null; Hud hud = rootObject.GetComponent <Hud>(); if (hud != null) { hud.ActiveBoss = null; } InitLevelChange(ExitType.Normal, null); levelChangeTimer *= 2; } if (DualityApp.Keyboard.KeyHit(Key.Escape)) { Scene.SwitchTo(new InGameMenu(root, this)); } Hud.ShowDebugText("- FPS: " + Time.Fps.ToString("N0") + " (" + Math.Round(Time.UnscaledDeltaTime * 1000, 1).ToString("N1") + " ms)"); Hud.ShowDebugText(" Diff.: " + difficulty + " | Actors: " + actors.Count.ToString("N0")); Hud.ShowDebugText(" Ambient Light: " + ambientLightCurrent.ToString("0.00") + " / " + ambientLightTarget.ToString("0.00")); Hud.ShowDebugText(" Collisions: " + collisionsCountA + " > " + collisionsCountB + " > " + collisionsCountC); collisionsCountA = 0; collisionsCountB = 0; collisionsCountC = 0; }