Exemple #1
0
    public void OnlineRemovePlayer(string control)
    {
        if (PlayerList.All(player => player.Control != control))
        {
            return;
        }
        Player playerToRemove = PlayerList.First(p => p.Control == control);

        if (stage == SelectStages.Chosen)
        {
            stage           = SelectStages.Browse;
            kCanHorizontal  = true;
            j1CanHorizontal = true;
            j2CanHorizontal = true;
            j3CanHorizontal = true;
            j4CanHorizontal = true;
        }

        if (playerToRemove.Set)
        {
            pickedClasses.Remove(playerToRemove.Class);
            playerToRemove.Set = false;
        }
        else
        {
            PlayerList.Remove(playerToRemove);
        }

        UpdateSelect(PlayerList);
    }
Exemple #2
0
 public void Reset()
 {
     currentStage = SelectStages.NotJoined;
     animator.SetBool("IsDone", false);
     GameDataMonobehaviour.instance.SetPlayerJoined(gamepadIndex, false);
     animator.SetBool("IsJoined", false);
 }
Exemple #3
0
    void CheckSubmit()
    {
        if (Input.GetButton("kStart"))
        {
            if (kSubmit)
            {
                if (stage == SelectStages.Browse)
                {
                    if (pickedClasses.Count > 0 && pickedClasses.Contains(PlayerList.Find(c => c.Control == PlayerId).Class))
                    {
                        PlayPlayersAudio(InvalidClip, PlayerId);
                        return;
                    }

                    AddPlayer(PlayerId);
                    stage          = SelectStages.Chosen;
                    kCanHorizontal = false;
                }
                kSubmit = false;
            }
        }
        if (Input.GetButton("j1Start"))
        {
            if (j1Submit)
            {
                if (stage == SelectStages.Browse)
                {
                    if (pickedClasses.Count > 0 && pickedClasses.Contains(PlayerList.Find(c => c.Control == PlayerId).Class))
                    {
                        PlayPlayersAudio(InvalidClip, PlayerId);
                        return;
                    }
                    AddPlayer(PlayerId);
                    stage           = SelectStages.Chosen;
                    j1CanHorizontal = false;
                }
                j1Submit = false;
            }
        }
        if (Input.GetButton("j2Start"))
        {
            if (j2Submit)
            {
                if (stage == SelectStages.Browse)
                {
                    if (pickedClasses.Count > 0 && pickedClasses.Contains(PlayerList.Find(c => c.Control == PlayerId).Class))
                    {
                        PlayPlayersAudio(InvalidClip, PlayerId);
                        return;
                    }

                    AddPlayer(PlayerId);
                    stage           = SelectStages.Chosen;
                    j2CanHorizontal = false;
                }
                j2Submit = false;
            }
        }
        if (Input.GetButton("j3Start"))
        {
            if (j3Submit)
            {
                if (stage == SelectStages.Browse)
                {
                    if (pickedClasses.Count > 0 && pickedClasses.Contains(PlayerList.Find(c => c.Control == PlayerId).Class))
                    {
                        PlayPlayersAudio(InvalidClip, PlayerId);
                        return;
                    }

                    AddPlayer(PlayerId);
                    stage           = SelectStages.Chosen;
                    j3CanHorizontal = false;
                }
                j3Submit = false;
            }
        }
        if (Input.GetButton("j4Start"))
        {
            if (j4Submit)
            {
                if (stage == SelectStages.Browse)
                {
                    if (pickedClasses.Count > 0 && pickedClasses.Contains(PlayerList.Find(c => c.Control == PlayerId).Class))
                    {
                        PlayPlayersAudio(InvalidClip, PlayerId);
                        return;
                    }

                    AddPlayer(PlayerId);
                    stage           = SelectStages.Chosen;
                    j4CanHorizontal = false;
                }
                j4Submit = false;
            }
        }
    }
Exemple #4
0
 private void InitialSubmit(string control)
 {
     selected = true;
     SelectInitialPlayer(PlayerId, control);
     stage = SelectStages.Browse;
 }
Exemple #5
0
 // Start is called before the first frame update
 void Start()
 {
     selectStages = GameObject.Find("SelectStagesUI").GetComponent <SelectStages>();
 }
