public GameManager(Ball ball, RectCollider rectCollider, Player one, Player two) { eventManager = new EventManager(ball, rectCollider, one, two); this.playerOne = one; this.playerTwo = two; }
public void Hit_ReflectOffNormal(Player player, InputData inputData, InputSettings inputSettings) { Vector2 normal = new Vector2(inputData.xValue, inputData.yValue); if (Vector2.Dot(normal, Velocity) < 0) { // Indicates the ball is going towards normal surface Velocity = Vector2.Reflect(Velocity, normal); //lastPlayerToHit = player; } }
public RectCollider( Texture2D texture, Rectangle rect, Color tint, Player owner) { this.texture = texture; this.destRect = rect; this.tint = tint; this.owner = owner; //this.location = location; this.velocity = Vector2.Zero; this.Acceleration = Vector2.Zero; }
public EventManager( Ball ball, RectCollider rectCollider, Player player1, Player player2) { this.collisionManager = new TennisForTwo.Managers.CollisionManager(); this.player1 = player1; this.player2 = player2; player1.mainDown += MainClick_Down; player1.secondaryDown += SecondaryClick_Down; player2.mainDown += MainClick_Down; player2.secondaryDown += SecondaryClick_Down; }
public void Hit(Player player, InputData inputData, InputSettings inputSettings) { if (lastPlayerToHit == player) { return; } else if (inputSettings.timeSinceLastInput >= inputSettings.InputDelay) { lastPlayerToHit = player; inputSettings.ResetDelay(); switch (inputSettings.ballHitMethod) { case InputSettings.BallHitMethod.SetVelocity: Hit_SetVelocity(player, inputData, inputSettings); break; case InputSettings.BallHitMethod.ReflectOffNormal: Hit_ReflectOffNormal(player, inputData, inputSettings); break; } } }
/// <summary> /// Updates the list of button changes and button states /// </summary> /// <param name="newInput"></param> public void Update(InputData newInput, Player player) { // Change the members to that of newInput this.previousData = new InputData(this); mainButtonDown = newInput.mainButtonDown; secondaryButtonDown = newInput.secondaryButtonDown; leftButtonDown = newInput.leftButtonDown; rightButtonDown = newInput.rightButtonDown; xValue = newInput.xValue; yValue = newInput.yValue; if (!previousData.mainButtonDown && mainButtonDown) player.OnMainDown(); if (!previousData.secondaryButtonDown && secondaryButtonDown) player.OnSecondaryDown(); if (!previousData.leftButtonDown && leftButtonDown) player.OnLeftDown(); if (!previousData.rightButtonDown && rightButtonDown) player.OnRightDown(); }
public void Hit_SetVelocity(Player player, InputData inputData, InputSettings inputSettings) { Vector2 newVelocity = new Vector2(inputData.xValue, inputData.yValue); Velocity = newVelocity * inputSettings.ballVelocity; lastPlayerToHit = player; }