Beispiel #1
0
        public int GetMaxMiniSpellForgeLevel()
        {
            LogicArrayList <LogicComponent> components = this.m_components[(int)LogicComponentType.UNIT_PRODUCTION];

            if (components.Size() > 0)
            {
                int maxUpgLevel = -1;
                int idx         = 0;

                do
                {
                    LogicUnitProductionComponent component = (LogicUnitProductionComponent)components[idx];

                    if (component.GetProductionType() != 0)
                    {
                        if (component.GetParent().GetGameObjectType() == LogicGameObjectType.BUILDING)
                        {
                            LogicBuilding parent = (LogicBuilding)component.GetParent();

                            if (parent.GetBuildingData().GetProducesUnitsOfType() == 2 && (!parent.IsConstructing() || parent.IsUpgrading()))
                            {
                                maxUpgLevel = LogicMath.Max(parent.GetUpgradeLevel(), maxUpgLevel);
                            }
                        }
                    }
                } while (++idx != components.Size());

                return(maxUpgLevel);
            }

            return(-1);
        }
Beispiel #2
0
 /// <summary>
 ///     Initializes the game object types array.
 /// </summary>
 public void InitGameObjectTypes()
 {
     if (this._gameObjectTypes == null)
     {
         this._gameObjectTypes = new LogicArrayList <bool>();
     }
 }
Beispiel #3
0
        public static void AddDonation(LogicArrayList <DonationContainer> arrayList, LogicLong avatarId, LogicCombatItemData data, int upgLevel)
        {
            Debugger.DoAssert(arrayList != null, "pDonations cannot be null");
            int index = -1;

            for (int i = 0; i < arrayList.Size(); i++)
            {
                if (LogicLong.Equals(arrayList[i].GetAvatarId(), avatarId))
                {
                    index = i;
                    break;
                }
            }

            if (index != -1)
            {
                arrayList[index].AddUnit(data, upgLevel);
            }
            else
            {
                DonationContainer donationContainer = new DonationContainer(avatarId.Clone());
                donationContainer.AddUnit(data, upgLevel);
                arrayList.Add(donationContainer);
            }
        }
        public LogicArrayList <AvatarRankingEntry> RemoveAvatarRankingList()
        {
            LogicArrayList <AvatarRankingEntry> tmp = this.m_avatarRankingList;

            this.m_avatarRankingList = null;
            return(tmp);
        }
Beispiel #5
0
 public LogicCalendar()
 {
     this.m_activeTimestamp      = -1;
     this.m_startedEvents        = new LogicArrayList <int>();
     this.m_calendarEvents       = new LogicArrayList <LogicCalendarEvent>();
     this.m_activeCalendarEvents = new LogicArrayList <LogicCalendarEvent>();
 }
 public void Destruct()
 {
     this.m_functionData  = null;
     this.m_calendarEvent = null;
     this.m_errorHandler  = null;
     this.m_parameters    = null;
 }
