コード例 #1
0
ファイル: LobbyView2D.cs プロジェクト: Woonsama/2020Weekend
    public void CreateCharacter(string prefabName = "")

    {
        var curUserData = UserManager.Instance.GetCurUserData();

        if (prefabName == "")
        {
            prefabName = curUserData.setCharPrefabName;
        }

        GameObject loadObj = Resources.Load("Prefab/" + prefabName) as GameObject;
        GameObject gameObj = GameObject.Instantiate(loadObj);

        LobbyCharacter lobbyCharacter = gameObj.GetComponent <LobbyCharacter>();

        gameObj.transform.SetParent(_characterRoot.transform);
        gameObj.transform.localScale       = Vector3.one;
        gameObj.transform.localPosition    = Vector3.zero;
        gameObj.transform.localEulerAngles = new Vector3(0, 180, 0);
        lobbyCharacter.SetAnim(LobbyCharacter.AnimType.Dance);

        if (curUserData.setHatPrefabName != "")
        {
            lobbyCharacter.CreateAcc(LobbyCharacter.AccessorieType.Hat, curUserData.setHatPrefabName);
        }

        UserManager.Instance.SetCharData(prefabName);
    }
コード例 #2
0
    public void OnClickAccItem(LobbyCharacter.AccessorieType acType, string prefabName, int index)
    {
        if (_currentSelectItemIndex != -1)
        {
            _itemDic[_currentSelectItemIndex].DisHighlightItem();
        }

        if (_lobbyCharacter == null)
        {
            foreach (Transform tr in _characterRoot.transform)
            {
                var lobbyChar = tr.GetComponent <LobbyCharacter>();
                if (lobbyChar != null)
                {
                    _lobbyCharacter = lobbyChar;
                    break;
                }
            }
        }

        if (_lobbyCharacter != null)
        {
            _lobbyCharacter.CreateAcc(acType, prefabName);
            UserManager.Instance.SetHatData(prefabName);
        }

        _currentSelectItemIndex = index;
        _itemDic[_currentSelectItemIndex].HighlightItem();
    }
コード例 #3
0
 void BuildLobbyCharacter()
 {
     headerText.text = gameManager.playerName;
     readyButtonText.text = "Ready";
     var obj = Network.Instantiate(lobbyCharacterPrefab,
                                   new Vector3(),
                                   new Quaternion(),
                                   (int)NetworkGroup.CharacterLobby) as GameObject;
     lobbyCharacter = obj.GetComponent<LobbyCharacter>();
 }
コード例 #4
0
    void BuildLobbyCharacter()
    {
        headerText.text      = gameManager.playerName;
        readyButtonText.text = "Ready";
        var obj = Network.Instantiate(lobbyCharacterPrefab,
                                      new Vector3(),
                                      new Quaternion(),
                                      (int)NetworkGroup.CharacterLobby) as GameObject;

        lobbyCharacter = obj.GetComponent <LobbyCharacter>();
    }
コード例 #5
0
    void JoinGame()
    {
        for (int i = 0; i < 4; i++)
        {
            LobbyCharacter thisChar = _lobby[i];
            if (!thisChar.joined && Input.GetButtonDown("A_" + (i + 1)))
            {
                _lobby[i].joined = true;
                numPlayersJoined++;
                Clicker.Instance.Click();
                print("joined");
            }


            if (Input.GetButtonDown("Y_" + (i + 1)))
            {
                _lobby[i].inverted = !_lobby[i].inverted;
                //PlayerPrefs.SetInt("P"+(i+1)+"Inverted", -1);
                print("Invert controsl for " + (i + 1));
                Clicker.Instance.Click();
            }

            //game mode
            if (Input.GetButtonDown("LB_" + (i + 1)))
            {
                IncrementGameMode(false);

                Clicker.Instance.Click();
            }
            else if (Input.GetButtonDown("RB_" + (i + 1)))
            {
                IncrementGameMode(true);
                Clicker.Instance.Click();
            }


            if (numPlayersJoined > 1 || (numPlayersJoined == 1 && Application.isEditor))
            {
                if (Input.GetButtonDown("Start_" + (i + 1)))
                {
                    StartCoroutine(ShowObjectiveThenStartGame());
                    PlayerPrefs.Save();
                    state = GameState.ShowObjective;
                    Clicker.Instance.Click();
                }
            }
        }
    }
