예제 #1
0
        private static void loadSifNvcs(Game.SifResource sif)
        {
            foreach (string nvcFile in sif.Actions)
            {
                try
                {
                    // just because an NVC is loaded doesn't automatically mean we should load and use it!
                    int underscore = nvcFile.IndexOf("_");
                    if (underscore >= 0)
                    {
                        int all = nvcFile.IndexOf("all", StringComparison.OrdinalIgnoreCase);
                        if (all != underscore + 1) // check for day limitations
                        {
                            // I think looking for underscore should be enough to determine which NVCs we need
                            // to examine closer... maybe...
                            int currentDay = GameManager.CurrentDay;
                            if (nvcFile.Substring(underscore + 1).Contains(currentDay.ToString()) == false)
                            {
                                continue;
                            }
                        }
                    }

                    NvcResource nvc = _sceneContentManager.Load <NvcResource>(nvcFile);
                    NvcManager.AddNvc(nvc, false);
                }
                catch (System.IO.FileNotFoundException)
                {
                    // do nothing, sometimes NVCs just don't exist
                }
            }
        }
예제 #2
0
 private static void loadGlobalNvc(Resource.ResourceManager content)
 {
     NvcManager.AddNvc(content.Load <NvcResource>("GLB_ALL.NVC"), true);
 }
예제 #3
0
        public static void LoadSif(string sif)
        {
            Logger.WriteInfo("Loading SIF: " + sif, LoggerStream.Normal);

            Animator.StopAll();
            Sheep.SheepMachine.CancelAllWaits();

            SifResource sifResource = _sceneContentManager.Load <SifResource>(sif);

            _currentRoom      = null;
            _currentLightmaps = null;
            _roomPositions.Clear();
            _cameras.Clear();
            _modelNounMap.Clear();
            _stks.Clear();
            NvcManager.Reset();

            // attempt to load a "parent" sif
            Gk3Main.Game.SifResource parentSif = null;
            if (sif.IndexOf('.') != 3 && sif.Length > 3) //if we're loading "XXX.SIF" then we're already loading the parent sif
            {
                string parentSifName = sif.Substring(0, 3);
                if (parentSifName.Equals(sif, StringComparison.OrdinalIgnoreCase) == false)
                {
                    try
                    {
                        parentSif = _sceneContentManager.Load <SifResource>(parentSifName);
                    }
                    catch
                    {
                        // ignore
                    }
                }
            }

            if (string.IsNullOrEmpty(sifResource.Scene) == false)
            {
                LoadScene(sifResource.Scene);
            }
            else if (parentSif != null && string.IsNullOrEmpty(parentSif.Scene) == false)
            {
                LoadScene(parentSif.Scene);
            }

            // load the pathing info
            if (string.IsNullOrEmpty(sifResource.Boundary) == false)
            {
                _currentPathMap = new ActorPathfinder(sifResource.Boundary, sifResource.BoundarySize, sifResource.BoundaryOffset);
            }
            else if (parentSif != null && string.IsNullOrEmpty(parentSif.Boundary) == false)
            {
                _currentPathMap = new ActorPathfinder(parentSif.Boundary, parentSif.BoundarySize, parentSif.BoundaryOffset);
            }

            // temp

            /* Math.Vector2 start = new Math.Vector2(17,41);
             * Math.Vector2 end = new Math.Vector2(35, 45);
             * Math.Vector2[] path = _currentPathMap.CalculatePath(start, end);
             * Logger.WriteInfo("path from " + start.ToString() + " to " + end.ToString());
             * if (path == null)
             *   Logger.WriteInfo("NO PATH FOUND!");
             * else
             *  _currentPathMap.PrintPathToLogger(path);
             */
            // load the models
            _modelNounMap.Clear();
            loadSifModels(sifResource);
            if (parentSif != null)
            {
                loadSifModels(parentSif);
            }

            // load the NVCs
            loadSifNvcs(sifResource);
            if (parentSif != null)
            {
                loadSifNvcs(parentSif);
            }
            NvcManager.Compile();

            // load the STKs
            Sound.SoundManager.StopChannel(Sound.SoundTrackChannel.Music);
            loadSifStks(sifResource);
            if (parentSif != null)
            {
                loadSifStks(parentSif);
            }

            // load positions and room cameras
            foreach (SifRoomCamera camera in sifResource.RoomCameras)
            {
                _cameras.Add(camera.Name, camera);
            }
            foreach (SifPosition position in sifResource.Positions)
            {
                _roomPositions.Add(position.Name, position);
            }

            if (parentSif != null)
            {
                foreach (SifRoomCamera camera in parentSif.RoomCameras)
                {
                    // only add if it doesn't exist yet
                    if (_cameras.ContainsKey(camera.Name) == false)
                    {
                        _cameras.Add(camera.Name, camera);
                    }
                }
                foreach (SifPosition position in parentSif.Positions)
                {
                    // only add if it doesn't exist yet
                    if (_roomPositions.ContainsKey(position.Name) == false)
                    {
                        _roomPositions.Add(position.Name, position);
                    }
                }
            }

            loadSifActorModels(sifResource);
            if (parentSif != null)
            {
                loadSifActorModels(parentSif);
            }

            Sound.SoundManager.StopChannel(Gk3Main.Sound.SoundTrackChannel.Ambient);

            setupCustomScenes(GameManager.CurrentLocation);
        }