Exemple #1
0
        public void TestPlayerGeneratorMapIDToSkin()
        {
            // ID 1 to Material 1
            Material expectedSkin = PlayerGenerator.materials[1];
            int      playerID     = 1;

            Material receivedSkin = PlayerGenerator.mapIDToSkin(playerID);

            Assert.AreSame(expectedSkin, receivedSkin);

            // ID 3 to Material 3
            expectedSkin = PlayerGenerator.materials[3];
            playerID     = 3;

            receivedSkin = PlayerGenerator.mapIDToSkin(playerID);

            Assert.AreSame(expectedSkin, receivedSkin);

            // ID materials.Length to Material 0
            expectedSkin = PlayerGenerator.materials[0];
            playerID     = PlayerGenerator.numberOfSkins;

            receivedSkin = PlayerGenerator.mapIDToSkin(playerID);

            Assert.AreSame(expectedSkin, receivedSkin);

            // ID materials.Length + 1 to Material 1
            expectedSkin = PlayerGenerator.materials[1];
            playerID     = PlayerGenerator.numberOfSkins + 1;

            receivedSkin = PlayerGenerator.mapIDToSkin(playerID);

            Assert.AreSame(expectedSkin, receivedSkin);
        }
Exemple #2
0
    public static GameObject GeneratePlayer(PlayerDTO playerDTO, GameObject playerFolder = null)
    {
        playerFolder = playerFolder ?? playersFolder;

        GameObject player = Object.Instantiate(
            PlayerGenerator.characterPrefab,
            new Vector3(playerDTO.location.x, 0, playerDTO.location.y),
            Quaternion.identity) as GameObject;

        player.transform.SetParent(playerFolder.transform, false);
        player.transform.Find("Dee").GetComponent <Renderer>().material = PlayerGenerator.mapIDToSkin(playerDTO.id);

        return(player);
    }