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); }
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; }
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; } }
void Awake() { paddleControl = gameObject.GetComponent <PaddleControl> (); }
public PaddleController(PaddleControl left_paddle, PaddleControl right_paddle) { m_left_paddle = left_paddle; m_right_paddle = right_paddle; Reset(); }