public override void Start() { Sprite sprite = Sprite.Create("Graphics/ChargedShotFx.lua::Sprite"); m_spriteCmp = new SpriteComponent(sprite, "ArenaOverlay5"); Owner.Attach(m_spriteCmp); m_color = Color.White; m_spriteCmp.Sprite.Alpha = 0.0f; m_fxTimer = new Timer(Engine.GameTime.Source, 1500f); m_fxTimer.Start(); var player = Owner.FindComponent <Player>(); var emitterDef = Engine.AssetManager.Get <ParticleEmitterDefinition>("Graphics/Particles/ChargingPlayer.lua::Emitter"); emitterDef.Color = player.PlayerColors[2]; m_particleCmp = new ParticleComponent(); m_particleCmp.Emitter = new ParticleEmitter(emitterDef); Owner.Attach(m_particleCmp); var emitterDefHL = Engine.AssetManager.Get <ParticleEmitterDefinition>("Graphics/Particles/ChargingPlayer.lua::EmitterHL"); emitterDefHL.Color = player.PlayerColors[2]; m_particleCmpHL = new ParticleComponent(); m_particleCmpHL.Emitter = new ParticleEmitter(emitterDefHL); m_particleCmpHL.LockRotation = true; Owner.Attach(m_particleCmpHL); }
private void StartFX() { var headEmitterDefAsset = Engine.AssetManager.GetAsset <ParticleEmitterDefinition>("Graphics/Particles/ChargedShot.lua::Ball"); var headEmitterDef = headEmitterDefAsset.Content; headEmitterDef.Color = Ball.LastPlayer.PlayerColors[2]; m_particleCmpHead = new ParticleComponent(); m_particleCmpHead.Emitter = new ParticleEmitter(headEmitterDef); Ball.Owner.Attach(m_particleCmpHead); var trailEmitterDefAsset = Engine.AssetManager.GetAsset <ParticleEmitterDefinition>("Graphics/Particles/ChargedShot.lua::Trail"); var trailEmitterDef = trailEmitterDefAsset.Content; trailEmitterDef.Color = Ball.LastPlayer.PlayerColors[2]; m_particleCmpTrail = new ParticleComponent(); m_particleCmpTrail.Emitter = new ParticleEmitter(trailEmitterDef); Ball.Owner.Attach(m_particleCmpTrail); var trailHlEmitterDefAsset = Engine.AssetManager.GetAsset <ParticleEmitterDefinition>("Graphics/Particles/ChargedShot.lua::TrailHighlight"); var trailHlEmitterDef = trailHlEmitterDefAsset.Content; trailHlEmitterDef.Color = Ball.LastPlayer.PlayerColors[2]; m_particleCmpTrailHighlight = new ParticleComponent(); m_particleCmpTrailHighlight.Emitter = new ParticleEmitter(trailHlEmitterDef); Ball.Owner.Attach(m_particleCmpTrailHighlight); }
/// <summary> /// Remove a particle-system to not be drawn anymore /// </summary> /// <param name="particleType">Particle-type on which the emitter is added</param> /// <param name="emitter">Component of the emitter</param> public static void RemoveInstance(ParticleType3D particleType, ParticleComponent emitter) { if (ParticleSystems3D.ContainsKey(particleType)) { ParticleSystems3D[particleType].RemoveInstance(emitter); } }
void NetworkSpawn(int spawnTileX, int spawnTileY) { movementComponent.ResetAll(); ParticleComponent.StopAll(); soundComponent.StopSound(CharacterSoundComponent.CharacterSound.Charge); transform.position = new Vector3(spawnTileX, 1, spawnTileY); OnCharacterSpawned?.Invoke(new Vector2DInt(spawnTileX, spawnTileY)); }
public override void Start() { m_params = new Asset <PassAssistParamters>(new PassAssistParamters()); Parameters.Angle = Engine.Debug.EditSingle("PassAssistAngle", 0.4f); Parameters.Strength = Engine.Debug.EditSingle("PassAssistStrength", 20); Parameters.Radius = Engine.Debug.EditSingle("PassAssistRadius", 80); Parameters.AngleSpeed = Engine.Debug.EditSingle("PassAssistAngleSpeed", 0.002f); Parameters.Speed = Engine.Debug.EditSingle("PassAssistSpeed", 10); Parameters.Acceleration = Engine.Debug.EditSingle("PassAssistAcceleration", 100); Parameters.MaxRotation = Engine.Debug.EditSingle("PassAssistMaxRotation", 3.2f); m_startPosition = Ball.Position; m_startTimeMs = Engine.GameTime.TimeMS; m_previousBallSpeedDir = Ball.BodyCmp.Body.LinearVelocity; Color effectColor; if (m_ballOwner != null) { effectColor = m_ballOwner.PlayerColors[2]; } else { effectColor = m_target.Team.ColorScheme.Color1; } var headEmitterDefAsset = Engine.AssetManager.GetAsset <ParticleEmitterDefinition>("Graphics/Particles/PassShot.lua::Ball"); var headEmitterDef = headEmitterDefAsset.Content; headEmitterDef.Color = effectColor; m_particleCmpHead = new ParticleComponent(); m_particleCmpHead.Emitter = new ParticleEmitter(headEmitterDef); Ball.Owner.Attach(m_particleCmpHead); var trailEmitterDefAsset = Engine.AssetManager.GetAsset <ParticleEmitterDefinition>("Graphics/Particles/PassShot.lua::Trail"); var trailEmitterDef = trailEmitterDefAsset.Content; trailEmitterDef.Color = effectColor; m_particleCmpTrail = new ParticleComponent(); m_particleCmpTrail.Emitter = new ParticleEmitter(trailEmitterDef); Ball.Owner.Attach(m_particleCmpTrail); var trailHlEmitterDefAsset = Engine.AssetManager.GetAsset <ParticleEmitterDefinition>("Graphics/Particles/PassShot.lua::TrailHighlight"); var trailHlEmitterDef = trailHlEmitterDefAsset.Content; trailHlEmitterDef.Color = effectColor; m_particleCmpTrailHighlight = new ParticleComponent(); m_particleCmpTrailHighlight.Emitter = new ParticleEmitter(trailHlEmitterDef); Ball.Owner.Attach(m_particleCmpTrailHighlight); Ball.BallSprite.Alpha = 0.5f; }
public override void Initialize() { World.Translation = new Vector3(pos, 0); phy = new ParticleComponent(ID + "Physics", Vector2.Zero, mass); AttachComponent(phy); base.Initialize(); }
/// <summary> /// Add a particle-system to render /// </summary> /// <param name="particleType">Particle-type on which the emitter is added</param> /// <param name="emitter">Component of the emitter</param> public static void AddInstance(ParticleType3D particleType, ParticleComponent emitter) { if (ParticleSystems3D.ContainsKey(particleType)) { ParticleSystems3D[particleType].Add(emitter); } else { Debug.LogError("ParticleType3D " + particleType.GetDescription() + " not properly initialized"); } }
// --------------------- BASE METHODS ------------------ public override void Awake() { _particleComponents = new ParticleComponent[_effects.Count]; foreach (Type type in _effects) { ParticleComponent pc = (ParticleComponent)Activator.CreateInstance(type); pc.Awake(); pc.gameObject = gameObject; PlayerParticleType ppt = (PlayerParticleType)Enum.Parse(typeof(PlayerParticleType), type.Name); _particleComponents[(int)ppt] = pc; } }
private void UpdateParticleColor(ParticleComponent particle, TimeSpan elapsedTime) { var graphicsComponent = particle.GameObject.GetComponent <ShapeGraphicsComponent>(); if (graphicsComponent is null) { return; } var ticksDifference = Math.Clamp(particle.TimeToLive.Ticks - elapsedTime.Ticks, 0f, particle.TimeToLive.Ticks); var startColorPercentage = ticksDifference / particle.TimeToLive.Ticks; var endColorPercentage = 1f - startColorPercentage; var nextColor = particle.StartColor.Lerp(particle.EndColor, endColorPercentage); graphicsComponent.Color = nextColor; }
public void Do() { if (m_player.Properties.Blink) { return; } m_player.Properties.Blink.Set(); m_player.Properties.MagnetDisabled.Set(); m_player.Properties.ControlDisabled.Set(); m_player.Properties.Invincible.Set(); m_blinkTimer.Start(); m_state = BlinkState.BlinkOut; m_tpPosition = m_player.Position; var partColor = Color.Lerp(m_player.PlayerColors[2], Color.White, 0.7f); var emitterDefAsset = Engine.AssetManager.GetAsset <ParticleEmitterDefinition>("Graphics/Particles/Teleport.lua::Emitter"); emitterDefAsset.Content.Color = partColor; m_particleInCmp = new ParticleComponent(); m_particleInCmp.Emitter = new ParticleEmitter(emitterDefAsset); m_particleInObject.Attach(m_particleInCmp); m_particleOutCmp = new ParticleComponent(); m_particleOutCmp.Emitter = new ParticleEmitter(emitterDefAsset); m_particleOutObject.Attach(m_particleOutCmp); if (Game.Arena.LeftGoal.Team == m_player.Team) { m_targetPosition = Game.Arena.LeftGoal.Position + Vector2.UnitX * 80; } else { m_targetPosition = Game.Arena.RightGoal.Position - Vector2.UnitX * 80; } m_holeInCmp.Position = m_player.Position; m_holeOutCmp.Position = m_targetPosition; m_holeInCmp.Visible = true; m_holeInCmp.Scale = 0; m_holeOutCmp.Visible = true; m_holeOutCmp.Scale = 0; }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; //graphics.IsFullScreen = true; graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720; graphics.ApplyChanges(); // IsMouseVisible = true; FrameRateCounter FrameRateCounter = new FrameRateCounter(this, "Fonts\\Default"); particleComponent = new ParticleComponent(this); this.Components.Add(FrameRateCounter); this.Components.Add(particleComponent); }
void NetworkInitialize(string viewname, int playerID, string nickname, int skinID) { this.playerID = playerID; playerNickname = nickname; model = CharacterDatabase.instance.standardModel; viewData = CharacterDatabase.instance.GetViewFromName(viewname); // Setup the correct view, probably in a view component view = Instantiate(viewData.prefab); view.transform.SetParent(transform, false); SetSkin(skinID); // gat components movementComponent = GetComponent <CharacterMovementComponent>(); flagComponent = GetComponent <CharacterFlagComponent>(); stateComponent = GetComponent <CharacterStateComponent>(); soundComponent = GetComponent <CharacterSoundComponent>(); ParticleComponent = GetComponent <CharacterParticlesComponent>(); deathComponent = GetComponent <CharacterDeathComponent>(); // initialize components movementComponent.ManualAwake(); flagComponent.ManualAwake(); stateComponent.ManualAwake(); soundComponent.ManualAwake(viewData, view.transform); ParticleComponent.ManualAwake(viewData, view.transform); if (photonView.isMine) { Match.instance.photonView.RPC("RegisterPlayer", PhotonTargets.AllViaServer, this.playerID, playerNickname); } #if DEBUG_TOOLS if (photonView.isMine) { FindObjectOfType <PlayerPage>().Initialize(this); } #endif }
public void EnableParticle(ushort id) { if (UseWorld) { var parts = ((ObjectComponent)WorldUI).Particles; var relevant = parts.FirstOrDefault(x => x.Resource?.ChunkID == id && float.IsPositiveInfinity(x.StopTime)); if (relevant == null) { var part = new ParticleComponent(WorldUI.blueprint, WorldUI.blueprint.ObjectParticles); //for now there is only one particle resource. In future get from iff. part.Resource = PART.BROKEN; part.Mode = ParticleType.GENERIC_BOX; GameThread.InUpdate(() => { part.Tex = Content.Content.Get().RCMeshes.GetTex("FSO_smoke.png"); WorldUI.blueprint.ObjectParticles.Add(part); }); ((ObjectComponent)WorldUI).Particles.Add(part); part.Owner = WorldUI; WorldUI.blueprint.Damage.Add(new BlueprintDamage(BlueprintDamageType.OBJECT_GRAPHIC_CHANGE, WorldUI.TileX, WorldUI.TileY, WorldUI.Level, WorldUI)); } } }
/// <summary> /// Add a new emitter to the particle-system. /// </summary> /// <param name="emitter">New emitter-component which adds particles to the system.</param> public void Add(ParticleComponent emitter) { _emitters.Add(emitter, Time.CurrentTime); }
public void SetCmps(Entity entity) { Particle = entity.GetComponent <ParticleComponent>(); Drag = entity.GetComponent <DragComponent>(); }
bool m_bodyCmp_OnCollision(FarseerPhysics.Dynamics.Contacts.Contact contact, RigidBodyComponent self, RigidBodyComponent other) { if (m_player != null && other.Owner == m_player.Owner) { return(false); } var player = other.Owner.FindComponent <Player>(); if (player != null) { if (m_properties.PassThroughPlayer && player.Properties.Tackling && !player.Properties.Shield) { Vector2 shieldDir = player.BodyCmp.Body.LinearVelocity; Vector2 ballDir = m_bodyCmp.Body.LinearVelocity; if (shieldDir.LengthSquared() > 0.001f && ballDir.LengthSquared() > 0.001f && Vector2.Dot(shieldDir, ballDir) < 0) { player.Properties.Shield.Set(); Engine.Log.Write("Shield up!!!"); PlayerShieldUpEffect shieldUpEffect = new PlayerShieldUpEffect(); shieldUpEffect.SetDuration(3000); player.AddEffect(shieldUpEffect); var emitterDef = Engine.AssetManager.Get <ParticleEmitterDefinition>("Graphics/Particles/Shield.lua::Emitter", false); var shieldParticleCmp = new ParticleComponent(); shieldParticleCmp.Emitter = new ParticleEmitter(emitterDef); shieldParticleCmp.Emitter.Definition.Color = player.PlayerColors[2]; shieldParticleCmp.DestroyOnEnd = true; var shieldParticleOject = new GameObject("ShieldParticleOject"); shieldParticleOject.Position = player.Position; shieldParticleOject.Orientation = player.Owner.Orientation; shieldParticleOject.Attach(shieldParticleCmp); shieldParticleOject.Attach(new DebugObjectComponent( obj => obj.Position = player.Position, 2000.0f)); } } foreach (var effect in m_effects.ToArray()) { effect.OnPlayerTouchBall(player); } if (m_properties.PassThroughPlayer && !player.Properties.Shield) { return(false); } } else if (!contact.FixtureB.IsSensor) { foreach (var effect in m_effects.ToArray()) { effect.OnWallCollision(contact.FixtureB); } } if (contact.FixtureA.CollisionCategories.HasFlag((Category)CollisionType.Wall) || contact.FixtureB.CollisionCategories.HasFlag((Category)CollisionType.Wall)) { m_audioCmpBallBounce.Play(); } else if (contact.FixtureA.CollisionCategories.HasFlag((Category)CollisionType.Player) || contact.FixtureB.CollisionCategories.HasFlag((Category)CollisionType.Player)) { m_audioCmpBallPlayerSnap.Play(); } return(true); }
public void SetCmps(Entity entity) { transform = entity.GetComponent <TransformComponent>(); particle = entity.GetComponent <ParticleComponent>(); }
public void Update() { var now = DateTime.UtcNow; var i = Math.Min(((now.Minute * 60) + (now.Second)) / 150f, 1f); //DECEMBER TEMP: snow replace //TODO: tie to tuning, or serverside weather system. //right now this is based on an rng advanced relative to the current UTC hour, with a fixed seed. //should also eventually introduce rain var ocolor = TintColor ?? Bp.OutsideColor.ToVector4(); var color = SRGBToLinear(LinearToSRGB(ocolor) - new Vector4(0.35f) * 1.5f + new Vector4(0.35f)); color.W = 1; var wint = WeatherIntensity; FogColor = (color * new Color(0x80, 0xC0, 0xFF, 0xFF).ToVector4()) * (1 - wint * 0.75f) + LinearToSRGB(ocolor) * (wint * 0.75f); FogColor.W = (wint) * (15 * 75f) + (1 - wint) * (300f * 75f); var enabled = WorldConfig.Current.Weather; if (LastI == i && LastHour == now.Hour && (Current?.Time ?? 0) < 100 && enabled == LastEnabled) { return; } var curInt = GetWeatherIntensity(now); var lastInt = GetWeatherIntensity(now - new TimeSpan(1, 0, 0)); LastI = i; LastHour = now.Hour; LastEnabled = enabled; WeatherIntensity = ModeToIntensity[curInt] * i + ModeToIntensity[lastInt] * (1 - i); Darken = ModeToDarken[curInt] * i + ModeToDarken[lastInt] * (1 - i); OutsideWeatherTint = Color.Lerp(Color.White, new Color(159, 164, 181), Darken); if (Bp != null) { Bp.OutsideWeatherTint = new Color(159, 164, 181); Bp.OutsideWeatherTintP = Darken; } if (WeatherIntensity > 0.01f && enabled) { bool isFaded = false; //is the new weather different enough? does the old one need to be refreshed? if (Current != null && (Current.Time > 100 || Math.Abs(Current.WeatherIntensity - WeatherIntensity) > 0.04f)) { Current.FadeProgress = 0; isFaded = true; Current = null; } if (Current == null) { Current = new ParticleComponent(Bp, Particles); Current.Mode = (ParticleType)(curInt / 3); Current.FadeProgress = isFaded ? (float?)-1 : null; Current.WeatherIntensity = WeatherIntensity; Particles.Add(Current); } } else { if (Current != null) { Current.FadeProgress = 0; Current = null; } } }
/// <summary> /// Remove an emitter from the particle-system. /// </summary> /// <param name="emitter">Emitter-component to remove.</param> public void RemoveInstance(ParticleComponent emitter) { _emitters.Remove(emitter); }