public void SettingChange()
    {
        if (canUseAxis)
        {
            if ((XCI.GetAxisRaw(XboxAxis.LeftStickX, XboxController.First) == 1 || KCI.GetAxisRaw(KeyboardAxis.Horizontal, KeyboardController.First) == 1) && numberRound < maxValue)
            {
                canUseAxis = false;
                numberRound++;
                GameObject.Find("AudioHandler").GetComponent <AudioBehaviour> ().audios [5].Play();
                SettingText();
            }
            if ((XCI.GetAxisRaw(XboxAxis.LeftStickX, XboxController.All) == -1 || KCI.GetAxisRaw(KeyboardAxis.Horizontal, KeyboardController.First) == -1) && numberRound > minValue)
            {
                canUseAxis = false;
                numberRound--;
                GameObject.Find("AudioHandler").GetComponent <AudioBehaviour> ().audios [5].Play();
                SettingText();
            }
        }

        if (XCI.GetAxisRaw(XboxAxis.LeftStickX, XboxController.First) == 0 && KCI.GetAxisRaw(KeyboardAxis.Horizontal, KeyboardController.First) == 0)
        {
            canUseAxis = true;
        }
    }
Beispiel #2
0
    void FixedUpdate()
    {
        float moveX = KCI.GetAxisRaw(KeyboardAxis.Horizontal, Kcontroller);
        float moveY = KCI.GetAxisRaw(KeyboardAxis.Vertical, Kcontroller);

        if (moveX > 0.1f && canControl)
        {
            rb.velocity = new Vector2(moveX * maxWalkSpeed, rb.velocity.y);
            //angle = 90;
        }
        if (moveX < -0.1f && canControl)
        {
            rb.velocity = new Vector2(moveX * maxWalkSpeed, rb.velocity.y);
            //angle = 270;
        }
        if (moveX == 0)
        {
            rb.velocity = new Vector2(0, rb.velocity.y);
        }
        if (moveY > 0.1f && canControl)
        {
            rb.velocity = new Vector2(rb.velocity.x, moveY * maxWalkSpeed);
            //angle = 180;
        }
        if (moveY < -0.1f && canControl)
        {
            rb.velocity = new Vector2(rb.velocity.x, moveY * maxWalkSpeed);
        }
        if (moveY == 0 && canControl)
        {
            rb.velocity = new Vector2(rb.velocity.x, 0);
        }
    }
Beispiel #3
0
    void Shoot(int powerup)
    {
        if (KCI.GetButtonDown(KeyboardButton.Action, Kcontroller) && countdown == 0 && powerup > 0)
        {
            countdown          = 10;
            audioSource.volume = 0.5f;
            audioSource.loop   = false;
            audioSource.Play();
            switch (powerup)
            {
            case 1:
                SingleShoot(getShootDir());
                break;

            case 2:
                doubleShootDir = getShootDir();
                DoubleShoot();
                break;

            case 3:
                FourDirShoot();
                break;
            }
        }
    }
Beispiel #4
0
 void Walk()
 {
     if (isKeyboard)
     {
         input = new Vector2(KCI.GetAxisRaw(KeyboardAxis.Horizontal, Kcontroller), KCI.GetAxisRaw(KeyboardAxis.Vertical, Kcontroller));
     }
     else
     {
         input = new Vector2(XCI.GetAxisRaw(XboxAxis.LeftStickX, Xcontroller), XCI.GetAxisRaw(XboxAxis.LeftStickY, Xcontroller));
     }
 }
