Exemple #1
0
    /**
     *	Unit test of the ListOfPlayers function
     */
    void TestListOfPlayers()
    {
        print("TestListOfPlayers...");
        List <string> playerList;
        PlayerColor   newPlayer;

        CreateFile();

        //Empty list
        playerList = ColorFileManager.ListOfPlayers(path);
        Assert.AreEqual(0, playerList.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 0!"));

        //Add a player
        newPlayer = new PlayerColor("Test", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        playerList = ColorFileManager.ListOfPlayers(path);
        Assert.AreEqual(1, playerList.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 1!"));

        //Add an other player
        newPlayer = new PlayerColor("Test2", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        playerList = ColorFileManager.ListOfPlayers(path);
        Assert.AreEqual(2, playerList.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 2!"));

        //Edit the first player
        newPlayer = new PlayerColor("Test", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        playerList = ColorFileManager.ListOfPlayers(path);
        Assert.AreEqual(2, playerList.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 2!"));

        DeleteFile();
    }
Exemple #2
0
    /**
     *	Unit test of the FindColors function
     */
    void TestFindColors()
    {
        print("TestFindColors...");
        Dictionary <string, Color> data;
        PlayerColor newPlayer;

        CreateFile();

        //Empty file
        data = ColorFileManager.FindColors("Test", path);
        Assert.AreEqual(null, data, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Data should not exist"));

        //Add a player
        newPlayer = new PlayerColor("Test", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        data = ColorFileManager.FindColors("Test", path);
        Assert.AreEqual(anger, data["Anger"], string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Wrong color!"));

        //Add an other player
        newPlayer = new PlayerColor("Test", surprise, anger, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        newPlayer = new PlayerColor("Test2", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        data = ColorFileManager.FindColors("Test", path);
        Assert.AreEqual(surprise, data["Anger"], string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Wrong color!"));

        DeleteFile();
    }
Exemple #3
0
    /**
     *	Unit test of the ResetFile function
     */
    void TestResetFile()
    {
        print("TestResetFile...");
        string[]      data;
        List <string> trueData;

        CreateFile();

        //Empty file
        DataFileManager.ResetFile(path);
        data     = System.IO.File.ReadAllLines(path);
        trueData = FileWithoutBlank(data);
        Assert.AreEqual(1, trueData.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 1!"));

        //Add a player
        PlayerColor newPlayer = new PlayerColor("Test", anger, surprise, joy, sadness);

        ColorFileManager.EditPlayer(newPlayer, path);
        data     = System.IO.File.ReadAllLines(path);
        trueData = FileWithoutBlank(data);
        Assert.AreEqual(2, trueData.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 2!"));

        //Reset the file
        ColorFileManager.ResetFile(path);
        data     = System.IO.File.ReadAllLines(path);
        trueData = FileWithoutBlank(data);
        Assert.AreEqual(1, trueData.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 1!"));

        //Check the first line of the file
        string firstline = "name;angerR;angerG;angerB;surpriseR;surpriseG;surpriseB;joyR;joyG;joyB;sadnessR;sadnessG;sadnessB";

        Assert.AreEqual(firstline, data[0], string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Invalid firstline!"));

        DeleteFile();
    }
Exemple #4
0
    /**
     *	Unit test of the RemovePlayer function
     */
    void TestRemovePlayer()
    {
        print("TestRemovePlayer...");
        PlayerColor newPlayer;

        string[]      data;
        List <string> trueData;

        CreateFile();

        //Empty file
        ColorFileManager.RemovePlayer("Test", path);

        //Player not in the file
        newPlayer = new PlayerColor("Test", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);
        newPlayer = new PlayerColor("Test2", anger, surprise, joy, sadness);
        ColorFileManager.EditPlayer(newPlayer, path);

        ColorFileManager.RemovePlayer("Test3", path);
        data     = System.IO.File.ReadAllLines(path);
        trueData = FileWithoutBlank(data);
        Assert.AreEqual(3, trueData.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 3!"));

        //Player in file
        ColorFileManager.RemovePlayer("Test", path);
        data     = System.IO.File.ReadAllLines(path);
        trueData = FileWithoutBlank(data);
        Assert.AreEqual(2, trueData.Count, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 2!"));

        DeleteFile();
    }
Exemple #5
0
    /**
     *  Find the colors of the player
     */
    void SetPlayerColors()
    {
        Dictionary <string, Color> temp = ColorFileManager.FindColors(PlayerPrefs.GetString("PlayerName"));

        if (temp != null)
        {
            playerColors = temp;
        }
    }
    /**
     *	Set colors for the player in the csv file
     */
    public void SetPlayer()
    {
        selectSound.Play();
        Dictionary <string, Color> playerColor = GUIColorPickerController.GetEmotionColors();
        PlayerColor newPlayer = new PlayerColor(dropdown.options[dropdown.value].text, playerColor["Anger"], playerColor["Surprise"], playerColor["Joy"], playerColor["Sadness"]);

        ColorFileManager.EditPlayer(newPlayer);
        DisabledPlayersSettingsScreen();
        EnabledPlayerMenu();
    }
    /**
     *	Delete a player in the csv file and go back to player selection screen
     */
    public void DeletePlayer()
    {
        selectSound.Play();
        string player = dropdown.options[dropdown.value].text;

        if (!isDefaultPlayer(player))
        {
            ColorFileManager.RemovePlayer(player);
        }
        DisabledPlayersSettingsScreen();
        EnabledPlayerMenu();
    }
    /**
     *	Display the player addition menu
     */
    public void AddPlayerScreen()
    {
        selectSound.Play();
        SetPlayerMenuElementState(false);
        inputField.SetActive(true);
        colorPicker.SetActive(true);
        addPlayerButton.SetActive(true);

        Dictionary <string, Color> playerColor = ColorFileManager.FindColors(defaultPlayer);

        GUIColorPickerController.SetEmotionColors(playerColor);
    }
    /**
     *	Add a new player with his colors in the csv file
     */
    public void AddPlayer()
    {
        selectSound.Play();
        string player = inputField.GetComponent <InputField>().text;

        if (player.Length != 0)
        {
            Dictionary <string, Color> playerColor = GUIColorPickerController.GetEmotionColors();
            PlayerColor newPlayer = new PlayerColor(player, playerColor["Anger"], playerColor["Surprise"], playerColor["Joy"], playerColor["Sadness"]);
            ColorFileManager.EditPlayer(newPlayer);
        }
        DisabledPlayersSettingsScreen();
        EnabledPlayerMenu();
    }
    /**
     *	Display the player settings screen
     */
    public void SetPlayerScreen()
    {
        selectSound.Play();
        string player = dropdown.options[dropdown.value].text;

        playerText.GetComponent <Text>().text = player;
        Dictionary <string, Color> playerColor = ColorFileManager.FindColors(player);

        SetPlayerMenuElementState(false);
        playerText.SetActive(true);
        colorPicker.SetActive(true);
        setPlayerButton.SetActive(true);

        GUIColorPickerController.SetEmotionColors(playerColor);
    }
 /**
  *	Update the dropdown element
  */
 public void UpdateDropdown()
 {
     dropdown.ClearOptions();
     dropdown.AddOptions(sortPlayersList(ColorFileManager.ListOfPlayers()));
     dropdown.value = searchDefaultIndex();
 }