コード例 #1
0
 public static Power GetDefaultMasterPower()
 {
     if (s_defaultMasterPower == null)
     {
         s_defaultMasterPower = new Power();
         List <PlayErrors.ErrorType> requirements = new List <PlayErrors.ErrorType>();
         s_defaultMasterPower.mPlayRequirementInfo.requirementsMap = PlayErrors.GetRequirementsMap(requirements);
     }
     return(s_defaultMasterPower);
 }
コード例 #2
0
 private void InitializeGame()
 {
     GameDbf.Load();
     DemoMgr.Get().Initialize();
     LocalOptions.Get().Initialize();
     if (DemoMgr.Get().GetMode() == DemoMode.APPLE_STORE)
     {
         DemoMgr.Get().ApplyAppleStoreDemoDefaults();
     }
     if (Network.TUTORIALS_WITHOUT_ACCOUNT != null)
     {
         Network.SetShouldBeConnectedToAurora(Options.Get().GetBool(Option.CONNECT_TO_AURORA));
     }
     Network.Initialize();
     Localization.Initialize();
     GameStrings.LoadCategory(GameStringCategory.GLOBAL);
     if (!PlayErrors.Init())
     {
         UnityEngine.Debug.LogError(string.Format("{0} failed to load!", "PlayErrors32"));
     }
     GameMgr.Get().Initialize();
     ChangedCardMgr.Get().Initialize();
     TavernBrawlManager.Init();
 }
コード例 #3
0
ファイル: API.cs プロジェクト: zanzo420/HearthstoneBot
        public bool drop_held_card_worker(int requested_zone_position)
        {
            PegCursor.Get().SetMode(PegCursor.Mode.STOPDRAG);

            InputManager input_man = InputManager.Get();

            if (input_man.heldObject == null)
            {
                Log.log("Nothing held, when trying to drop");
                return(false);
            }
            Card component = input_man.heldObject.GetComponent <Card>();

            ZonePlay m_myPlayZone = PrivateHacker.get_m_myPlayZone();
            ZoneHand m_myHandZone = PrivateHacker.get_m_myHandZone();

            component.SetDoNotSort(false);
            iTween.Stop(input_man.heldObject);
            Entity entity = component.GetEntity();

            component.NotifyLeftPlayfield();
            GameState.Get().GetGameEntity().NotifyOfCardDropped(entity);
            m_myPlayZone.UnHighlightBattlefield();
            DragCardSoundEffects component2 = component.GetComponent <DragCardSoundEffects>();

            if (component2)
            {
                component2.Disable();
            }
            UnityEngine.Object.Destroy(input_man.heldObject.GetComponent <DragRotator>());
            input_man.heldObject = null;
            ProjectedShadow componentInChildren = component.GetActor().GetComponentInChildren <ProjectedShadow>();

            if (componentInChildren != null)
            {
                componentInChildren.DisableShadow();
            }

            // Check that the card is on the hand
            Zone card_zone = component.GetZone();

            if ((card_zone == null) || card_zone.m_ServerTag != TAG_ZONE.HAND)
            {
                return(false);
            }

            bool does_target = false;

            bool is_minion = entity.IsMinion();
            bool is_weapon = entity.IsWeapon();

            if (is_minion || is_weapon)
            {
                Zone zone = (!is_weapon) ? (Zone)m_myPlayZone : (Zone)PrivateHacker.get_m_myWeaponZone();
                if (zone)
                {
                    GameState gameState     = GameState.Get();
                    int       card_position = Network.NoPosition;
                    if (is_minion)
                    {
                        card_position = ZoneMgr.Get().PredictZonePosition(zone, requested_zone_position);
                        gameState.SetSelectedOptionPosition(card_position);
                    }
                    if (input_man.DoNetworkResponse(entity))
                    {
                        if (is_weapon)
                        {
                            PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddLocalZoneChange(component, zone, zone.GetLastPos()));
                        }
                        else
                        {
                            PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddPredictedLocalZoneChange(component, zone, requested_zone_position, card_position));
                        }
                        PrivateHacker.ForceManaUpdate(entity);
                        if (is_minion && gameState.EntityHasTargets(entity))
                        {
                            does_target = true;
                            if (TargetReticleManager.Get())
                            {
                                bool showArrow = true;
                                TargetReticleManager.Get().CreateFriendlyTargetArrow(entity, entity, true, showArrow, null);
                            }
                            PrivateHacker.set_m_battlecrySourceCard(component);
                        }
                    }
                    else
                    {
                        gameState.SetSelectedOptionPosition(Network.NoPosition);
                    }
                }
            }
            // Spell support
            else
            {
                if (entity.IsSpell())
                {
                    if (GameState.Get().EntityHasTargets(entity))
                    {
                        input_man.heldObject = null;
                        EnemyActionHandler.Get().NotifyOpponentOfCardDropped();
                        m_myHandZone.UpdateLayout(-1, true);
                        m_myPlayZone.SortWithSpotForHeldCard(-1);

                        return(true);
                    }
                    if (!GameState.Get().HasResponse(entity))
                    {
                        PlayErrors.DisplayPlayError(PlayErrors.GetPlayEntityError(entity), entity);
                    }
                    else
                    {
                        input_man.DoNetworkResponse(entity);
                        if (entity.IsSecret())
                        {
                            ZoneSecret m_mySecretZone = PrivateHacker.get_m_mySecretZone();
                            PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddLocalZoneChange(component, m_mySecretZone, m_mySecretZone.GetLastPos()));
                        }
                        else
                        {
                            PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddLocalZoneChange(component, TAG_ZONE.PLAY));
                        }
                        PrivateHacker.ForceManaUpdate(entity);
                        PrivateHacker.PlayPowerUpSpell(component);
                        PrivateHacker.PlayPlaySpell(component);
                    }
                }
            }
            m_myHandZone.UpdateLayout(-1, true);
            m_myPlayZone.SortWithSpotForHeldCard(-1);
            if (does_target)
            {
                if (EnemyActionHandler.Get())
                {
                    EnemyActionHandler.Get().NotifyOpponentOfTargetModeBegin(component);
                }
            }
            else
            {
                if (GameState.Get().GetResponseMode() != GameState.ResponseMode.SUB_OPTION)
                {
                    EnemyActionHandler.Get().NotifyOpponentOfCardDropped();
                }
            }
            return(true);
        }