Beispiel #5
0
    void Choosing()
    {
        if (!isKeyboard && isSet && !ready)
        {
            if (XCI.GetButtonDown(XboxButton.A, Xcontroller))
            {
                GameObject.Find("AudioHandler").GetComponent <AudioBehaviour> ().audios [9].Play();
                ready = true;
                PlayerPrefs.SetString(playerNumber, gameObject.GetComponent <SpriteRenderer> ().sprite.name);
                GiveControll();

                if (gameObject.GetComponent <SpriteRenderer> ().sprite.name != "Player Random")
                {
                    int element = int.Parse(gameObject.GetComponent <SpriteRenderer> ().sprite.name.Substring(7));
                    Search("Selection").GetComponent <SpriteRenderer> ().sprite = Handler.GetComponent <SelectionController> ().AbleSelection.Find(x => x.name == "Player" + " " + element.ToString() + " " + "Selection");
                    Handler.GetComponent <SelectionController> ().SpriteNotAble(gameObject.GetComponent <SpriteRenderer> ().sprite,
                                                                                Search("Arrow").GetComponent <SpriteRenderer> ().sprite,
                                                                                Search("Selection").GetComponent <SpriteRenderer> ().sprite);
                }
                else
                {
                    Search("Selection").GetComponent <SpriteRenderer> ().sprite = Handler.GetComponent <SelectionController> ().AbleSelection [Handler.GetComponent <SelectionController> ().AbleSelection.Count - 1];
                    Handler.GetComponent <SelectionController>().playersAreRandom.Add(gameObject);
                }
            }
        }
        else if (isKeyboard && isSet && !ready)
        {
            if (KCI.GetButtonDown(KeyboardButton.Jump, Kcontroller))
            {
                GameObject.Find("AudioHandler").GetComponent <AudioBehaviour> ().audios [9].Play();
                ready = true;
                PlayerPrefs.SetString(playerNumber, gameObject.GetComponent <SpriteRenderer> ().sprite.name);
                GiveControll();

                if (gameObject.GetComponent <SpriteRenderer> ().sprite.name != "Player Random")
                {
                    int element = int.Parse(gameObject.GetComponent <SpriteRenderer> ().sprite.name.Substring(7));
                    Search("Selection").GetComponent <SpriteRenderer> ().sprite = Handler.GetComponent <SelectionController> ().AbleSelection.Find(x => x.name == "Player" + " " + element.ToString() + " " + "Selection");
                    Handler.GetComponent <SelectionController> ().SpriteNotAble(gameObject.GetComponent <SpriteRenderer> ().sprite,
                                                                                Search("Arrow").GetComponent <SpriteRenderer> ().sprite,
                                                                                Search("Selection").GetComponent <SpriteRenderer> ().sprite);
                }
                else
                {
                    Search("Selection").GetComponent <SpriteRenderer> ().sprite = Handler.GetComponent <SelectionController> ().AbleSelection [Handler.GetComponent <SelectionController> ().AbleSelection.Count - 1];
                    Handler.GetComponent <SelectionController>().playersAreRandom.Add(gameObject);
                }
            }
        }
    }
Beispiel #6
0
 void Update()
 {
     if (itsNotButton)
     {
         if (XCI.GetButtonDown(XboxButton.A))
         {
             PlayerPrefs.SetInt("PlayerController", 0);
             GoTo();
         }
         if (KCI.GetButtonDown(KeyboardButton.Jump, KeyboardController.First) || KCI.GetButtonDown(KeyboardButton.Jump, KeyboardController.Second))
         {
             PlayerPrefs.SetInt("PlayerController", 1);
             GoTo();
         }
     }
 }
Beispiel #7
0
    void Unchoosing()
    {
        if (!isKeyboard && isSet && ready)
        {
            if (XCI.GetButtonDown(XboxButton.B, Xcontroller))
            {
                GameObject.Find("AudioHandler").GetComponent <AudioBehaviour> ().audios [5].Play();
                ready = false;
                PlayerPrefs.SetString(playerNumber, "none");

                if (gameObject.GetComponent <SpriteRenderer> ().sprite.name != "Player Random")
                {
                    Handler.GetComponent <SelectionController> ().SpriteAble(gameObject.GetComponent <SpriteRenderer> ().sprite,
                                                                             Search("Arrow").GetComponent <SpriteRenderer> ().sprite,
                                                                             Search("Selection").GetComponent <SpriteRenderer> ().sprite);
                }
                else
                {
                    Handler.GetComponent <SelectionController>().playersAreRandom.Remove(gameObject);
                }

                Search("Selection").GetComponent <SpriteRenderer> ().sprite = Handler.GetComponent <SelectionController> ().AbleSelection [0];
            }
        }
        else if (isKeyboard && isSet && ready)
        {
            if (KCI.GetButtonDown(KeyboardButton.Action, Kcontroller))
            {
                GameObject.Find("AudioHandler").GetComponent <AudioBehaviour> ().audios [5].Play();
                ready = false;
                PlayerPrefs.SetString(playerNumber, "none");

                if (gameObject.GetComponent <SpriteRenderer> ().sprite.name != "Player Random")
                {
                    Handler.GetComponent <SelectionController> ().SpriteAble(gameObject.GetComponent <SpriteRenderer> ().sprite,
                                                                             Search("Arrow").GetComponent <SpriteRenderer> ().sprite,
                                                                             Search("Selection").GetComponent <SpriteRenderer> ().sprite);
                }
                else
                {
                    Handler.GetComponent <SelectionController>().playersAreRandom.Remove(gameObject);
                }

                Search("Selection").GetComponent <SpriteRenderer> ().sprite = Handler.GetComponent <SelectionController> ().AbleSelection [0];
            }
        }
    }
 void GoingBack()
 {
     if (XCI.GetButtonDown(XboxButton.B, XboxController.First) || KCI.GetButtonDown(KeyboardButton.Action, KeyboardController.First))
     {
         if (SceneManager.GetActiveScene().name == "CharactersSelection")
         {
             if (GameObject.Find("SelectionHandler").GetComponent <SelectionController> ().nobodyReady)
             {
                 GameObject.Find("AudioHandler").GetComponent <AudioBehaviour>().audios[1].Play();
                 SceneManager.LoadScene(sceneToGoBack);
             }
         }
         else
         {
             GameObject.Find("AudioHandler").GetComponent <AudioBehaviour>().audios[1].Play();
             SceneManager.LoadScene(sceneToGoBack);
         }
     }
 }
