コード例 #1
0
        public bool Update(GameTime time)
        {
            if (IsPaused)
            {
                mLastTimeResources = time.TotalGameTime.TotalMilliseconds - (time.TotalGameTime.TotalMilliseconds - mLastTimeResources);
                foreach (var player in BuildingsByPlayer.Keys)
                {
                    foreach (var unit in BuildingsByPlayer[player])
                    {
                        if (unit.UnitType == UnitTypes.Quarry || unit.UnitType == UnitTypes.GoldMine)
                        {
                            unit.IsPaused(time);
                        }
                    }
                }
                return(false);
            }

            if (mLastTimeResources + 5000 < time.TotalGameTime.TotalMilliseconds)
            {
                foreach (var player in Resources.Keys)
                {
                    Resources[player][Unit.Resources.Gold]++;
                    Resources[player][Unit.Resources.Stone]++;
                }

                mLastTimeResources = time.TotalGameTime.TotalMilliseconds;
            }

            AddQueuedUnits();

            SpatialUnitsByPlayer.Update(UnitsByPlayer);

            TriggerAutoDefense(time);

            RunUnitLifecycle(time);


            if (CheckVictory())
            {
                return(true);
            }
            HeroRespawnManager.Update();
            mEnemy.Update(time);

            InGameTime(time);
            InGameStatistics();
            return(false);
        }