Ejemplo n.º 1
0
 /// <summary>
 /// The subscriber and subscription occurs in the GameScreen class
 /// everytime a settler is added the Gamescreen starts to listen for
 /// a build command center event from it (if it recieves it it unsubscribes from
 /// this settle instance and also removes the settler from GameScreen)
 /// </summary>
 private void OnBuildCommandCenter()
 {
     if (BuildCommandCenter != null)
     {
         //I commented it out, so we get no Errors due to no Multiple Graph Compatibility.
         BuildCommandCenter(this, EventArgs.Empty, AbsolutePosition, this);
         //Note: It doesnt matter if this is called multiple times from settlers other than the first settler. It will only set variables
         //to true, that has been true already.
         mUi.Activate();
     }
     // debug.
     mUi.Activate();
 }
Ejemplo n.º 2
0
        public void ReloadContent(ContentManager content, GraphicsDeviceManager graphics, Map.Map map, FogOfWar fow, Camera camera, ref Director director, UserInterfaceScreen ui)
        {
            mMap      = map;
            mFow      = fow;
            mCamera   = camera;
            mDirector = director;
            mDirector.GetSoundManager.SetLevelThemeMusic("Tutorial");
            mDirector.GetSoundManager.SetSoundPhase(SoundPhase.Build);
            mSelBox = new SelectionBox(Color.White, mCamera, ref mDirector);
            AddObject(mSelBox);
            //All collider items have to be readded to the ColliderMap
            var colliderlist = new List <ICollider>();

            foreach (var spatial in mSpatialObjects)
            {
                var collider = spatial as ICollider;
                if (collider != null && !colliderlist.Contains(collider))
                {
                    mMap.UpdateCollider(collider);
                    colliderlist.Add(collider);
                }
            }

            //Reload the content for all ingame objects like Platforms etc.
            foreach (var drawable in mDrawables)
            {
                //TODO: Add terrain when its in master
                var possibleMilitaryUnit = drawable as MilitaryUnit;
                var possibleEnemy        = drawable as EnemyUnit;
                var possibleSettler      = drawable as Settler;
                var possiblegenunit      = drawable as GeneralUnit;
                var possiblerock         = drawable as Rock;
                var possiblepuddle       = drawable as Puddle;
                var conUnit = drawable as FreeMovingUnit;
                if (conUnit != null)
                {
                    mSelBox.SelectingBox += conUnit.BoxSelected;
                }
                possibleEnemy?.ReloadContent(content, ref mDirector, camera, ref mMap);
                possiblepuddle?.ReloadContent(ref mDirector);
                possiblerock?.ReloadContent(ref mDirector);
                //This should also affect enemy units, since they are military units
                possibleMilitaryUnit?.ReloadContent(content, ref mDirector, camera, ref map);
                possibleSettler?.ReloadContent(ref mDirector, mCamera, ref map, this, ui);
                if (possibleSettler != null)
                {
                    possibleSettler.BuildCommandCenter += SettlerBuild;
                }
                possiblegenunit?.ReloadContent(ref mDirector, content);
            }

            //Reload the content for all ingame objects like Platforms etc.
            foreach (var updateable in mUpdateables)
            {
                //TODO: Add terrain when its in master
                var possibleMilitaryUnit = updateable as MilitaryUnit;
                var possibleEnemy        = updateable as EnemyUnit;
                var possibleSettler      = updateable as Settler;
                var possiblegenunit      = updateable as GeneralUnit;
                var possiblerock         = updateable as Rock;
                var possiblepuddle       = updateable as Puddle;

                var freeMovingUnit = updateable as FreeMovingUnit;
                if (freeMovingUnit != null && freeMovingUnit.Friendly)
                {
                    mSelBox.SelectingBox += freeMovingUnit.BoxSelected;
                }
                possibleEnemy?.ReloadContent(content, ref mDirector, camera, ref mMap);
                possiblepuddle?.ReloadContent(ref mDirector);
                possiblerock?.ReloadContent(ref mDirector);
                //This should also affect enemy units, since they are military units
                possibleMilitaryUnit?.ReloadContent(content, ref mDirector, camera, ref map);
                possibleSettler?.ReloadContent(ref mDirector, mCamera, ref map, this, ui);
                if (possibleSettler != null)
                {
                    possibleSettler.BuildCommandCenter += SettlerBuild;
                }
                possiblegenunit?.ReloadContent(ref mDirector, content);
            }

            //Reload the content for all ingame objects like Platforms etc.
            foreach (var spatial in mSpatialObjects)
            {
                //TODO: Add terrain when its in master
                var possibleMilitaryUnit = spatial as MilitaryUnit;
                var possibleEnemy        = spatial as EnemyUnit;
                var possibleSettler      = spatial as Settler;
                var possiblegenunit      = spatial as GeneralUnit;
                var possiblerock         = spatial as Rock;
                var possiblepuddle       = spatial as Puddle;
                var freeMovingUnit       = spatial as FreeMovingUnit;
                var possibleplatform     = spatial as PlatformBlank;
                var possibleroad         = spatial as Road;
                if (freeMovingUnit != null && freeMovingUnit.Friendly)
                {
                    mSelBox.SelectingBox += freeMovingUnit.BoxSelected;
                }

                possibleroad?.ReloadContent(ref mDirector);
                possibleEnemy?.ReloadContent(content, ref mDirector, camera, ref mMap);
                possibleplatform?.ReloadContent(content, ref mDirector);
                possiblepuddle?.ReloadContent(ref mDirector);
                possiblerock?.ReloadContent(ref mDirector);
                //This should also affect enemy units, since they are military units
                possibleMilitaryUnit?.ReloadContent(content, ref mDirector, camera, ref map);
                possibleSettler?.ReloadContent(ref mDirector, mCamera, ref map, this, ui);

                if (possibleSettler != null)
                {
                    possibleSettler.BuildCommandCenter += SettlerBuild;
                }
                possiblegenunit?.ReloadContent(ref mDirector, content);
            }

            if (mUistarted)
            {
                ui.Activate();
            }
        }