void Update() { //Debug.Log(gamepad.GetStick_L().Y); if (((gamepad.GetStick_L().X) > 0.2f || (gamepad.GetStick_L().X) < -0.2f)) { //&& rb.velocity.x<maxSpeed Move(); } if (gamepad.GetButtonDown("A") && !dashOn) { dashOn = true; StartCoroutine(DashTimer()); } if (gamepad.GetStick_L().Y != 0 && onTheWall) { moveDown(); } if (gamepad.GetButton("X")) { Stop(); } if (gamepad.GetButton("Start")) { Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name); } if (gamepad.GetButtonDown("Y")) { colorChanger.GetComponent <Renderer>().material.SetColor("_Color", Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f)); } }
// Update is called once per frame void Update() { if (gamepad.GetButton("A")) { Debug.Log("oui"); } }
void Update() { if (gamepad.IsConnected) { // Moving in straight lines if (gamepad.GetButton("DPad_Up")) { Vector3 movement = new Vector3(0.0f, 0.0f, -1.0f); gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed; lastMove = movement; } else if (gamepad.GetButton("DPad_Down")) { Vector3 movement = new Vector3(0.0f, 0.0f, 1.0f); gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed; lastMove = movement; } else if (gamepad.GetButton("DPad_Left")) { Vector3 movement = new Vector3(1.0f, 0.0f, 0.0f); gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed; lastMove = movement; } else if (gamepad.GetButton("DPad_Right")) { Vector3 movement = new Vector3(-1.0f, 0.0f, 0.0f); gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed; lastMove = movement; } // Moving Diagonally if (gamepad.GetButton("DPad_Up") && gamepad.GetButton("DPad_Left")) { Vector3 movement = new Vector3(0.75f, 0.0f, -0.75f); gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed; lastMove = movement; } else if (gamepad.GetButton("DPad_Up") && gamepad.GetButton("DPad_Right")) { Vector3 movement = new Vector3(-0.75f, 0.0f, -0.75f); gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed; lastMove = movement; } else if (gamepad.GetButton("DPad_Down") && gamepad.GetButton("DPad_Left")) { Vector3 movement = new Vector3(0.75f, 0.0f, 0.75f); gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed; lastMove = movement; } else if (gamepad.GetButton("DPad_Down") && gamepad.GetButton("DPad_Right")) { Vector3 movement = new Vector3(-0.75f, 0.0f, 0.75f); gameObject.GetComponent <Rigidbody>().velocity = movement * moveSpeed; lastMove = movement; } // Dodge Roll if (gamepad.GetButtonDown("A")) { if (dodgeTimer >= dodgeCool) { dodgeTimer = 0; // timer power fade gamepad.AddRumble(0.1f, new Vector2(0.1f, 0.1f), 0.1f); gameObject.GetComponent <Rigidbody>().velocity = lastMove * moveSpeed * 3; } } // Player Attacks if (gamepad.GetButtonDown("X")) { if (attackTimer >= attackSpeed) { Instantiate(attackGhost, (gameObject.GetComponent <Transform>().position + (lastMove * attackRange)), Quaternion.identity); attackTimer = 0; } } /*************Cheats*************/ /********************************/ /*if (Input.GetKeyDown("8")) * { * next Round * }*/ if (Input.GetKeyDown("9")) { health = 9999; } if (Input.GetKeyDown("0")) { health = 0; } /*********************************/ /*********************************/ if (health >= 4) { h1.GetComponent <SpriteRenderer>().enabled = true; h2.GetComponent <SpriteRenderer>().enabled = true; h3.GetComponent <SpriteRenderer>().enabled = true; h4.GetComponent <SpriteRenderer>().enabled = true; } else if (health == 3) { h1.GetComponent <SpriteRenderer>().enabled = false; h2.GetComponent <SpriteRenderer>().enabled = true; h3.GetComponent <SpriteRenderer>().enabled = true; h4.GetComponent <SpriteRenderer>().enabled = true; } else if (health == 2) { h1.GetComponent <SpriteRenderer>().enabled = false; h2.GetComponent <SpriteRenderer>().enabled = false; h3.GetComponent <SpriteRenderer>().enabled = true; h4.GetComponent <SpriteRenderer>().enabled = true; } else if (health == 1) { h1.GetComponent <SpriteRenderer>().enabled = false; h2.GetComponent <SpriteRenderer>().enabled = false; h3.GetComponent <SpriteRenderer>().enabled = false; h4.GetComponent <SpriteRenderer>().enabled = true; } // Needs to be replaced by a downed mechanic else { // Destroys the player character if they lose all health Destroy(gameObject); h1.GetComponent <SpriteRenderer>().enabled = false; h2.GetComponent <SpriteRenderer>().enabled = false; h3.GetComponent <SpriteRenderer>().enabled = false; h4.GetComponent <SpriteRenderer>().enabled = false; loseText.GetComponent <Transform>().position = new Vector3(0f, -2.45983f, 12.14942f); } // Update Timers dodgeTimer++; attackTimer++; } }