Ejemplo n.º 1
0
    protected override void Update()
    {
        base.Update();

        if (Input.GetKeyDown(KeyCode.P))
            PauseResumeGame();

        if (!isPaused)
        {
            UpdateTeleport();
            GroundCheck();
            //Keyboard input for left/right movement
            if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
            {
                lateralDirection = LateralDirection.kLeft;
            }
            else if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
            {
                lateralDirection = LateralDirection.kRight;
            }
            else
            {
                lateralDirection = LateralDirection.kNone;
            }

            //Keyboard input for jumping
            if (Input.GetKeyDown(KeyCode.Space))
            {
                isJump = true;
            }

            if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                DoTeleport();
            }

            m_rigidbody.gravityScale = m_rigidbody.velocity.y > 0 ? kRisingGravity : kFallingGravity;
            Debug.DrawRay(transform.position, Vector3.down * .55f, Color.red);
        }
    }
        public static Tuple <Point2D, Point2D> GetMinMaxPointsAtGreatestBoundaryExtent(this Polygon2D boundary,
                                                                                       LateralDirection direction)
        {
            List <Point2D> points = boundary.Vertices.ToList();

            var minPoint = points[0];
            var maxPoint = points[0];

            for (var i = 1; i < points.Count; i++)
            {
                var point = points[i];

                switch (direction)
                {
                case LateralDirection.X:
                    if (point.X < minPoint.X)
                    {
                        minPoint = point;
                    }
                    if (point.X > maxPoint.X)
                    {
                        maxPoint = point;
                    }
                    break;

                case LateralDirection.Y:
                    if (point.Y < minPoint.Y)
                    {
                        minPoint = point;
                    }
                    if (point.Y > maxPoint.Y)
                    {
                        maxPoint = point;
                    }
                    break;

                default:
                    throw new InvalidEnumArgumentException();
                }
            }

            return(new Tuple <Point2D, Point2D>(minPoint, maxPoint));
        }
 public BodyPart(string name, LateralDirection orientation)
     : this()
 {
     Name = name;
     LateralOrientation = orientation;
 }