public void StartClearing()
 {
     int constructionTime = GetObstacleData().ClearTimeSeconds;
     if (constructionTime < 1)
     {
         ClearingFinished();
     }
     else
     {
         m_vTimer = new Timer();
         m_vTimer.StartTimer(constructionTime, m_vLevel.GetTime());
         m_vLevel.WorkerManager.AllocateWorker(this);
     }
 }
        public void StartConstructing(int newX, int newY)
        {
            X = newX;
            Y = newY;
            int constructionTime = 0;// GetConstructionItemData().GetConstructionTime(UpgradeLevel + 1);

            if (constructionTime < 1)
            {
                FinishConstruction();
            }
            else
            {
                m_vTimer = new Timer();
                m_vTimer.StartTimer(constructionTime, m_vLevel.Avatar.LastTickSaved);
                m_vLevel.WorkerManager.AllocateWorker(this);
                m_vIsConstructing = true;
            }
        }
Esempio n. 3
0
 public ObstacleManager(Level level)
 {
     m_vLevel = level;
     if (m_vObstacleLimit == -1)
     {
         m_vObstacleLimit          = CSVManager.DataTables.GetGlobals().GetGlobalData("OBSTACLE_COUNT_MAX").NumberValue;
         m_vObstacleRespawnSeconds =
             CSVManager.DataTables.GetGlobals().GetGlobalData("OBSTACLE_RESPAWN_SECONDS").NumberValue;
     }
     if (m_vSpawnAbleObstacles.Count() == 0)
     {
         var dt = CSVManager.DataTables.GetTable(7);
         for (var i = 0; i < dt.GetItemCount(); i++)
         {
             var od = (ObstacleData)dt.GetItemAt(i);
             if (!od.IsTombstone)
             {
                 if (!od.GetName().Contains("Gembox"))
                 {
                     if (od.RespawnWeight > 0)
                     {
                         m_vSpawnAbleObstacles.Add(od);
                         SumWeights += od.RespawnWeight;
                     }
                 }
                 else
                 {
                     m_vGemBoxes.Add(od);
                 }
             }
         }
     }
     m_vNormalTimer  = new Timer();
     m_vGemBoxTimer  = new Timer();
     m_vSpecialTimer = new Timer();
     m_vNormalTimer.StartTimer(m_vObstacleRespawnSeconds, level.GetTime());
     m_vGemBoxTimer.StartTimer(m_vObstacleRespawnSeconds * 2, level.GetTime());
     m_vSpecialTimer.StartTimer(m_vObstacleRespawnSeconds, level.GetTime());
     m_vObstacleClearCount = 0;
     m_vRespawnSeed        = new Random().Next();
 }
        public new void Load(JObject jsonObject)
        {
            UpgradeLevel = jsonObject["lvl"].ToObject <int>();

            // ??
            m_vLevel.WorkerManager.DeallocateWorker(this);

            var constTimeToken = jsonObject["const_t"];

            if (constTimeToken != null)
            {
                m_vTimer          = new Timer();
                m_vIsConstructing = true;

                var remainingConstructionTime = constTimeToken.ToObject <int>();
                m_vTimer.StartTimer(remainingConstructionTime, m_vLevel.GetTime());
                m_vLevel.WorkerManager.AllocateWorker(this);
            }

            Locked = false;
            var lockedToken = jsonObject["locked"];

            if (lockedToken != null)
            {
                Locked = lockedToken.ToObject <bool>();
            }

            var boostToken = jsonObject["boost_endTime"];

            if (boostToken != null)
            {
                m_vBoostEndTime = jsonObject["boost_endTime"].ToObject <DateTime>();
                IsBoosted       = true;
            }

            SetUpgradeLevel(UpgradeLevel);
            base.Load(jsonObject);
        }
 public void AddUnitToProductionQueue(CombatItemData cd)
 {
     if(CanAddUnitToQueue(cd))
     {
         for(int i=0;i<GetSlotCount();i++)
         {
             if ((CombatItemData)m_vUnits[i].Data == cd)
             {
                 m_vUnits[i].Value++;
                 return;
             }
         }
         DataSlot ds = new DataSlot(cd, 1);
         m_vUnits.Add(ds);
         if(m_vTimer == null)
         {
             ClientAvatar ca = GetParent().GetLevel().GetHomeOwnerAvatar();
             m_vTimer = new Timer();
             int trainingTime = cd.GetTrainingTime(ca.GetUnitUpgradeLevel(cd));
             m_vTimer.StartTimer(trainingTime, GetParent().GetLevel().GetTime());
         }
     }
 }
