Esempio n. 1
0
 public void UnlockCrystals(int numCrystals)
 {
     if (this.IsFriendlySide())
     {
         ManaCrystalMgr.Get().UnlockCrystals(numCrystals);
     }
 }
Esempio n. 2
0
 public void DestroyManaCrystal(int numCrystals)
 {
     if (this.IsFriendlySide())
     {
         ManaCrystalMgr.Get().DestroyManaCrystals(numCrystals);
     }
 }
Esempio n. 3
0
 public void SpendManaCrystal(int numCrystals)
 {
     if (this.IsFriendlySide())
     {
         ManaCrystalMgr.Get().SpendManaCrystals(numCrystals);
     }
 }
Esempio n. 4
0
 public void CancelAllProposedMana(Entity entity)
 {
     if (this.IsFriendlySide())
     {
         ManaCrystalMgr.Get().CancelAllProposedMana(entity);
     }
 }
Esempio n. 5
0
 public void AddTempManaCrystal(int numCrystals)
 {
     if (this.IsFriendlySide())
     {
         ManaCrystalMgr.Get().AddTempManaCrystals(numCrystals);
     }
 }
Esempio n. 6
0
 public void HandleSameTurnOverloadChanged(int crystalsChanged)
 {
     if (this.IsFriendlySide())
     {
         ManaCrystalMgr.Get().HandleSameTurnOverloadChanged(crystalsChanged);
     }
 }
Esempio n. 7
0
 public void AddManaCrystal(int numCrystals, bool isTurnStart)
 {
     if (this.IsFriendlySide())
     {
         ManaCrystalMgr.Get().AddManaCrystals(numCrystals, isTurnStart);
     }
 }
 public void MarkAsOwedForOverload(bool immediatelyLockForOverload)
 {
     if (this.IsOwedForOverload())
     {
         if (immediatelyLockForOverload)
         {
             this.PayOverload();
         }
     }
     else
     {
         GameObject obj2 = (GameObject)GameUtils.InstantiateGameObject((string)ManaCrystalMgr.Get().manaLockPrefab, base.gameObject, false);
         if (UniversalInputManager.UsePhoneUI != null)
         {
             obj2.transform.localRotation = Quaternion.Euler(Vector3.zero);
             obj2.transform.localPosition = new Vector3(0f, 0.1f, 0f);
             float x = 1.1f;
             obj2.transform.localScale = new Vector3(x, x, x);
         }
         else
         {
             float num2 = 1f / base.transform.localScale.x;
             obj2.transform.localScale = new Vector3(num2, num2, num2);
         }
         this.m_overloadOwedSpell = obj2.transform.FindChild("Lock_Mana").GetComponent <Spell>();
         this.m_overloadOwedSpell.RemoveStateFinishedCallback(new Spell.StateFinishedCallback(this.OnOverloadUnlockedAnimComplete));
         if (immediatelyLockForOverload)
         {
             this.m_overloadOwedSpell.AddStateFinishedCallback(new Spell.StateFinishedCallback(this.OnOverloadBirthCompletePayOverload));
         }
         this.m_overloadOwedSpell.ActivateState(SpellStateType.BIRTH);
     }
 }
Esempio n. 9
0
 public void ProposeManaCrystalUsage(Entity entity)
 {
     if (this.IsFriendlySide())
     {
         ManaCrystalMgr.Get().ProposeManaCrystalUsage(entity);
     }
 }
 private void Awake()
 {
     s_instance = this;
     if (base.gameObject.GetComponent <AudioSource>() == null)
     {
         base.gameObject.AddComponent <AudioSource>();
     }
 }
    public void MarkAsTemp()
    {
        this.m_isTemp = true;
        ManaCrystalMgr mgr = ManaCrystalMgr.Get();

        this.gem.GetComponentInChildren <MeshRenderer>().material = mgr.tempManaCrystalMaterial;
        this.gem.transform.FindChild("Proposed_Quad").gameObject.GetComponent <MeshRenderer>().material = mgr.tempManaCrystalProposedQuadMaterial;
    }
