コード例 #1
0
 public ResourceProductionComponent(ConstructionItem ci, Level level)
     : base(ci)
 {
     this.m_vTimeSinceLastClick = level.GetTime();
     this.m_vProductionResourceData = ObjectManager.DataTables.GetResourceByName(((BuildingData)ci.GetData()).ProducesResource);
     this.m_vResourcesPerHour = ((BuildingData)ci.GetData()).ResourcePerHour;
     this.m_vMaxResources = ((BuildingData)ci.GetData()).ResourceMax;
 }
コード例 #2
0
        public CombatComponent(ConstructionItem ci, Level level) : base(ci)
        {
            var bd = (BuildingData)ci.GetData();

            if (bd.AmmoCount != 0)
            {
                m_vAmmo = bd.AmmoCount;
            }
        }
コード例 #3
0
        public GameObject GetShortestTaskGO()
        {
            GameObject shortestTaskGO = null;
            int        shortestGOTime = 0;
            int        currentGOTime;

            foreach (var go in m_vGameObjectReferences)
            {
                currentGOTime = -1;
                if (go.ClassId == 3)
                {
                    Obstacle o = (Obstacle)go;
                    if (o.IsClearingOnGoing())
                    {
                        currentGOTime = o.GetRemainingClearingTime();
                    }
                }
                else
                {
                    ConstructionItem c = (ConstructionItem)go;
                    if (c.IsConstructing())
                    {
                        currentGOTime = c.GetRemainingConstructionTime();
                    }
                    else
                    {
                        var hero = c.GetHeroBaseComponent();
                        if (hero != null)
                        {
                            if (hero.IsUpgrading())
                            {
                                currentGOTime = hero.GetRemainingUpgradeSeconds();
                            }
                        }
                    }
                }
                if (shortestTaskGO == null)
                {
                    if (currentGOTime > -1)
                    {
                        shortestTaskGO = go;
                        shortestGOTime = currentGOTime;
                    }
                }
                else if (currentGOTime > -1)
                {
                    if (currentGOTime < shortestGOTime)
                    {
                        shortestGOTime = currentGOTime;
                        shortestTaskGO = go;
                    }
                }
            }
            return(shortestTaskGO);
        }
コード例 #4
0
        public void CollectResources()
        {
            ConstructionItem ci               = (ConstructionItem)GetParent();
            TimeSpan         span             = ci.GetLevel().GetTime() - this.m_vTimeSinceLastClick;
            float            currentResources = ((this.m_vResourcesPerHour[ci.UpgradeLevel] / (60f * 60f)) * (float)(span.TotalSeconds));

            currentResources = Math.Min(Math.Max(currentResources, 0), this.m_vMaxResources[ci.UpgradeLevel]);

            if (currentResources >= 1)
            {
                ClientAvatar ca = ci.GetLevel().GetPlayerAvatar();
                if (ca.GetResourceCap(this.m_vProductionResourceData) >= ca.GetResourceCount(this.m_vProductionResourceData) + currentResources)
                {
                    Debugger.WriteLine(String.Format("Collect {0} {1}", (int)currentResources, this.m_vProductionResourceData.GetName()), null, 5, ConsoleColor.Green);

                    ca.CommodityCountChangeHelper(0, this.m_vProductionResourceData, (int)currentResources);
                    this.m_vTimeSinceLastClick = ci.GetLevel().GetTime();
                }
            }
        }
コード例 #5
0
 public ResourceProductionComponent(ConstructionItem ci, Level level) : base(ci)
 {
     m_vTimeSinceLastClick = level.Avatar.LastTickSaved;
 }