コード例 #6
0
    void JoinGameGUI()
    {
        //select number of players
        float unit = Screen.width / 20;

        //float vUnit = Screen.height/10;

        //background
        GUI.Box(new Rect(Screen.width / 2 - unit * 7.5f, Screen.height * 0.05f, unit * 15, Screen.height * 0.9f), "");

        GUI.Box(new Rect(0, 0, Screen.width / 2, Screen.height / 2), "", joinGameSkin.GetStyle("Red"));
        GUI.Box(new Rect(Screen.width / 2, 0, Screen.width / 2, Screen.height / 2), "", joinGameSkin.GetStyle("Blue"));
        GUI.Box(new Rect(0, Screen.height / 2, Screen.width / 2, Screen.height / 2), "", joinGameSkin.GetStyle("Green"));
        GUI.Box(new Rect(Screen.width / 2, Screen.height / 2, Screen.width / 2, Screen.height / 2), "", joinGameSkin.GetStyle("Yellow"));

        float startingX = Screen.width / 4;
        float startingY = Screen.height / 6;

        joinGameSkin.GetStyle("JoinText").normal.textColor = Color.black;
        for (int i = 0; i < 4; i++)
        {
            LobbyCharacter thisChar = _lobby[i];

            string playerName = "";
            joinGameSkin.GetStyle("JoinText").normal.textColor = Color.black;

            string invertedText = "";
            if (!thisChar.inverted)
            {
                invertedText = "Y LOOK NORMAL";
            }
            else
            {
                invertedText = "Y LOOK INVERTED";
            }

            switch (i)
            {
            case 0:
                //red
                playerName = "RED\n";

                GUI.Box(new Rect(startingX - 2.5f * unit, startingY - unit, unit * 5, unit * 2f), playerName, joinGameSkin.GetStyle("JoinText"));

                GUI.Box(new Rect(startingX - 2.5f * unit + unit * 0.5f, startingY - unit + unit * 0.9f, unit * 5, unit * 2f), invertedText, joinGameSkin.GetStyle("JoinText"));

                GUI.Box(new Rect(startingX - 3.25f * unit - unit * 0.13f, startingY - unit + unit * 1.35f, unit * 1, unit * 1f), "", controllerIcons.GetStyle("Y"));

                break;

            case 1:
                playerName = "BLUE\n";
                GUI.Box(new Rect(startingX + Screen.width / 2 - 2.5f * unit, startingY - unit, unit * 5, unit * 2f), playerName, joinGameSkin.GetStyle("JoinText"));

                GUI.Box(new Rect(startingX + Screen.width / 2 - 2.5f * unit + unit * 0.5f, startingY - unit + unit * 0.9f, unit * 5, unit * 2f), invertedText, joinGameSkin.GetStyle("JoinText"));

                GUI.Box(new Rect(startingX + Screen.width / 2 - 3.25f * unit - unit * 0.1f, startingY - unit + unit * 1.35f, unit * 1, unit * 1f), "", controllerIcons.GetStyle("Y"));

                break;

            case 2:
                playerName = "GREEN\n";
                GUI.Box(new Rect(startingX - 2.5f * unit, startingY - unit + Screen.height / 2, unit * 5, unit * 2f), playerName, joinGameSkin.GetStyle("JoinText"));

                GUI.Box(new Rect(startingX - 2.5f * unit + unit * 0.5f, startingY + Screen.height / 2 - unit + unit * 0.9f, unit * 5, unit * 2f), invertedText, joinGameSkin.GetStyle("JoinText"));

                GUI.Box(new Rect(startingX - 3.25f * unit - unit * 0.13f, startingY + Screen.height / 2 - unit + unit * 1.35f, unit * 1, unit * 1f), "", controllerIcons.GetStyle("Y"));

                break;

            case 3:
                playerName = "YELLOW\n";
                GUI.Box(new Rect(startingX + Screen.width / 2 - 2.5f * unit, startingY - unit + Screen.height / 2, unit * 5, unit * 2f), playerName, joinGameSkin.GetStyle("JoinText"));

                GUI.Box(new Rect(startingX + Screen.width / 2 - 2.5f * unit + unit * 0.5f, startingY + Screen.height / 2 - unit + unit * 0.9f, unit * 5, unit * 2f), invertedText, joinGameSkin.GetStyle("JoinText"));

                GUI.Box(new Rect(startingX + Screen.width / 2 - 3.25f * unit - unit * 0.13f, startingY - unit + Screen.height / 2 + unit * 1.35f, unit * 1, unit * 1f), "", controllerIcons.GetStyle("Y"));

                break;
            }

            string joinedText = "";


            if (thisChar.joined)
            {
                joinedText += "READY";
                joinGameSkin.GetStyle("JoinText").normal.textColor = Color.white;
            }
            else
            {
                joinedText += "PRESS \t\t\t\t\t TO JOIN";
                joinGameSkin.GetStyle("JoinText").normal.textColor = Color.black;
            }


            switch (i)
            {
            case 0:
                //red
                playerName = "RED\n";

                GUI.Box(new Rect(startingX - 2.5f * unit, startingY - unit + unit + unit, unit * 5, unit * 2f), joinedText, joinGameSkin.GetStyle("JoinText"));


                if (!thisChar.joined)
                {
                    GUI.Box(new Rect(startingX - 2.5f * unit + unit * 1.9f, startingY - unit + unit * 1.5f + unit, unit * 1, unit * 1f), "", controllerIcons.GetStyle("A"));
                }

                break;

            case 1:
                playerName = "BLUE\n";
                GUI.Box(new Rect(startingX + Screen.width / 2 - 2.5f * unit, startingY - unit + unit + unit, unit * 5, unit * 2f), joinedText, joinGameSkin.GetStyle("JoinText"));


                if (!thisChar.joined)
                {
                    GUI.Box(new Rect(startingX + Screen.width / 2 - 2.5f * unit + unit * 1.9f, startingY - unit + unit * 1.5f + unit, unit * 1, unit * 1f), "", controllerIcons.GetStyle("A"));
                }

                break;

            case 2:
                playerName = "GREEN\n";
                GUI.Box(new Rect(startingX - 2.5f * unit, startingY - unit + Screen.height / 2 + unit + unit, unit * 5, unit * 2f), joinedText, joinGameSkin.GetStyle("JoinText"));


                if (!thisChar.joined)
                {
                    GUI.Box(new Rect(startingX - 2.5f * unit + unit * 1.9f, startingY - unit + Screen.height / 2 + unit * 1.5f + unit, unit * 1, unit * 1f), "", controllerIcons.GetStyle("A"));
                }

                break;

            case 3:
                playerName = "YELLOW\n";
                GUI.Box(new Rect(startingX + Screen.width / 2 - 2.5f * unit, startingY - unit + Screen.height / 2 + unit + unit, unit * 5, unit * 2f), joinedText, joinGameSkin.GetStyle("JoinText"));


                if (!thisChar.joined)
                {
                    GUI.Box(new Rect(startingX + Screen.width / 2 - 2.5f * unit + unit * 1.9f, startingY - unit + Screen.height / 2 + unit * 1.5f + unit, unit * 1, unit * 1f), "", controllerIcons.GetStyle("A"));
                }

                break;
            }
        }

        GUI.Box(new Rect(0, Screen.height / 2 - 3, Screen.width, 6), "", scoreSkin.GetStyle("Box"));
        GUI.Box(new Rect(Screen.width / 2 - 3, 0, 6, Screen.height), "", scoreSkin.GetStyle("Box"));

        string startText;

        if (numPlayersJoined > 1)
        {
            startText = "PRESS START";
        }
        else
        {
            startText = "WAIT FOR PLAYERS";
        }

        GUI.Box(new Rect(Screen.width / 2 - unit * 3.5f, Screen.height / 2 - 0.05f * Screen.height, unit * 7, Screen.height * 0.1f), startText, pauseSkin.GetStyle("Title"));

        //game mode selection
        GUI.Box(new Rect(Screen.width / 2 - unit * 3.5f, 0, unit * 7, Screen.height * 0.05f), CurrentGameMode.ToString(), pauseSkin.GetStyle("GameMode"));

        GUI.Box(new Rect(Screen.width / 2 - unit * 3.5f, Screen.height * 0.95f, unit * 7, Screen.height * 0.05f), "SCORE LIMIT " + scoreToWin, pauseSkin.GetStyle("GameMode"));

        //ICONS
        GUI.Box(new Rect(Screen.width / 2 - unit * 2.6f - unit * 0.8f, -Screen.height * 0.0105f, unit * 0.8f, unit * 0.8f), "", controllerIcons.GetStyle("LB"));
        GUI.Box(new Rect(Screen.width / 2 + unit * 2.6f, -Screen.height * 0.0105f, unit * 0.8f, unit * 0.8f), "", controllerIcons.GetStyle("RB"));

        GUI.Box(new Rect(Screen.width / 2 - unit * 2.3f, Screen.height * 0.955f, unit * 0.5f, unit * 0.5f), "", controllerIcons.GetStyle("Dpad"));


        //each player can say they're playing, increasing numPlayersJoined by 1, then set num players

        //JoinGameControlsGUI();
    }
コード例 #7
0
 public void Set(LobbyCharacter lobbyCharacter)
 {
     playerName = lobbyCharacter.playerName;
     color = lobbyCharacter.color.ToColor();
     isReady = lobbyCharacter.isReady;
 }
コード例 #8
0
 public void Set(LobbyCharacter lobbyCharacter)
 {
     playerName = lobbyCharacter.playerName;
     color      = lobbyCharacter.color.ToColor();
     isReady    = lobbyCharacter.isReady;
 }