Esempio n. 12
0
 private void InitManaCrystalMgr()
 {
     if (this.IsFriendlySide())
     {
         int tag               = base.GetTag(GAME_TAG.TEMP_RESOURCES);
         int numCrystals       = base.GetTag(GAME_TAG.RESOURCES);
         int shownChangeAmount = base.GetTag(GAME_TAG.RESOURCES_USED);
         int num4              = base.GetTag(GAME_TAG.OVERLOAD_OWED);
         ManaCrystalMgr.Get().AddManaCrystals(numCrystals, false);
         ManaCrystalMgr.Get().AddTempManaCrystals(tag);
         ManaCrystalMgr.Get().UpdateSpentMana(shownChangeAmount);
         ManaCrystalMgr.Get().MarkCrystalsOwedForOverload(num4);
     }
 }
 public void SetHandEnlarged(bool enlarged)
 {
     this.m_handEnlarged = enlarged;
     if (enlarged)
     {
         base.gameObject.transform.localPosition = this.m_enlargedHandPosition;
         base.gameObject.transform.localScale    = this.m_enlargedHandScale;
         ManaCrystalMgr.Get().ShowPhoneManaTray();
     }
     else
     {
         base.gameObject.transform.localPosition = this.m_startingPosition;
         base.gameObject.transform.localScale    = this.m_startingScale;
         ManaCrystalMgr.Get().HidePhoneManaTray();
     }
     this.UpdateCenterAndWidth();
     this.m_handMoving = true;
     this.UpdateLayout(-1, true);
     this.m_handMoving = false;
 }
 private void OnDestroy()
 {
     s_instance = null;
 }