Beispiel #9
0
    void Deselecting(GameObject selected)
    {
        for (int i = 0; i < enableXboxList.Count; i++)
        {
            if (XCI.GetButtonDown(XboxButton.B, enableXboxList[i]) && !selected.GetComponent <PlayerSelection>().isKeyboard&& selected.GetComponent <PlayerSelection>().Xcontroller == enableXboxList[i])
            {
                ControlUnset(selected, enableXboxList [i]);
                selected.GetComponent <PlayerSelection> ().confirmText.enabled = true;
            }
        }

        for (int i = 0; i < enableKeyboardList.Count; i++)
        {
            if (KCI.GetButtonDown(KeyboardButton.Action, enableKeyboardList[i]) && selected.GetComponent <PlayerSelection>().isKeyboard&& selected.GetComponent <PlayerSelection>().Kcontroller == enableKeyboardList[i])
            {
                ControlUnset(selected, enableKeyboardList[i]);
                selected.GetComponent <PlayerSelection> ().confirmText.enabled = true;
            }
        }
    }
Beispiel #10
0
    public void Selecting(GameObject selected)
    {
        for (int i = 0; i < ableXboxList.Count; i++)
        {
            if (XCI.GetButtonDown(XboxButton.A, ableXboxList[i]))
            {
                ControlSet(selected, ableXboxList [i]);
                selected.GetComponent <PlayerSelection> ().confirmText.enabled = false;
            }
        }

        for (int i = 0; i < ableKeyboardList.Count; i++)
        {
            if (KCI.GetButtonDown(KeyboardButton.Jump, ableKeyboardList[i]))
            {
                ControlSet(selected, ableKeyboardList[i]);
                selected.GetComponent <PlayerSelection> ().confirmText.enabled = false;
            }
        }
    }
Beispiel #11
0
 void Pivot()
 {
     if (KCI.GetAxisRaw(KeyboardAxis.Horizontal, Kcontroller) == 1)
     {
         transform.rotation = Quaternion.Euler(0, 0, 0);
         shootDir           = 1;
     }
     else if (KCI.GetAxisRaw(KeyboardAxis.Horizontal, Kcontroller) == -1)
     {
         transform.rotation = Quaternion.Euler(0, 0, 180);
         shootDir           = 2;
     }
     else if (KCI.GetAxisRaw(KeyboardAxis.Vertical, Kcontroller) == 1)
     {
         transform.rotation = Quaternion.Euler(0, 0, 90);
         shootDir           = 3;
     }
     else if (KCI.GetAxisRaw(KeyboardAxis.Vertical, Kcontroller) == -1)
     {
         transform.rotation = Quaternion.Euler(0, 0, 270);
         shootDir           = 4;
     }
 }
Beispiel #12
0
    public void GoTo()
    {
        if (SceneManager.GetActiveScene().name == "SplashScreen")
        {
            GameObject.Find("AudioHandler").GetComponent <AudioBehaviour> ().audios [7].Play();
        }
        else
        {
            GameObject.Find("AudioHandler").GetComponent <AudioBehaviour> ().audios [9].Play();
        }

        if (XCI.GetButtonDown(XboxButton.A, XboxController.First))
        {
            PlayerPrefs.SetInt("PlayerController", 0);
        }

        if (KCI.GetButtonDown(KeyboardButton.Jump, KeyboardController.First))
        {
            PlayerPrefs.SetInt("PlayerController", 1);
        }

        SceneManager.LoadScene(nextScene);
    }