Esempio n. 6
0
 public void AddUnitToProductionQueue(CombatItemData cd)
 {
     if (CanAddUnitToQueue(cd))
     {
         for (var i = 0; i < GetSlotCount(); i++)
         {
             if ((CombatItemData)m_vUnits[i].Data == cd)
             {
                 m_vUnits[i].Value++;
                 return;
             }
         }
         var ds = new DataSlot(cd, 1);
         m_vUnits.Add(ds);
         if (m_vTimer == null)
         {
             var ca = GetParent().GetLevel().GetHomeOwnerAvatar();
             m_vTimer = new Timer();
             var trainingTime = cd.GetTrainingTime(ca.GetUnitUpgradeLevel(cd));
             m_vTimer.StartTimer(trainingTime, GetParent().GetLevel().GetTime());
         }
     }
 }
Esempio n. 7
0
        public void AddUnitToProductionQueue(CombatItemData cd)
        {
            if (!CanAddUnitToQueue(cd))
            {
                return;
            }
            for (int index = 0; index < GetSlotCount(); ++index)
            {
                if ((CombatItemData)m_vUnits[index].Data == cd)
                {
                    ++m_vUnits[index].Value;
                    return;
                }
            }
            m_vUnits.Add(new DataSlot((Data)cd, 1));
            if (m_vTimer != null)
            {
                return;
            }
            ClientAvatar avatar = GetParent().GetLevel().GetHomeOwnerAvatar();

            m_vTimer = new Timer();
            m_vTimer.StartTimer(cd.GetTrainingTime(avatar.GetUnitUpgradeLevel(cd)), GetParent().GetLevel().GetTime());
        }
 public override void Load(JObject jsonObject)
 {
     JObject unitProdObject = (JObject)jsonObject["unit_prod"];
     m_vIsSpellForge = (unitProdObject["unit_type"].ToObject<int>() == 1);
     var timeToken = unitProdObject["t"];
     if (timeToken != null)
     {
         m_vTimer = new Timer();
         int remainingTime = timeToken.ToObject<int>();
         m_vTimer.StartTimer(remainingTime, GetParent().GetLevel().GetTime());
     }
     JArray unitJsonArray = (JArray)unitProdObject["slots"];
     if (unitJsonArray != null)
     {
         foreach (JObject unitJsonObject in unitJsonArray)
         {
             int id = unitJsonObject["id"].ToObject<int>();
             int cnt = unitJsonObject["cnt"].ToObject<int>();
             m_vUnits.Add(new DataSlot(ObjectManager.DataTables.GetDataById(id),cnt));
         }
     }
 }
 public void RemoveUnit(CombatItemData cd)
 {
     int index = -1;
     if(GetSlotCount() >= 1)
     {
         for(int i=0;i<GetSlotCount();i++)
         {
             if (m_vUnits[i].Data == cd)
                 index = i;
         }
     }
     if(index != -1)
     {
         if (m_vUnits[index].Value >= 1)
         {
             m_vUnits[index].Value--;
             if (m_vUnits[index].Value == 0)
             {
                 m_vUnits.RemoveAt(index);
                 if(GetSlotCount() >= 1)
                 {
                     DataSlot ds = m_vUnits[0];
                     CombatItemData newcd = (CombatItemData)m_vUnits[0].Data;
                     ClientAvatar ca = GetParent().GetLevel().GetHomeOwnerAvatar();
                     m_vTimer = new Timer();
                     int trainingTime = newcd.GetTrainingTime(ca.GetUnitUpgradeLevel(newcd));
                     m_vTimer.StartTimer(trainingTime, GetParent().GetLevel().GetTime());
                 }
             }
         }
     }    
 }
        public override void Load(JObject jsonObject)
        {
            JObject unitUpgradeObject = (JObject)jsonObject["unit_upg"];
            if (unitUpgradeObject != null)
            {
                m_vTimer = new Timer();
                int remainingTime = unitUpgradeObject["t"].ToObject<int>();
                m_vTimer.StartTimer(remainingTime, GetParent().GetLevel().GetTime());

                int id = unitUpgradeObject["id"].ToObject<int>();
                m_vCurrentlyUpgradedUnit = (CombatItemData)ObjectManager.DataTables.GetDataById(id);
            }
        }
 public void StartUpgrading(CombatItemData cid)
 {
     if(CanStartUpgrading(cid))
     {
         m_vCurrentlyUpgradedUnit = cid;
         m_vTimer = new Timer();
         m_vTimer.StartTimer(GetTotalSeconds(), GetParent().GetLevel().GetTime());
     }
 }
        public new void Load(JObject jsonObject)
        {
            this.UpgradeLevel = jsonObject["lvl"].ToObject<int>();
            this.m_vLevel.WorkerManager.DeallocateWorker(this);
            var constTimeToken = jsonObject["const_t"];
            if( constTimeToken != null)
            {
                m_vTimer = new Timer();
                this.m_vIsConstructing = true;
                int remainingConstructionTime = constTimeToken.ToObject<int>();
                m_vTimer.StartTimer(remainingConstructionTime, m_vLevel.GetTime());//a changer ici, utilise seconds_from_last_respawn?
                this.m_vLevel.WorkerManager.AllocateWorker(this);
            }
            this.Locked = false;
            var lockedToken = jsonObject["locked"];
            if (lockedToken != null)
            {
                this.Locked = lockedToken.ToObject<bool>();
            }

            this.SetUpgradeLevel(this.UpgradeLevel);            
            base.Load(jsonObject);
        }
 public void StartUpgrading()
 {
     int constructionTime = GetConstructionItemData().GetConstructionTime(UpgradeLevel + 1);
     if (constructionTime < 1)
     {
         FinishConstruction();
     }
     else
     {
         //todo : collecter les ressources avant upgrade si un component de ressources est défini
         m_vIsConstructing = true;
         m_vTimer = new Timer();
         m_vTimer.StartTimer(constructionTime, m_vLevel.GetTime());
         m_vLevel.WorkerManager.AllocateWorker(this);
     }
 }
 public void StartConstructing(int newX, int newY)
 {
     this.X = newX;
     this.Y = newY;
     int constructionTime = GetConstructionItemData().GetConstructionTime(UpgradeLevel + 1);
     if (constructionTime < 1)
     {
         FinishConstruction();
     }
     else
     {
         m_vTimer = new Timer();
         m_vTimer.StartTimer(constructionTime, m_vLevel.GetTime());
         m_vLevel.WorkerManager.AllocateWorker(this);
         m_vIsConstructing = true;
     }
 }
        public override void Load(JObject jsonObject)
        {
            JObject unitUpgradeObject = (JObject)jsonObject["hero_upg"];
            if (unitUpgradeObject != null)
            {
                m_vTimer = new Timer();
                int remainingTime = unitUpgradeObject["t"].ToObject<int>();
                m_vTimer.StartTimer(remainingTime, GetParent().GetLevel().GetTime());

                m_vUpgradeLevelInProgress = unitUpgradeObject["level"].ToObject<int>();
            }
        }
 public void StartUpgrading()
 {
     if(CanStartUpgrading())
     {
         GetParent().GetLevel().WorkerManager.AllocateWorker(GetParent());
         m_vTimer = new Timer();
         m_vTimer.StartTimer(GetTotalSeconds(), GetParent().GetLevel().GetTime());
         m_vUpgradeLevelInProgress = GetParent().GetLevel().GetPlayerAvatar().GetUnitUpgradeLevel(m_vHeroData) + 1;
         //SetHeroState v27(v24, v26, 1);
         //Not 100% done
     }
 }