Exemple #1
0
    public float GetYOffset(bool side, Vector3 pos)
    {
        PaddleControl paddle   = GetPaddle(side);
        Vector3       offset   = paddle.transform.InverseTransformPoint(pos);
        float         y_offset = offset.y;

        y_offset = Mathf.Clamp(y_offset / m_paddle_length, -1f, 1f);       // account for non-1 paddle size, clamp for weird angles

        return(y_offset);
    }
Exemple #2
0
		public Paddle(Vector2 position, Vector2 velocity, bool player) {
			this.iPosition = this.cPosition = position;
			this.velocity = velocity;
			this.speed = (float)Math.Abs(velocity.Y);
			this.paddleSize = new Vector2(10, 50);
			this.boundry = new Rectangle((int)cPosition.X, (int)cPosition.Y, (int)paddleSize.X, (int)paddleSize.Y);
			this.time = "";
			this.cTime = new TimeSpan(0, 0, 0);
			if (player == true)
				control = PaddleControl.Player;
			else
				control = PaddleControl.Computer;
		}
Exemple #3
0
 public Paddle(Vector2 position, Vector2 velocity, bool player)
 {
     this.iPosition  = this.cPosition = position;
     this.velocity   = velocity;
     this.speed      = (float)Math.Abs(velocity.Y);
     this.paddleSize = new Vector2(10, 50);
     this.boundry    = new Rectangle((int)cPosition.X, (int)cPosition.Y, (int)paddleSize.X, (int)paddleSize.Y);
     this.time       = "";
     this.cTime      = new TimeSpan(0, 0, 0);
     if (player == true)
     {
         control = PaddleControl.Player;
     }
     else
     {
         control = PaddleControl.Computer;
     }
 }
Exemple #4
0
 void Awake()
 {
     paddleControl = gameObject.GetComponent <PaddleControl> ();
 }
Exemple #5
0
 public PaddleController(PaddleControl left_paddle, PaddleControl right_paddle)
 {
     m_left_paddle  = left_paddle;
     m_right_paddle = right_paddle;
     Reset();
 }