Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        panel.SetActive(false);
        testLog.GetComponent <Text>().text = "test input";
        testLog.GetComponent <Text>().text = GameGlobal.getInstance().getTest();

        gameModel = GameGlobal.getInstance().getGameModel();
        if (gameModel != null)
        {
            //Summon players
            players = gameModel.getPlayers();
            //player 1
            controller1 = loadInstance(players[0].getCharacter(), StartOne.transform.position, false).GetComponent <NewPlayerController>();
            controller1.setItem(players[0].getItemName());
            controller1.tag = "Player";
            //player 2
            controller2 = loadInstance(players[1].getCharacter(), StartTwo.transform.position, false).GetComponent <NewPlayerController>();
            controller2.setItem(players[1].getItemName());
            controller2.tag = "Player 2";

            //Setting

            controller1.playerOne = true;
            controller2.playerOne = false;
            controller2.Flip();
            controller1.setName(players[0].getName());
            controller2.setName(players[1].getName());
        }
    }
    public void onClickStart()
    {
        GameGlobal.getInstance().setTest(player1Name.text + " VS " + player2Name.text);
        List <Player> players        = new List <Player>();
        List <String> characterNames = gameLoader.getCharacterList();
        List <String> itemsNames     = gameLoader.getItemsList();

        players.Add(new Player(
                        player1Name.text,
                        characterNames[player1Select.getCurrCharacter()],
                        itemsNames[player1ItemsSelect.getCurrItem()]
                        ));
        players.Add(new Player(
                        player2Name.text,
                        characterNames[player2Select.getCurrCharacter()],
                        itemsNames[player2ItemsSelect.getCurrItem()]
                        ));
        GameGlobal.getInstance().setGameModel(gameLoader.createGame(players));
        SceneManager.LoadScene(1);
    }