Exemplo n.º 1
0
        public void FinishTaskOfOneWorker()
        {
            GameObject go = GetShortestTaskGO();

            if (go != null)
            {
                if (go.ClassId == 3)
                {
                    Obstacle o = (Obstacle)go;
                    if (o.IsClearingOnGoing())
                    {
                        o.SpeedUpClearing();
                    }
                }
                else
                {
                    ConstructionItem b = (ConstructionItem)go;
                    if (b.IsConstructing())
                    {
                        b.SpeedUpConstruction();
                    }
                    else
                    {
                        var hero = b.GetHeroBaseComponent();
                        if (hero != null)
                        {
                            hero.SpeedUpUpgrade();
                        }
                    }
                }
            }
        }
Exemplo n.º 2
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);
        }