Esempio n. 15
0
        private static List <BotPlaysResult> GetValidPermutations(List <BotPlay[]> perms)
        {
            List <BotPlaysResult> validPerms = new List <BotPlaysResult>();

            foreach (BotPlay[] playList in perms)
            {
                int            mana          = ManaCrystalMgr.Get().GetSpendableManaCrystals();
                List <VCard>   vBoard        = GetVirtualBoard();
                List <VCard>   vHand         = GetVirtualHand();
                List <VCard>   vSectetZone   = GetVirtualSecretZone();
                List <BotPlay> validPlayList = new List <BotPlay>();

                foreach (BotPlay play in playList)
                {
                    VCard vCard       = GetVCardInList(vHand, play.Source) ?? GetVCardInList(vBoard, play.Source);
                    VCard targetVCard = GetVCardInList(vBoard, play.Target);

                    if (vCard != null && play.IsSummonOnly && Found(vHand, play.Source))//inHand
                    {
                        if (vCard.Cost > mana || AllyMinionsCount(vBoard) >= 7)
                        {
                            continue;
                        }

                        vHand.Remove(vCard);

                        if (play.Source.GetEntity().IsMinion())
                        {
                            vCard.PlayedThisTurn = true;
                            vBoard.Add(vCard);
                        }
                        else if (play.Source.GetEntity().IsSecret())
                        {
                            vSectetZone.Add(vCard);
                        }
                        mana -= vCard.Cost;
                        validPlayList.Add(play);
                    }

                    if (vCard != null && targetVCard != null && play.IsTargeted && Found(vBoard, play.Target)) //onBoard
                    {
                        if (Found(vHand, play.Source) && play.Source.GetEntity().IsSpell())                    //spell in hand
                        {
                            if (vCard.Cost > mana || targetVCard.IsImmune || targetVCard.IsStealthed)
                            {
                                continue;
                            }

                            var   board = vBoard;
                            _Func f1    = delegate
                            {
                                int spellPower = GetSpellPower(board);
                                vCard.Health -= play.Source.GetEntity().GetDamage() + spellPower;
                                return(vCard);
                            };
                            UpdateVBoardCard(ref vBoard, f1);

                            vHand.Remove(vCard);
                            validPlayList.Add(play);
                        }
                        else if (vCard != null && targetVCard != null && Found(vBoard, play.Source) &&
                                 Found(vBoard, play.Target) && IsVAttackValid(vBoard, play) && vCard.CanAttack)//minion attack
                        {
                            if (targetVCard.IsImmune || targetVCard.IsStealthed)
                            {
                                continue;
                            }

                            _Func allyUpdate = delegate
                            {
                                targetVCard.Health -= vCard.Attack;
                                return(targetVCard);
                            };
                            _Func targetUpdate = delegate
                            {
                                vCard.Health -= targetVCard.Attack;
                                return(targetVCard);
                            };
                            UpdateVBoardCard(ref vBoard, allyUpdate);
                            UpdateVBoardCard(ref vBoard, targetUpdate);

                            vCard.VAttack();
                            validPlayList.Add(play);
                        }
                    }

                    if (targetVCard != null && play.IsTargetOnlyAction && Found(vBoard, play.Target))
                    {
                        var lastPlay = validPlayList[validPlayList.Count - 1];
                        if (lastPlay.IsSummonOnly && Lib.HasBattleCryTargetAction(lastPlay.Source))
                        {
                            #region HandleBattleCryAction

                            //Apply play on target
                            Lib.BattleCryTargetAction action = Lib.GetBattleCryTargetAction(play.Source);
                            if (!Lib.CorrespondsToBattleCryAction(play.Source, action))
                            {
                                continue;
                            }

                            if (targetVCard.IsImmune && !targetVCard.IsAlly)
                            {
                                continue;
                            }

                            if (action.OnlyIfHoldingDragon && !IsHoldingDragon(vHand))
                            {
                                continue;
                            }

                            if (action.OnlyIfSectretExists && !IsSecretActive(vSectetZone))
                            {
                                continue;
                            }

                            if (vCard != null && action.BecomeCopy)
                            {
                                vBoard.Remove(GetVCardInList(vBoard, play.Source));
                                var copy = targetVCard;
                                copy.IsAlly = true;
                                vBoard.Add(copy);
                            }
                            if (action.CopyDeathrattle)
                            {
                            }
                            //todo:add CopyDeathrattle
                            if (vCard != null && action.CopyStats)
                            {
                                var   card     = vCard;
                                var   card1    = targetVCard;
                                _Func allyFunc = delegate
                                {
                                    card.Attack = card1.Attack;
                                    card.Health = card1.Health;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, allyFunc);
                            }
                            if (action.DestroyLegendary && play.Target.GetEntity().GetRarity() == TAG_RARITY.LEGENDARY)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    card.Health = -1;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }
                            else
                            {
                                continue;
                            }

                            if (action.DestroyTaunt && targetVCard.HasTaunt && !targetVCard.IsSilenced)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    // ReSharper disable once AccessToModifiedClosure
                                    card.Health = -1;
                                    // ReSharper disable once AccessToModifiedClosure
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }
                            else
                            {
                                continue;
                            }

                            if (action.Freeze)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    card.IsFrozen = true;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }

                            if (action.GiveDivineShield)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    card.HasDivineShield = true;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }

                            if (action.GiveImmune)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    card.IsImmune = true;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }

                            if (action.GiveStealth)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    card.IsStealthed = true;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }

                            if (action.GiveTaunt)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    card.HasTaunt = true;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }

                            if (action.GiveWindfury)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    card.HasWindFury = true;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }

                            if (action.MakeCopy)
                            {
                                var copy = targetVCard;
                                copy.IsAlly = true;
                                vBoard.Add(copy);
                            }

                            if (action.Make_1_1_CopyForHand)
                            {
                                var copy = targetVCard;
                                copy.IsAlly   = true;
                                copy.Health   = 1;
                                copy.Attack   = 1;
                                copy.IsBuffed = false;
                                copy.Cost     = 1;
                                vHand.Add(copy);
                            }

                            if (action.ReturnTargetToHand)
                            {
                                if (targetVCard.IsAlly)
                                {
                                    vBoard.Remove(targetVCard);
                                    vHand.Add(targetVCard);
                                }
                                else
                                {
                                    vBoard.Remove(targetVCard);
                                }
                            }

                            if (action.SetAttackToExactValue)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    card.Attack = action.ExactAttack;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }

                            if (action.SetHealthToExactValue)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    card.Attack = action.ExactHealth;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }

                            if (action.Silence)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    card.IsSilenced = true;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }

                            if (vCard != null && action.SwapHealth)
                            {
                                var   card       = targetVCard;
                                var   card1      = vCard;
                                _Func targetFunc = delegate
                                {
                                    card.Health = card1.Health;
                                    return(card);
                                };
                                _Func allyFunc = delegate
                                {
                                    card1.Health = card.Health;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, allyFunc);
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }

                            if (action.SwapStatsOfTargetItself)
                            {
                                var   card       = targetVCard;
                                _Func targetFunc = delegate
                                {
                                    int h = card.Health;
                                    int a = card.Attack;
                                    card.Attack = h;
                                    card.Health = a;
                                    return(card);
                                };
                                UpdateVBoardCard(ref vBoard, targetFunc);
                            }

                            if (action.TransfromMinionInOneMoreCost)
                            {
                            }
                            //todo:Add TransfromMinionInOneMoreCost
                            if (action.TakeControl)
                            {
                                vBoard.Remove(targetVCard);
                                var c = targetVCard;
                                c.IsAlly = true;
                                vBoard.Add(c);
                            }

                            #endregion

                            validPlayList.Add(play);
                        }
                    }
                }

                validPerms.Add(new BotPlaysResult {
                    BotPlayList = validPlayList, VBoard = vBoard, VHand = vHand
                });
            }
            return(validPerms);
        }
