// Update is called once per frame void Update() { if (MinigameInputHelper.IsButton1Up(1) || MinigameInputHelper.IsButton1Up(2) || MinigameInputHelper.IsButton2Up(1) || MinigameInputHelper.IsButton2Up(2)) { SceneManager.LoadScene("Menu_Scene"); } }
// Update is called once per frame void Update() { MovePaddle(); if (MinigameInputHelper.IsButton1Down(playerNumber)) { leftFlipper.GetComponent <PinballPongFlipper>().Flip(); } if (MinigameInputHelper.IsButton1Up(playerNumber)) { leftFlipper.GetComponent <PinballPongFlipper>().UnFlip(); } if (MinigameInputHelper.IsButton2Down(playerNumber)) { rightFlipper.GetComponent <PinballPongFlipper>().Flip(); } if (MinigameInputHelper.IsButton2Up(playerNumber)) { rightFlipper.GetComponent <PinballPongFlipper>().UnFlip(); } }
void Update() { if (direction) { spriteRenderer.flipX = false; } else { spriteRenderer.flipX = true; } float horizontal_axis = MinigameInputHelper.GetHorizontalAxis(player + 1); bool button1 = MinigameInputHelper.IsButton1Down(player + 1); bool button2 = MinigameInputHelper.IsButton2Down(player + 1); bool button2Up = MinigameInputHelper.IsButton2Up(player + 1); float pos_x = gameObject.transform.position.x; float pos_y = gameObject.transform.position.y; float o_pos_x = other.transform.position.x; float o_pos_y = other.transform.position.y; //double p1_height = this.GetComponent<MoveScript>().playerHeight; double p1_width = 0.6 * this.GetComponent <MoveScript>().playerWidth; time += Time.deltaTime; if (horizontal_axis < -0.1) { direction = true; //left } else if (horizontal_axis > 0.1) { direction = false; //right } if ((button1 || MinigameInputHelper.IsButton1Held(player + 1)) && time >= cooldown && TYPE != 4 && ballCharge < 30) { ballCharge++; } if (MinigameInputHelper.IsButton1Up(player + 1) && time >= cooldown && ballCharge > 0 && TYPE != 4) { if (player == 0) { animator.Play("Attack"); } else { animator.Play("Attack2"); } //animator.SetInteger("state", 3 + TYPE); attacktime = 0; time = 0; GameObject p; attacktime = 0; if (direction && !gameObject.GetComponent <ActionScript>().defenseOn) { p = Instantiate(projectile, transform.position - new Vector3((float)2, -1, 0), transform.rotation); p.GetComponent <Rigidbody2D>().velocity = new Vector2(-2.5f, 1.0f) * ballCharge; } else if (!gameObject.GetComponent <ActionScript>().defenseOn) { p = Instantiate(projectile, transform.position + new Vector3((float)2, 1, 0), transform.rotation); p.GetComponent <Rigidbody2D>().velocity = new Vector2(2.5f, 1.0f) * ballCharge; } ballCharge = 0; } //if(attacktime > 0.5 && animator.GetInteger("state") == 3 + TYPE) animator.SetInteger("state", 0 + TYPE); if (button1 && time >= cooldown && TYPE != 0) //kick { double xdist = gameObject.transform.position.x - other.transform.position.x; /*if (!direction && ((pos_x < 0 && xdist > 0 && xdist < 2) || * (pos_x > 0 && xdist < 0 && xdist > -2)) && * other.GetComponent<ActionScript>().defenseOn) * { * other.GetComponent<ActionScript>().shieldHits = other.GetComponent<ActionScript>().shieldHits + 1; * }*/ time = 0; if (player == 0) { animator.Play("K_Attack"); } else { animator.Play("Attack_K2"); } if (direction && xdist > 0 && xdist < 3 * p1_width) /*((pos_x < 0 && xdist > 0 && xdist < 2*p1_width) || * (pos_x > 0 && xdist < 0 && xdist > -2*p1_width)))*/ { if (!other.GetComponent <ActionScript>().defenseOn) { gameObject.GetComponent <HealthScript>().TakeDamage(1); Debug.Log("reached here"); } else { other.GetComponent <ActionScript>().shieldHits++; other.GetComponent <Renderer>().material.SetColor("_Color", Color.blue); Debug.Log(shieldHits); /*if (shieldHits >= 3) * { * shield.transform.localScale = new Vector3(0, 0, 0); * defenseOn = false; * shieldHits = 0; * defCooldown = 0; * }*/ } } /*if (direction && ((pos_x < 0 && xdist < 0 && xdist > -2) || * (pos_x > 0 && xdist > 0 && xdist < 2)) && * other.GetComponent<ActionScript>().defenseOn) * { * other.GetComponent<ActionScript>().shieldHits++; * }*/ if (!direction && xdist < 0 && xdist > -3 * p1_width) /*((pos_x < 0 && xdist < 0 && xdist > -2*p1_width) || * (pos_x > 0 && xdist > 0 && xdist < 2*p1_width)))*/ { if (!other.GetComponent <ActionScript>().defenseOn) { gameObject.GetComponent <HealthScript>().TakeDamage(1); Debug.Log("reached here"); } else { other.GetComponent <ActionScript>().shieldHits++; other.GetComponent <Renderer>().material.SetColor("_Color", Color.blue); Debug.Log(shieldHits); /*if (shieldHits >= 3) * { * shield.transform.localScale = new Vector3(0, 0, 0); * defenseOn = false; * shieldHits = 0; * defCooldown = 0; * }*/ } } } /*if (button1 && TYPE != 0) { * Debug.Log("karate attack"); * * //animator.SetInteger("state", 3 + TYPE); * Debug.Log(animator.GetInteger("state")); * attacktime = 0; * } * /*dif (button1 && time >= cooldown && TYPE != 0 && !other.GetComponent<ActionScript>().defenseOn){//punch //IS THERE A SHIELD CHECK HERE?? yes! * double xdist = pos_x - o_pos_x; * if (!direction && ((pos_x < 0 && xdist > 0 && xdist < 2*p1_width) || * (pos_x > 0 && xdist < 0 && xdist > -2*p1_width))) * { * gameObject.GetComponent<HealthScript>().TakeDamage(1); * } * if (direction && ((pos_x < 0 && xdist < 0 && xdist > -2*p1_width) || * (pos_x > 0 && xdist > 0 && xdist < 2*p1_width))) * { * gameObject.GetComponent<HealthScript>().TakeDamage(1); * } * }*/ defCooldown += Time.deltaTime; if (defCooldown > 3 && !defenseOn) { GameObject.Find("shieldready" + player).transform.localScale = new Vector3(1, 1, 1); } else { GameObject.Find("shieldready" + player).transform.localScale = new Vector3(0, 0, 0); } if (button2 && TYPE != 8 && defCooldown > 3) { shield.transform.localScale = new Vector3(1, 1, 1); defenseOn = true; defCooldown = 0; } if (shieldHits >= 3) { shield.transform.localScale = new Vector3(0, 0, 0); defenseOn = false; shieldHits = 0; defCooldown = 0; } if (button2Up) { shield.transform.localScale = new Vector3(0, 0, 0); defenseOn = false; } attacktime += Time.deltaTime; }
void Update() { // load the level select menu if any button is pressed if (MinigameInputHelper.IsButton1Up(1) || MinigameInputHelper.IsButton1Up(2) || MinigameInputHelper.IsButton2Up(1) || MinigameInputHelper.IsButton2Up(2) ) { if (selected == 0) { LoadLevelMenu(); } else if (selected == 1) { LoadSettings(); } else if (selected == 2) { MinigameController.Instance.FinishGame(LastMinigameFinish.NONE);; } } if (coolDown <= 0) { float joystick1 = MinigameInputHelper.GetVerticalAxis(1); float joystick2 = MinigameInputHelper.GetVerticalAxis(2); if (joystick1 > 0 || joystick2 > 0) { selected = (selected + 2) % 3; coolDown = 0.3f; } else if (joystick1 < 0 || joystick2 < 0) { selected = (selected + 1) % 3; coolDown = 0.3f; } } if (selected == 0) { myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(null); play.GetComponent <Button>().Select(); } else if (selected == 1) { myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(null); settings.GetComponent <Button>().Select(); } else if (selected == 2) { myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(null); exit.GetComponent <Button>().Select(); } if (coolDown > 0) { coolDown -= Time.deltaTime; } }
void Update() { // load the level select menu if any button is pressed if (MinigameInputHelper.IsButton1Up(1) || MinigameInputHelper.IsButton1Up(2) || MinigameInputHelper.IsButton2Up(1) || MinigameInputHelper.IsButton2Up(2)) { if (selected == 3) { LoadMainMenu(); return; } if (selected == 0) { LevelState.beatMapFilename = "Tempo/Beatmaps/Easy"; LevelState.songFilename = "Tempo/Songs/Easy"; } else if (selected == 1) { LevelState.beatMapFilename = "Tempo/Beatmaps/Intermediate"; LevelState.songFilename = "Tempo/Songs/Intermediate"; } else if (selected == 2) { LevelState.beatMapFilename = "Tempo/Beatmaps/Expert"; LevelState.songFilename = "Tempo/Songs/Expert"; } else if (selected == 4) { LevelState.beatMapFilename = "Tempo/Beatmaps/Click Track"; LevelState.songFilename = "Tempo/Songs/Click Track"; } PlayGame(); } if (coolDown <= 0) { // are one or more of the joysticks being pushed float joystick1 = MinigameInputHelper.GetVerticalAxis(1); float joystick2 = MinigameInputHelper.GetVerticalAxis(2); bool joystick_up = joystick1 > 0 || joystick2 > 0; bool joystick_down = joystick1 < 0 || joystick2 < 0; if (joystick_up) { selected = (selected + 4) % 5; coolDown = 0.3f; } else if (joystick_down) { selected = (selected + 1) % 5; coolDown = 0.3f; } myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(null); buttons[selected].GetComponent <Button>().Select(); } else if (coolDown > 0) { coolDown -= Time.deltaTime; } }