Beispiel #13
0
 void Passing()
 {
     if (!isKeyboard && isSet && !ready)
     {
         if (XCI.GetAxisRaw(XboxAxis.LeftStickX, Xcontroller) == 1f && canUseAxis)
         {
             canUseAxis = false;
             ChangeCurrentSprite("next");
         }
         else if (XCI.GetAxisRaw(XboxAxis.LeftStickX, Xcontroller) == -1f && canUseAxis)
         {
             canUseAxis = false;
             ChangeCurrentSprite("previous");
         }
         else if (XCI.GetAxisRaw(XboxAxis.LeftStickX, Xcontroller) == 0f)
         {
             canUseAxis = true;
         }
     }
     else if (isKeyboard && isSet && !ready)
     {
         if (KCI.GetAxisRaw(KeyboardAxis.Horizontal, Kcontroller) == 1f && canUseAxis)
         {
             canUseAxis = false;
             ChangeCurrentSprite("next");
         }
         else if (KCI.GetAxisRaw(KeyboardAxis.Horizontal, Kcontroller) == -1f && canUseAxis)
         {
             canUseAxis = false;
             ChangeCurrentSprite("previous");
         }
         else if (KCI.GetAxisRaw(KeyboardAxis.Horizontal, Kcontroller) == 0f)
         {
             canUseAxis = true;
         }
     }
 }
Beispiel #14
0
    void Punch()
    {
        if (((XCI.GetButtonDown(XboxButton.X, Xcontroller) && !isKeyboard) || (KCI.GetButtonDown(KeyboardButton.Action, Kcontroller) && isKeyboard)) && controller.interPlayersCollision)
        {
            pushing      = true;
            lerpVelocity = 0f;
            enemyPlayer  = controller.horizontalLastHit.transform;
            inittial     = enemyPlayer.position.x;
            distance     = 1.5f;

            if (transform.position.x > inittial)
            {
                if (enemyPlayer.GetComponent <Controller2D> ().distanceWallLeft - enemyPlayer.GetComponent <BoxCollider2D> ().bounds.size.x / 2 < distance)
                {
                    distance = enemyPlayer.GetComponent <Controller2D> ().distanceWallLeft - enemyPlayer.GetComponent <BoxCollider2D> ().bounds.size.x / 2;
                }
                if (enemyPlayer.GetComponent <Controller2D> ().distanceWallLeft <= enemyPlayer.GetComponent <BoxCollider2D>().bounds.size.x / 2)
                {
                    distance = 0f;
                }
                if ((enemyPlayer.GetComponent <Controller2D> ().distanceWallLeft == 0) && (enemyPlayer.GetComponent <Controller2D> ().colliderLeft == null))
                {
                    distance = 1.5f;
                }
                distance *= -1;
            }
            else
            {
                if ((enemyPlayer.GetComponent <Controller2D> ().distanceWallRight - enemyPlayer.GetComponent <BoxCollider2D>().bounds.size.x / 2 < distance))
                {
                    distance = enemyPlayer.GetComponent <Controller2D> ().distanceWallRight - enemyPlayer.GetComponent <BoxCollider2D>().bounds.size.x / 2;
                }
                if (enemyPlayer.GetComponent <Controller2D> ().distanceWallRight <= enemyPlayer.GetComponent <BoxCollider2D>().bounds.size.x / 2)
                {
                    distance = 0f;
                }
                if ((enemyPlayer.GetComponent <Controller2D> ().distanceWallRight == 0) && (enemyPlayer.GetComponent <Controller2D> ().colliderRight == null))
                {
                    distance = 1.5f;
                }
                distance *= 1;
            }
            final      = inittial + distance;
            lerpTarget = new Vector3(final, enemyPlayer.position.y, enemyPlayer.position.z);
            GameObject.Find("AudioHandler").GetComponent <AudioBehaviour> ().audios [8].Play();
        }

        if (pushing)
        {
            lerpVelocity += Time.deltaTime * 5f;
            if (lerpVelocity > 1f)
            {
                lerpVelocity = 1f;
            }

            float perc = lerpVelocity / 1f;

            if (distance >= 0f)
            {
                if (enemyPlayer.position.x >= final || perc == 1f)
                {
                    pushing  = false;
                    distance = 0;
                }
            }
            else
            {
                if (enemyPlayer.position.x <= final || perc == 1f)
                {
                    pushing  = false;
                    distance = 0;
                }
            }

            enemyPlayer.position = Vector3.Lerp(enemyPlayer.position, lerpTarget, perc);
        }
    }
