Exemple #1
0
        internal void FinishTaskOfOneWorker()
        {
            GameObject GameObject = this.GetShortestTaskGO();

            if (GameObject != null)
            {
                if (GameObject is Building)
                {
                    Building          Building          = (Building)GameObject;
                    HeroBaseComponent HeroBaseComponent = Building.HeroBaseComponent;
                    if (Building.Constructing)
                    {
                        Building.SpeedUpConstruction();
                    }
                    else if (HeroBaseComponent != null)
                    {
                        if (HeroBaseComponent.Upgrading)
                        {
                            HeroBaseComponent.SpeedUpUpgrade();
                        }
                    }
                }
                else if (GameObject is Obstacle)
                {
                    Obstacle Obstacle = (Obstacle)GameObject;
                    if (Obstacle.ClearingOnGoing)
                    {
                        Obstacle.SpeedUpClearing();
                    }
                }
                else if (GameObject is Trap)
                {
                    Trap Trap = (Trap)GameObject;
                    if (Trap.Constructing)
                    {
                        Trap.SpeedUpConstruction();
                    }
                }
                else if (GameObject is VillageObject)
                {
                    VillageObject VillageObject = (VillageObject)GameObject;
                    if (VillageObject.Constructing)
                    {
                        VillageObject.SpeedUpConstruction();
                    }
                }
            }
        }
Exemple #2
0
        internal GameObject GetShortestTaskGO()
        {
            if (this.GameObjects.Count > 0)
            {
                Task Task = new Task();

                for (int i = 0; i < GameObjects.Count; i++)
                {
                    GameObject Construction  = GameObjects[i];
                    int        RemainingTime = -1;

                    if (Construction is Building)
                    {
                        Building          Building          = (Building)Construction;
                        HeroBaseComponent HeroBaseComponent = Building.HeroBaseComponent;
                        if (HeroBaseComponent != null)
                        {
                            if (HeroBaseComponent.Upgrading)
                            {
                                RemainingTime = HeroBaseComponent.RemainingUpgradeTime;
                            }
                        }
                        else if (!Building.Constructing)
                        {
                            Logging.Error(this.GetType(), "GetShortestTaskGO() : Worker allocated to building with remaining construction time 0");
                        }
                        else
                        {
                            RemainingTime = Building.RemainingConstructionTime;
                        }
                    }
                    else if (Construction is Obstacle)
                    {
                        Obstacle Obstacle = (Obstacle)Construction;
                        if (!Obstacle.ClearingOnGoing)
                        {
                            Logging.Error(this.GetType(), "GetShortestTaskGO() : Worker allocated to obstacle with remaining clearing time 0");
                        }
                        else
                        {
                            RemainingTime = Obstacle.RemainingClearingTime;
                        }
                    }
                    else if (Construction is Trap)
                    {
                        Trap Trap = (Trap)Construction;
                        if (!Trap.Constructing)
                        {
                            Logging.Error(this.GetType(), "GetShortestTaskGO() : Worker allocated to Trap with remaining construction time 0");
                        }
                        else
                        {
                            RemainingTime = Trap.RemainingConstructionTime;
                        }
                    }
                    else if (Construction is VillageObject)
                    {
                        VillageObject VillageObject = (VillageObject)Construction;
                        if (!VillageObject.Constructing)
                        {
                            Logging.Error(this.GetType(), "GetShortestTaskGO() : Worker allocated to village object with remaining clearing time 0");
                        }
                        else
                        {
                            RemainingTime = VillageObject.RemainingConstructionTime;
                        }
                    }

                    if (RemainingTime != -1)
                    {
                        if (Task.GameObject == null)
                        {
                            Task.GameObject       = Construction;
                            Task.RemainingSeconds = RemainingTime;
                        }
                        else if (Task.RemainingSeconds > RemainingTime)
                        {
                            Task.GameObject       = Construction;
                            Task.RemainingSeconds = RemainingTime;
                        }
                    }
                }

                return(Task.GameObject);
            }

            return(null);
        }