Example #1
0
 private void Start()
 {
     gameManager   = FindObjectOfType <GameManager>();
     manaPool      = FindObjectOfType <ManaPool>();
     turnManager   = FindObjectOfType <TurnManager>();
     minionManager = FindObjectOfType <MinionManager>();
 }
 public CollectionManager(MegaManager newMegaMan)
 {
     RED_PLACEMENT   = new Vector3(1.77f, -2.19f, 0);
     GREEN_PLACEMENT = RED_PLACEMENT + Vector3.right * TOKEN_SEPARATION;
     BLUE_PLACEMENT  = GREEN_PLACEMENT + Vector3.right * TOKEN_SEPARATION;
     ManaPool        = new ManaPool();
 }
Example #3
0
 public Player(Deck deck, IPlayerAI playerAI, int startingLife = 20, int firstMulligan = 6)
 {
     _LandCountAllowedToPlayEachTurn = 1;
     _NextMulliganCardCount          = firstMulligan;
     Deck = deck ?? throw new ArgumentNullException();
     foreach (var card in Deck.Cards)
     {
         foreach (var ability in card.Abilities)
         {
             ability.Owner = this;
         }
     }
     // 103.3 Each player begins the game with a starting life total of 20.
     StartingLife = startingLife;
     Life         = StartingLife;
     // 103.1 At the start of a game, the player's decks become their libraries.
     Library      = new Library(Deck.Cards);
     Hand         = new Hand();
     Graveyard    = new Graveyard();
     Exile        = new Exile();
     Battlefield  = new Battlefield();
     OutOfTheGame = new OutOfTheGame();
     AI           = playerAI ?? throw new ArgumentNullException();
     AI.Player    = this; // TODO : Can we do without this back reference?
     ManaPool     = new ManaPool();
 }
    public void Subtract(ManaCost manaCost)
    {
        if (!ManaPool.CheckIfCanAfford(manaCost))
        {
            Debug.Log("Don't try and subtract mana, when you can't afford it!");
            return;
        }

        ManaPool -= manaCost;
        List <Token> tokens = new List <Token>();

        for (int r = RedManaTokens.Count - 1; r > ManaPool.Red - 1; r--)
        {
            tokens.Add(PullOutToken(RedManaTokens[r]));
        }
        for (int g = GreenManaTokens.Count - 1; g > ManaPool.Green - 1; g--)
        {
            tokens.Add(PullOutToken(GreenManaTokens[g]));
        }
        for (int b = BlueManaTokens.Count - 1; b > ManaPool.Blue - 1; b--)
        {
            tokens.Add(PullOutToken(BlueManaTokens[b]));
        }

        GridManager.TokenBag.AddTokens(tokens);
    }
Example #5
0
 public void Dispose()
 {
     ManaPool.Dispose();
     YourBattlefield.Dispose();
     OpponentsBattlefield.Dispose();
     Zones.Dispose();
     You.Dispose();
     Opponent.Dispose();
 }
Example #6
0
    private void Awake()
    {
        this.manaContainer = this.transform.Find("ManaContainer");
        this.hint          = this.transform.Find("Hint").gameObject;

        if (this.gameObject.name == "PlayerManaPool")
        {
            ManaPool.playerInstance = this;
        }
    }
Example #7
0
    void Start()
    {
        turnText      = GameObject.Find("TurnText").GetComponent <Text>();
        manaText      = GameObject.Find("ManaText").GetComponent <Text>();
        confirmButton = GameObject.Find("ConfirmButton").GetComponent <Button>();
        m_manapool    = GameObject.Find("ManaTransform").GetComponent <ManaPool>();

        PlayerSetting();
        FieldSetting();
        stateMachine.Init(instance, new SettingLogic());
        SoundManager.Instance.PlayBGM(1);
    }
Example #8
0
        public void TestManaPool()
        {
            var manapool = new ManaPool();

            manapool.AddMana(ManaSymbol.Red);
            Assert.AreEqual(manapool.Count, 1);
            manapool.AddMana(ManaSymbol.Green, ManaSymbol.Green);
            manapool.RemoveMana(ManaSymbol.Red, ManaSymbol.Green);
            Assert.AreEqual(manapool.Count, 1);
            foreach (var mana in manapool)
            {
                Assert.AreEqual(mana, ManaSymbol.Green);
            }
            manapool.Empty();
            foreach (var mana in manapool)
            {
                Assert.Fail();
            }
        }
