bool doAction() { bool right = Input.GetKey("right"); bool left = Input.GetKey("left"); bool jump = Input.GetKey(KeyCode.Space); //bool shoot = Input.GetKey(); bool doAction = false; if (jump) { currentTotemState = CurrentTotemState.JUMP; //checkear si esta en el aire no hacer jump doAction = true; } else if (right || left) { doAction = checkTravel(right); } /*else if (shoot) * { * currentPlayerState = PlayerState.ATTACK; * doAction = true; * }*/ return(doAction); }
// Update is called once per frame public bool Update() { if (doAction()) { //Realizar el movimiento con su animacion y cambio de posicion o el ataque //Llamar a la funcion de MovimientoController //Despues de realizar el movimiento o ataque, se debe actualizar initialPosition y el estado del personaje a iddle if (currentTotemState == CurrentTotemState.ATTACK) { //movementController.SendMessage("Attack", GetCurrentTotem()); //Falta el gameobject que permite atacar currentTotemTravel = 0; changeTurn = true; } else { // movementController.Move(GetCurrentTotem()); if (currentTotemState == CurrentTotemState.RIGHT || currentTotemState == CurrentTotemState.LEFT) { currentTotemTravel += Math.Abs(GetCurrentTotem().transform.position.x - lastX); } } currentTotemState = CurrentTotemState.IDDLE; } return(changeTurn); }
void Start() { Debug.Log("PlayerController :: Start called"); currentTotemState = CurrentTotemState.IDDLE; currentTotemTravel = 0; maxTravel = 20f; changeTurn = false; CreateTotems(); }
bool checkTravel(bool right) { if (currentTotemTravel < maxTravel) { lastX = GetCurrentTotem().transform.position.x; //Console("Recorrido:" + recorrido); //print("Right:" + right); currentTotemState = right ? CurrentTotemState.RIGHT : CurrentTotemState.LEFT; return(true); } changeTurn = true; //Una vez se haya creado el ataque esta linea sobrará, ya que se cambiara de turno una vez ataque currentTotemTravel = 0; //Esta igual que la de arriba, (recorrido = limiteRecorrido) return(false); }