예제 #1
0
    public void inputMovementManagement()
    {
        if (Input.GetKey("z"))
        {
            yButtonState = yDirection.Up;
        }
        else if (Input.GetKey("s"))
        {
            yButtonState = yDirection.Down;
        }
        else
        {
            yButtonState = yDirection.None;
        }

        if (Input.GetKey("q"))
        {
            xButtonState = xDirection.Left;
        }
        else if (Input.GetKey("d"))
        {
            xButtonState = xDirection.Right;
        }
        else
        {
            xButtonState = xDirection.None;
        }
    }
예제 #2
0
        //private MyReplay replayer;


        private void Start()

        {
            myBall = GetComponent <Rigidbody>();

            // Set the maximum angular velocity.
            myBall.maxAngularVelocity = topSpeed;
            //myBall. = topSpeed;
            xAnaloguePosition = CrossPlatformInputManager.GetAxis("Horizontal");
            myXdirection      = xDirection.NONE;
        }//end Start
예제 #3
0
        private void ChangeDirection(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Right: xDir = xDirection.Right; yDir = yDirection.None; break;

            case Keys.Left:  xDir = xDirection.Left;  yDir = yDirection.None; break;

            case Keys.Up:    xDir = xDirection.None;  yDir = yDirection.Up;   break;

            case Keys.Down:  xDir = xDirection.None;  yDir = yDirection.Down; break;
            }
        }
예제 #4
0
        public bool Update(xDirection xd, yDirection yd)
        {
            for (int n = Tail.Count - 1; n >= 1; n--)
            {
                Tail[n] = new Point(Tail[n - 1].X, Tail[n - 1].Y);
            }

            if (Tail.Count >= 1)
            {
                Tail[0] = new Point(Head.X, Head.Y);
            }
            Head = new Point(Head.X + (int)xd, Head.Y + (int)yd);

            int x = Head.X;

            Lerp(ref x, 0, Form1.ColCount - 1);

            int y = Head.Y;

            Lerp(ref y, 0, Form1.RowCount - 1);

            Head = new Point(x, y);

            foreach (Point p in Tail)
            {
                if (p.Equals(Head))
                {
                    return(false);
                }
            }

            if (Head.Equals(Fruit))
            {
                EatFruit();
                SortFruit();
            }

            return(true);
        }
예제 #5
0
        public void Move(Vector3 moveDirection, bool jump)
        {
            myBall.maxAngularVelocity = topSpeed;

            //are we on the ground?
            if (Grounded())
            {
                //if we are on the ground allow a jump request from BallUserControl
                ballJump = jump;
            }
            else
            {
                //we are in the air so ignore the request and let Ball deal with jump mechanic
                ballJump = false;
            }

            xAnaloguePosition = CrossPlatformInputManager.GetAxis("Horizontal");                //top speed is set by the position of the stick unless its max then use topSpeed
            currentVelocity   = myBall.velocity.z;
            //Debug.Log ("Ang Vel " + myBall.angularVelocity);
            //Debug.Log (" Vel " + myBall.velocity);
            if (xAnaloguePosition < 0)
            {
                myXdirection = xDirection.LEFT;
            }
            else if (xAnaloguePosition > 0)
            {
                myXdirection = xDirection.RIGHT;
            }
            else
            {
                myXdirection = xDirection.NONE;
            }            //end if on Direction

            //can we accelerate?

            if (CanWeAccelerate())
            {
                // If using torque to rotate the ball...
                if (ballTorqueOn)
                {
                    // ... add torque around the axis defined by the move direction.
                    myBall.AddTorque(new Vector3(moveDirection.z, 0, -moveDirection.x) * moveForce);
                }
                else
                {
                    // Otherwise add force in the move direction.
                    myBall.AddForce(moveDirection * moveForce);
                }         //end if on ball torque bool
            }             //end if on myXdirection


            if (ballJump)
            {
                //jump
                myBall.AddForce(Vector3.up * jumpPower, ForceMode.Impulse);

//				if (myBall.velocity.y < 0) { //if we have reached the apex or ar falling...
//					myBall.velocity += Vector3.up * Physics.gravity.y * (fallMulitplier - 1) * (Time.fixedDeltaTime); // the minus one means then that the multiplier is a 2x / 2.5 x as we already have 1 gravirty
//				}
//
////				else if (myBall.velocity.y > 0 && !CrossPlatformInputManager.GetButton ("Jump")) {
////					myBall.velocity += Vector3.up * Physics.gravity.y * (shortJumpingMultiplier - 1) * (Time.deltaTime);
////				}

                if (myBall.velocity.y < 0)
                {
                }
            }     //end if jump
        }         //end Move Method