Example #9
0
    public void SpawnManaPool()
    {
        GameObject manaPanel = Instantiate(pfManaPanel, Match.Get().transform);

        manapool = manaPanel.GetComponent <ManaPool>();

        manapool.SetPlayer(this);

        //TODO: Change this, all this, to work with networking
        if (id == 0)
        {
            manaPanel.transform.position = new Vector3(0f, 2.85f, -0.4f);
        }
        else
        {
            //move it offscreen for now
            manaPanel.transform.position = new Vector3(100f, 100f, -0.4f);
        }
    }
Example #10
0
 public void ResetPlayer()
 {
     AdditionalTurnCount = 0;
     Battlefield         = new Battlefield();
     Command             = new Command();
     Graveyard           = new Graveyard();
     Hand        = new Hand();
     Library     = new Library();
     Life        = 20;
     LoseMessage = @"";
     ManaPool    = new ManaPool();
     if (Deck != null)
     {
         SelectDeck(Deck);
     }
     else
     {
         Deck = new Deck();
     }
 }
Example #11
0
        public void PayManaCost(Card card)
        {
            var remainingManaCost    = card.TypedManaCost.Clone();
            var availableManaEffects = GetAvailableAbilities <ManaActivatedAbility>()
                                       .Select(a => a.GetEffect <AddToManaPoolEffect>())
                                       .Where(e => e != null)
                                       .ToList();

            // TODO : take into account !e.AvailableMana.ProducesOnlyOneMana...

            // Pay Colorless
            if (remainingManaCost.Colorless > 0)
            {
                var onlyOneManaEffect = availableManaEffects
                                        .Where(e => e.AvailableMana.ProducesOnlyOneMana)
                                        .Where(e => e.AvailableMana.Colorless > 0 || e.AvailableMana.AnyType > 0)
                                        .OrderBy(e => e.AvailableMana.Colorless > 0)
                                        .ThenBy(e => e.AvailableMana.AnyType > 0)
                                        .ToList();
                while (remainingManaCost.Colorless > 0)
                {
                    var ability = (IActivatedAbility)onlyOneManaEffect[0].Ability;
                    if (ability.IsAvailable)
                    {
                        ability.Activate();
                    }
                    onlyOneManaEffect.RemoveAt(0);
                    remainingManaCost.Colorless--;
                }
            }
            // Pay White
            if (remainingManaCost.White > 0)
            {
                var onlyOneManaEffect = availableManaEffects
                                        .Where(e => e.AvailableMana.ProducesOnlyOneMana)
                                        .Where(e => e.AvailableMana.White > 0 || e.AvailableMana.AnyColor > 0 || e.AvailableMana.AnyType > 0)
                                        .OrderBy(e => e.AvailableMana.White > 0)
                                        .ThenBy(e => e.AvailableMana.AnyColor > 0)
                                        .ThenBy(e => e.AvailableMana.AnyType > 0)
                                        .ToList();
                while (remainingManaCost.White > 0)
                {
                    var ability = (IActivatedAbility)onlyOneManaEffect[0].Ability;
                    if (ability.IsAvailable)
                    {
                        ability.Activate();
                    }
                    onlyOneManaEffect.RemoveAt(0);
                    remainingManaCost.White--;
                }
            }
            // Pay Blue
            if (remainingManaCost.Blue > 0)
            {
                var onlyOneManaEffect = availableManaEffects
                                        .Where(e => e.AvailableMana.ProducesOnlyOneMana)
                                        .Where(e => e.AvailableMana.Blue > 0 || e.AvailableMana.AnyColor > 0 || e.AvailableMana.AnyType > 0)
                                        .OrderBy(e => e.AvailableMana.Blue > 0)
                                        .ThenBy(e => e.AvailableMana.AnyColor > 0)
                                        .ThenBy(e => e.AvailableMana.AnyType > 0)
                                        .ToList();
                while (remainingManaCost.Blue > 0)
                {
                    var ability = (IActivatedAbility)onlyOneManaEffect[0].Ability;
                    if (ability.IsAvailable)
                    {
                        ability.Activate();
                    }
                    onlyOneManaEffect.RemoveAt(0);
                    remainingManaCost.Blue--;
                }
            }
            // Pay Black
            if (remainingManaCost.Black > 0)
            {
                var onlyOneManaEffect = availableManaEffects
                                        .Where(e => e.AvailableMana.ProducesOnlyOneMana)
                                        .Where(e => e.AvailableMana.Black > 0 || e.AvailableMana.AnyColor > 0 || e.AvailableMana.AnyType > 0)
                                        .OrderBy(e => e.AvailableMana.Black > 0)
                                        .ThenBy(e => e.AvailableMana.AnyColor > 0)
                                        .ThenBy(e => e.AvailableMana.AnyType > 0)
                                        .ToList();
                while (remainingManaCost.Black > 0)
                {
                    var ability = (IActivatedAbility)onlyOneManaEffect[0].Ability;
                    if (ability.IsAvailable)
                    {
                        ability.Activate();
                    }
                    onlyOneManaEffect.RemoveAt(0);
                    remainingManaCost.Black--;
                }
            }
            // Pay Red
            if (remainingManaCost.Red > 0)
            {
                var onlyOneManaEffect = availableManaEffects
                                        .Where(e => e.AvailableMana.ProducesOnlyOneMana)
                                        .Where(e => e.AvailableMana.Red > 0 || e.AvailableMana.AnyColor > 0 || e.AvailableMana.AnyType > 0)
                                        .OrderBy(e => e.AvailableMana.Red > 0)
                                        .ThenBy(e => e.AvailableMana.AnyColor > 0)
                                        .ThenBy(e => e.AvailableMana.AnyType > 0)
                                        .ToList();
                while (remainingManaCost.Red > 0)
                {
                    var ability = (IActivatedAbility)onlyOneManaEffect[0].Ability;
                    if (ability.IsAvailable)
                    {
                        ability.Activate();
                    }
                    onlyOneManaEffect.RemoveAt(0);
                    remainingManaCost.Red--;
                }
            }
            // Pay Green
            if (remainingManaCost.Green > 0)
            {
                var onlyOneManaEffect = availableManaEffects
                                        .Where(e => e.AvailableMana.ProducesOnlyOneMana)
                                        .Where(e => e.AvailableMana.Green > 0 || e.AvailableMana.AnyColor > 0 || e.AvailableMana.AnyType > 0)
                                        .OrderBy(e => e.AvailableMana.Green > 0)
                                        .ThenBy(e => e.AvailableMana.AnyColor > 0)
                                        .ThenBy(e => e.AvailableMana.AnyType > 0)
                                        .ToList();
                while (remainingManaCost.Green > 0)
                {
                    var ability = (IActivatedAbility)onlyOneManaEffect[0].Ability;
                    if (ability.IsAvailable)
                    {
                        ability.Activate();
                    }
                    onlyOneManaEffect.RemoveAt(0);
                    remainingManaCost.Green--;
                }
            }
            // Pay Generic
            if (remainingManaCost.Generic > 0)
            {
                var onlyOneManaEffect = availableManaEffects
                                        .Where(e => e.AvailableMana.ProducesOnlyOneMana)
                                        .Where(e => e.Ability.IsAvailable)
                                        .ToList();
                while (remainingManaCost.Generic > 0)
                {
                    var ability = (IActivatedAbility)onlyOneManaEffect[0].Ability;
                    if (ability.IsAvailable)
                    {
                        ability.Activate();
                    }
                    onlyOneManaEffect.RemoveAt(0);
                    remainingManaCost.Generic--;
                }
            }
            // Pay X
            if ((remainingManaCost.XValue * remainingManaCost.X) > 0)
            {
                var onlyOneManaEffect = availableManaEffects
                                        .Where(e => e.AvailableMana.ProducesOnlyOneMana)
                                        .Where(e => e.Ability.IsAvailable)
                                        .ToList();
                for (int i = 0; i < remainingManaCost.X; i++)
                {
                    var remainingX = remainingManaCost.XValue;
                    while (remainingX > 0)
                    {
                        var ability = (IActivatedAbility)onlyOneManaEffect[0].Ability;
                        if (ability.IsAvailable)
                        {
                            ability.Activate();
                        }
                        onlyOneManaEffect.RemoveAt(0);
                        remainingX--;
                    }
                }
            }

            ManaPool.Pay(card.TypedManaCost);
        }
Example #12
0
 public void EmptyManaPool()
 {
     ManaPool.EmptyManaPool();
 }
Example #13
0
 public Delta[] GetManaDeltas()
 {
     return(ManaPool.GetAddDeltas(6 - Lives));
 }
Example #14
0
 void Start()
 {
     playerTurn = true;
     manaPool   = FindObjectOfType <ManaPool>();
 }