コード例 #1
0
 public GameState(Camera camera, int gridSize, ContentManager content)
 {
     mGridSize            = gridSize;
     mCamera              = camera;
     UnitsByPlayer        = new Dictionary <Players, List <IUnit> >();
     SpatialUnitsByPlayer = new SpatialStructuredUnits(mGridSize);
     BuildingsByPlayer    = new Dictionary <Players, List <IUnit> >();
     HeroesByPlayer       = new Dictionary <Players, Hero>();
     UnitsByModel         = new Dictionary <ModelManager.Model, List <IUnit> >();
     Resources            = new Dictionary <Players, Dictionary <Resources, int> >();
     VillagePos           = new Dictionary <Players, Vector2>();
     VillagesByPlayer     = new Dictionary <Players, Village>();
     mMap               = new TileStates[0, 0];
     mPathZones         = new PathFindingZones(0, 0, mGridSize);
     IsPaused           = true;
     mCollision         = new CollisionHandler(gridSize, UnitsByPlayer, IsObstructed);
     mEnemy             = new DummyKi();
     HeroRespawnManager = new HeroRespawnManager();
     mDamageFactor      = new Dictionary <Players, float>();
     foreach (var player in PlayerConstants.sPlayers)
     {
         mDamageFactor.Add(player, 1f);
     }
     mBlockedSound      = new SoundEffectManager(content, "sounds/Logo_miss");
     mStatistics        = new Statistics(content, null, null);
     StatisticsByPlayer = new Dictionary <Players, Dictionary <string, int> >();
     InitStatisticsByPlayer(Players.Player);
     InitStatisticsByPlayer(Players.Ai);
     mPathFinderInstances = new ThreadLocal <PathFinder>(() => new PathFinder(IsObstructed, gridSize));
     mContent             = content;
 }
コード例 #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            ExitWrapper.Init(this);
            mGraphics.GraphicsProfile = GraphicsProfile.HiDef;

            if (Settings.Dict["Fullscreen"] == "on")
            {
                ScreenSize.CurrentSize(mGraphics);
            }
            else
            {
                mGraphics.ApplyChanges();
            }
            IsMouseVisible = false;
            mCamera        = new Camera(mGraphics)
            {
                Position = AMainMenuPage.sCameraPosition
            };
            CameraWrapper.Init(mCamera);
            Globals.GetResolution(mGraphics);
            mInputManager = new InputManager(Content);
            mInputManager.GetCam(mCamera);
            ExitWrapper.LoadInputManager(mInputManager);
            CameraWrapper.LoadInputManager(mInputManager);
            ModelManager.Initialize(mGraphics.GraphicsDevice, Content, mCamera);
            AKi.LoadInputManager(mInputManager);
            ToolBox.Initialize(mGraphics, mCamera);
            SoundManager.Init();
            mMusicManager = new MusicManager(Content, "music/background", "music/win", "music/lose");

            mSoundEffectManager = new SoundEffectManager(Content, "sounds/battering_ram", "sounds/bowman", "sounds/cavalry", "sounds/swordsman", "sounds/hero");
            AAudioMenu.Init(mSoundEffectManager, mMusicManager);
            GameState.Init(mSoundEffectManager);

            base.Initialize();
        }