Пример #1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        Vector2 move = new Vector2();

        for (int i = 0; i < 4; i++)
        {
            GamePadState g = GamePad.GetState((PlayerIndex)i);
            move = StickFixer.fixStick(new Vector2(g.ThumbSticks.Left.X, g.ThumbSticks.Left.Y), 0.15f);
            if ((g.Buttons.A == ButtonState.Pressed || move != Vector2.zero) && !activePlayers[i])
            {
                pucks[i].GetComponent <SpriteRenderer>().enabled = true;
                activePlayers[i] = true;
            }
        }
    }
Пример #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        Vector2 move = new Vector2();

        rb.velocity = Vector2.zero;
        for (int i = 0; i < 4; i++)
        {
            GamePadState g = GamePad.GetState((PlayerIndex)i);
            move += StickFixer.fixStick(new Vector2(g.ThumbSticks.Left.X, g.ThumbSticks.Left.Y), 0.15f);

            if (g.Buttons.A == ButtonState.Pressed && selected)
            {
                selected.click();
            }
        }
        rb.velocity += move * 15f;
    }
    // Update is called once per frame
    void FixedUpdate()
    {
        if (aPressCooldown > 0)
        {
            aPressCooldown--;
        }
        if (yPressCooldown > 0)
        {
            yPressCooldown--;
        }
        if (bPressCooldown > 0)
        {
            bPressCooldown--;
        }
        Vector2 move = new Vector2();

        rb.velocity = Vector2.zero;
        GamePadState g = GamePad.GetState((PlayerIndex)playerNum);

        move += StickFixer.fixStick(new Vector2(g.ThumbSticks.Left.X, g.ThumbSticks.Left.Y), 0.15f);

        if (selected && selected.transform.parent != null)
        {
            if (keyboardActive && selected.transform.parent.gameObject == keyboard && g.Buttons.A == ButtonState.Pressed)
            {
                if (selected.name == "DEL" && nameTag.text.Length > 0 && aPressCooldown < 20)
                {
                    nameTag.text   = nameTag.text.Substring(0, (nameTag.text.Length - 1));
                    aPressCooldown = 30;
                }
                else if (selected.name == "space" && aPressCooldown < 15 && nameTag.text.Length < 6)
                {
                    nameTag.text  += " ";
                    aPressCooldown = 30;
                }
                else if (selected.name == "123")
                {
                    keyboardHelper("1234567890");
                }
                else if (selected.name == "specialChars")
                {
                    keyboardHelper("!?-.()$");
                }
                else if (selected.name == "accept")
                {
                    if (nameTag.text != "")
                    {
                        name = nameTag.text;
                        creator.assignName(playerNum, name);
                    }
                    else
                    {
                        nameTag.text = "Player " + (playerNum + 1).ToString();
                        name         = "";
                        creator.assignName(playerNum, null);
                    }
                    setKeyboardActive(false);
                }
                else if (selected.name == "cancel")
                {
                    nameTag.text = "Player " + (playerNum + 1).ToString();
                    name         = "";
                    creator.assignName(playerNum, null);
                    setKeyboardActive(false);
                }
                else
                {
                    keyboardHelper(selected.name);
                }
                aPressCooldown = 30;
            }
        }

        if (g.Buttons.A == ButtonState.Pressed && selected && aPressCooldown == 0)
        {
            MapItem MenuButton = selected.GetComponent <MapItem>();
            if (MenuButton != null)
            {
                MenuButton.click();
            }
            else
            {
                aPressCooldown = 30;
                if (selected.name == "CharSelectSquareKeith")
                {
                    creator.activatePlayer(playerNum, 0);
                    characterSelected = true;
                }
                if (selected.name == "CharSelectSquareWalt")
                {
                    creator.activatePlayer(playerNum, 1);
                    characterSelected = true;
                }
                if (selected.name == "CharSelectSquareRandom")
                {
                    creator.activatePlayer(playerNum, -1);
                    characterSelected = true;
                }
                if (selected == nameBox)
                {
                    setKeyboardActive(true);
                    nameTag.text = name;
                }
            }
        }



        if (g.Buttons.Y == ButtonState.Pressed && characterSelected && yPressCooldown == 0)
        {
            creator.changeColor(playerNum, true);
            yPressCooldown = 30;
        }
        if (g.Buttons.Start == ButtonState.Pressed)
        {
            creator.goToMapSelect();
        }
        rb.velocity += move * 10f;

        if (playerNum == 0 && g.DPad.Up == ButtonState.Pressed)
        {
            creator.createDummy();
        }

        if (g.Buttons.B == ButtonState.Pressed && characterSelected && bPressCooldown == 0)
        {
            creator.deactivatePlayer(playerNum);
            characterSelected = false;
            bPressCooldown    = 30;
        }
    }
Пример #4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        #region history
        inputItem i = new inputItem();
        i.dir  = new Vector2(control.MoveHor, control.MoveVer);
        i.dir  = StickFixer.fixStick(i.dir, AxisAdjust);
        i.time = Time.time;
        if (inputHistory.Count == historyMax)
        {
            inputHistory.RemoveAt(inputHistory.Count - 1);
        }
        //Debug.Log(i.dir);
        inputHistory.Insert(0, i);
        #endregion

        if (control.Jump > 0.55f || control.MoveVer > 0.55f)
        {
            JumpDown += 1;
        }
        else
        {
            JumpDown = 0;
        }

        if (control.MoveVer > 0.55f)
        {
            JumpTap += 1;
        }
        else
        {
            JumpTap = 0;
        }
        //print(JumpDown);
        if (control.Dash > 0.55f)
        {
            DashDown += 1;
        }
        else
        {
            DashDown = 0;
        }
        if (control.Attack)
        {
            AttackDown += 1;
        }
        else
        {
            AttackDown = 0;
        }
        if (control.FinisherSlash)
        {
            SlashDown += 1;
        }
        else
        {
            SlashDown = 0;
        }
        if (control.Dodge)
        {
            DodgeDown += 1;
        }
        else
        {
            DodgeDown = 0;
        }

        if (control.Shoot)
        {
            ShootDown += 1;
        }
        else
        {
            ShootDown = 0;
        }
        Quads.RemoveAt(1);
        Quads.Insert(0, AQuad);
    }