void SetColor()
    {
        var swap = GetComponent <SwapTextureFromImage> ();

        swap.targetColors = CharacterColors.GetPalette(0);
        swap.swapColors   = CharacterColors.GetPalette(PlayerColorIndex);
    }
Exemplo n.º 2
0
    PlayerInput CreatePlayer(PlayerInputConfiguration configuration)
    {
        if (players.Count < maxPlayers)
        {
            var playerPosition = playerPositions[configuration.PlayerColorIndex];
            var gameObject     = (GameObject)Instantiate(playerPrefabs[configuration.PlayerColorIndex], playerPosition, Quaternion.identity);

            var swap = gameObject.GetComponent <SwapTexture> ();
            swap.swapColors = CharacterColors.GetPalette(configuration.PlayerColorIndex);

            var player = gameObject.GetComponent <PlayerInput>();

            player.Actions = configuration.Actions;

            players.Add(player);
            gameObject.name     = "Player" + configuration.PlayerSuffix;
            player.PlayerSuffix = configuration.PlayerSuffix;
            return(player);
        }
        return(null);
    }