Esempio n. 1
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;
            }
        }
    }
Esempio n. 2
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);
                }
            }
        }
    }
Esempio n. 3
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();
         }
     }
 }
Esempio n. 4
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);
         }
     }
 }
Esempio n. 6
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;
            }
        }
    }
Esempio n. 7
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;
            }
        }
    }
Esempio n. 8
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);
    }
Esempio n. 9
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);
        }
    }
Esempio n. 10
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;
        }
    }