public static void UpdateParticle(ParticleManager<ParticleState>.Particle particle) { var vel = particle.State.Velocity; float speed = vel.Length(); Vector2.Add(ref particle.Position, ref vel, out particle.Position); // fade the particle if its PercentLife or speed is low. float alpha = Math.Min(1, Math.Min(particle.PercentLife * 2, speed * 1f)); alpha *= alpha; particle.Color.A = (byte)(255 * alpha); // the length of bullet particles will be less dependent on their speed than other particles if (particle.State.Type == ParticleType.Bullet) particle.Scale.X = particle.State.LengthMultiplier * Math.Min(Math.Min(1f, 0.1f * speed + 0.1f), alpha); else particle.Scale.X = particle.State.LengthMultiplier * Math.Min(Math.Min(1f, 0.2f * speed + 0.1f), alpha); particle.Orientation = vel.ToAngle(); var pos = particle.Position; Vector2 screenSize = new Vector2(GameplayScreen.thisViewport.Width, GameplayScreen.thisViewport.Height); int width = (int)screenSize.X; int height = (int)screenSize.Y; // collide with the edges of the screen if (pos.X < 0) vel.X = Math.Abs(vel.X); else if (pos.X > width) vel.X = -Math.Abs(vel.X); if (pos.Y < 0) vel.Y = Math.Abs(vel.Y); else if (pos.Y > height) vel.Y = -Math.Abs(vel.Y); //if (particle.State.Type != ParticleType.IgnoreGravity) //{ // foreach (var blackHole in EntityManager.BlackHoles) // { // var dPos = blackHole.Position - pos; // float distance = dPos.Length(); // var n = dPos / distance; // vel += 10000 * n / (distance * distance + 10000); // // add tangential acceleration for nearby particles // if (distance < 400) // vel += 45 * new Vector2(n.Y, -n.X) / (distance + 100); // } //} if (Math.Abs(vel.X) + Math.Abs(vel.Y) < 0.00000000001f) // denormalized floats cause significant performance issues vel = Vector2.Zero; else if (particle.State.Type == ParticleType.Enemy) vel *= 0.94f; else vel *= 0.96f + Math.Abs(pos.X) % 0.04f; // rand.Next() isn't thread-safe, so use the position for pseudo-randomness particle.State.Velocity = vel; }
void Start () { manager = GameObject.FindGameObjectWithTag("Manager").GetComponent<GameManager>(); PartM = manager.PM; SFX = manager.SFX; projectileFolder = manager.ProjectilesFolder; currentHealth = InitialHealth; }
void Awake() { mPlayer = InGame.Instance.Player (); mShootEffect = transform.Find("turret_explosion_effect").gameObject; mShotsManager = GetComponent<ParticleManager> (); mBase = transform.Find("Turret_anim/Base").gameObject; mBasePos = mBase.transform.localPosition; }
void Awake () { if (playerStatusManager == null) playerStatusManager = GameObject.Find("PlayerStatusManager").GetComponent<PlayerStatusManager>(); if (particleManager == null) particleManager = GameObject.Find("ParticleManager").GetComponent<ParticleManager>(); }
void Awake() { _index = 0; _target = patrolPoints[_index]; _body = GetComponent<Rigidbody>(); _speed = _normalSpeed; _particleManager = GetComponent<ParticleManager>(); }
// Use this for initialization public override void DriverSetup() { _mngSystem = gobSystemManager.GetComponent<ParticleManager>(); sysMySys = gameObject.GetComponent<ParticleSystem>() as ParticleSystem; _mngSystem.RegisterSystem(sysMySys, this); renSystemRenderer = sysMySys.GetComponent<Renderer>() as Renderer; AdditionalSetup(); }
public static ParticleManager getInstance() { if (instance == null) { instance = new ParticleManager(); } return instance; }
void Start () { manager = GameObject.FindGameObjectWithTag("Manager").GetComponent<GameManager>(); SFX = manager.SFX; PM = manager.PM; lane = manager.obtainLane(transform); floordistance = manager.obtainDistanceBetweenLanes(); distanceBetweenLanes = manager.obtainDistanceBetweenLanes(); projectileFolder = manager.ProjectilesFolder; }
public override void Initialize() { spriteBatch = ScreenManager.SpriteBatch; ParticleManager = new ParticleManager<ParticleState>(1024*20, ParticleState.UpdateParticle); EntityManager.Add(Player.Instance); MediaPlayer.IsRepeating = true; MediaPlayer.Play(Sound.Music); }
public override void LoadContent() { texture = ScreenManager.Game.Content.Load<Texture2D>("GameOverScreen"); spriteFont = ScreenManager.Game.Content.Load<SpriteFont>("Kootenay"); particleManager = new ParticleManager(ScreenManager.Game); if (!particleManager.HasTypeAlready(typeof(ExplosionParticleSystem))) particleManager.Register(new ExplosionParticleSystem(ScreenManager.Game, 1)); particleManager.AddParticleSystem(typeof(ExplosionParticleSystem), new Vector2(235, 55)); base.LoadContent(); }
void Awake () { if (playerStatusManager == null) playerStatusManager = GameObject.Find("PlayerStatusManager").GetComponent<PlayerStatusManager>(); if (particleManager == null) particleManager = GameObject.Find("ParticleManager").GetComponent<ParticleManager>(); playerStatusManager.OnGoldChanged += HandleOnGoldChanged; }
// Use this for initialization void Start () { waveManager = GameObject.Find("WaveManager").GetComponent<HeroWaveManager>(); waveGUIManager = GameObject.Find("WaveGUIManager").GetComponent<WaveGUIManager>(); monsterSpawners = GameObject.FindGameObjectsWithTag("MonsterSpawner"); particleManager = GameObject.Find("ParticleManager").GetComponent<ParticleManager>(); pausedSpawners = new List<MonsterSpawner>(8); pauseSprite = GameObject.Find("PauseToggleButton").GetComponent<tk2dSprite>(); }
static void UpdateStatsReplacement(Character[] c, ParticleManager pMan, StatusEffects sType, int i, int pOwner, float finalHitValue, float recharge) { OrigUpdateStats(c, pMan, sType, i, pOwner, finalHitValue, recharge); if (i == 0) { // finalHitValue gets adjusted in numerous places in the original code, and I'm too lazy and don't want to reimplement that code, // so I will assume if you only have 1 HP you would have been dead anyway. It's not your lucky day. // while loop just in case UpdateStats() adjusts the hit to be > 1 (or < 1, which casts to 0) and nullify it. while (c[i].HP == 1) { OrigUpdateStats(c, pMan, sType, i, pOwner, 1f, recharge); } } }
public SubMenuScene(GraphicsDevice graphicsDevice) : base(graphicsDevice) { particleManager = new ParticleManager(10000); AddActor(new Starfield()); AddActor(new Grid()); AddActor(particleManager); particleManager.CreateParticles(); AddPostprocess(new Bloom(new SpriteBatch(graphicsDevice), graphicsDevice)); random = new Random(); }
void Start() { GameObject go; // SETUP PANEL CONTROLS go = GameObject.Find("sliderDepthMin"); depthZMinSlider = go.GetComponent<Slider>(); go = GameObject.Find("sliderDepthMax"); depthZMaxSlider = go.GetComponent<Slider>(); go = GameObject.Find("sliderDepthMinLabel"); depthMinText = go.GetComponent<Text>(); go = GameObject.Find("sliderDepthMaxLabel"); depthMaxText = go.GetComponent<Text>(); go = GameObject.Find("Text"); txtOut = go.GetComponent<Text>(); go = GameObject.Find("EditorPanel"); dragCorners2D = go.GetComponent<DragCorners2D>(); go = GameObject.Find("goParticles"); particleManager = go.GetComponent<ParticleManager>(); go = GameObject.Find("toggleClipToZone"); toggleClipToZone = go.GetComponent<Toggle>(); go = GameObject.Find("toggleNormalizeToZone"); toggleNormalizeToZone = go.GetComponent<Toggle>(); toggleClipToZone.onValueChanged.AddListener(delegate { toggleClipToZoneChanged(); }); toggleNormalizeToZone.onValueChanged.AddListener(delegate { toggleNormalizeToZoneChanged(); }); txtOut.text = "UPDATE GO:"; depthZMinSlider.onValueChanged.AddListener(delegate { slidersMinMaxChanged(); }); depthZMaxSlider.onValueChanged.AddListener(delegate { slidersMinMaxChanged(); }); depthZMinSlider.value = 500; depthZMaxSlider.value = 1800; slidersMinMaxChanged(); }
public MainMenuScene(GraphicsDevice graphicsDevice, AudioManager audioManager) : base(graphicsDevice) { particleEffectDelay = 0; particleManager = new ParticleManager(10000); this.audioManager = audioManager; AddActor(new Starfield()); AddActor(new Grid()); AddActor(particleManager); AddActor(audioManager); particleManager.CreateParticles(); AddPostprocess(new Bloom(new SpriteBatch(graphicsDevice), graphicsDevice)); random = new Random(); }
public GameplayScene(GraphicsDevice graphicsDevice, AudioManager audioManager) : base(graphicsDevice) { EndScene = false; ShipManager = new ShipManager(10); BulletManager = new BulletManager(100); EnemyManager = new EnemyManager(50); MultiplierManager = new MultiplierManager(100); ParticleManager = new ParticleManager(10000); Hud = new HUD(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height); AudioManager = audioManager; postgameTimer = TimeSpan.FromSeconds(3); gameOver = false; AddActor(new Starfield()); AddActor(new Grid()); AddActor(ShipManager); AddActor(BulletManager); AddActor(EnemyManager); AddActor(MultiplierManager); AddActor(ParticleManager); AddActor(Hud); AddActor(audioManager); ShipManager.CreateShips(); BulletManager.CreateBullets(); EnemyManager.CreateEnemies(); MultiplierManager.CreateMultipliers(); ParticleManager.CreateParticles(); AddPostprocess(new Bloom(new SpriteBatch(graphicsDevice), graphicsDevice)); ShipManager.ActivateShip(true); Camera.TargetActor = ShipManager.PlayerShip; Hud.PlayerShip = ShipManager.PlayerShip; AudioManager.TargetListener = ShipManager.PlayerShip; AudioManager.Stop(); }
public static void UpdateParticle(ParticleManager<ParticleState>.Particle particle) { var vel = particle.State.Velocity; particle.Position += vel; particle.Orientation = vel.ToAngle(); float speed = vel.Length(); float alpha = Math.Min(1, Math.Min(particle.PercentLife * 2, speed * 1f)); alpha *= alpha; particle.Color.A = (byte)(255 * alpha); particle.Scale.X = particle.State.LengthMultiplier * Math.Min(Math.Min(1f, 0.2f * speed + 0.1f), alpha); // denormalized floats cause significant performance issues if (Math.Abs(vel.X) + Math.Abs(vel.Y) < 0.00000000001f) vel = Vector2.Zero; vel *= 0.85f; // particles gradually slow down particle.State.Velocity = vel; }
//----------------------//------------------------// public static void UpdateParticle(ParticleManager<ParticleState>.Particle particle, GameTime gameTime) { var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; var vel = particle.State.Velocity; particle.Sprite.Position += vel * elapsed; particle.Sprite.Position += particle.State.Gravity * Vector2.UnitY; float alpha = Math.Max(0, particle.PercentLife * 2 - particle.State.AlphaBase); alpha *= alpha; if (particle.State.Type == ParticleType.Spark) { particle.State.H -= 1.4f; particle.Sprite.Color = ColorUtil.HSVToColor(MathHelper.ToRadians(particle.State.H), 0.5f, 0.91f); particle.Sprite.Rotation = vel.ToAngle(); var x = Math.Min(Math.Min(particle.State.Width, 0.2f * vel.Length() + 0.1f), alpha); particle.Sprite.Scale = new Vector2(x, particle.Sprite.Scale.Y); } else if (particle.State.Type == ParticleType.Confetti) { particle.Sprite.Rotation = vel.ToAngle() + particle.State.Rotation; } else { particle.Sprite.Alpha = alpha; } if (Math.Abs(vel.X) + Math.Abs(vel.Y) < 0.00000000001f) vel = Vector2.Zero; if (particle.State.UseCustomVelocity) vel *= particle.State.VelocityMultiplier; else vel *= 0.97f; particle.State.Rotation += 0.08f; particle.State.Velocity = vel; }
void Awake() { instance = this; }
/// <summary> /// Dispose all managers. /// </summary> protected override void Dispose(bool disposing) { if (fpsCounter != null) { fpsCounter = null; } if (textManager != null) { textManager.Dispose(); textManager = null; } if (fontManager != null) { fontManager.Dispose(); fontManager = null; } inputManager = null; if (collisionContext != null) { collisionContext.ClearAllLayer(); collisionContext = null; } if (particleManager != null) { particleManager.ClearAllParticles(); particleManager = null; } if (soundManager != null) { soundManager.Dispose(); soundManager = null; } if (screenManager != null) { screenManager.Dispose(); screenManager = null; } if (viewer != null) { viewer.Dispose(); viewer = null; } if (resourceManager != null) { resourceManager.Dispose(); resourceManager = null; } if (debugFont != null) debugFont = null; base.Dispose(disposing); }
private IEnumerable <object> Load() { if (GameSettings.VerboseLogging) { DebugConsole.NewMessage("LOADING COROUTINE", Color.Lime); } GUI.GraphicsDevice = base.GraphicsDevice; GUI.Init(Content); GUIComponent.Init(Window); DebugConsole.Init(Window); DebugConsole.Log(SelectedPackage == null ? "No content package selected" : "Content package \"" + SelectedPackage.Name + "\" selected"); yield return(CoroutineStatus.Running); LightManager = new Lights.LightManager(base.GraphicsDevice); Hull.renderer = new WaterRenderer(base.GraphicsDevice, Content); TitleScreen.LoadState = 1.0f; yield return(CoroutineStatus.Running); GUI.LoadContent(); TitleScreen.LoadState = 2.0f; yield return(CoroutineStatus.Running); Mission.Init(); MapEntityPrefab.Init(); LevelGenerationParams.LoadPresets(); TitleScreen.LoadState = 10.0f; yield return(CoroutineStatus.Running); JobPrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Jobs)); // Add any missing jobs from the prefab into Config.JobNamePreferences. foreach (JobPrefab job in JobPrefab.List) { if (!Config.JobNamePreferences.Contains(job.Name)) { Config.JobNamePreferences.Add(job.Name); } } StructurePrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Structure)); TitleScreen.LoadState = 20.0f; yield return(CoroutineStatus.Running); ItemPrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Item)); TitleScreen.LoadState = 30.0f; yield return(CoroutineStatus.Running); Debug.WriteLine("sounds"); CoroutineManager.StartCoroutine(SoundPlayer.Init()); int i = 0; while (!SoundPlayer.Initialized) { i++; TitleScreen.LoadState = SoundPlayer.SoundCount == 0 ? 30.0f : Math.Min(30.0f + 40.0f * i / Math.Max(SoundPlayer.SoundCount, 1), 70.0f); yield return(CoroutineStatus.Running); } TitleScreen.LoadState = 70.0f; yield return(CoroutineStatus.Running); GameModePreset.Init(); Submarine.RefreshSavedSubs(); TitleScreen.LoadState = 80.0f; yield return(CoroutineStatus.Running); GameScreen = new GameScreen(GraphicsDeviceManager.GraphicsDevice, Content); TitleScreen.LoadState = 90.0f; yield return(CoroutineStatus.Running); MainMenuScreen = new MainMenuScreen(this); LobbyScreen = new LobbyScreen(); ServerListScreen = new ServerListScreen(); EditMapScreen = new EditMapScreen(); EditCharacterScreen = new EditCharacterScreen(); yield return(CoroutineStatus.Running); ParticleManager = new ParticleManager("Content/Particles/ParticlePrefabs.xml", GameScreen.Cam); DecalManager = new DecalManager("Content/Particles/DecalPrefabs.xml"); yield return(CoroutineStatus.Running); LocationType.Init(); MainMenuScreen.Select(); TitleScreen.LoadState = 100.0f; hasLoaded = true; if (GameSettings.VerboseLogging) { DebugConsole.NewMessage("LOADING COROUTINE FINISHED", Color.Lime); } yield return(CoroutineStatus.Success); }
protected override void Initialize() { base.Initialize(); EntityManager.Add(PlayerShip.Instance); MediaPlayer.IsRepeating = true; MediaPlayer.Play(Sound.Music); ParticleManager = new ParticleManager<ParticleState>(1024 * 20, ParticleState.UpdateParticle); }
DrawableSpaceStateManager _buildSpaceStateManager(GlobalGameUISingleton globalGameUiSingleton, CameraService cameraService, TextureManager textureManager, ParticleManager particleManager, TextDrawingService textDrawingService, MessageService_ToServer messageService, IClientWebViewConfig clientWebviewConfig, LidgrenNetworkingService networkingService, BloomComponent bloom) { CollisionManager instance_collisionManager; ParticleManager instance_particleManager = null; SimulationManager instance_simulationManager; TargetingService instance_targetingService; TeamManager instance_teamManager; UIConversionService instance_uiConversionService; ClientShipManager instance_clientShipManager; PhysicsManager instance_physicsManager; ProjectileManager instance_projectileManager; StructureFactoryManager instance_structureFactoryManager; WarpHoleManager instance_warpholeManager; SelectionManager instance_selectionManager; FloatyAreaObjectManager instance_floatyAreaObjectManager; //Space unique BackgroundManager instance_backgroundManager = null; SpaceManager instance_spaceManager; BorderManager instance_borderManager = null; GravityManager instance_gravityManager; SpaceObjectManager instance_spaceObjectManager; instance_collisionManager = new CollisionManager(messageService); if (_loadGraphics) { instance_particleManager = new ParticleManager(_graphics, _spriteBatch, Content, textureManager); } instance_simulationManager = new SimulationManager(); instance_targetingService = new TargetingService(); instance_teamManager = new TeamManager(instance_targetingService); PlayerShipManager instance_playerShipManager = new PlayerShipManager(messageService); IClientPlayerInfoManager instance_clientPlayerInfoManager = new PlayablePlayerInfoManager(instance_playerShipManager); instance_uiConversionService = new UIConversionService(cameraService, instance_playerShipManager, _spriteBatch); instance_physicsManager = new PhysicsManager(); instance_projectileManager = new ProjectileManager(instance_particleManager, instance_physicsManager.World, _spriteBatch, instance_targetingService, instance_simulationManager, messageService, instance_collisionManager); instance_clientShipManager = new ClientShipManager(instance_particleManager, instance_playerShipManager, _spriteBatch, textureManager, instance_simulationManager, instance_targetingService, instance_teamManager, instance_projectileManager, messageService, instance_clientPlayerInfoManager, false); instance_structureFactoryManager = new StructureFactoryManager(messageService, instance_physicsManager.World, instance_projectileManager, instance_targetingService, instance_teamManager, textureManager, instance_clientShipManager, _spriteBatch, false); instance_warpholeManager = new WarpHoleManager(messageService, instance_particleManager, instance_physicsManager, instance_clientShipManager, _loadGraphics ? textureManager.Warphole : null); instance_selectionManager = new SelectionManager(textDrawingService, _spriteBatch, instance_clientShipManager, messageService, instance_physicsManager, instance_playerShipManager, instance_targetingService, instance_uiConversionService); if (_loadGraphics) { instance_backgroundManager = new BackgroundManager(Content, instance_particleManager, _spriteBatch, cameraService, new Random(8)); } instance_borderManager = new BorderManager(_loadGraphics?textureManager.tex_DotW:null, _spriteBatch, instance_physicsManager); instance_gravityManager = new GravityManager(instance_physicsManager); instance_spaceObjectManager = new SpaceObjectManager(textureManager, messageService, _spriteBatch, instance_particleManager, instance_physicsManager); instance_spaceManager = new SpaceManager(_spriteBatch, instance_borderManager, instance_gravityManager, instance_physicsManager, instance_spaceObjectManager, instance_warpholeManager); instance_floatyAreaObjectManager = new FloatyAreaObjectManager(instance_physicsManager.World, textureManager, messageService, _spriteBatch, particleManager); return(new DrawableSpaceStateManager( messageService, instance_clientPlayerInfoManager, instance_backgroundManager, bloom, instance_collisionManager, this, Window, globalGameUiSingleton, networkingService, _spriteBatch, instance_particleManager, instance_physicsManager, instance_playerShipManager, instance_projectileManager, instance_selectionManager, instance_simulationManager, instance_clientShipManager, instance_spaceManager, instance_structureFactoryManager, textureManager, instance_targetingService, instance_teamManager, instance_warpholeManager, instance_spaceObjectManager, instance_uiConversionService, instance_floatyAreaObjectManager)); }
DrawablePlanetStateManager _buildPlanetStateManager(GlobalGameUISingleton globalGameUiSingleton, CameraService cameraService, TextureManager textureManager, ParticleManager particleManager, TextDrawingService textDrawingService, MessageService_ToServer messageService, LidgrenNetworkingService networkingService) { CollisionManager instance_collisionManager; ParticleManager instance_particleManager = null; SimulationManager instance_simulationManager; TargetingService instance_targetingService; TeamManager instance_teamManager; UIConversionService instance_uiConversionService; ClientShipManager instance_clientShipManager; PhysicsManager instance_physicsManager; ProjectileManager instance_projectileManager; StructureFactoryManager instance_structureFactoryManager; WarpHoleManager instance_warpholeManager; SelectionManager instance_selectionManager; FloatyAreaObjectManager instance_floatyAreaObjectManager; instance_collisionManager = new CollisionManager(messageService); if (_loadGraphics) { instance_particleManager = new ParticleManager(_graphics, _spriteBatch, Content, textureManager); } instance_simulationManager = new SimulationManager(); instance_targetingService = new TargetingService(); instance_teamManager = new TeamManager(instance_targetingService); PlayerShipManager instance_playerShipManager = new PlayerShipManager(messageService); IClientPlayerInfoManager instance_clientPlayerInfoManager = new PlayablePlayerInfoManager(instance_playerShipManager); instance_uiConversionService = new UIConversionService(cameraService, instance_playerShipManager, _spriteBatch); instance_physicsManager = new PhysicsManager(); instance_projectileManager = new ProjectileManager(instance_particleManager, instance_physicsManager.World, _spriteBatch, instance_targetingService, instance_simulationManager, messageService, instance_collisionManager); instance_clientShipManager = new ClientShipManager(instance_particleManager, instance_playerShipManager, _spriteBatch, textureManager, instance_simulationManager, instance_targetingService, instance_teamManager, instance_projectileManager, messageService, instance_clientPlayerInfoManager, false); instance_structureFactoryManager = new StructureFactoryManager(messageService, instance_physicsManager.World, instance_projectileManager, instance_targetingService, instance_teamManager, textureManager, instance_clientShipManager, _spriteBatch, false); instance_warpholeManager = new WarpHoleManager(messageService, instance_particleManager, instance_physicsManager, instance_clientShipManager, _loadGraphics?textureManager.Warphole:null); instance_selectionManager = new SelectionManager(textDrawingService, _spriteBatch, instance_clientShipManager, messageService, instance_physicsManager, instance_playerShipManager, instance_targetingService, instance_uiConversionService); instance_floatyAreaObjectManager = new FloatyAreaObjectManager(instance_physicsManager.World, textureManager, messageService, _spriteBatch, particleManager); PhysicsConfig physicsConfig = new PhysicsConfig(); return(new DrawablePlanetStateManager( _spriteBatch, instance_clientPlayerInfoManager, instance_collisionManager, globalGameUiSingleton, instance_particleManager, instance_physicsManager, instance_playerShipManager, instance_projectileManager, instance_clientShipManager, instance_structureFactoryManager, textureManager, networkingService, instance_selectionManager, instance_simulationManager, instance_targetingService, instance_teamManager, GameStateType.Planet, instance_uiConversionService, instance_warpholeManager, Window, instance_floatyAreaObjectManager, messageService, physicsConfig.PlanetTileWidth, physicsConfig.PlanetTileHeight)); }
private IEnumerable <object> Load() { if (GameSettings.VerboseLogging) { DebugConsole.NewMessage("LOADING COROUTINE", Color.Lime); } SoundManager = new Sounds.SoundManager(); SoundManager.SetCategoryGainMultiplier("default", Config.SoundVolume); SoundManager.SetCategoryGainMultiplier("ui", Config.SoundVolume); SoundManager.SetCategoryGainMultiplier("waterambience", Config.SoundVolume); SoundManager.SetCategoryGainMultiplier("music", Config.MusicVolume); SoundManager.SetCategoryGainMultiplier("voip", Config.VoiceChatVolume); if (Config.EnableSplashScreen) { (TitleScreen as LoadingScreen).SplashScreen = new Video(base.GraphicsDevice, SoundManager, "Content/splashscreen.mp4", 1280, 720); } GUI.Init(Window, Config.SelectedContentPackages, GraphicsDevice); DebugConsole.Init(); SteamManager.Initialize(); if (Config.AutoUpdateWorkshopItems) { if (SteamManager.AutoUpdateWorkshopItems()) { ContentPackage.LoadAll(ContentPackage.Folder); Config.ReloadContentPackages(); } } if (SelectedPackages.Count == 0) { DebugConsole.Log("No content packages selected"); } else { DebugConsole.Log("Selected content packages: " + string.Join(", ", SelectedPackages.Select(cp => cp.Name))); } #if DEBUG GameSettings.ShowUserStatisticsPrompt = false; GameSettings.SendUserStatistics = false; #endif InitUserStats(); yield return(CoroutineStatus.Running); LightManager = new Lights.LightManager(base.GraphicsDevice, Content); WaterRenderer.Instance = new WaterRenderer(base.GraphicsDevice, Content); TitleScreen.LoadState = 1.0f; yield return(CoroutineStatus.Running); GUI.LoadContent(); TitleScreen.LoadState = 2.0f; yield return(CoroutineStatus.Running); MissionPrefab.Init(); MapEntityPrefab.Init(); Tutorials.Tutorial.Init(); MapGenerationParams.Init(); LevelGenerationParams.LoadPresets(); ScriptedEventSet.LoadPrefabs(); AfflictionPrefab.LoadAll(GetFilesOfType(ContentType.Afflictions)); TitleScreen.LoadState = 10.0f; yield return(CoroutineStatus.Running); StructurePrefab.LoadAll(GetFilesOfType(ContentType.Structure)); TitleScreen.LoadState = 15.0f; yield return(CoroutineStatus.Running); ItemPrefab.LoadAll(GetFilesOfType(ContentType.Item)); TitleScreen.LoadState = 25.0f; yield return(CoroutineStatus.Running); JobPrefab.LoadAll(GetFilesOfType(ContentType.Jobs)); // Add any missing jobs from the prefab into Config.JobNamePreferences. foreach (JobPrefab job in JobPrefab.List) { if (!Config.JobPreferences.Contains(job.Identifier)) { Config.JobPreferences.Add(job.Identifier); } } NPCConversation.LoadAll(GetFilesOfType(ContentType.NPCConversations)); ItemAssemblyPrefab.LoadAll(); TitleScreen.LoadState = 30.0f; yield return(CoroutineStatus.Running); Debug.WriteLine("sounds"); int i = 0; foreach (object crObj in SoundPlayer.Init()) { CoroutineStatus status = (CoroutineStatus)crObj; if (status == CoroutineStatus.Success) { break; } i++; TitleScreen.LoadState = SoundPlayer.SoundCount == 0 ? 30.0f : Math.Min(30.0f + 40.0f * i / Math.Max(SoundPlayer.SoundCount, 1), 70.0f); yield return(CoroutineStatus.Running); } TitleScreen.LoadState = 70.0f; yield return(CoroutineStatus.Running); GameModePreset.Init(); Submarine.RefreshSavedSubs(); TitleScreen.LoadState = 80.0f; yield return(CoroutineStatus.Running); GameScreen = new GameScreen(GraphicsDeviceManager.GraphicsDevice, Content); TitleScreen.LoadState = 90.0f; yield return(CoroutineStatus.Running); MainMenuScreen = new MainMenuScreen(this); LobbyScreen = new LobbyScreen(); ServerListScreen = new ServerListScreen(); if (SteamManager.USE_STEAM) { SteamWorkshopScreen = new SteamWorkshopScreen(); } SubEditorScreen = new SubEditorScreen(); ParticleEditorScreen = new ParticleEditorScreen(); LevelEditorScreen = new LevelEditorScreen(); SpriteEditorScreen = new SpriteEditorScreen(); CharacterEditorScreen = new CharacterEditorScreen(); yield return(CoroutineStatus.Running); TitleScreen.LoadState = 95.0f; ParticleManager = new ParticleManager(GameScreen.Cam); ParticleManager.LoadPrefabs(); TitleScreen.LoadState = 97.0f; LevelObjectPrefab.LoadAll(); DecalManager = new DecalManager(); TitleScreen.LoadState = 99.0f; yield return(CoroutineStatus.Running); LocationType.Init(); MainMenuScreen.Select(); CheckContentPackage(); TitleScreen.LoadState = 100.0f; hasLoaded = true; if (GameSettings.VerboseLogging) { DebugConsole.NewMessage("LOADING COROUTINE FINISHED", Color.Lime); } yield return(CoroutineStatus.Success); }
//------------------------------------------------------------------------- public void create(uint my_et_player_rpcid, bool single, bool is_bot, IRenderListener listener, string configure_filepath, List <JsonPacket> json_packet_list, List <RouteJsonPacket> route_json_packet_list) { mMyPlayerId = my_et_player_rpcid; mbSingle = single; mListener = listener; mbInit = false; mIsBot = is_bot; mConfigurePath = configure_filepath; InputController.Instance.onFingerTouch += _onFingerTouch; InputController.Instance.onFingerLongPress += _onFingerLongPress; InputController.Instance.onFingerUp += _onFingerUp; InputController.Instance.onFingerDragMove += _onFingerDragMove; InputController.Instance.onFingerTouchTurret += _onFingerTouchTurret; InputController.Instance.onFingerTouchBuffer += _onFingerTouchBuffer; InputController.Instance.onFingerTouchFish += _onFingerTouchFish; InputController.Instance.ActiveInput = true; CCoordinate.setCoordinate(new EbVector3(Screen.width, Screen.height, 0), EbVector3.Zero, new EbVector3(Screen.width, Screen.height, 0)); mSceneBox = new CSceneBox(); mProtocol = new CRenderProtocol(this); mTurretHelper = new CTurretHelper(); mLayerAlloter = new RenderLayerAlloter(); mEffectMgr = new CEffectMgr(); if (!isBot()) { mEffectMgr.regEffectFactory(new EffectShockScreenFactory()); mEffectMgr.regEffectFactory(new EffectFrameAnimationFactory()); mEffectMgr.regEffectFactory(new EffectPlayAudioFactory()); mEffectMgr.regEffectFactory(new EffectLightingFactory()); mEffectMgr.regEffectFactory(new EffectLockScreenFactory()); mEffectMgr.regEffectFactory(new EffectFullScreenFactory()); mEffectMgr.regEffectFactory(new EffectAOEFactory()); } else { //mEffectMgr.regEffectFactory(new EffectShockScreenFactory()); mEffectMgr.regEffectFactory(new EffectFrameAnimationFactory()); //mEffectMgr.regEffectFactory(new EffectPlayAudioFactory()); mEffectMgr.regEffectFactory(new EffectLightingFactory()); mEffectMgr.regEffectFactory(new EffectLockScreenFactory()); mEffectMgr.regEffectFactory(new EffectFullScreenFactory()); mEffectMgr.regEffectFactory(new EffectAOEFactory()); } mSpriteFishFactory = new SpriteFishFactory(this); mJsonPacketList = json_packet_list; mRouteJsonPacketList = route_json_packet_list; mRenderConfigure = new RenderConfigure(mConfigurePath); mSoundMgr = MbMain.Instance.getSoundMgr(); mRenderObjectPool = new CRenderObjectPool(this); mParticlemanager = new ParticleManager(this); mLoadableManager = new LoadableManager(); mLoadableManager.create(mRenderObjectPool); }
public void ShowParticle() { ParticleManager manager = gameManager.GetOrCreateManager <ParticleManager>(); manager.Show(particle, transform.position, 2.0f); }
public Poison() { TextureData = ResourceManager.GetTextureData("particles/poison_bubble"); particleManager = new ParticleManager(bubbleParticleTime, TextureData); resetFieldsForUpdate(); }
/// <summary> /// /// </summary> private void SelectCode(byte code) { // select descriptor cbOpCode.SelectedIndex = cbOpCode.Items.IndexOf(ParticleManager.GetParticleDescriptor(code)); }
void Awake() { main = this; }
protected override void Initialize() { StaticClassSerializer.Load(typeof(PlayerData), "data.bin"); // Manage inputs like keyboard or gamepad Components.Add(new InputHandler(this)); // Display FPS at the top left screen's corner Components.Add(new FrameRateCounter(this)); _stateManager = new GameStateManager(this); Components.Add(_stateManager); // Screens TitleScreen = new TitleScreen(this, _stateManager); DebugScreen = new DebugScreen(this, _stateManager); PatternTestScreen = new PatternTestScreen(this, _stateManager); GameConfigurationScreen = new GameConfigurationScreen(this, _stateManager); GameplayScreen = new GameplayScreen(this, _stateManager); LeaderboardScreen = new LeaderboardScreen(this, _stateManager); ImprovementScreen = new ImprovementScreen(this, _stateManager); GameOverScreen = new GameOverScreen(this, _stateManager); OptionsScreen = new OptionsScreen(this, _stateManager); KeyboardInputsScreen = new KeyboardInputsScreen(this, _stateManager); GamepadInputsScreen = new GamepadInputsScreen(this, _stateManager); _stateManager.ChangeState(TitleScreen); ParticleManager = new ParticleManager<ParticleState>(1024 * 20, ParticleState.UpdateParticle); base.Initialize(); }
internal void RenderFrame(double delta) { frameTimer.Reset(); frameTimer.Start(); Graphics.BeginFrame(this); Graphics.BindIb(defaultIb); accumulator += delta; Vertices = 0; if (!Focused && !ScreenLockedInput) { SetNewScreen(new PauseScreen(this)); } CheckScheduledTasks(delta); float t = (float)(ticksAccumulator / ticksPeriod); LocalPlayer.SetInterpPosition(t); Graphics.Clear(); Graphics.SetMatrixMode(MatrixType.Modelview); Matrix4 modelView = Camera.GetView(delta); View = modelView; Graphics.LoadMatrix(ref modelView); Culling.CalcFrustumEquations(ref Projection, ref modelView); bool visible = activeScreen == null || !activeScreen.BlocksWorld; if (Map.IsNotLoaded) { visible = false; } if (visible) { AxisLinesRenderer.Render(delta); Players.RenderModels(Graphics, delta, t); Players.RenderNames(Graphics, delta, t); CurrentCameraPos = Camera.GetCameraPos(LocalPlayer.EyePosition); ParticleManager.Render(delta, t); Camera.GetPickedBlock(SelectedPos); // TODO: only pick when necessary EnvRenderer.Render(delta); if (SelectedPos.Valid && !HideGui) { Picking.Render(delta, SelectedPos); } MapRenderer.Render(delta); SelectionManager.Render(delta); Players.RenderHoveredNames(Graphics, delta, t); bool left = IsMousePressed(MouseButton.Left); bool middle = IsMousePressed(MouseButton.Middle); bool right = IsMousePressed(MouseButton.Right); InputHandler.PickBlocks(true, left, middle, right); if (!HideGui) { BlockHandRenderer.Render(delta, t); } } else { SelectedPos.SetAsInvalid(); } Graphics.Mode2D(Width, Height, EnvRenderer is StandardEnvRenderer); fpsScreen.Render(delta); if (activeScreen == null || !activeScreen.HidesHud && !activeScreen.RenderHudAfter) { hudScreen.Render(delta); } if (activeScreen != null) { activeScreen.Render(delta); } if (activeScreen != null && !activeScreen.HidesHud && activeScreen.RenderHudAfter) { hudScreen.Render(delta); } Graphics.Mode3D(EnvRenderer is StandardEnvRenderer); if (screenshotRequested) { TakeScreenshot(); } Graphics.EndFrame(this); LimitFPS(); }
//非公開関数=============================================================================================================== //Awake==================================================================================================================== void Awake() { sta_obj = this; }
public AttackBase(float size, string textureName, Buff.buff buffType, string seName, float startRange, CharacterManager characterManager, CharacterBase actor, ParticleManager particleManager) { this.characterManager = characterManager; this.textureName = textureName; this.buffType = buffType; this.size = size; this.seName = seName; this.particleManager = particleManager; this.actor = actor; this.startRange = startRange; }
void Awake() { instance = GetComponent <ParticleManager>(); }
// Use this for initialization void Awake() { // keep player along levels mBoltParticleManager = GetComponents<ParticleManager>()[1]; mPickupTextManager = GetComponents<ParticleManager>()[0]; // init compoments mRb = GetComponent<Rigidbody>(); mAntenLensFlare = GetComponentInChildren<LensFlare>(); mAni = transform.Find ("Chubby_Hover").GetComponent<Animator> (); mMovementControls = new MovementControls(this); mDash = transform.Find("Burst_Trail").gameObject; skinnedMeshRenderer = GetComponentsInChildren<SkinnedMeshRenderer>().Where(x => x.name != "Backpack").ToArray(); mDownSwipeSound = AudioManager.Instance.GetSoundsEvent("DownSwipe/DownSwipe", true, 4); mHurtHitSound = AudioManager.Instance.GetSoundsEvent("TakeDamage/TakeDamage", true, 3); mCoinPickUpSound = AudioManager.Instance.GetSoundsEvent("ScewsPling/ScrewsPling", true, 4); mInflateSound = AudioManager.Instance.GetSoundsEvent("Inflate/Inflate", true, 4); mDeflateSound = AudioManager.Instance.GetSoundsEvent("Deflate/Deflate", true, 4); mInflateSound.mVolume = 100; mDeflateSound.mVolume = 100; transform.position = Vector3.zero; }
void OnApplicationQuit() { m_Instance = null; }
private void Start() { particleManager = GameObject.Find("Particle Manager").GetComponent <ParticleManager>(); color = GetComponent <SpriteRenderer>().color; }
protected virtual MainManager _manualBuild() { #region Singletons ClientManager clientManager = new ClientManager(new CoreNetworkConfig()); CameraService cameraService = new CameraService(); ParticleManager particleManager = null; TextDrawingService textDrawingService = null; TextureManager textureManager = null; BloomComponent bloom = null; if (_loadGraphics) { textureManager = new TextureManager(Content); particleManager = new ParticleManager(_graphics, _spriteBatch, Content, textureManager); textDrawingService = new TextDrawingService(textureManager.DefaultDrawFont, _spriteBatch); bloom = new BloomComponent(Content, _spriteBatch); } LidgrenMessenger messenger = new LidgrenMessenger(clientManager); MessageService_ToServer messageService = new MessageService_ToServer(messenger); IClientWebViewConfig clientWebviewConfig = null; switch (_environment) { case ClientEnvironmentType.Development: clientWebviewConfig = new DebugClientWebViewConfig(); break; default: throw new Exception("You should add a production config, yo!"); } var chatManager = new NewChatManager(clientManager); LidgrenNetworkingService networkingService = new LidgrenNetworkingService(); GlobalGameUISingleton globalGameUiSingleton = new GlobalGameUISingleton(clientWebviewConfig, GraphicsDevice, Window, _spriteBatch); GlobalGameWebLayer globalGameWebLayer = new GlobalGameWebLayer(clientWebviewConfig, new GameInterfaceWebView(globalGameUiSingleton, chatManager, new GameInterfaceViewModel())); // Force the static to initialize now Utilities.NextUnique(); #endregion List <IGameState> gameStates = new List <IGameState>(); gameStates.Add(_buildPlanetStateManager(globalGameUiSingleton, cameraService, textureManager, particleManager, textDrawingService, messageService, networkingService)); gameStates.Add(_buildSpaceStateManager(globalGameUiSingleton, cameraService, textureManager, particleManager, textDrawingService, messageService, clientWebviewConfig, networkingService, bloom)); //gameStates.Add(_buildMoonStateManager(chatManager, CefSharpViewFactory, cameraService, textureManager, particleManager, textDrawingService, messageService, clientWebviewConfig, networkingService)); gameStates.Add(_buildPortStateManager(globalGameUiSingleton, messageService, networkingService)); gameStates.Add(_buildLoginStateManager(globalGameUiSingleton, clientManager, messageService, networkingService)); gameStates.Add(_buildColonyStateManager(globalGameUiSingleton, messageService, networkingService)); GameStateManager gameStateManager = BuildGameStateManager(cameraService, gameStates, textDrawingService, globalGameWebLayer); MainNetworkingManager mainNetworkingManager = new MainNetworkingManager(chatManager, clientManager, networkingService); return(new MainManager(bloom, textDrawingService, this, gameStateManager, _graphics, mainNetworkingManager)); }
// Use this for initialization void Start() { instance = this; }
void Awake() { rB2D = GetComponent <Rigidbody2D>(); partMan = GameObject.Find("_Keepers").GetComponent <ParticleManager>(); }
private void Awake() { manager = LevelCommon.FindLevelCommonComponent <ParticleManager>(); }
public static void UpdateParticle(ParticleManager<ParticleState>.Particle particle) { var vel = particle.State.Velocity; float speed = vel.Length; // using Vector2.Add() should be slightly faster than doing "x.Position += vel;" because the Vector2s // are passed by reference and don't need to be copied. Since we may have to update a very large // number of particles, this method is a good candidate for optimizations. Vector2.Add(ref particle.Position, ref vel, out particle.Position); // fade the particle if its PercentLife or speed is low. float alpha = Math.Min(1, Math.Min(particle.PercentLife * 2, speed * 1f)); alpha *= alpha; particle.Tint.A = alpha; // the length of bullet particles will be less dependent on their speed than other particles if (particle.State.Type == ParticleType.Bullet) particle.Scale.X = particle.State.LengthMultiplier * Math.Min(Math.Min(1f, 0.1f * speed + 0.1f), alpha); else particle.Scale.X = particle.State.LengthMultiplier * Math.Min(Math.Min(1f, 0.2f * speed + 0.1f), alpha); particle.Orientation = vel.ToAngle(); var pos = particle.Position; int width = (int)GameRoot.ScreenSize.X; int height = (int)GameRoot.ScreenSize.Y; // collide with the edges of the screen if (pos.X < 0) vel.X = Math.Abs(vel.X); else if (pos.X > width) vel.X = -Math.Abs(vel.X); if (pos.Y < 0) vel.Y = Math.Abs(vel.Y); else if (pos.Y > height) vel.Y = -Math.Abs(vel.Y); if (particle.State.Type != ParticleType.IgnoreGravity) { foreach (var blackHole in EntityManager.BlackHoles) { var dPos = blackHole.Position - pos; float distance = dPos.Length; var n = dPos / distance; vel += 10000 * n / (distance * distance + 10000); // add tangential acceleration for nearby particles if (distance < 400) vel += 45 * new Vector2(n.Y, -n.X) / (distance + 100); } } if (Math.Abs(vel.X) + Math.Abs(vel.Y) < 0.00000000001f) // denormalized floats cause significant performance issues vel = Vector2.Zero; else if (particle.State.Type == ParticleType.Enemy) vel *= 0.94f; else vel *= 0.96f + Math.Abs(pos.X) % 0.04f; // rand.Next() isn't thread-safe, so use the position for pseudo-randomness particle.State.Velocity = vel; }
void Start() { manager = GameObject.FindGameObjectWithTag("Manager").GetComponent<GameManager>(); PM = manager.PM; SFX = manager.SFX; }
/// <summary> /// Core framework constructor. /// </summary> public FrameworkCore() : base() { game = this; graphicsDeviceManager = new GraphicsDeviceManager(this); viewer = new Viewer(this); inputManager = new InputComponentManager(); fontManager = new FontManager(); screenManager = new GameScreenManager(this); textManager = new TextManager(this); resourceManager = new ResourceManager(this, "Content"); particleManager = new ParticleManager(); collisionContext = new CollisionContext(); soundManager = new SoundManager(); gameEventManager = new GameEventManager(); fpsCounter = new FpsCounter(); // Entry GameScreenManager AddComponent(screenManager); // Disable vertical retrace to get highest framerates possible for // testing performance. //graphicsDeviceManager.SynchronizeWithVerticalRetrace = false; // Update as fast as possible, do not use fixed time steps IsFixedTimeStep = false; }
private void Start() { particleManager = GameObject.Find("ParticleManager").GetComponent <ParticleManager>(); }
private void Awake() { particleManager = this; }
private void Awake() { Instance = this; }
/// <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() { Graphics.PreferredBackBufferWidth = Constants.InternalResolutionWidth; Graphics.PreferredBackBufferHeight = Constants.InternalResolutionHeight; Graphics.SynchronizeWithVerticalRetrace = false; IsFixedTimeStep = false; Graphics.ApplyChanges(); //Components.Add(new FrameRateCounter(this, "Content\\Fonts\\fpsfont", 1f)); Components.Add(new GameObjectInfoDisplay(this, 0.5f, "Content\\Fonts\\debugfont", new Vector2(0f, 25f))); var componentFactory = new ComponentFactory(); var gameObjectFactory = new GameObjectFactory(this.Content); gameObjectFactory.PathToXML = "EntityDefinitions\\entity.xml"; var inputHandler = new InputHandler(false); var playerManager = new PlayerManager(); var collisionManager = new CollisionManager(new RectangleF(0f, 0f, Constants.InternalResolutionWidth, Constants.InternalResolutionHeight)); particleManager = new ParticleManager(Content, "ParticleEffects\\", "Textures\\"); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); renderer = new Renderer(Graphics, spriteBatch); renderer.SpriteSortMode = SpriteSortMode.FrontToBack; renderer.SetInternalResolution(Constants.InternalResolutionWidth, Constants.InternalResolutionHeight); renderer.SetScreenResolution(1920, 1080, false); cameraService = new CameraManager(); var camera = new BasicCamera2D(GraphicsDevice, "main"); cameraService.AddCamera(camera); GameServiceManager.AddService(typeof(IGameObjectFactory), gameObjectFactory); GameServiceManager.AddService(typeof(IComponentFactory), componentFactory); GameServiceManager.AddService(typeof(RenderableFactory), new RenderableFactory(Content)); GameServiceManager.AddService(typeof(IInputHandler), inputHandler); GameServiceManager.AddService(typeof(PlayerManager), playerManager); GameServiceManager.AddService(typeof(IGameObjectManager), new GameObjectManager()); GameServiceManager.AddService(typeof(ICollisionManager), collisionManager); GameServiceManager.AddService(typeof(IBehaviorFactory), new BehaviorFactory()); GameServiceManager.AddService(typeof(IActionFactory), new ActionFactory()); GameServiceManager.AddService(typeof(IRandomGenerator), new RandomGenerator()); GameServiceManager.AddService(typeof(IParticleManager), particleManager); GameServiceManager.AddService(typeof(IProjectileManager), new ProjectileManager()); GameServiceManager.AddService(typeof(IActionManager), new ActionManager()); GameServiceManager.AddService(typeof(ILayerManager), new LayerManager("layers.xml", Content)); GameServiceManager.AddService(typeof(IRenderer), renderer); GameServiceManager.AddService(typeof(ICameraService), cameraService); GameServiceManager.AddService(typeof(ILevelLogicManager), new LevelLogicManager()); //Initialize the GameServices);); foreach (var service in GameServiceManager.Services) { service.Initialize(); } base.Initialize(); }
public abstract AttackBase Clone(CharacterBase actor, ParticleManager particleManager);
public JunkParticleSystem(Game game, ParticleManager particleManager, int howManyEffects) : base(game, particleManager, howManyEffects) { }
internal void OnLoad() { Mouse = window.Mouse; Keyboard = window.Keyboard; #if ANDROID Graphics = new OpenGLESApi(); #elif !USE_DX Graphics = new OpenGLApi(); #else Graphics = new Direct3D9Api(this); #endif Graphics.MakeApiInfo(); ErrorHandler.AdditionalInfo = Graphics.ApiInfo; #if ANDROID Drawer2D = new CanvasDrawer2D(Graphics); #else Drawer2D = new GdiPlusDrawer2D(Graphics); #endif Entities = new EntityList(this); AcceptedUrls.Load(); DeniedUrls.Load(); ETags.Load(); LastModified.Load(); if (Options.GetBool(OptionsKey.SurvivalMode, false)) { Mode = new SurvivalGameMode(); } else { Mode = new CreativeGameMode(); } Components.Add(Mode); Input = new InputHandler(this); defaultIb = Graphics.MakeDefaultIb(); ParticleManager = new ParticleManager(); Components.Add(ParticleManager); TabList = new TabList(); Components.Add(TabList); LoadOptions(); LoadGuiOptions(); Chat = new Chat(); Components.Add(Chat); WorldEvents.OnNewMap += OnNewMapCore; WorldEvents.OnNewMapLoaded += OnNewMapLoadedCore; Events.TextureChanged += TextureChangedCore; BlockInfo.Allocate(256); BlockInfo.Init(); ModelCache = new ModelCache(this); ModelCache.InitCache(); Downloader = new AsyncDownloader(Drawer2D); Components.Add(Downloader); Lighting = new BasicLighting(); Components.Add(Lighting); Drawer2D.UseBitmappedChat = ClassicMode || !Options.GetBool(OptionsKey.UseChatFont, false); Drawer2D.BlackTextShadows = Options.GetBool(OptionsKey.BlackText, false); Graphics.Mipmaps = Options.GetBool(OptionsKey.Mipmaps, false); TerrainAtlas1D.game = this; TerrainAtlas2D.game = this; Animations = new Animations(); Components.Add(Animations); Inventory = new Inventory(); Components.Add(Inventory); SurvInv = new SurvivalInventory(); Components.Add(SurvInv); Inventory.Map = new BlockID[BlockInfo.Count]; RecipeList = Recipes.MakeRecipeList(); BlockInfo.SetDefaultPerms(); World = new World(this); LocalPlayer = new LocalPlayer(this); Components.Add(LocalPlayer); Entities.List[EntityList.SelfID] = LocalPlayer; Width = window.Width; Height = window.Height; MapRenderer = new MapRenderer(this); string renType = Options.Get(OptionsKey.RenderType) ?? "normal"; if (!SetRenderType(renType)) { SetRenderType("normal"); } if (IPAddress == null) { Server = new Singleplayer.SinglePlayerServer(this); } else { Server = new Network.NetworkProcessor(this); } Graphics.LostContextFunction = Server.Tick; Cameras.Add(new FirstPersonCamera(this)); Cameras.Add(new ThirdPersonCamera(this, false)); Cameras.Add(new ThirdPersonCamera(this, true)); Camera = Cameras[0]; UpdateProjection(); Gui = new GuiInterface(this); Components.Add(Gui); CommandList = new CommandList(); Components.Add(CommandList); SelectionManager = new SelectionManager(); Components.Add(SelectionManager); WeatherRenderer = new WeatherRenderer(); Components.Add(WeatherRenderer); HeldBlockRenderer = new HeldBlockRenderer(); Components.Add(HeldBlockRenderer); Graphics.DepthTest = true; Graphics.DepthTestFunc(CompareFunc.LessEqual); //Graphics.DepthWrite = true; Graphics.AlphaBlendFunc(BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha); Graphics.AlphaTestFunc(CompareFunc.Greater, 0.5f); Culling = new FrustumCulling(); Picking = new PickedPosRenderer(); Components.Add(Picking); AudioPlayer = new AudioPlayer(); Components.Add(AudioPlayer); AxisLinesRenderer = new AxisLinesRenderer(); Components.Add(AxisLinesRenderer); SkyboxRenderer = new SkyboxRenderer(); Components.Add(SkyboxRenderer); CelestialRenderer = new CelestialRenderer(); Components.Add(CelestialRenderer); PluginLoader.game = this; List <string> nonLoaded = PluginLoader.LoadAll(); for (int i = 0; i < Components.Count; i++) { Components[i].Init(this); } ExtractInitialTexturePack(); for (int i = 0; i < Components.Count; i++) { Components[i].Ready(this); } InitScheduledTasks(); if (nonLoaded != null) { for (int i = 0; i < nonLoaded.Count; i++) { Overlay warning = new PluginOverlay(this, nonLoaded[i]); Gui.ShowOverlay(warning, false); } } window.LoadIcon(); string connectString = "Connecting to " + IPAddress + ":" + Port + ".."; if (Graphics.WarnIfNecessary(Chat)) { MapBordersRenderer.UseLegacyMode(true); EnvRenderer.UseLegacyMode(true); } Gui.SetNewScreen(new LoadingMapScreen(this, connectString, "")); Server.Connect(IPAddress, Port); }
void Start() { TheParticleManager = this; }
internal void OnLoad() { Mouse = window.Mouse; Keyboard = window.Keyboard; #if !USE_DX Graphics = new OpenGLApi(); #else Graphics = new Direct3D9Api(this); #endif Graphics.MakeGraphicsInfo(); Options.Load(); Players = new EntityList(this); AcceptedUrls.Load(); DeniedUrls.Load(); ViewDistance = Options.GetInt(OptionsKey.ViewDist, 16, 4096, 512); UserViewDistance = ViewDistance; CameraClipping = Options.GetBool(OptionsKey.CameraClipping, true); InputHandler = new InputHandler(this); defaultIb = Graphics.MakeDefaultIb(); ParticleManager = new ParticleManager(this); MouseSensitivity = Options.GetInt(OptionsKey.Sensitivity, 1, 100, 30); LoadGui(); UseClassicGui = Options.GetBool(OptionsKey.UseClassicGui, true); UseClassicTabList = Options.GetBool(OptionsKey.UseClassicTabList, false); UseClassicOptions = Options.GetBool(OptionsKey.UseClassicOptions, false); AllowCustomBlocks = Options.GetBool(OptionsKey.AllowCustomBlocks, true); PureClassicMode = Options.GetBool("mode-classic", false); UseCPE = Options.GetBool(OptionsKey.UseCPE, true); AllowServerTextures = Options.GetBool(OptionsKey.AllowServerTextures, true); BlockInfo = new BlockInfo(); BlockInfo.Init(); ChatLines = Options.GetInt(OptionsKey.ChatLines, 1, 30, 12); ClickableChat = Options.GetBool(OptionsKey.ClickableChat, false); ModelCache = new ModelCache(this); ModelCache.InitCache(); AsyncDownloader = new AsyncDownloader(skinServer); Drawer2D = new GdiPlusDrawer2D(Graphics); Drawer2D.UseBitmappedChat = !Options.GetBool(OptionsKey.ArialChatFont, false); ViewBobbing = Options.GetBool(OptionsKey.ViewBobbing, false); ShowBlockInHand = Options.GetBool(OptionsKey.ShowBlockInHand, true); InvertMouse = Options.GetBool(OptionsKey.InvertMouse, false); SimpleArmsAnim = Options.GetBool(OptionsKey.SimpleArmsAnim, false); TerrainAtlas1D = new TerrainAtlas1D(Graphics); TerrainAtlas = new TerrainAtlas2D(Graphics, Drawer2D); Animations = new Animations(this); defTexturePack = Options.Get(OptionsKey.DefaultTexturePack) ?? "default.zip"; TexturePackExtractor extractor = new TexturePackExtractor(); extractor.Extract("default.zip", this); // in case the user's default texture pack doesn't have all required textures if (defTexturePack != "default.zip") { extractor.Extract(DefaultTexturePack, this); } Inventory = new Inventory(this); BlockInfo.SetDefaultBlockPermissions(Inventory.CanPlace, Inventory.CanDelete); Map = new Map(this); LocalPlayer = new LocalPlayer(this); Players[255] = LocalPlayer; width = Width; height = Height; MapRenderer = new MapRenderer(this); MapBordersRenderer = new MapBordersRenderer(this); EnvRenderer = new StandardEnvRenderer(this); if (IPAddress == null) { Network = new Singleplayer.SinglePlayerServer(this); } else { Network = new NetworkProcessor(this); } Graphics.LostContextFunction = Network.Tick; firstPersonCam = new FirstPersonCamera(this); thirdPersonCam = new ThirdPersonCamera(this); forwardThirdPersonCam = new ForwardThirdPersonCamera(this); Camera = firstPersonCam; FieldOfView = Options.GetInt(OptionsKey.FieldOfView, 1, 150, 70); ZoomFieldOfView = FieldOfView; UpdateProjection(); CommandManager = new CommandManager(); CommandManager.Init(this); SelectionManager = new SelectionManager(this); WeatherRenderer = new WeatherRenderer(this); WeatherRenderer.Init(); BlockHandRenderer = new BlockHandRenderer(this); BlockHandRenderer.Init(); FpsLimitMethod method = Options.GetEnum(OptionsKey.FpsLimit, FpsLimitMethod.LimitVSync); SetFpsLimitMethod(method); Graphics.DepthTest = true; Graphics.DepthTestFunc(CompareFunc.LessEqual); //Graphics.DepthWrite = true; Graphics.AlphaBlendFunc(BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha); Graphics.AlphaTestFunc(CompareFunc.Greater, 0.5f); fpsScreen = new FpsScreen(this); fpsScreen.Init(); hudScreen = new HudScreen(this); hudScreen.Init(); Culling = new FrustumCulling(); EnvRenderer.Init(); MapBordersRenderer.Init(); Picking = new PickedPosRenderer(this); AudioPlayer = new AudioPlayer(this); ModifiableLiquids = Options.GetBool(OptionsKey.ModifiableLiquids, false); AxisLinesRenderer = new AxisLinesRenderer(this); LoadIcon(); string connectString = "Connecting to " + IPAddress + ":" + Port + ".."; Graphics.WarnIfNecessary(Chat); SetNewScreen(new LoadingMapScreen(this, connectString, "Waiting for handshake")); Network.Connect(IPAddress, Port); }
/// <summary> /// Constructs a new ParticleSystem. /// </summary> /// <param name="game">The host for this particle system. The game keeps the /// content manager and sprite batch for us.</param> /// <param name="particleManager"></param> /// <param name="howManyEffects">the maximum number of particle effects that /// are expected on screen at once.</param> /// <remarks>it is tempting to set the value of howManyEffects very high. /// However, this value should be set to the minimum possible, because /// it has a large impact on the amount of memory required, and slows down the /// Update and Draw functions.</remarks> protected ParticleSystem(Game game, ParticleManager particleManager, int howManyEffects) : base(game) { this.particleManager = particleManager; this.howManyEffects = howManyEffects; }
public void Update(ParticleManager pMan, Character[] c) { CheckTransitions(c); if (TransOutFrame > 0f) { TransOutFrame -= Game1.FrameTime * 3f; if (TransOutFrame <= 0f) { Path = TransitionDestination[(int)TransDir]; Read(); TransInFrame = 1.1f; for (var i = 1; i < c.Length; i++) { c[i] = null; } pMan.Reset(); } } if (TransInFrame > 0f) { TransInFrame -= Game1.FrameTime * 3f; } if (MapScript.IsReading) { MapScript.DoScript(c); } if (Bucket != null) { if (!Bucket.IsEmpty) { Bucket.Update(c); } } Frame += Game1.FrameTime; if (Fog) { if ((int)(PFrame * 10f) != (int)(Frame * 10f)) { pMan.AddParticle(new Fog(Rand.GetRandomVector2(0f, 1280f, 600f, 1000f))); } } for (var i = 0; i < 64; i++) { if (Segments[LayerMap, i] != null) { if (SegmentDefinitions[Segments[LayerMap, i].Index].Flags == (int)SegmentFlags.Torch) { pMan.AddParticle( new Smoke( Segments[LayerMap, i].Location * 2f + new Vector2(20f, 13f), Rand.GetRandomVector2(-50.0f, 50.0f, -300.0f, -200.0f), 1.0f, 0.8f, 0.6f, 1.0f, Rand.GetRandomFloat(0.25f, 0.5f), Rand.GetRandomInt(0, 4) ), true ); pMan.AddParticle( new Fire( Segments[LayerMap, i].Location * 2f + new Vector2(20f, 37f), Rand.GetRandomVector2(-30.0f, 30.0f, -250.0f, -200.0f), Rand.GetRandomFloat(0.25f, 0.75f), Rand.GetRandomInt(0, 4) ), true ); } } } }
/// <summary> /// Creates all the static particle emitters used in the game. /// </summary> public void CreateParticles() { ParticleManager = new ParticleManager(ComponentManager); // Smoke EmitterData puff = ParticleManager.CreatePuffLike("puff", new SpriteSheet(ContentPaths.Particles.puff), Point.Zero, BlendState.AlphaBlend); ParticleManager.RegisterEffect("puff", puff); // Bubbles EmitterData bubble = ParticleManager.CreatePuffLike("splash2", new SpriteSheet(ContentPaths.Particles.splash2), Point.Zero, BlendState.AlphaBlend); bubble.ConstantAccel = new Vector3(0, 5, 0); bubble.EmissionSpeed = 3; bubble.LinearDamping = 0.9f; bubble.GrowthSpeed = -2.5f; bubble.MinScale = 1.5f; bubble.MaxScale = 2.5f; bubble.ParticleDecay = 1.5f; bubble.HasLighting = false; ParticleManager.RegisterEffect("splash2", bubble); EmitterData splat = ParticleManager.CreatePuffLike("splat", new SpriteSheet(ContentPaths.Particles.splat), Point.Zero, BlendState.AlphaBlend); splat.ConstantAccel = Vector3.Zero; splat.EmissionRadius = 0.01f; splat.EmissionSpeed = 0.0f; splat.GrowthSpeed = -1.75f; splat.MinAngle = -0.0f; splat.MaxAngle = 0.0f; splat.MinAngular = -0.01f; splat.MaxAngular = 0.01f; splat.MaxParticles = 500; splat.MinScale = 0.05f; splat.ParticleDecay = 1.5f; splat.HasLighting = false; splat.MaxScale = 1.1f; splat.EmitsLight = false; ParticleManager.RegisterEffect("splat", splat); EmitterData heart = ParticleManager.CreatePuffLike("heart", new SpriteSheet(ContentPaths.Particles.heart), Point.Zero, BlendState.AlphaBlend); heart.MinAngle = 0.01f; heart.MaxAngle = 0.01f; heart.MinAngular = 0.0f; heart.MinAngular = 0.0f; heart.ConstantAccel = Vector3.Up * 20; ParticleManager.RegisterEffect("heart", heart); // Fire SpriteSheet fireSheet = new SpriteSheet(ContentPaths.Particles.more_flames, 32, 32); EmitterData flame = ParticleManager.CreatePuffLike("flame", fireSheet, Point.Zero, BlendState.AlphaBlend); flame.ConstantAccel = Vector3.Up*20; flame.EmissionSpeed = 2; flame.GrowthSpeed = -1.9f; flame.MinAngle = -0.2f; flame.MaxAngle = 0.2f; flame.MinAngular = -0.01f; flame.MaxAngular = 0.01f; flame.MaxParticles = 500; flame.MinScale = 0.2f; flame.HasLighting = false; flame.MaxScale = 2.0f; flame.EmitsLight = true; flame.Blend = new BlendState() { AlphaSourceBlend = Blend.One, AlphaDestinationBlend = Blend.InverseSourceAlpha, ColorDestinationBlend = Blend.InverseSourceAlpha, ColorSourceBlend = Blend.One }; ParticleManager.RegisterEffect("flame", flame, flame.Clone(fireSheet, new Point(1, 0)), flame.Clone(fireSheet, new Point(2, 0)), flame.Clone(fireSheet, new Point(3, 0))); EmitterData greenFlame = ParticleManager.CreatePuffLike("green_flame", new SpriteSheet(ContentPaths.Particles.green_flame), new Point(0, 0), BlendState.Additive); greenFlame.ConstantAccel = Vector3.Up * 20; greenFlame.EmissionSpeed = 2; greenFlame.GrowthSpeed = -1.9f; greenFlame.MinAngle = -0.2f; greenFlame.MaxAngle = 0.2f; greenFlame.MinAngular = -0.01f; greenFlame.MaxAngular = 0.01f; greenFlame.HasLighting = false; ParticleManager.RegisterEffect("green_flame", greenFlame); List<Point> frm2 = new List<Point> { new Point(0, 0) }; // Leaves EmitterData testData2 = new EmitterData { Animation = new Animation(GraphicsDevice, new SpriteSheet(ContentPaths.Particles.leaf), "leaf", 32, 32, frm2, true, Color.White, 1.0f, 1.0f, 1.0f, false), ConstantAccel = new Vector3(0, -10, 0), LinearDamping = 0.95f, AngularDamping = 0.99f, EmissionFrequency = 1.0f, EmissionRadius = 2.0f, EmissionSpeed = 5.0f, GrowthSpeed = -0.5f, MaxAngle = 3.14159f, MinAngle = 0.0f, MaxParticles = 1000, MaxScale = 0.5f, MinScale = 0.1f, MinAngular = -5.0f, MaxAngular = 5.0f, ParticleDecay = 0.5f, ParticlesPerFrame = 0, Sleeps = true, ReleaseOnce = true, CollidesWorld = true, Texture = TextureManager.GetTexture(ContentPaths.Particles.leaf) }; ParticleManager.RegisterEffect("Leaves", testData2); // Various resource explosions ParticleManager.CreateGenericExplosion(ContentPaths.Particles.dirt_particle, "dirt_particle"); EmitterData stars = ParticleManager.CreatePuffLike( "star_particle", new SpriteSheet(ContentPaths.Particles.star_particle), new Point(0, 0), BlendState.Additive); stars.MinAngle = -0.1f; stars.MaxAngle = 0.1f; stars.MinScale = 0.2f; stars.MaxScale = 0.5f; stars.AngularDamping = 0.99f; stars.LinearDamping = 0.999f; stars.GrowthSpeed = -0.8f; stars.EmissionFrequency = 5; stars.CollidesWorld = false; stars.HasLighting = false; ParticleManager.RegisterEffect("star_particle", stars); ParticleManager.CreateGenericExplosion(ContentPaths.Particles.stone_particle, "stone_particle"); ParticleManager.CreateGenericExplosion(ContentPaths.Particles.sand_particle, "sand_particle"); ParticleManager.CreateGenericExplosion(ContentPaths.Particles.dirt_particle, "dirt_particle"); SpriteSheet bloodSheet = new SpriteSheet(ContentPaths.Particles.gibs, 32, 32); // Blood explosion // ParticleEmitter b = ParticleManager.CreateGenericExplosion(ContentPaths.Particles.blood_particle, "blood_particle").Emitters[0]; EmitterData b = ParticleManager.CreateExplosionLike("blood_particle", bloodSheet, Point.Zero, BlendState.AlphaBlend); b.MinScale = 0.75f; b.MaxScale = 1.0f; b.Damping = 0.1f; b.GrowthSpeed = -0.8f; b.RotatesWithVelocity = true; ParticleManager.RegisterEffect("blood_particle", b); ParticleManager.RegisterEffect("gibs", b.Clone(bloodSheet, new Point(1, 0)), b.Clone(bloodSheet, new Point(2, 0)), b.Clone(bloodSheet, new Point(3, 0))); }
public DrawablePlanetStateManager( SpriteBatch spriteBatch, IClientPlayerInfoManager clientPlayerInfoManager, CollisionManager collisionManager, GlobalGameUISingleton globalGameUiSingleton, ParticleManager particleManager, PhysicsManager physicsManager, PlayerShipManager playerShipManager, ProjectileManager projectileManager, ClientShipManager clientShipManager, StructureFactoryManager structureFactoryManager, TextureManager textureManager, INetworkingService networkingService, SelectionManager selectionManager, SimulationManager simulationManager, TargetingService targetService, TeamManager teamManager, GameStateType stateType,//Should be planet or moon UIConversionService uiConversionService, WarpHoleManager warpholeManager, GameWindow window, FloatyAreaObjectManager floatyAreaObjectManager, MessageService_ToServer messageService, int tileWidth, int tileHeight) : base(null, clientPlayerInfoManager, globalGameUiSingleton, collisionManager, physicsManager, playerShipManager, projectileManager, clientShipManager, structureFactoryManager, warpholeManager, networkingService, selectionManager, simulationManager, targetService, teamManager, stateType, floatyAreaObjectManager, messageService, tileWidth, tileHeight) { _spriteBatch = spriteBatch; _textureManager = textureManager; _particleManager = particleManager; Camera = new Camera2D(window); Camera.Zoom = 1f; //ViewModel = new PlanetViewModel(clientShipManager); _planetGameView = new PlanetGameView( Camera, uiConversionService, particleManager, ViewModel, projectileManager, clientShipManager, spriteBatch, textureManager, floatyAreaObjectManager, globalGameUiSingleton.GameUI, SendStructurePlacementRequest); _spriteBatch = spriteBatch; globalGameUiSingleton.GameUI.RegisterCallbackVoid("SendStructurePlacementRequest", SendStructurePlacementRequest); _viewUpdateList.Add(_planetGameView); _drawList = new HashSet <IDraw>(); _drawList.Add(_planetGameView); _synchronousUpdateList.Add(_particleManager); }