Beispiel #7
0
        /// <summary>
        ///     Removes the stream entry array.
        /// </summary>
        /// <returns></returns>
        public LogicArrayList <AvatarStreamEntry> RemoveStreamEntries()
        {
            LogicArrayList <AvatarStreamEntry> tmp = this._entries;

            this._entries = null;
            return(tmp);
        }
        protected sealed override void Decode(ByteStream stream)
        {
            for (int i = 0; i < 2; i++)
            {
                LogicArrayList <AllianceRankingEntry> allianceRankingList = this.AllianceRankingList[i];

                for (int j = stream.ReadVInt(); j > 0; j--)
                {
                    AllianceRankingEntry allianceRankingEntry = new AllianceRankingEntry();
                    allianceRankingEntry.Decode(stream);
                    allianceRankingList.Add(allianceRankingEntry);
                }
            }

            for (int j = stream.ReadVInt(); j > 0; j--)
            {
                AvatarRankingEntry avatarRankingEntry = new AvatarRankingEntry();
                avatarRankingEntry.Decode(stream);
                this.AvatarRankingList.Add(avatarRankingEntry);
            }

            for (int j = stream.ReadVInt(); j > 0; j--)
            {
                AvatarDuelRankingEntry avatarDuelRankingEntry = new AvatarDuelRankingEntry();
                avatarDuelRankingEntry.Decode(stream);
                this.AvatarDuelRankingList.Add(avatarDuelRankingEntry);
            }
        }
        /// <summary>
        ///     Decodes this instance.
        /// </summary>
        public override void Decode()
        {
            base.Decode();

            this._subTick  = this.Stream.ReadInt();
            this._checksum = this.Stream.ReadInt();

            int arraySize = this.Stream.ReadInt();

            if (arraySize <= 512)
            {
                if (arraySize > 0)
                {
                    this._commands = new LogicArrayList <LogicCommand>(arraySize);

                    do
                    {
                        LogicCommand command = LogicCommandManager.DecodeCommand(this.Stream);

                        if (command == null)
                        {
                            break;
                        }

                        this._commands.Add(command);
                    } while (--arraySize != 0);
                }
            }
        }
        protected sealed override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONArray allianceRankingListArray = jsonObject.GetJSONArray(SeasonDocument.JSON_ATTRIBUTE_ALLIANCE_RANKINGS);
            LogicJSONArray avatarRankingArray       = jsonObject.GetJSONArray(SeasonDocument.JSON_ATTRIBUTE_AVATAR_RANKINGS);
            LogicJSONArray avatarDuelRankingArray   = jsonObject.GetJSONArray(SeasonDocument.JSON_ATTRIBUTE_AVATAR_DUEL_RANKINGS);

            for (int i = 0; i < 2; i++)
            {
                LogicJSONArray allianceRankingArray = allianceRankingListArray.GetJSONArray(i);
                LogicArrayList <AllianceRankingEntry> allianceRankingList = this.AllianceRankingList[i];

                for (int j = 0; j < allianceRankingArray.Size(); j++)
                {
                    AllianceRankingEntry allianceRankingEntry = new AllianceRankingEntry();
                    allianceRankingEntry.Load(allianceRankingArray.GetJSONObject(j));
                    allianceRankingList.Add(allianceRankingEntry);
                }
            }

            for (int i = 0; i < avatarRankingArray.Size(); i++)
            {
                AvatarRankingEntry avatarRankingEntry = new AvatarRankingEntry();
                avatarRankingEntry.Load(avatarRankingArray.GetJSONObject(i));
                this.AvatarRankingList.Add(avatarRankingEntry);
            }

            for (int i = 0; i < avatarDuelRankingArray.Size(); i++)
            {
                AvatarDuelRankingEntry avatarDuelRankingEntry = new AvatarDuelRankingEntry();
                avatarDuelRankingEntry.Load(avatarDuelRankingArray.GetJSONObject(i));
                this.AvatarDuelRankingList.Add(avatarDuelRankingEntry);
            }

            this.NextCheckTime = DateTime.Parse(jsonObject.GetJSONString(SeasonDocument.JSON_ATTRIBUTE_NEXT_CHECK_TIME).GetStringValue());
        }
        protected sealed override void Encode(ByteStream stream)
        {
            for (int i = 0; i < 2; i++)
            {
                LogicArrayList <AllianceRankingEntry> allianceRankingList = this.AllianceRankingList[i];

                stream.WriteVInt(allianceRankingList.Size());

                for (int j = 0; j < allianceRankingList.Size(); j++)
                {
                    allianceRankingList[j].Encode(stream);
                }
            }

            stream.WriteVInt(this.AvatarRankingList.Size());

            for (int i = 0; i < this.AvatarRankingList.Size(); i++)
            {
                this.AvatarRankingList[i].Encode(stream);
            }

            stream.WriteVInt(this.AvatarDuelRankingList.Size());

            for (int i = 0; i < this.AvatarDuelRankingList.Size(); i++)
            {
                this.AvatarDuelRankingList[i].Encode(stream);
            }
        }
        protected sealed override void Save(LogicJSONObject jsonObject)
        {
            LogicJSONArray allianceRankingListArray = new LogicJSONArray(2);
            LogicJSONArray avatarRankingArray       = new LogicJSONArray(SeasonDocument.RANKING_LIST_SIZE);
            LogicJSONArray avatarDuelRankingArray   = new LogicJSONArray(SeasonDocument.RANKING_LIST_SIZE);

            for (int i = 0; i < 2; i++)
            {
                LogicJSONArray allianceRankingArray = new LogicJSONArray(SeasonDocument.RANKING_LIST_SIZE);
                LogicArrayList <AllianceRankingEntry> allianceRankingList = this.AllianceRankingList[i];

                for (int j = 0; j < allianceRankingList.Size(); j++)
                {
                    allianceRankingArray.Add(allianceRankingList[j].Save());
                }

                allianceRankingListArray.Add(allianceRankingArray);
            }

            for (int i = 0; i < this.AvatarRankingList.Size(); i++)
            {
                avatarRankingArray.Add(this.AvatarRankingList[i].Save());
            }

            for (int i = 0; i < this.AvatarDuelRankingList.Size(); i++)
            {
                avatarDuelRankingArray.Add(this.AvatarDuelRankingList[i].Save());
            }

            jsonObject.Put(SeasonDocument.JSON_ATTRIBUTE_ALLIANCE_RANKINGS, allianceRankingListArray);
            jsonObject.Put(SeasonDocument.JSON_ATTRIBUTE_AVATAR_RANKINGS, avatarRankingArray);
            jsonObject.Put(SeasonDocument.JSON_ATTRIBUTE_AVATAR_DUEL_RANKINGS, avatarDuelRankingArray);
            jsonObject.Put(SeasonDocument.JSON_ATTRIBUTE_NEXT_CHECK_TIME, new LogicJSONString(this.NextCheckTime.ToString("O")));
        }
