Exemple #1
0
        public override int Execute(LogicLevel level)
        {
            LogicBuilding allianceCastle = level.GetGameObjectManagerAt(0).GetAllianceCastle();

            if (allianceCastle != null)
            {
                LogicBunkerComponent bunkerComponent = allianceCastle.GetBunkerComponent();

                if (bunkerComponent != null && bunkerComponent.GetRequestCooldownTime() == 0)
                {
                    LogicAvatar homeOwnerAvatar = level.GetHomeOwnerAvatar();

                    homeOwnerAvatar.GetChangeListener().RequestAllianceUnits(allianceCastle.GetUpgradeLevel(),
                                                                             bunkerComponent.GetUsedCapacity(),
                                                                             bunkerComponent.GetMaxCapacity(),
                                                                             homeOwnerAvatar.GetAllianceCastleUsedSpellCapacity(),
                                                                             homeOwnerAvatar.GetAllianceCastleTotalSpellCapacity(),
                                                                             this.m_message);

                    bunkerComponent.StartRequestCooldownTime();

                    return(0);
                }
            }

            return(-1);
        }
Exemple #2
0
        public override int Execute(LogicLevel level)
        {
            if (LogicDataTables.GetGlobals().UseTroopRequestSpeedUp())
            {
                LogicClientAvatar      playerAvatar      = level.GetPlayerAvatar();
                LogicGameObjectManager gameObjectManager = level.GetGameObjectManagerAt(0);
                LogicBuilding          allianceCastle    = gameObjectManager.GetAllianceCastle();

                if (allianceCastle != null)
                {
                    LogicBunkerComponent bunkerComponent = allianceCastle.GetBunkerComponent();

                    if (bunkerComponent != null)
                    {
                        if (playerAvatar.GetAllianceCastleUsedCapacity() < playerAvatar.GetAllianceCastleTotalCapacity() ||
                            playerAvatar.GetAllianceCastleUsedSpellCapacity() < playerAvatar.GetAllianceCastleTotalSpellCapacity())
                        {
                            int speedUpCost = LogicGamePlayUtil.GetSpeedUpCost(bunkerComponent.GetRequestCooldownTime(), 3, 0);

                            if (playerAvatar.HasEnoughDiamonds(speedUpCost, true, level))
                            {
                                playerAvatar.UseDiamonds(speedUpCost);
                                playerAvatar.GetChangeListener().DiamondPurchaseMade(11, 0, 0, speedUpCost, level.GetVillageType());
                                bunkerComponent.StopRequestCooldownTime();

                                return(0);
                            }

                            return(-6);
                        }

                        return(-5);
                    }

                    return(-4);
                }

                return(-3);
            }

            return(-1);
        }