예제 #1
0
        /// <summary>
        ///     Gets the shortest task.
        /// </summary>
        public LogicGameObject GetShortestTaskGO()
        {
            LogicGameObject gameObject = null;

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

                switch (this._constructions[i].GetGameObjectType())
                {
                case 0:
                    LogicBuilding building = (LogicBuilding)tmp;

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

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

                    break;

                case 3:
                    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 4:
                    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 8:

                    break;
                }

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

            return(gameObject);
        }