Exemple #6
0
    // Update is called once per frame
    void Update()
    {
        input = GameInput.GetPlayerDevice(gamepadIndex);
        if (input == null)
        {
            return;
        }


        if (currentStage == SelectStages.NotJoined)
        {
            if (input.Action1.WasPressed)
            {
                currentStage = SelectStages.NotSelected;
                GameDataMonobehaviour.instance.SetPlayerJoined(gamepadIndex, true);
                animator.SetBool("IsJoined", true);
            }
            if (input.Action2.WasPressed && gamepadIndex == 0)
            {
                mainMenuManager.OpenMainMenuScreen();
            }
        }
        else if (currentStage == SelectStages.Selected)
        {
            if (gamepadIndex == 0 && input.Action1.WasPressed)
            {
                Debug.Log("test");
                mainMenuManager.StartLevelSelectScreen();
            }
            else if (input.Action2.WasPressed)
            {
                currentStage = SelectStages.NotSelected;
                animator.SetBool("IsDone", false);
            }
        }
        else
        {
            bool  left         = input.LeftStick.Left.IsPressed;
            bool  right        = input.LeftStick.Right.IsPressed;
            float colourAdjust = input.RightTrigger.Value - input.LeftTrigger.Value;

            if (Time.time - lastInput >= 0.5)
            {
                if (left)
                {
                    ChangeCharacter((int)Mathf.Repeat(currentCharacterIndex - 1, characterDefinitionSet.Count));
                    lastInput = Time.time;
                }
                else if (right)
                {
                    ChangeCharacter((int)Mathf.Repeat(currentCharacterIndex + 1, characterDefinitionSet.Count));
                    lastInput = Time.time;
                }
                else
                {
                    lastInput = -0.5f;
                }
            }

            float currentHue = 0;
            float currentS, currentV = 0;
            Color colour = GameDataMonobehaviour.instance.playerColour[gamepadIndex];
            Color.RGBToHSV(colour, out currentHue, out currentS, out currentV);
            currentHue = currentHue + colourAdjust * Time.deltaTime * 0.3f;
            colour     = Color.HSVToRGB(currentHue, 1, 1);
            GameDataMonobehaviour.instance.playerColour[gamepadIndex] = colour;
            huebar.SetSelector(currentHue % 1, Color.HSVToRGB(currentHue, 1, 1));

            tankRepresentation.SetColour(colour);

            if (input.Action1.WasPressed)
            {
                currentStage = SelectStages.Selected;
                GameDataMonobehaviour.instance.selectedCharacter[gamepadIndex] = currentCharacter;
                GameDataMonobehaviour.instance.selectedTank[gamepadIndex]      = currentTank;
                animator.SetBool("IsDone", true);
                Debug.Log("yes");
            }
            else if (input.Action2.WasPressed)
            {
                currentStage = SelectStages.NotJoined;
                GameDataMonobehaviour.instance.SetPlayerJoined(gamepadIndex, false);
                animator.SetBool("IsJoined", false);
            }
        }
    }
Exemple #7
0
    protected virtual void RemovePlayer(string control)
    {
        if (PlayerList.All(player => player.Control != control))
        {
            return;
        }
        Player playerToRemove = PlayerList.First(p => p.Control == control);

        switch (control)
        {
        case "k":
            if (kStage == SelectStages.Browse)
            {
                kStage         = SelectStages.Disabled;
                kCanHorizontal = false;
                PlayerList.Remove(playerToRemove);
            }
            if (kStage == SelectStages.Chosen)
            {
                kStage         = SelectStages.Browse;
                kCanHorizontal = true;
                pickedClasses.Remove(playerToRemove.Class);
                playerToRemove.Set = false;
            }
            break;

        case "j1":
            if (j1Stage == SelectStages.Browse)
            {
                j1Stage         = SelectStages.Disabled;
                j1CanHorizontal = false;
                PlayerList.Remove(playerToRemove);
            }
            if (j1Stage == SelectStages.Chosen)
            {
                j1Stage         = SelectStages.Browse;
                j1CanHorizontal = true;
                pickedClasses.Remove(playerToRemove.Class);
                playerToRemove.Set = false;
            }
            break;

        case "j2":
            if (j2Stage == SelectStages.Browse)
            {
                j2Stage         = SelectStages.Disabled;
                j2CanHorizontal = false;
                PlayerList.Remove(playerToRemove);
            }
            if (j2Stage == SelectStages.Chosen)
            {
                j2Stage         = SelectStages.Browse;
                j2CanHorizontal = true;
                pickedClasses.Remove(playerToRemove.Class);
                playerToRemove.Set = false;
            }
            break;

        case "j3":
            if (j3Stage == SelectStages.Browse)
            {
                j3Stage         = SelectStages.Disabled;
                j3CanHorizontal = false;
                PlayerList.Remove(playerToRemove);
            }
            if (j3Stage == SelectStages.Chosen)
            {
                j3Stage         = SelectStages.Browse;
                j3CanHorizontal = true;
                pickedClasses.Remove(playerToRemove.Class);
                playerToRemove.Set = false;
            }
            break;

        case "j4":
            if (j4Stage == SelectStages.Browse)
            {
                j4Stage         = SelectStages.Disabled;
                j4CanHorizontal = false;
                PlayerList.Remove(playerToRemove);
            }
            if (j4Stage == SelectStages.Chosen)
            {
                j4Stage         = SelectStages.Browse;
                j4CanHorizontal = true;
                pickedClasses.Remove(playerToRemove.Class);
                playerToRemove.Set = false;
            }
            break;

        default:
            Debug.LogError(control + " not found!");
            break;
        }

        UpdateSelect(PlayerList);
    }