Beispiel #13
0
 public void SetMaxPercentageArray(LogicArrayList <int> max)
 {
     for (int i = 0; i < max.Size(); i++)
     {
         this.m_maxPercentageResourceCount[i] = max[i];
     }
 }
        public LogicArrayList <AvatarDuelRankingEntry> RemoveLastSeasonAvatarRankingList()
        {
            LogicArrayList <AvatarDuelRankingEntry> tmp = this.m_lastSeasonAvatarRankingList;

            this.m_lastSeasonAvatarRankingList = null;
            return(tmp);
        }
Beispiel #15
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);
        }
        public override void Destruct()
        {
            base.Destruct();

            this.m_avatarRankingList           = null;
            this.m_lastSeasonAvatarRankingList = null;
        }
Beispiel #17
0
        /// <summary>
        ///     Loads resources file.
        /// </summary>
        private static void LoadResources()
        {
            ResourceManager.ContentUrlList        = new LogicArrayList <string>();
            ResourceManager.ChronosContentUrlList = new LogicArrayList <string>();
            ResourceManager.AppStoreUrlList       = new LogicArrayList <string>();

            string resourceFile = WebManager.DownloadConfigString("/res/resources.json");

            if (resourceFile != null)
            {
                LogicJSONObject jsonObject          = (LogicJSONObject)LogicJSONParser.Parse(resourceFile);
                LogicJSONArray  contentArray        = jsonObject.GetJSONArray("content");
                LogicJSONArray  chronosContentArray = jsonObject.GetJSONArray("chronosContent");
                LogicJSONArray  appStoreArray       = jsonObject.GetJSONArray("appstore");

                for (int i = 0; i < contentArray.Size(); i++)
                {
                    ResourceManager.ContentUrlList.Add(contentArray.GetJSONString(i).GetStringValue());
                }

                for (int i = 0; i < chronosContentArray.Size(); i++)
                {
                    ResourceManager.ChronosContentUrlList.Add(chronosContentArray.GetJSONString(i).GetStringValue());
                }

                for (int i = 0; i < appStoreArray.Size(); i++)
                {
                    ResourceManager.AppStoreUrlList.Add(appStoreArray.GetJSONString(i).GetStringValue());
                }
            }
            else
            {
                Debugger.Error("ResourceManager::loadResources resources.json not exist");
            }
        }
        public override void Destruct()
        {
            base.Destruct();

            this.m_lootCount = null;
            this.m_capCount  = null;
        }
        public LogicArrayList <AllianceHeaderEntry> RemoveAlliances()
        {
            LogicArrayList <AllianceHeaderEntry> tmp = this.m_allianceList;

            this.m_allianceList = null;
            return(tmp);
        }
        public override void Destruct()
        {
            base.Destruct();

            if (this.m_donationContainerList != null)
            {
                for (int i = this.m_donationContainerList.Size() - 1; i >= 0; i--)
                {
                    this.m_donationContainerList[i].Destruct();
                    this.m_donationContainerList.Remove(i);
                }

                this.m_donationContainerList = null;
            }

            if (this.m_unitCount != null)
            {
                for (int i = this.m_unitCount.Size() - 1; i >= 0; i--)
                {
                    this.m_unitCount[i].Destruct();
                    this.m_unitCount.Remove(i);
                }

                this.m_unitCount = null;
            }

            this.m_message = null;
        }
Beispiel #21
0
        /// <summary>
        ///     Decodes this instance.
        /// </summary>
        public override void Decode()
        {
            base.Decode();

            int cnt = this.Stream.ReadInt();

            if (cnt != -1)
            {
                this._entries = new LogicArrayList <AvatarStreamEntry>(cnt);

                for (int i = 0; i < cnt; i++)
                {
                    AvatarStreamEntry entry = AvatarStreamEntryFactory.CreateStreamEntryByType(this.Stream.ReadInt());

                    if (entry == null)
                    {
                        Debugger.Warning("Corrupted AvatarStreamMessage");
                        break;
                    }

                    entry.Decode(this.Stream);
                }
            }
            else
            {
                this._entries = null;
            }
        }
