private void checkInput() { // these are false unless one of keys is pressed isLeft = false; isRight = false; isJump = false; isGoDown = false; movingDir = moving.None; #region Pebble (F) if (Input.GetKeyDown(KeyCode.F)) { //OnPress -> set pebble power to 0 and create powerBar if(!pebble) { //Only if not already existing (can't have 2 pebbles at the same time) powerPebble = 0f; // setPebbleBarPos(); pebbleBar.transform.localScale = new Vector3(0f,1f,1f); preparePebble = specialCast = true; } } if (Input.GetKey(KeyCode.F)) { //Hold F to add power if(powerPebble <= pebbleMaxStrengh && !pebble) { //Pebble max strenght preparePebble = specialCast = true; powerPebble += 0.2f; pebbleBar.transform.localScale = new Vector3(powerPebble,0.3f,1f); //Resize powerBar setPebbleBarPos(); } } if (Input.GetKeyUp(KeyCode.F)) { //RELEASE THE PEBBLE !! if(!pebble) { //If no pebble already existing preparePebble = false; launchPebble = true; GOpebble = Instantiate(Resources.Load("Prefabs/04Gameplay/Pebble")) as GameObject; pebble = GOpebble.GetComponent<Pebble>(); //Create Pebble pebble.setPosition((transform.position.x-transform.localScale.x/2),(transform.position.y+transform.localScale.y/2), -6f); //Pebble ini position pebble.setCallerObject(thisTransform); pebbleDirection = (facingDir == facing.Right) ? 1 : -1; //Direction of the pebble pebble.throwPebble(powerPebble, pebbleDirection); //Throw pebble function powerPebble = 0f; //reset power pebbleBar.transform.localScale = new Vector3(powerPebble,0.3f,1f); //reset power bar pebbleBar.transform.position = new Vector3((powerPebble/2)+thisTransform.position.x,thisTransform.position.y+2f,-30f); } } if (Input.GetKeyDown(KeyCode.KeypadPlus)) { pebbleCount += 1; } if (Input.GetKeyDown(KeyCode.KeypadMinus)) { pebbleCount -= 1; } #endregion #region TEMPORARY MUST NOT BE IN FINAL VERSION (Y) & (T) -> Destroy current circles if (Input.GetKeyDown(KeyCode.Y)) { soundInstru2.destroyCircle(); } if (Input.GetKeyDown(KeyCode.T)) { soundInstru1.destroyCircle(); } #endregion #region Instru Skill (R) if (Input.GetKeyDown(KeyCode.R) && grounded && !specialCast) { playSoundInstru(); StartCoroutine("specialCircleCast"); } #endregion #region Sprint management (LeftShift) if(Input.GetKeyDown("left shift")) {//OnPress moveVel = moveVelSprint; //Increase Player Speed //footStepDelay = footStepDelaySprint; //Decrease FootStep Delay isSprint = true; } if(Input.GetKeyUp("left shift")) {//OnRelease moveVel = moveVelINI; //Decrease Player Speed //footStepDelay = footStepDelayINI; //Increase FootStep Delay isSprint = false; } if(Input.GetKeyDown("left shift")) {//LeftShift input toSprint=true; } else if(Input.GetKeyUp("left shift")) {//NO LeftShift input toWalk=true; } /*if(!blockCoroutine) {*/ if(toSprint && grounded) { StopCoroutine("queueWaveState"); StartCoroutine(queueWaveState("ToSprint",soundEmitt1)); StartCoroutine(queueWaveState("ToSprint",soundEmitt2)); StartCoroutine(queueWaveState("ToSprint",soundEmitt3)); // /*if(soundEmitt1.getAlpha() <= 0f)*/ soundEmitt1.circleWalkToSprint(); // /*if(soundEmitt2.getAlpha() <= 0f)*/ soundEmitt2.circleWalkToSprint(); // /*if(soundEmitt3.getAlpha() <= 0f)*/ soundEmitt3.circleWalkToSprint(); toSprint=false; footStepDelay = footStepDelaySprint; } else if (toWalk && grounded) { StopCoroutine("queueWaveState"); StartCoroutine(queueWaveState("ToWalk",soundEmitt1)); StartCoroutine(queueWaveState("ToWalk",soundEmitt2)); StartCoroutine(queueWaveState("ToWalk",soundEmitt3)); // /*if(soundEmitt1.getAlpha() <= 0f)*/ soundEmitt1.circleSprintToWalk(); // /*if(soundEmitt2.getAlpha() <= 0f)*/ soundEmitt2.circleSprintToWalk(); // /*if(soundEmitt3.getAlpha() <= 0f)*/ soundEmitt3.circleSprintToWalk(); toWalk=false; footStepDelay = footStepDelayINI; } /*}*/ #endregion #region Movement (Left), (Right), (Up), (Down), (Space) if((Input.GetKey("left") || Input.GetKey(KeyCode.Q)) && !specialCast) { //If input left & not casting instru isLeft = true; shootLeft = true; facingDir = facing.Left; if(!blockCoroutine && grounded) StartCoroutine("waitB4FootStep"); } if(((Input.GetKeyUp("left") || Input.GetKeyUp(KeyCode.Q)) && !specialCast) || ((Input.GetKeyUp("right") || Input.GetKeyUp(KeyCode.D)) && !isLeft && !specialCast)) { StopCoroutine("footStep"); StopCoroutine("waitB4FootStep"); blockCoroutine = false; } if(((Input.GetKeyDown("left") || Input.GetKeyDown(KeyCode.Q)) && !specialCast) || ((Input.GetKeyDown("right") || Input.GetKeyDown(KeyCode.D)) && !isLeft && !specialCast)) { StopCoroutine("waitB4FootStep"); StopCoroutine("footStep"); blockCoroutine = false; } if ((Input.GetKey("right") || Input.GetKey(KeyCode.D)) && !isLeft && !specialCast) { //If input right & not casting instru isRight = true; facingDir = facing.Right; shootLeft = false; if(!blockCoroutine && grounded) StartCoroutine("waitB4FootStep"); } if ((Input.GetKeyDown("down") || Input.GetKeyDown(KeyCode.S)) && !specialCast && (grounded || isGrab)) { if(isGrab) {checkingGrabPosition = false;StopCoroutine("checkGrabberPosition");isGrab = false;} else { if ( onEnvironment != null && onEnvironment.typeList == Environment.types.wood) { onEnvironment.GetComponent<BoxCollider>().enabled = false; StartCoroutine(EnableCollider(onEnvironment.GetComponent<BoxCollider>())); } } } if ((Input.GetKeyDown("up") || Input.GetKeyDown(KeyCode.Z)) && !specialCast && (grounded || isGrab)) { if(isGrab) {checkingGrabPosition = false;StopCoroutine("checkGrabberPosition");isGrab = false;} isJump = true; grounded = false; } #endregion #region Alpha (1), (2), (3) if (Input.GetKeyDown(KeyCode.Alpha1)) { //skill_axe.useSkill(Skills.SkillList.Axe); } if (Input.GetKeyDown(KeyCode.Alpha2)) { } if (Input.GetKeyDown(KeyCode.Alpha3)) { } #endregion #region (Escape) if (Input.GetKeyDown(KeyCode.Escape)) { if (GameEventManager.state != GameEventManager.GameState.Pause) GameEventManager.TriggerGamePause(); else if (GameEventManager.state == GameEventManager.GameState.Pause) GameEventManager.TriggerGameUnpause(); } #endregion if(grounded && checkingGrabPosition) {checkingGrabPosition = false;StopCoroutine("checkGrabberPosition");} if(grounded) { if(!firstGrounded) { //print("BEGIN BEING GROUNDED"); firstGrounded = true; firstFalling = false; //StopCoroutine("footStep"); playSoundFall(); //cptWave = 1; if(fallFast) { fallFast = false; //soundEmitt3.circleWalkToSprint(); soundEmitt3.resetCircle(transform.localScale.x/1.5f,playerDirLeft, true); } // soundEmitt1.circleFallToGrounded(); // soundEmitt2.circleFallToGrounded(); // soundEmitt3.circleFallToGrounded(); StopCoroutine("footStep"); StopCoroutine("waitB4FootStep"); StopCoroutine("waitB4FallWave"); blockFallWavesCorout = blockCoroutine = false; StopCoroutine("queueWaveState"); if(isSprint) { footStepDelay = footStepDelaySprint; StartCoroutine(queueWaveState("ToSprint",soundEmitt1)); StartCoroutine(queueWaveState("ToSprint",soundEmitt2)); StartCoroutine(queueWaveState("ToSprint",soundEmitt3)); } else { footStepDelay=footStepDelayINI; StartCoroutine(queueWaveState("ToGround",soundEmitt1)); StartCoroutine(queueWaveState("ToGround",soundEmitt2)); StartCoroutine(queueWaveState("ToGround",soundEmitt3)); } } } else { if(!firstFalling) { //print("BEGIN FALLING"); StopCoroutine("footStep"); StopCoroutine("waitB4FootStep"); blockCoroutine = false; footStepDelay=footStepDelayFall; firstFalling = true; delayB4FallWaves = 0.7f; firstGrounded = false; // soundEmitt1.circleGroundedToFall(); // soundEmitt2.circleGroundedToFall(); // soundEmitt3.circleGroundedToFall(); StopCoroutine("queueWaveState"); StartCoroutine(queueWaveState("ToFall",soundEmitt1)); StartCoroutine(queueWaveState("ToFall",soundEmitt2)); StartCoroutine(queueWaveState("ToFall",soundEmitt3)); } if(!blockCoroutine && !blockFallWavesCorout && !isGrab) {/*StopCoroutine("waitB4FallWave");*/StartCoroutine("waitB4FallWave");} } // print (vectorMove.y); // if(!grounded && !blockCoroutine) {/*footStepDelay=footStepDelayFall;StartCoroutine("waitB4FallWave");*/} // else if (grounded && !blockCoroutine) { // /**/ // } }