Esempio n. 1
0
        public override int Execute(LogicLevel level)
        {
            LogicArrayList <LogicComponent> components = level.GetComponentManager().GetComponents(LogicComponentType.VILLAGE2_UNIT);
            int remainingSecs = 0;

            for (int i = 0; i < components.Size(); i++)
            {
                remainingSecs += ((LogicVillage2UnitComponent)components[i]).GetRemainingSecs();
            }

            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();
            int speedUpCost = LogicGamePlayUtil.GetSpeedUpCost(remainingSecs, 4, 1);

            if (!playerAvatar.HasEnoughDiamonds(speedUpCost, true, level))
            {
                return(-1);
            }

            playerAvatar.UseDiamonds(speedUpCost);

            for (int i = 0; i < components.Size(); i++)
            {
                LogicVillage2UnitComponent component = (LogicVillage2UnitComponent)components[i];

                if (component.GetCurrentlyTrainedUnit() != null && component.GetRemainingSecs() > 0)
                {
                    component.ProductionCompleted();
                }
            }

            playerAvatar.GetChangeListener().DiamondPurchaseMade(16, 0, 0, speedUpCost, 1);

            return(0);
        }