Esempio n. 1
0
        public bool FinishTaskOfOneWorker()
        {
            LogicGameObject gameObject = this.GetShortestTaskGO();

            if (gameObject != null)
            {
                switch (gameObject.GetGameObjectType())
                {
                case LogicGameObjectType.BUILDING:
                    LogicBuilding building = (LogicBuilding)gameObject;

                    if (building.IsConstructing())
                    {
                        return(building.SpeedUpConstruction());
                    }

                    if (building.GetHeroBaseComponent() != null)
                    {
                        return(building.GetHeroBaseComponent().SpeedUp());
                    }

                    break;

                case LogicGameObjectType.OBSTACLE:
                    LogicObstacle obstacle = (LogicObstacle)gameObject;

                    if (obstacle.IsClearingOnGoing())
                    {
                        return(obstacle.SpeedUpClearing());
                    }

                    break;

                case LogicGameObjectType.TRAP:
                    LogicTrap trap = (LogicTrap)gameObject;

                    if (trap.IsConstructing())
                    {
                        return(trap.SpeedUpConstruction());
                    }

                    break;

                case LogicGameObjectType.VILLAGE_OBJECT:
                    LogicVillageObject villageObject = (LogicVillageObject)gameObject;

                    if (villageObject.IsConstructing())
                    {
                        return(villageObject.SpeedUpCostruction());
                    }

                    break;
                }
            }

            return(false);
        }
Esempio n. 2
0
        public LogicGameObject GetShortestTaskGO()
        {
            LogicGameObject gameObject = null;

            for (int i = 0, minRemaining = -1, tmpRemaining = 0; i < this.m_constructions.Size(); i++, tmpRemaining = 0)
            {
                LogicGameObject tmp = this.m_constructions[i];

                switch (this.m_constructions[i].GetGameObjectType())
                {
                case LogicGameObjectType.BUILDING:
                    LogicBuilding building = (LogicBuilding)tmp;

                    if (building.IsConstructing())
                    {
                        tmpRemaining = building.GetRemainingConstructionTime();
                    }
                    else
                    {
                        LogicHeroBaseComponent heroBaseComponent = building.GetHeroBaseComponent();

                        if (heroBaseComponent == null)
                        {
                            Debugger.Warning("LogicWorkerManager - Worker allocated to building with remaining construction time 0");
                        }
                        else
                        {
                            if (heroBaseComponent.IsUpgrading())
                            {
                                tmpRemaining = heroBaseComponent.GetRemainingUpgradeSeconds();
                            }
                            else
                            {
                                Debugger.Warning("LogicWorkerManager - Worker allocated to altar/herobase without hero upgrading");
                            }
                        }
                    }

                    break;

                case LogicGameObjectType.OBSTACLE:
                    LogicObstacle obstacle = (LogicObstacle)tmp;

                    if (obstacle.IsClearingOnGoing())
                    {
                        tmpRemaining = obstacle.GetRemainingClearingTime();
                    }
                    else
                    {
                        Debugger.Warning("LogicWorkerManager - Worker allocated to obstacle with remaining clearing time 0");
                    }

                    break;

                case LogicGameObjectType.TRAP:
                    LogicTrap trap = (LogicTrap)tmp;

                    if (trap.IsConstructing())
                    {
                        tmpRemaining = trap.GetRemainingConstructionTime();
                    }
                    else
                    {
                        Debugger.Warning("LogicWorkerManager - Worker allocated to trap with remaining construction time 0");
                    }

                    break;

                case LogicGameObjectType.VILLAGE_OBJECT:
                    LogicVillageObject villageObject = (LogicVillageObject)tmp;

                    if (villageObject.IsConstructing())
                    {
                        tmpRemaining = villageObject.GetRemainingConstructionTime();
                    }
                    else
                    {
                        Debugger.Error("LogicWorkerManager - Worker allocated to building with remaining construction time 0 (vilobj)");
                    }

                    break;
                }

                if (gameObject == null || minRemaining > tmpRemaining)
                {
                    gameObject   = tmp;
                    minRemaining = tmpRemaining;
                }
            }

            return(gameObject);
        }