Beispiel #22
0
        public static async Task <LogicArrayList <AllianceHeaderEntry> > GetAllianceHeaderList(LogicArrayList <LogicLong> ids)
        {
            LogicArrayList <AllianceHeaderEntry> allianceList = new LogicArrayList <AllianceHeaderEntry>(ids.Size());

            Task <IOperationResult <string> >[] results = new Task <IOperationResult <string> > [ids.Size()];

            for (int i = 0; i < ids.Size(); i++)
            {
                results[i] = ServerSearch.AllianceDatabase.Get(ids[i]);
            }

            for (int i = 0; i < ids.Size(); i++)
            {
                IOperationResult <string> result = await results[i];

                if (result.Success)
                {
                    LogicJSONObject     jsonObject          = LogicJSONParser.ParseObject(result.Value);
                    AllianceHeaderEntry allianceHeaderEntry = new AllianceHeaderEntry();

                    allianceHeaderEntry.Load(jsonObject);
                    allianceHeaderEntry.SetAllianceId(new LogicLong(jsonObject.GetJSONNumber(CouchbaseDocument.JSON_ATTRIBUTE_ID_HIGH).GetIntValue(),
                                                                    jsonObject.GetJSONNumber(CouchbaseDocument.JSON_ATTRIBUTE_ID_LOW).GetIntValue()));
                    allianceList.Add(allianceHeaderEntry);
                }
            }

            return(allianceList);
        }
        private void SortProduction(LogicArrayList <LogicCombatItemData> arrayList)
        {
            for (int i = 0; i < arrayList.Size(); i++)
            {
                bool change = false;

                for (int j = 0; j < arrayList.Size() - 1; j++)
                {
                    LogicCombatItemData data     = arrayList[j];
                    LogicCombatItemData nextData = arrayList[j + 1];

                    int sort1 = data.GetRequiredProductionHouseLevel() + 100 * data.GetUnitOfType() + 500 * data.GetCombatItemType();
                    int sort2 = nextData.GetRequiredProductionHouseLevel() + 100 * nextData.GetUnitOfType() + 500 * nextData.GetCombatItemType();

                    if (sort1 > sort2)
                    {
                        arrayList[j]     = nextData;
                        arrayList[j + 1] = data;
                        change           = true;
                    }
                }

                if (!change)
                {
                    break;
                }
            }
        }
        public override void Decode(ByteStream stream)
        {
            base.Decode(stream);

            int count = stream.ReadInt();

            if (count > 0)
            {
                this.m_excludeMemberList = new LogicArrayList <LogicLong>();
                this.m_excludeMemberList.EnsureCapacity(count);

                if (count > 50)
                {
                    Debugger.Error(string.Format("Number of excluded players ({0}) is too high.", count));
                }

                for (int i = 0; i < count; i++)
                {
                    this.m_excludeMemberList.Add(stream.ReadLong());
                }
            }

            this.m_enemyAllianceId = stream.ReadLong();

            stream.ReadInt();
            stream.ReadInt();
        }
Beispiel #25
0
        public LogicArrayList <StreamEntry> RemovestreamEntries()
        {
            LogicArrayList <StreamEntry> tmp = this.m_streamEntryList;

            this.m_streamEntryList = null;
            return(tmp);
        }
        public override void Destruct()
        {
            base.Destruct();

            this.m_excludeMemberList = null;
            this.m_enemyAllianceId   = null;
        }
Beispiel #27
0
 /// <summary>
 ///     Initializes the ignore object array.
 /// </summary>
 public void InitIgnoreObjects()
 {
     if (this._ignoreGameObjects == null)
     {
         this._ignoreGameObjects = new LogicArrayList <LogicGameObject>();
     }
 }
        public LogicArrayList <FriendEntry> RemoveFriendEntries()
        {
            LogicArrayList <FriendEntry> tmp = this.m_friendEntryList;

            this.m_friendEntryList = null;
            return(tmp);
        }
        public override void Decode()
        {
            base.Decode();

            this.m_subTick  = this.m_stream.ReadInt();
            this.m_checksum = this.m_stream.ReadInt();

            int arraySize = this.m_stream.ReadInt();

            if (arraySize <= 512)
            {
                if (arraySize > 0)
                {
                    this.m_commands = new LogicArrayList <LogicCommand>(arraySize);

                    do
                    {
                        LogicCommand command = LogicCommandManager.DecodeCommand(this.m_stream);

                        if (command == null)
                        {
                            break;
                        }

                        this.m_commands.Add(command);
                    } while (--arraySize != 0);
                }
            }
            else
            {
                Debugger.Error(string.Format("BattleEndClientTurn::decode() command count is too high! ({0})", arraySize));
            }
        }
Beispiel #30
0
        public LogicComponent GetClosestComponent(int x, int y, LogicComponentFilter filter)
        {
            LogicArrayList <LogicComponent> components = this.m_components[(int)filter.GetComponentType()];
            LogicComponent closestComponent            = null;

            int closestDistance = 0;

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

                if (filter.TestComponent(component))
                {
                    int distance = component.GetParent().GetPosition().GetDistanceSquaredTo(x, y);

                    if (distance < closestDistance || closestComponent == null)
                    {
                        closestDistance  = distance;
                        closestComponent = component;
                    }
                }
            }

            return(closestComponent);
        }