コード例 #4
0
    public static Power Create(string definition, List <PowerInfo> infos)
    {
        Power power = new Power {
            mDefinition = definition
        };
        List <PlayErrors.ErrorType> requirements = new List <PlayErrors.ErrorType>();

        if ((infos != null) && (infos.Count > 0))
        {
            foreach (PowerInfo info in infos)
            {
                PlayErrors.ErrorType reqId = info.reqId;
                int param = info.param;
                PlayErrors.ErrorType type2 = reqId;
                switch (type2)
                {
                case PlayErrors.ErrorType.REQ_TARGET_MAX_ATTACK:
                    power.mPlayRequirementInfo.paramMaxAtk = param;
                    goto Label_012E;

                case PlayErrors.ErrorType.REQ_TARGET_WITH_RACE:
                    power.mPlayRequirementInfo.paramRace = param;
                    goto Label_012E;

                case PlayErrors.ErrorType.REQ_NUM_MINION_SLOTS:
                    power.mPlayRequirementInfo.paramNumMinionSlots = param;
                    goto Label_012E;

                default:
                    switch (type2)
                    {
                    case PlayErrors.ErrorType.REQ_MINION_CAP_IF_TARGET_AVAILABLE:
                        power.mPlayRequirementInfo.paramNumMinionSlotsWithTarget = param;
                        goto Label_012E;

                    case PlayErrors.ErrorType.REQ_MINIMUM_ENEMY_MINIONS:
                        power.mPlayRequirementInfo.paramMinNumEnemyMinions = param;
                        goto Label_012E;

                    default:
                        if (type2 != PlayErrors.ErrorType.REQ_TARGET_MIN_ATTACK)
                        {
                            if (type2 == PlayErrors.ErrorType.REQ_MINIMUM_TOTAL_MINIONS)
                            {
                                break;
                            }
                            if (type2 == PlayErrors.ErrorType.REQ_TARGET_IF_AVAILABLE_AND_MINIMUM_FRIENDLY_MINIONS)
                            {
                                break;
                            }
                        }
                        else
                        {
                            power.mPlayRequirementInfo.paramMinAtk = param;
                        }
                        goto Label_012E;
                    }
                    power.mPlayRequirementInfo.paramMinNumTotalMinions = param;
                    goto Label_012E;
                }
                power.mPlayRequirementInfo.paramMinNumFriendlyMinions = param;
Label_012E:
                requirements.Add(reqId);
            }
        }
        power.mPlayRequirementInfo.requirementsMap = PlayErrors.GetRequirementsMap(requirements);
        return(power);
    }
