protected override void PreUpdate() { _background.Transform.Translate2D(new Vector2(-16, -16) * Time.DeltaTime * _defaultZoom); if (InputManager.Instance.MouseKeyHeld(MouseKey.LeftMouse)) { DefaultCamera.Parent.Transform.Translate2D((InputManager.Instance.MouseDelta * new Vector2(0, GraphicsManager.Instance.Height)) / DefaultCamera.Zoom / Config.ConfigValues.PixelSize); _audio.Play(); _audio.Loop(true); } DefaultCamera.Zoom = _defaultZoom + JMath.Clamp(JMath.Sin(Time.TotalSeconds * JMath.TWO_PI * (BPM / 60)), 0, 1) * 0.025f; if (DefaultCamera.Parent.Transform.Position2D.Y > 0) { DefaultCamera.Parent.Transform.Position2D = new Vector2(DefaultCamera.Parent.Transform.Position2D.X, 0); } if (DefaultCamera.Parent.Transform.Position2D.Y < _lowestScroll) { DefaultCamera.Parent.Transform.Position2D = new Vector2(DefaultCamera.Parent.Transform.Position2D.X, _lowestScroll); } _title.Transform.Rotation2D = JMath.Sin(Time.TotalSeconds) * (JMath.PI_OVER_TWO / 16); _start.Transform.Rotation2D = JMath.Sin(Time.TotalSeconds + 1) * (JMath.PI_OVER_TWO / 16); }
public void BallEnter(Ball ball) { if (m_goalTimer.Active) { return; } m_goalSprite.Sprite.SetAnimation("Normal"); m_goalSprite.Visible = true; m_goalSprite.Sprite.Playing = true; m_goalsCount++; if (ball != null) { ball.SetSlowMode(true); } Owner.RigidBodyCmp.Body.CollidesWith = (Category)CollisionType.None; m_ballIn = true; Engine.World.EventManager.ThrowEvent((int)EventId.Goal, m_team); m_AudioCmpGoal.Play(); m_goalTimer.Start(); }
public void Eat(Vegetation pFood) { _movement.Stop(1f); _status.Eat(pFood); pFood.Destroy(); _audio.Play(); }
public void Pass(Player target, Vector2 direction) { Ball ball = m_ball; float impulse = Parameters.ShotImpulse; //Use base shot impulse for pass? //impulse *= ComputeSkillCoef("ChargedShotPower", Parameters.Skills.ChargedShotPowerBase, Parameters.Skills.ChargedShotPowerCoef); DettachBall(impulse * direction); PassAssistEffect passEffect = new PassAssistEffect(target, this); passEffect.Strength = ComputeSkillCoef("PassCurve", Parameters.Skills.PassCurveBase, Parameters.Skills.PassCurveCoef); ball.AddEffect(passEffect); m_audioCmpBallShot.Play(); Engine.World.EventManager.ThrowEvent((int)EventId.PlayerPassAssist, this); }
void PassBallToTeam() { var ball = Game.GameManager.Ball; ball.AddEffect(new PassAssistEffect(m_playerToAim, null)); Vector2 impulseDirection = m_playerToAim.Position - GetWorldTransform().Position; impulseDirection.Normalize(); float launchImpulse = 280; ball.BodyCmp.Body.ApplyLinearImpulse(impulseDirection * launchImpulse); m_audioCmpBallLaunch.Play(); Engine.World.EventManager.ThrowEvent((int)EventId.LauncherShot, this); }
public void Shoot() { if (_playerState.CurrentWeapon != null && _playerState.CurrentWeapon.Shoot()) { _bulletFactory.Create(_playerState.CurrentWeapon.WeaponData.BulletData, _shootingTransform.position, _shootingTransform.rotation); _audioComponent.Play(_playerState.CurrentWeapon.WeaponData.ShootingSound); if (_playerState.CurrentWeapon.AmmoLoaded <= 0) { _playerState.CurrentWeapon.Reload(); } _flashAnimation.Flash(); } }
public void OnBeginPlay() { Actor alarmSound = new Actor("AlarmSound"); AudioComponent alarmAudioComponent = new AudioComponent(alarmSound); SoundWave alarmSoundWave = SoundWave.Load("/Game/Tests/AlarmSound"); Debug.AddOnScreenMessage(-1, 5.0f, Color.PowderBlue, "Sound wave duration: " + alarmSoundWave.Duration + " seconds"); alarmSoundWave.Loop = true; alarmAudioComponent.SetSound(alarmSoundWave); alarmAudioComponent.Play(); Assert.IsTrue(alarmAudioComponent.IsPlaying); }
public static void OnBeginPlay() { Debug.Log(LogLevel.Display, "Hello, Unreal Engine!"); Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!"); Actor alarmSound = new Actor("AlarmSound"); AudioComponent alarmAudioComponent = new AudioComponent(alarmSound); SoundWave alarmSoundWave = SoundWave.Load("/Game/Tests/AlarmSound"); Debug.AddOnScreenMessage(-1, 5.0f, Color.PowderBlue, "Sound wave duration: " + alarmSoundWave.Duration + " seconds"); alarmSoundWave.Loop = true; alarmAudioComponent.SetSound(alarmSoundWave); alarmAudioComponent.Play(); }
public void StartChargingShot() { ShakeComponent playerShake = Owner.FindComponent <ShakeComponent>(); playerShake.StartShake(); Color color = Ball.LastPlayer.Team.ColorScheme.Color1; PlayerChargedShotFx playerChargedShotCmp = new PlayerChargedShotFx(); Owner.Attach(playerChargedShotCmp); playerChargedShotCmp.Color = color; m_chargedShotTimer.Reset(); m_chargedShotTimer.Start(); m_chargingShot = true; m_audioCmpCharge.Play(); }
private void WebsiteClick(UIEvent ev) { WebsiteEnter(null); AudioComponent audio = _website.GetComponent <AudioComponent>(); audio.Play(); audio.SetVolume(0.35f); if (!_finished) { AddDebt(1); Vector2 pos = DefaultCamera.ScreenPointToWorld(InputManager.Instance.MousePosition); BurstDollars(1, pos); _websiteSprite.Texture = ResourceManager.Load <Texture2D>($"Textures/Website{Random.NextRange(0, MAX_WEBSITES)}.png"); } }
void UpdateMatchSoundEvents() { if (m_matchState == MatchState.FirstPeriod || m_matchState == MatchState.SecondPeriod) { if ((m_elapsedTime >= (m_halfTimeDuration - 4000) && m_elapsedTimeMSPrevious < (m_halfTimeDuration - 4000)) || (m_elapsedTime >= (m_halfTimeDuration - 3000) && m_elapsedTimeMSPrevious < (m_halfTimeDuration - 3000)) || (m_elapsedTime >= (m_halfTimeDuration - 2000) && m_elapsedTimeMSPrevious < (m_halfTimeDuration - 2000)) || (m_elapsedTime >= (m_halfTimeDuration - 1000) && m_elapsedTimeMSPrevious < (m_halfTimeDuration - 1000))) { m_audioCmpTimerPeriodLastSeconds.Play(); int remainingTimeS = (int)(m_halfTimeDuration - m_elapsedTimeMSPrevious) / 1000; Engine.World.EventManager.ThrowEvent((int)EventId.LastSeconds, remainingTimeS); } else if (m_elapsedTime >= m_halfTimeDuration && m_elapsedTimeMSPrevious < m_halfTimeDuration) { m_audioCmpTimerPeriodEnd.Play(); } } }
private void PlayComponent(GameObject _parentGameObject) { if (m_hashKeys.Count > 0) { object key = m_hashKeys[UnityEngine.Random.Range(0, m_hashKeys.Count)]; object obj = m_childComponents[key]; if (obj is AudioComponent) { AudioComponent audioComponent = obj as AudioComponent; audioComponent.Play(_parentGameObject); m_timesPlayed++; } if (obj is AudioRandomComponent) { AudioRandomComponent audioRandomComponent = obj as AudioRandomComponent; audioRandomComponent.Play(_parentGameObject); m_timesPlayed++; } } }
public override void Launch() { if (!Enabled) { return; } Game.GameManager.Ball.BodyCmp.Body.Enabled = true; Game.GameManager.Ball.BallSprite.Alpha = 255; Transform parent = new Transform(Owner.Position, Owner.Orientation); Transform world = parent.Compose(m_transform); float launchImpulse = 200; Ball ball = Game.GameManager.Ball; ball.BodyCmp.SetPosition(world.Position + m_ballSpawnOffset.Rotate(world.Orientation)); ball.BodyCmp.Body.ApplyLinearImpulse(m_direction.Rotate(world.Orientation) * launchImpulse); m_audioCmpBallLaunch.Play(); Engine.World.EventManager.ThrowEvent((int)EventId.LauncherShot, this); }
private void SelectNextItem(int direction, bool playSound, MenuController ctrl) { if (direction == 0) { return; } for (int i = 1; i < m_items.Count; i++) { int idx = (m_itemIndex + i * direction + 2 * m_items.Count) % m_items.Count; var item = GetItemByIndex(idx); if (item.Enabled) { SelectItem(idx); if (playSound && m_audioCmpSelect != null) { m_audioCmpSelect.Play(); } var selectedItem = GetItemByIndex(m_itemIndex); m_script.OnItemSelect(selectedItem.Name, ctrl); break; } } }
protected override void InitializeScene() { GraphicsManager.Instance.Context.UseDepth(true); _fps = new Text(GUI.Root); _fps.Dimensions = new Vector2(10000, 16); DefaultCamera.ClearColor = new Color(63, 136, 197, 255); DefaultCamera.Parent.Transform.Position2D = new Vector2(0, -46); ScaleGame(); _background = AddGameObject("Background"); TileMap map = _background.AddComponent <TileMap>(); map.TileSize = 16; map.MapData = ResourceManager.Load <Texture2D>("Textures/backgroundData.png"); map.MapData.Wrap = Texture2D.WrapMode.Repeat; map.Sprites = ResourceManager.Load <Texture2D>("Textures/background.png"); AudioComponent music = _background.AddComponent <AudioComponent>(); music.SetAudioClip(ResourceManager.Load <AudioClip>("Sounds/main.mp3")); music.Play(); _website = AddGameObject("website"); _websiteSprite = _website.AddComponent <Sprite>(); _websiteSprite.Texture = ResourceManager.Load <Texture2D>("Textures/Website0.png"); _websiteSprite.Offset = new Vector2(-_websiteSprite.Texture.Width / 2, -_websiteSprite.Texture.Height / 2); _websiteSprite.Priority = 0.1f; EmptyUIElement websiteHit = new EmptyUIElement(GUI.Root); websiteHit.Dimensions = new Vector2(200, 200) * DefaultCamera.Zoom; websiteHit.Pivot = UIDefaults.Centered; websiteHit.OnMouseUp += WebsiteClick; websiteHit.OnMouseEnter += WebsiteEnter; websiteHit.OnMouseExit += WebsiteExit; AudioComponent webAudio = _website.AddComponent <AudioComponent>(); webAudio.SetAudioClip(ResourceManager.Load <AudioClip>("Sounds/buy.mp3")); UIComponent websiteUI = _website.AddComponent <UIComponent>(); websiteUI.Setup(websiteHit, this); GameObject buyParticles = AddGameObject("Particles"); _websiteParticles = buyParticles.AddComponent <BurstParticleComponent>(); _websiteParticles.Texture = ResourceManager.Load <Texture2D>("Textures/Dollar.png"); _websiteParticles.Gravity = new Vector2(0, 5); _websiteParticles.BurstAmount = 5; _websiteParticles.OnRequestParticle += () => { Particle particle = new Particle(); particle.particleFrames = 1; particle.sourceRectangles = new Rectangle[] { new Rectangle(0, 0, 8, 8) }; particle.velocity = new Vector2(Random.NextRange(-1.0f, 1.0f), Random.NextRange(-0.5f, -1.0f)); particle.color = Color.White; particle.lifeTime = Random.NextRange(0.25f, 1.0f); particle.totalLifeTime = particle.lifeTime; particle.size = new Vector2(1, 1); return(particle); }; _websiteParticles.OnParticleUpdate += (particle) => { particle.size = new Vector2(2, 2) * (particle.lifeTime / particle.totalLifeTime); }; _debtCounter = AddGameObject("Debt counter"); _debtCounter.Transform.Position2D = new Vector2(0, 54); _debtText = _debtCounter.AddComponent <TextComponent>(); _debtText.Font = ResourceManager.Load <Font>("Fonts/8-bit.bff"); _debtText.DisplayText = GetDisplayString(debt); _debtText.Alignment = TextAlignment.Center; _debtTextShadow = _debtCounter.AddComponent <TextComponent>(); _debtTextShadow.Font = ResourceManager.Load <Font>("Fonts/8-bit.bff"); _debtTextShadow.Color = Color.Black; _debtTextShadow.Alignment = TextAlignment.Center; _debtTextShadow.DisplayText = _debtText.DisplayText; _debtTextShadow.Offset = new Vector2(2, -2); _debtPerSecondCounter = AddGameObject("DPS counter"); _debtPerSecondCounter.Transform.Position2D = new Vector2(0, 47); _debtPerSecondText = _debtPerSecondCounter.AddComponent <TextComponent>(); _debtPerSecondText.DisplayText = GetDisplayString(debt); _debtPerSecondText.Alignment = TextAlignment.Center; _debtPerSecondTextShadow = _debtPerSecondCounter.AddComponent <TextComponent>(); _debtPerSecondTextShadow.Offset = new Vector2(1, -1); _debtPerSecondTextShadow.Color = Color.Black; _debtPerSecondTextShadow.DisplayText = _debtPerSecondText.DisplayText; _debtPerSecondTextShadow.Alignment = TextAlignment.Center; _fixedCharges = new GameObject[FixedCharges.Length]; _fixedChargesGenerated = new ulong[FixedCharges.Length]; // Setup fixed charges objects. for (int i = 0; i < FixedCharges.Length; ++i) { FixedCharge fixedCharge = FixedCharges[i]; GameObject charge = AddGameObject($"Fixed charge {i}"); charge.Enabled = false; _fixedCharges[i] = charge; charge.Transform.Position = new Vector3(0, -80 - i * 20, 0.25f); Sprite chargeSprite = charge.AddComponent <Sprite>(); chargeSprite.Texture = ResourceManager.Load <Texture2D>("Textures/Charge.png"); chargeSprite.Offset = new Vector2(-chargeSprite.Texture.Width / 2, -chargeSprite.Texture.Height / 2); chargeSprite.Priority = 0.5f; EmptyUIElement chargeHit = new EmptyUIElement(GUI.Root); chargeHit.Dimensions = new Vector2(chargeSprite.Texture.Width * 2 * DefaultCamera.Zoom, chargeSprite.Texture.Height * DefaultCamera.Zoom); chargeHit.Pivot = UIDefaults.Centered; TextComponent chargeText = charge.AddComponent <TextComponent>(); chargeText.Offset = new Vector2(-60, -9); chargeText.Color = Color.Black; chargeText.DisplayText = $"???? {GetDisplayStringSmall(fixedCharge.price)}"; TextComponent chargeDebtText = charge.AddComponent <TextComponent>(); chargeDebtText.Offset = new Vector2(22, -9); chargeDebtText.Color = Color.Black; chargeDebtText.DisplayText = $"${fixedCharge.debtPerSecond.KiloFormat()}/s"; UIComponent chargeUI = charge.AddComponent <UIComponent>(); chargeUI.Setup(chargeHit, this); AudioComponent audio = charge.AddComponent <AudioComponent>(); audio.SetAudioClip(ResourceManager.Load <AudioClip>("Sounds/ka-ching.mp3")); // Setup UI events. chargeHit.OnMouseEnter += (ev) => { _popup.Transform.Position2D = charge.Transform.Position2D; _popup.Enabled = true; _popupEnabledThisFrame = true; CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) => { chargeSprite.Size = new Vector2(1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f); charge.Transform.Scale = new Vector3(1, 1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f); _popup.GetComponent <Sprite>().Size = new Vector2(1, 1) * (Easings.CircularEaseOut(x)); _popup.Transform.Scale = new Vector3(1, 1, 1) * (Easings.CircularEaseOut(x)); })); }; chargeHit.OnMouseStay += (ev) => { _popup.GetComponent <TextComponent>().DisplayText = $"{fixedCharge.desc}\nHave: {fixedCharge.owned} (${fixedCharge.debtPerSecond * fixedCharge.owned}/s)\nTotal: {GetDisplayStringSmall(_fixedChargesGenerated[fixedCharge.id])}"; }; chargeHit.OnMouseExit += (ev) => { if (!_popupEnabledThisFrame) { _popup.Enabled = false; } CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) => { chargeSprite.Size = new Vector2(1, 1) * (1 + Easings.QuadraticEaseOut(1.0f - x) / 4.0f); charge.Transform.Scale = new Vector3(1, 1, 1) * (1 + Easings.QuadraticEaseOut(1.0f - x) / 4.0f); })); }; chargeHit.OnMouseUp += (ev) => { if (debt >= fixedCharge.price) { debtPerSecond += fixedCharge.debtPerSecond; debt -= fixedCharge.price; _shownDebt = debt; _helpText.Enabled = false; fixedCharge.owned++; fixedCharge.price = (ulong)(fixedCharge.price * JMath.Pow(1.15f, fixedCharge.owned)); chargeText.DisplayText = $"{fixedCharge.name} {GetDisplayStringSmall(fixedCharge.price)}"; audio.Stop(); audio.Play(); audio.SetVolume(0.5f); } CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) => { chargeSprite.Size = new Vector2(1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f); charge.Transform.Scale = new Vector3(1, 1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f); })); }; } _popup = AddGameObject("Popup"); _popup.Enabled = false; Sprite popupSprite = _popup.AddComponent <Sprite>(); popupSprite.Texture = ResourceManager.Load <Texture2D>("Textures/WebsiteBuyFrame.png"); popupSprite.Offset = new Vector2(-popupSprite.Texture.Width / 2, popupSprite.Texture.Height / 64); popupSprite.Priority = 0.000001f; TextComponent popupText = _popup.AddComponent <TextComponent>(); popupText.Alignment = TextAlignment.Left; popupText.Offset = new Vector2(-50, popupSprite.Texture.Height / 1.5f); popupText.DisplayText = "All your base\nare belong to\nus."; popupText.Color = Color.Black; _timer = AddGameObject("Timer"); _timer.Transform.Position2D = new Vector2(0, -68); _timerText = _timer.AddComponent <TextComponent>(); _timerText.Alignment = TextAlignment.Center; _timerText.DisplayText = "2:30 remaining"; EmptyUIElement startelement = new EmptyUIElement(GUI.Root); startelement.Dimensions = new Vector2(80, 20) * _defaultZoom * 2; startelement.Pivot = UIDefaults.Centered; startelement.OnMouseEnter += (ev) => { CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) => { _exit.GetComponent <Sprite>().Size = new Vector2(1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f); })); }; startelement.OnMouseExit += (ev) => { CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) => { _exit.GetComponent <Sprite>().Size = new Vector2(1, 1) * (1 + Easings.QuadraticEaseOut(1.0f - x) / 4.0f); })); }; startelement.OnMouseUp += (x) => { SceneManager.SwitchToScene(new MainMenu(ResourceManager)); }; _exit = AddGameObject("Exit"); _exit.Transform.Position2D = new Vector2(0, 108); _exit.AddComponent <UIComponent>().Setup(startelement, this); Sprite exitSprite = _exit.AddComponent <Sprite>(); exitSprite.Texture = ResourceManager.Load <Texture2D>("Textures/buttons.png"); exitSprite.SourceRectangle = new Rectangle(0, 20, 128, 20); exitSprite.Offset = new Vector2(-35, -9); _helpText = AddGameObject("help").AddComponent <TextComponent>(); _helpText.DisplayText = "Exchange debt to gain\n debt automatically!"; _helpText.Alignment = TextAlignment.Center; _helpText.Parent.Transform.Position2D = new Vector2(0, -110); _helpText.Enabled = false; _exit.Enabled = false; }
public void PlayAudio(string str, bool force = false) { audio.Play(str, force); }
protected override void InitializeScene() { ScaleGame(); Text text = new Text(GUI.Root); text.Pivot = UIDefaults.TopCenter; text.Anchor = UIDefaults.TopCenter; text.ShadowOffset = new Point(1, -1); text.DisplayText = "Created by Mathijs Koning and Thom Zeilstra for Ludum Dare 48"; text.ResizeToText(16); _background = AddGameObject("Background"); TileMap map = _background.AddComponent <TileMap>(); map.TileSize = 16; map.MapData = ResourceManager.Load <Texture2D>("Textures/backgroundData.png"); map.MapData.Wrap = Texture2D.WrapMode.Repeat; map.Sprites = ResourceManager.Load <Texture2D>("Textures/background.png"); _audio = _background.AddComponent <AudioComponent>(); _audio.SetAudioClip(ResourceManager.Load <AudioClip>("Sounds/menu.mp3")); _audio.Play(); _audio.Loop(true); _title = AddGameObject("Title"); _title.Transform.Position2D = new Vector2(0, 64); Sprite titleSprite = _title.AddComponent <Sprite>(); titleSprite.Texture = ResourceManager.Load <Texture2D>("Textures/Title.png"); titleSprite.Offset = new Vector2(-titleSprite.Texture.Width / 2, -titleSprite.Texture.Height / 2); titleSprite.Size = new Vector2(2, 2); _leaderboardText = AddGameObject().AddComponent <TextComponent>(); _leaderboardText.Alignment = TextAlignment.Center; _leaderboardText.DisplayText = "Loading leaderboard..."; _leaderboardText.Color = Color.Black; _leaderboardText.Parent.Transform.Position2D = new Vector2(0, -48); _nameText = AddGameObject().AddComponent <TextComponent>(); _nameText.Alignment = TextAlignment.Center; _nameText.DisplayText = "Logging in..."; _nameText.Color = Color.Black; UIElement ui = new EmptyUIElement(GUI.Root); ui.Dimensions = new Vector2(128, 16) * _defaultZoom * 2; ui.Pivot = UIDefaults.BottomCenter; ui.OnMouseUp += (ev) => { AskUsername("Leaderboard user name:"); }; ui.OnMouseEnter += (ev) => { _nameText.Color = Color.White; }; ui.OnMouseExit += (ev) => { _nameText.Color = Color.Black; }; UIComponent uiComp = _nameText.Parent.AddComponent <UIComponent>(); uiComp.Setup(ui, this); _nameText.Parent.Transform.Position2D = new Vector2(0, 16); EmptyUIElement startelement = new EmptyUIElement(GUI.Root); startelement.Dimensions = new Vector2(80, 20) * _defaultZoom * 2; startelement.Pivot = UIDefaults.Centered; startelement.OnMouseEnter += (ev) => { CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) => { _start.GetComponent <Sprite>().Size = new Vector2(1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f); })); }; startelement.OnMouseExit += (ev) => { CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) => { _start.GetComponent <Sprite>().Size = new Vector2(1, 1) * (1 + Easings.QuadraticEaseOut(1.0f - x) / 4.0f); })); }; startelement.OnMouseUp += (x) => { if (PlayfabManager.Identity.Username == null) { AskUsername("Leaderboard user name:"); } else { SceneManager.SwitchToScene(new MainScene(ResourceManager)); } }; _start = AddGameObject("Start"); _start.Transform.Position2D = new Vector2(0, 0); _start.AddComponent <UIComponent>().Setup(startelement, this); Sprite startSprite = _start.AddComponent <Sprite>(); startSprite.Texture = ResourceManager.Load <Texture2D>("Textures/buttons.png"); startSprite.SourceRectangle = new Rectangle(0, 0, 128, 20); startSprite.Offset = new Vector2(-35, -9); Login(); }
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); }