Esempio n. 16
0
    private void OnFriendlyPlayerTagChanged(TagDelta change)
    {
        GAME_TAG tag = (GAME_TAG)change.tag;

        switch (tag)
        {
        case GAME_TAG.CURRENT_SPELLPOWER:
            break;

        case GAME_TAG.TEMP_RESOURCES:
        {
            int num  = change.oldValue - this.m_usedTempMana;
            int num2 = change.newValue - change.oldValue;
            if (num2 < 0)
            {
                this.m_usedTempMana += num2;
            }
            if (this.m_usedTempMana < 0)
            {
                this.m_usedTempMana = 0;
            }
            if (num < 0)
            {
                num = 0;
            }
            int numCrystals = (change.newValue - num) - this.m_usedTempMana;
            if (numCrystals > 0)
            {
                this.AddTempManaCrystal(numCrystals);
            }
            else
            {
                this.DestroyTempManaCrystal(-numCrystals);
            }
            return;
        }

        case GAME_TAG.OVERLOAD_OWED:
            this.HandleSameTurnOverloadChanged(change.newValue - change.oldValue);
            return;

        case GAME_TAG.CURRENT_PLAYER:
            if (change.newValue == 1)
            {
                ManaCrystalMgr.Get().OnCurrentPlayerChanged();
                this.m_queuedSpentMana = 0;
                if (GameState.Get().IsMainPhase())
                {
                    TurnStartManager.Get().BeginListeningForTurnEvents();
                }
            }
            return;

        case GAME_TAG.RESOURCES_USED:
        {
            int num4 = change.oldValue + this.m_queuedSpentMana;
            int num5 = change.newValue - change.oldValue;
            if (num5 > 0)
            {
                this.m_queuedSpentMana -= num5;
            }
            if (this.m_queuedSpentMana < 0)
            {
                this.m_queuedSpentMana = 0;
            }
            int shownChangeAmount = (change.newValue - num4) + this.m_queuedSpentMana;
            ManaCrystalMgr.Get().UpdateSpentMana(shownChangeAmount);
            return;
        }

        case GAME_TAG.RESOURCES:
            if (change.newValue <= change.oldValue)
            {
                this.DestroyManaCrystal(change.oldValue - change.newValue);
                return;
            }
            if (!GameState.Get().IsTurnStartManagerActive() || !this.IsFriendlySide())
            {
                this.AddManaCrystal(change.newValue - change.oldValue);
                return;
            }
            TurnStartManager.Get().NotifyOfManaCrystalGained(change.newValue - change.oldValue);
            return;

        default:
            switch (tag)
            {
            case GAME_TAG.SPELLPOWER_DOUBLE:
            case GAME_TAG.HEALING_DOUBLE:
                break;

            case GAME_TAG.MULLIGAN_STATE:
                if ((change.newValue == 4) && (MulliganManager.Get() == null))
                {
                    foreach (Card card in this.GetHandZone().GetCards())
                    {
                        card.GetActor().TurnOnCollider();
                    }
                }
                return;

            default:
                if ((tag == GAME_TAG.OVERLOAD_LOCKED) && (change.newValue < change.oldValue))
                {
                    this.UnlockCrystals(change.oldValue - change.newValue);
                }
                return;
            }
            break;
        }
        List <Card> cards = this.GetHandZone().GetCards();

        for (int i = 0; i < cards.Count; i++)
        {
            if (cards[i].GetEntity().IsSpell())
            {
                cards[i].GetActor().UpdatePowersText();
            }
        }
    }
Esempio n. 17
0
 public void UpdateMana(int amount)
 {
     Source.NotifyOfSpentMana(amount);
     Source.UpdateManaCounter();
     ManaCrystalMgr.Get().UpdateSpentMana(amount);
 }