Ejemplo n.º 1
0
        public void update()
        {
            var movement = new Vector2(_movementInput.value, 0);

            if (_jumpInput.isPressed && _mState == EntityConstants.MovementStates.REST)
            {
                _velocity.Y = -1 * EntityConstants.JumpVelocity / EntityConstants.PixelPerMeter;
                _mState     = EntityConstants.MovementStates.JUMP;
            }

            var distance = Vector2.Multiply(movement, EntityConstants.PlayerVelocity);

            distance = Vector2.Multiply(distance, Time.deltaTime);

            // movement component
            if (_mState == EntityConstants.MovementStates.JUMP)
            {
                distance.Y = (float)UpdateJump();
            }

            Debug.log(this.transform.localPosition);

            //_mover.move(distance, out result);
            _moveComp.update(distance);
            Animate();
            // movement component

            var ground = this.transform.localPosition;

            Debug.log(ground);

            ground.Y += armor.Height / 2 + 1;
            var hit = Physics.linecast(this.transform.localPosition, ground);

            Debug.log(ground);

            if (hit.collider != null && hit.collider.entity.name.Equals("ground"))
            {
                _velocity.Y = 0;
                _mState     = EntityConstants.MovementStates.REST;
            }
            else
            {
                _mState = EntityConstants.MovementStates.JUMP;
            }

            HandleFireInput();

            Debug.log(_mState);
        }
Ejemplo n.º 2
0
        public void update()
        {
            if (_mover == null)
            {
                return;
            }

            if (entity.localPosition.Y > 1000)
            {
                return;
            }

            _velocity.Y = (float)UpdateJump();
            _mover.update(_velocity);
        }