Exemple #1
0
    public static Player Create(PlayerParameters parameters)
    {
        GameObject playerObject = new GameObject("Player_" + parameters.HeroClass.Name());

        playerObject.transform.localScale       = Vector3.one * 50f;
        playerObject.transform.localEulerAngles = new Vector3(90f, 0f, 0f);
        playerObject.transform.position         = parameters.PlayerPosition;

        Player player = playerObject.AddComponent <Player>();

        player.Deck = parameters.Deck;

        foreach (BaseCard card in player.Deck)
        {
            card.Player = player;
        }

        player.ManaController  = ManaController.Create(player, parameters.ManaPosition, parameters.DisplayCrystals);
        player.HandController  = HandController.Create(player, parameters.HandPosition, parameters.HandInverted);
        player.BoardController = BoardController.Create(player, parameters.BoardPosition);

        player.Hero = new Hero()
        {
            Player     = player,
            Class      = parameters.HeroClass,
            BaseHealth = parameters.HeroHealth,
            BaseArmor  = parameters.HeroArmor
        };

        player.Hero.Initialize();

        player.HeroController = HeroController.Create(player.Hero);

        player.Hero.HeroPower = (BaseHeroPower)Activator.CreateInstance(parameters.HeroPower, new object[] { player.Hero });

        return(player);
    }