Beispiel #1
0
        public void Update(GameTime gametime)
        {
            foreach (var updateable in mUpdateables)
            {
                updateable.Update(gametime);
            }

            List <ISpatial> copyList = (mSpatialObjects.Concat(mMap.GetStructureMap().GetPlatformList()).ToList());

            foreach (var spatial in copyList)
            {
                var collidingObject = spatial as ICollider;

                if (collidingObject != null)
                {
                    mMap.UpdateCollider(collidingObject);
                }

                spatial.RelativePosition = Vector2.Transform(spatial.AbsolutePosition, mCamera.GetTransform());
                spatial.RelativeSize     = spatial.AbsoluteSize * mCamera.GetZoom();

                spatial.Update(gametime);
            }
            mMap.GetStructureMap().Update(gametime);

            mFow.Update(gametime);

            mTransformMatrix = mCamera.GetTransform();
        }
Beispiel #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();
            }
        }