// Use this for initialization void Start() { curStam = maxStam = 5.0f; puppet = gameObject.GetComponent<PuppetScript>(); lastAttack = ATTACKS.NONE; if (guard) stance = guard.GetComponent<MyStance>(); }
void HandleInput() { float lHorizontal, lVertical, rHorizontal, rVertical; lHorizontal = InputChecker.GetAxis(InputChecker.PLAYER_NUMBER.ONE, InputChecker.JOYSTICK.LEFT, InputChecker.AXIS.X); lVertical = InputChecker.GetAxis(InputChecker.PLAYER_NUMBER.ONE, InputChecker.JOYSTICK.LEFT, InputChecker.AXIS.Y); rHorizontal = InputChecker.GetAxis(InputChecker.PLAYER_NUMBER.ONE, InputChecker.JOYSTICK.RIGHT, InputChecker.AXIS.X); rVertical = InputChecker.GetAxis(InputChecker.PLAYER_NUMBER.ONE, InputChecker.JOYSTICK.RIGHT, InputChecker.AXIS.Y); Vector3 dir = new Vector3(lHorizontal, 0.0f, -lVertical); puppet.Move(dir); if(InputChecker.GetButton(InputChecker.PLAYER_NUMBER.ONE, InputChecker.CONTROLLER_BUTTON.LEFTSTICK_CLICK, InputChecker.BUTTON_STATE.DOWN) && !puppet.rockedOn) { puppet.ResetCamera(); } if (InputChecker.GetTrigger(InputChecker.PLAYER_NUMBER.ONE, InputChecker.TRIGGER.RIGHT) > 0.0f) { SetLastNone(); if (guard) guard.SetActive(true); if (InputChecker.GetButton(InputChecker.PLAYER_NUMBER.ONE, InputChecker.CONTROLLER_BUTTON.X, InputChecker.BUTTON_STATE.HELD)) { puppet.GuardLeft(); if (stance) { stance.SetLeftRed(); stance.ClearRight(); stance.ClearTop(); } } else if (InputChecker.GetButton(InputChecker.PLAYER_NUMBER.ONE, InputChecker.CONTROLLER_BUTTON.B, InputChecker.BUTTON_STATE.HELD)) { puppet.GuardRight(); if (stance) { stance.SetRightRed(); stance.ClearLeft(); stance.ClearTop(); } } else if (InputChecker.GetButton(InputChecker.PLAYER_NUMBER.ONE, InputChecker.CONTROLLER_BUTTON.Y, InputChecker.BUTTON_STATE.HELD)) { puppet.GuardUpwards(); if (stance) { stance.SetTopRed(); stance.ClearLeft(); stance.ClearRight(); } } else { if (stance) stance.Clear(); } } //else //{ //} else { if (guard) guard.SetActive(false); //if (bufferTime <= 0.0f) //{ if (InputChecker.GetButton(InputChecker.PLAYER_NUMBER.ONE, InputChecker.CONTROLLER_BUTTON.BUMPER_R, InputChecker.BUTTON_STATE.DOWN)) { //puppet.rockedOn = !puppet.rockedOn; puppet.ToggleLockon(); } if (InputChecker.GetButton(InputChecker.PLAYER_NUMBER.ONE, InputChecker.CONTROLLER_BUTTON.BACK, InputChecker.BUTTON_STATE.DOWN)) { if (Application.loadedLevelName != "Hub_Scene") Application.LoadLevel("Hub_Scene"); else Application.LoadLevel("Menu_Scene"); } if (InputChecker.GetButton(InputChecker.PLAYER_NUMBER.ONE, InputChecker.CONTROLLER_BUTTON.X, InputChecker.BUTTON_STATE.DOWN)) { if (bufferTime >= 0.0f /*&& curStam >= 1.0f*/) { //if (!animation.isPlaying) //{ //curStam -= 1.0f; //if (curStam < 0.0f) // curStam = 0.0f; //} //int x = 5; //for debug switch (lastAttack) { case ATTACKS.NONE: puppet.SlashRTL(); break; case ATTACKS.VERT: puppet.SlashRTL(); break; case ATTACKS.LTR: puppet.SlashVert(); break; case ATTACKS.RTL: puppet.SlashLTR(); break; default: break; } } bufferTime = maxTime; } else if (InputChecker.GetButton(InputChecker.PLAYER_NUMBER.ONE, InputChecker.CONTROLLER_BUTTON.Y, InputChecker.BUTTON_STATE.DOWN)) { //puppet thrust } else if (InputChecker.GetButton(InputChecker.PLAYER_NUMBER.ONE, InputChecker.CONTROLLER_BUTTON.B, InputChecker.BUTTON_STATE.DOWN)) { //puppet kick } else if (InputChecker.GetButton(InputChecker.PLAYER_NUMBER.ONE, InputChecker.CONTROLLER_BUTTON.A, InputChecker.BUTTON_STATE.DOWN)) { //puppet dodge //if (curStam >= 2.0f) //{ // curStam -= 2.0f; // if (curStam < 0.0f) // curStam = 0.0f; if (lHorizontal > deadZone) puppet.DodgeRight(); else if (lHorizontal < -deadZone) puppet.DodgeLeft(); else if (lVertical < -deadZone) puppet.DodgeForward(); else puppet.DodgeBackwards(); //} } //} else { bufferTime -= Time.deltaTime; if (bufferTime <= 0.0f) { bufferTime = 0.0f; lastAttack = ATTACKS.NONE; } } } Vector3 camDir = new Vector3(rHorizontal, -rVertical, 0.0f); puppet.MoveCamera(camDir); }
void SetLastNone() { lastAttack = ATTACKS.NONE; }
void SetLastVert() { lastAttack = ATTACKS.VERT; }
void SetLastRTL() { lastAttack = ATTACKS.RTL; }
// Sam: ugly interface for animations void SetLastLTR() { lastAttack = ATTACKS.LTR; }