Ejemplo n.º 1
0
//        public override PlayerState HandleInput()
//        {
//			if (pc.stateEnded && ((Input.GetButton("Attack1") && pc.canAttack1()) || (Input.GetButton("Attack2")  && pc.canAttack2())))
//			{
//				if (Input.GetButton("Attack1") && pc.canAttack1())
//				{
//					return new Attack1(pc);
//				}
//				if (Input.GetButton("Attack2") && pc.canAttack2())
//				{
//					return new Attack2(pc);
//				}
//			}
//			if (pc.stateEnded && (Input.GetButton("Vertical") || Input.GetButton("Horizontal")))
//			{
//				if (Input.GetButton("Dash") && pc.canDash())
//				{
//					Vector3 dir = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
//					return new Dash(pc, dir);
//				}
//				return new Running(pc);
//			}
//			return new PlayerMovement.Idle(pc);
//        }

        public override void Update()
        {
            this.moveX = Input.GetAxisRaw("Horizontal");
            this.moveZ = Input.GetAxisRaw("Vertical");

            if (pc.movementInput == Vector3.zero ||
                (pc.canShield() && Input.GetAxisRaw("Shield") != 0) ||
                (pc.canDash() && Input.GetAxisRaw("Dash") != 0) ||
                (pc.canAttack1() && Input.GetAxisRaw("Attack1") != 0) ||
                (pc.canAttack2() && Input.GetAxisRaw("Attack2") != 0))
            {
                pc.stateEnded = true;
//				Debug.Log ("Shield " + Input.GetAxisRaw("Shield"));
//				Debug.Log ("Dash " + Input.GetAxisRaw("Dash"));
//				Debug.Log ("Attack1 " + Input.GetAxisRaw("Attack1"));
//				Debug.Log ("Attack2 " + Input.GetAxisRaw("Attack2"));
                pc.nextState = HandleInput();
//				Debug.Log (pc.nextState);
                if (pc.nextState != null)
                {
                    pc.stateEnded = false;
                }
            }
            else
            {
                Direction newDirection = DirectionUtil.FloatToDir(moveZ, moveX);
                pc.movingDirection = DirectionUtil.FloatToDir(moveZ, moveX);
            }
        }
Ejemplo n.º 2
0
//        public override PlayerState HandleInput()
//        {
//			if (pc.stateEnded && ((Input.GetButton("Attack1") && pc.canAttack1()) || (Input.GetButton("Attack2")  && pc.canAttack2())))
//            {
//				if (Input.GetButton("Attack1") && pc.canAttack1())
//                {
//                    return new Attack1(pc);
//                }
//				if (Input.GetButton("Attack2") && pc.canAttack2())
//                {
//                    return new Attack2(pc);
//                }
//            }
//            if (pc.stateEnded && (Input.GetButton("Vertical") || Input.GetButton("Horizontal")))
//            {
//		          if (Input.GetButton("Dash") && pc.canDash())
//                {
//					Vector3 dir = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
//					return new Dash(pc, dir);
//                }
//                return new Running(pc);
//            }
//            return null;
//        }

        public override void Update()
        {
            if (pc.movementInput != Vector3.zero)
            {
                // Change the direction we're facingDirection
                pc.facingDirection = DirectionUtil.FloatToDir(pc.movementInput.z, pc.movementInput.x);
                // End State
                pc.stateEnded = true;
                return;
            }

            if (Input.anyKey)
            {
                pc.stateEnded = true;
                return;
            }
        }