private Point3[] GetOcclusionMapping(Dominant dominant, XDir xDir, YDir yDir, ZDir zDir) { if (dominant == Dominant.X) { return(new[] { new Point3((int)xDir, 0, (int)zDir), new Point3((int)xDir, (int)yDir, 0), new Point3((int)xDir, (int)yDir, (int)zDir), }); } if (dominant == Dominant.Y) { return(new[] { new Point3(0, (int)yDir, (int)zDir), new Point3((int)xDir, (int)yDir, 0), new Point3((int)xDir, (int)yDir, (int)zDir), }); } if (dominant == Dominant.Z) { return(new[] { new Point3(0, (int)yDir, (int)zDir), new Point3((int)xDir, 0, (int)zDir), new Point3((int)xDir, (int)yDir, (int)zDir), }); } throw new NotSupportedException(); }
public void SetBall(int server) { if (server == 1) { xDir = XDir.RIGHT; yDir = YDir.DOWN; transform.position = paddles[0].transform.position - ballPaddleOffset; } else if (server == 2) { xDir = XDir.LEFT; yDir = YDir.UP; transform.position = paddles[1].transform.position + ballPaddleOffset; } }
private void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.CompareTag("Paddle1") || other.gameObject.CompareTag("Paddle2")) { collideSound.Play(); PaddleState paddleState = other.gameObject.GetComponent <PaddleController>().paddleState; if (paddleState == PaddleState.PLAYER) { gradient = Random.Range(3, 6); } else if (paddleState == PaddleState.COMPUTER) { if (GameControl.difficulty == Difficulty.EASY) { gradient = Random.Range(4, 6); } else if (GameControl.difficulty == Difficulty.MEDIUM) { gradient = Random.Range(3, 6); } else if (GameControl.difficulty == Difficulty.HARD) { gradient = Random.Range(2, 6); } } contact = other.contacts[0].point; if (other.gameObject.CompareTag("Paddle1")) { if ((contact.x - paddles[0].transform.position.x) < 0f) { xDir = XDir.LEFT; } else if ((contact.x - paddles[0].transform.position.x) > 0f) { xDir = XDir.RIGHT; } } else if (other.gameObject.CompareTag("Paddle2")) { if ((contact.x - paddles[1].transform.position.x) < 0f) { xDir = XDir.LEFT; } else if ((contact.x - paddles[1].transform.position.x) > 0f) { xDir = XDir.RIGHT; } } if (yDir == YDir.UP) { yDir = YDir.DOWN; } else if (yDir == YDir.DOWN) { yDir = YDir.UP; } } }
public void MoveUp() { y = YDir.Up; }
public void MoveDown() { y = YDir.Down; }
public void ResetMovement() { x = 0; y = 0; }
private int GetOcclusion(Dominant dominant, XDir xDir, YDir yDir, ZDir zDir) { return(CalculateOcclusion(GetOcclusionValues(GetOcclusionMapping(dominant, xDir, yDir, zDir)))); }