コード例 #5
0
    public static Power LoadFromXml(XmlElement rootElement)
    {
        Power power = new Power {
            mDefinition = rootElement.GetAttribute("definition")
        };
        XPathNavigator              navigator    = rootElement.CreateNavigator();
        XPathExpression             expr         = navigator.Compile("./PlayRequirement");
        XPathNodeIterator           iterator     = navigator.Select(expr);
        List <PlayErrors.ErrorType> requirements = new List <PlayErrors.ErrorType>();

        while (iterator.MoveNext())
        {
            int        num;
            XmlElement node = (XmlElement)((IHasXmlNode)iterator.Current).GetNode();
            if (int.TryParse(node.GetAttribute("reqID"), out num))
            {
                PlayErrors.ErrorType item = (PlayErrors.ErrorType)num;
                requirements.Add(item);
                switch (item)
                {
                case PlayErrors.ErrorType.REQ_TARGET_MIN_ATTACK:
                {
                    if (!int.TryParse(node.GetAttribute("param"), out power.mPlayRequirementInfo.paramMinAtk))
                    {
                        Log.Rachelle.Print(string.Format("Unable to read play requirement param minAtk for power {0}.", power.GetDefinition()), new object[0]);
                    }
                    continue;
                }

                case PlayErrors.ErrorType.REQ_TARGET_MAX_ATTACK:
                {
                    if (!int.TryParse(node.GetAttribute("param"), out power.mPlayRequirementInfo.paramMaxAtk))
                    {
                        Log.Rachelle.Print(string.Format("Unable to read play requirement param maxAtk for power {0}.", power.GetDefinition()), new object[0]);
                    }
                    continue;
                }

                case PlayErrors.ErrorType.REQ_TARGET_WITH_RACE:
                {
                    if (!int.TryParse(node.GetAttribute("param"), out power.mPlayRequirementInfo.paramRace))
                    {
                        Log.Rachelle.Print(string.Format("Unable to read play requirement param race for power {0}.", power.GetDefinition()), new object[0]);
                    }
                    continue;
                }

                case PlayErrors.ErrorType.REQ_NUM_MINION_SLOTS:
                {
                    if (!int.TryParse(node.GetAttribute("param"), out power.mPlayRequirementInfo.paramNumMinionSlots))
                    {
                        Log.Rachelle.Print(string.Format("Unable to read play requirement param num minion slots for power {0}.", power.GetDefinition()), new object[0]);
                    }
                    continue;
                }

                case PlayErrors.ErrorType.REQ_MINION_CAP_IF_TARGET_AVAILABLE:
                {
                    if (!int.TryParse(node.GetAttribute("param"), out power.mPlayRequirementInfo.paramNumMinionSlotsWithTarget))
                    {
                        Log.Rachelle.Print(string.Format("Unable to read play requirement param num minion slots with target for power {0}.", power.GetDefinition()), new object[0]);
                    }
                    continue;
                }

                case PlayErrors.ErrorType.REQ_MINIMUM_ENEMY_MINIONS:
                {
                    if (!int.TryParse(node.GetAttribute("param"), out power.mPlayRequirementInfo.paramMinNumEnemyMinions))
                    {
                        Log.Rachelle.Print(string.Format("Unable to read play requirement param num enemy minions for power {0}.", power.GetDefinition()), new object[0]);
                    }
                    continue;
                }

                case PlayErrors.ErrorType.REQ_MINIMUM_TOTAL_MINIONS:
                {
                    if (!int.TryParse(node.GetAttribute("param"), out power.mPlayRequirementInfo.paramMinNumTotalMinions))
                    {
                        Log.Rachelle.Print(string.Format("Unable to read play requirement param num total minions for power {0}.", power.GetDefinition()), new object[0]);
                    }
                    continue;
                }
                }
                if ((item == PlayErrors.ErrorType.REQ_TARGET_IF_AVAILABLE_AND_MINIMUM_FRIENDLY_MINIONS) && !int.TryParse(node.GetAttribute("param"), out power.mPlayRequirementInfo.paramMinNumFriendlyMinions))
                {
                    Log.Rachelle.Print(string.Format("Unable to read play requirement param num friendly minions for power {0}.", power.GetDefinition()), new object[0]);
                }
            }
        }
        power.mPlayRequirementInfo.requirementsMap = PlayErrors.GetRequirementsMap(requirements);
        return(power);
    }