public void ShootBallChargedAfterDelay() { Ball ball = m_ball; if (ball == null) { return; } var direction = new Vector2((float)Math.Cos(m_ballAngle), (float)Math.Sin(m_ballAngle)); float impulse = Parameters.ChargedShot.ShotImpulse; impulse *= ComputeSkillCoef("ChargedShotPower", Parameters.Skills.ChargedShotPowerBase, Parameters.Skills.ChargedShotPowerCoef); DettachBall(impulse * direction); BashEffect bashEffect = new BashEffect(); bashEffect.SetDuration(Parameters.ChargedShot.BallBashTimeMS); ball.AddEffect(bashEffect); TargetEffect targetEffect = new TargetEffect(this); targetEffect.SetDuration(Parameters.ChargedShot.BallBashTimeMS); targetEffect.Strength = ComputeSkillCoef("ChargedShotCurve", Parameters.Skills.ChargedShotCurveBase, Parameters.Skills.ChargedShotCurveCoef); ball.AddEffect(targetEffect); ScreenShake.Add(3, direction, 150); m_audioCmpBallShot.Play(); Engine.World.EventManager.ThrowEvent((int)EventId.PlayerShootBallCharged, this); }
public override void Start() { if (!Player.Properties.Stunned) { BeginStun(); } //Audio Player.AudioCmpStun.Play(); //Set properties Player.Properties.ControlDisabled.Set(); Player.Properties.MagnetDisabled.Set(); Player.Properties.Stunned.Set(); ScreenShake.Add(2.0f, Vector2.Zero, 60); }
private bool CollideWithPlayer(Player otherPlayer) { if (Properties.Tackling) { ScreenShake.Add(1.0f); } if (otherPlayer.Properties.Tackling && !Properties.Tackling) { Stun(otherPlayer.Parameters.Tackle.StunTimeMS, otherPlayer.Parameters.Tackle.StunSpeedMod, otherPlayer.Parameters.Tackle.Power); if (m_properties.Bashed) { return(true); } Vector2 otherPlayerToPlayerDir = Position - otherPlayer.Position; Vector2 otherPlayerDir = otherPlayer.m_bodyCmp.Body.LinearVelocity; if (otherPlayerDir.LengthSquared() < 0.01f) { return(true); } Vector2 otherPlayerDirNormalized = otherPlayerDir; otherPlayerDirNormalized.Normalize(); float side = LBE.MathHelper.CrossProductSign(otherPlayerDirNormalized, otherPlayerToPlayerDir); float angleMin = 0.3f * (float)Math.PI; float angleMax = 0.5f * (float)Math.PI; float angleRandom = Engine.Random.NextFloat(angleMin, angleMax); float finalAngle = angleRandom * side; Vector2 bashDir = otherPlayerDirNormalized.Rotate(finalAngle); Bash(bashDir); return(false); } return(true); }
public override void Update() { if (Game.GameManager.Paused) { return; } UpdateEffects(); // Check if the player can Grab the ball if (!Properties.MagnetDisabled && m_ballTrigger.Active && m_ball == null) { Ball ball = m_ballTrigger.ActiveObjects[0].Owner.FindComponent <Ball>(); if (ball != null && ball.Player == null && !ball.Properties.Untakable) { ball.AttachToPlayer(this); AttachBall(ball); } } if (m_ball == null && m_magnetSensor.Active) { ApplyMagnet(); } // Update ball control for mouse if (Parameters.ControllerType == InputType.MouseKeyboard) { CustomInput2D cInput = (CustomInput2D)m_input.BallCtrl.Inputs.Find(delegate(IInput2D i) { return(i.GetType() == typeof(CustomInput2D)); }); if (cInput != null) { Vector2 MousePos = new Vector2(Engine.Input.MouseState().X, Engine.Input.MouseState().Y); MousePos = Engine.Renderer.Cameras[(int)CameraId.Game].ScreenToWorld(MousePos); Vector2 MousePlayerAxe = MousePos - Owner.Position; MousePlayerAxe.Normalize(); cInput.Set(MousePlayerAxe); cInput.Update(); } } // Update object rotation Owner.Orientation = m_ballAngle; // Debug ball axis Vector2 ballAxis = new Vector2((float)Math.Cos(Owner.Orientation), (float)Math.Sin(Owner.Orientation)); if (m_input != null && m_input.BallCtrl.Get() != Vector2.Zero) { ballAxis = m_input.BallCtrl.Get(); } ballAxis.Normalize(); Engine.Debug.Screen.AddLine(Owner.Position, Owner.Position + ballAxis * Parameters.Radius * 1.5f * 3); // Debug player direction Axis Engine.Debug.Screen.Brush.LineColor = Color.Blue; Engine.Debug.Screen.AddLine(Owner.Position, Owner.Position + m_moveDirection * Parameters.Radius * 2); if (Engine.Debug.Flags.ColorEdit == true) { DebugColorEdit(); } float shakeScale = 0.2f; if (m_chargingShot && m_chargedShotTimer.Active) { float completion = m_chargedShotTimer.TimeMS / m_chargedShotTimer.TargetTime; ScreenShake.Add(shakeScale * LBE.MathHelper.Clamp(0, 1, completion)); } else if (m_chargingShot && m_chargedShotTimer.Active == false) { ScreenShake.Add(shakeScale); } if (m_chargedShotDelayTimer.Active) { float time = 1 - m_chargedShotDelayTimer.Completion; //time = (float)Math.Pow(time, 0.2f); float slowCoef = 0.1f; Engine.TimeCoef = LBE.MathHelper.Lerp(slowCoef, 1, time); Engine.Log.Write("Time: " + time); Engine.Log.Write("Slow: " + Engine.TimeCoef); } if (m_properties.Shooting && m_ball == null) { m_properties.Shooting.Unset(); Engine.TimeCoef = 1.0f; } if (m_properties.Shooting && !m_chargedShotDelayTimer.Active) { Engine.TimeCoef = 1.0f; m_properties.Shooting.Unset(); ShootBallChargedAfterDelay(); } }
public ScreenShake() { m_instance = this; }