Beispiel #15
0
    void Jump()
    {
        int wallDirX = (controller.collisions.left) ? -1 : 1;

        float targetVelocityX = input.x * moveSpeed;

        velocity.x = Mathf.SmoothDamp(velocity.x, targetVelocityX, ref velocityXSmoothing, (controller.collisions.below)?accelerationTimeGrounded:accelerationTimeAirborne);

        bool wallSliding = false;

        onWall = wallSliding;
        if ((controller.collisions.left || controller.collisions.right) && !controller.collisions.below && velocity.y < 0 && controller.horizontalLastHit.collider.tag != "Player" && controller.horizontalLastHit.collider.tag != "Slideless")
        {
            wallSliding = true;
            onWall      = wallSliding;

            if (velocity.y < -wallSlideSpeedMax)
            {
                velocity.y = -wallSlideSpeedMax;
            }

            if (timeToWallUnstick > 0)
            {
                velocityXSmoothing = 0;
                velocity.x         = 0;

                if (input.x != wallDirX && input.x != 0)
                {
                    timeToWallUnstick -= Time.deltaTime;
                }
                else
                {
                    timeToWallUnstick = wallStickTime;
                }
            }
            else
            {
                timeToWallUnstick = wallStickTime;
            }
        }

        if ((XCI.GetButtonDown(XboxButton.A, Xcontroller) && !isKeyboard) || (KCI.GetButtonDown(KeyboardButton.Jump, Kcontroller) && isKeyboard))
        {
            if ((XCI.GetButtonDown(XboxButton.A, Xcontroller) && !isKeyboard) || (KCI.GetButtonDown(KeyboardButton.Jump, Kcontroller) && isKeyboard))
            {
                if (wallSliding)
                {
                    GameObject.Find("AudioHandler").GetComponent <AudioBehaviour> ().audios [6].Play();
                    if (wallDirX == input.x)
                    {
                        velocity.x = -wallDirX * wallJumpClimb.x;
                        velocity.y = wallJumpClimb.y;
                    }
                    else if (input.x == 0)
                    {
                        velocity.x = -wallDirX * wallJumpOff.x;
                        velocity.y = wallJumpOff.y;
                    }
                    else
                    {
                        velocity.x = -wallDirX * wallLeap.x;
                        velocity.y = wallLeap.y;
                    }
                }

                jumpButton = true;


                if (controller.collisions.below)
                {
                    curState   = "Air";
                    velocity.y = maxJumpVelocity;
                    GameObject.Find("AudioHandler").GetComponent <AudioBehaviour> ().audios [6].Play();
                }
            }
        }

        if ((XCI.GetButtonUp(XboxButton.A, Xcontroller) && !isKeyboard) || (KCI.GetButtonUp(KeyboardButton.Jump, Kcontroller) && isKeyboard))
        {
            jumpButton = false;
            if (velocity.y > minJumpVelocity)
            {
                velocity.y = minJumpVelocity;
            }
        }

        velocity.y += gravity * Time.deltaTime;
        controller.Move(velocity * Time.deltaTime, input);

        if (controller.collisions.above || controller.collisions.below)
        {
            velocity.y = 0;
        }
    }
Beispiel #16
0
    void Update()
    {
        float moveX    = KCI.GetAxisRaw(KeyboardAxis.Horizontal, Kcontroller);
        float moveY    = KCI.GetAxisRaw(KeyboardAxis.Vertical, Kcontroller);
        float pivotDir = pivot.transform.rotation.eulerAngles.z;

        dir = (-1 < pivotDir && pivotDir < 1) ? "right" : (179 < pivotDir && pivotDir < 181) ? "left" : dir;

        print(dir);

        idle = (moveX == 0 && moveY == 0);

        if (idle)
        {
            if (dir == "left")
            {
                GetComponent <Animator> ().Play("IdleBack");
            }
            else
            {
                GetComponent <Animator> ().Play("Idle");
            }
        }
        else
        {
            if (moveX != 0 && moveY == 0)
            {
                if ((Input.GetKey(KeyCode.A) && Kcontroller.ToString() == "First") || (Input.GetKey(KeyCode.LeftArrow) && Kcontroller.ToString() == "Second"))
                {
                    GetComponent <Animator> ().Play("WalkingLeft");
                }
                else if ((Input.GetKey(KeyCode.D) && Kcontroller.ToString() == "First") || (Input.GetKey(KeyCode.RightArrow) && Kcontroller.ToString() == "Second"))
                {
                    GetComponent <Animator> ().Play("WalkingRight");
                }
            }
            else if (moveX == 0 && moveY != 0)
            {
                if (moveY > 0)
                {
                    if (dir == "right")
                    {
                        GetComponent <Animator> ().Play("WalkingUpRight");
                    }
                    if (dir == "left")
                    {
                        GetComponent <Animator> ().Play("WalkingUpLeft");
                    }
                }
                else
                {
                    if (dir == "right")
                    {
                        GetComponent <Animator> ().Play("WalkingRight");
                    }
                    if (dir == "left")
                    {
                        GetComponent <Animator> ().Play("WalkingLeft");
                    }
                }
            }
        }
    }