예제 #1
0
        public override void Load(LogicJSONObject jsonObject)
        {
            this.LoadUpgradeLevel(jsonObject);

            if (this.m_constructionTimer != null)
            {
                this.m_constructionTimer.Destruct();
                this.m_constructionTimer = null;
            }

            LogicJSONNumber constTimeObject = jsonObject.GetJSONNumber("const_t");

            if (constTimeObject != null)
            {
                int constTime = constTimeObject.GetIntValue();

                if (!LogicDataTables.GetGlobals().ClampBuildingTimes())
                {
                    if (this.m_upgLevel < this.GetVillageObjectData().GetUpgradeLevelCount() - 1)
                    {
                        constTime = LogicMath.Min(constTime, this.GetVillageObjectData().GetBuildTime(this.m_upgLevel + 1));
                    }
                }

                this.m_constructionTimer = new LogicTimer();
                this.m_constructionTimer.StartTimer(constTime, this.m_level.GetLogicTime(), false, -1);

                LogicJSONNumber constTimeEndObject = jsonObject.GetJSONNumber("const_t_end");

                if (constTimeEndObject != null)
                {
                    this.m_constructionTimer.SetEndTimestamp(constTimeEndObject.GetIntValue());
                }

                LogicJSONNumber conffObject = jsonObject.GetJSONNumber("con_ff");

                if (conffObject != null)
                {
                    this.m_constructionTimer.SetFastForward(conffObject.GetIntValue());
                }

                LogicVillageObjectData villageObjectData = this.GetVillageObjectData();

                if (villageObjectData.IsRequiresBuilder() && !villageObjectData.IsAutomaticUpgrades())
                {
                    this.m_level.GetWorkerManagerAt(this.m_villageType).AllocateWorker(this);
                }

                this.m_upgrading = this.m_upgLevel != -1;
            }

            this.m_upgLevel = LogicMath.Clamp(this.m_upgLevel, 0, this.GetVillageObjectData().GetUpgradeLevelCount() - 1);

            base.Load(jsonObject);

            this.SetPositionXY((this.GetVillageObjectData().GetTileX100() << 9) / 100,
                               (this.GetVillageObjectData().GetTileY100() << 9) / 100);
        }