Esempio n. 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
                }
            }
        }
Esempio n. 2
0
        private static void loadSifStks(Game.SifResource sif)
        {
            foreach (string stkFile in sif.SoundTracks)
            {
                Sound.SoundTrackResource stk = _sceneContentManager.Load <Sound.SoundTrackResource>(stkFile);
                stk.Start(Game.GameManager.TickCount);

                _stks.Add(stk);
            }
        }
Esempio n. 3
0
        private static void loadSifModels(Game.SifResource sif)
        {
            foreach (Game.SifModel model in sif.Models)
            {
                if (model.Type == Gk3Main.Game.SifModelType.Prop ||
                    model.Type == SifModelType.GasProp)
                {
                    AddModel(model.Name, !model.Hidden &&
                             GameManager.IsInInventory(model.Noun, true) == false &&
                             GameManager.IsInInventory(model.Noun, false) == false);

                    if (model.Type == SifModelType.GasProp)
                    {
                        AddGas(model.Gas);
                    }
                }

                if (_currentRoom != null)
                {
                    // hide the surface if it shouldn't be visible
                    if (model.Type == SifModelType.HitTest || model.Hidden)
                    {
                        _currentRoom.SetSurfaceVisibility(model.Name, false);
                    }
                }

                if (string.IsNullOrEmpty(model.Noun) == false && _modelNounMap.ContainsKey(model.Name) == false)
                {
                    Nouns n = NounUtils.ConvertStringToNoun(model.Noun);
                    _modelNounMap.Add(model.Name, n);
                }

                // play the first frame of the init animation (if it exists)
                if (model.InitAnim != null)
                {
                    _sceneContentManager.Load <MomResource>(model.InitAnim + ".ANM").Play(true);
                }
            }
        }
Esempio n. 4
0
        private static void loadSifActorModels(Game.SifResource sif)
        {
            foreach (Game.SifActor actor in sif.Actors)
            {
                AddActor(actor.Model, actor.Noun, Math.Vector3.Zero, 0, actor.IsEgo);

                if (string.IsNullOrEmpty(actor.Pos) == false)
                {
                    SetActorPosition(actor.Noun, actor.Pos);
                }

                if (string.IsNullOrEmpty(actor.Noun) == false)
                {
                    Nouns n = NounUtils.ConvertStringToNoun(actor.Noun);
                    _modelNounMap.Add(actor.Model, n);
                }

                // play the first frame of the init animation (if it exists)
                if (actor.InitAnim != null)
                {
                    try
                    {
                        _sceneContentManager.Load <MomResource>(actor.InitAnim + ".ANM").Play(true);
                    }
                    catch (System.IO.FileNotFoundException)
                    {
                        // apparently, especially when playing the GK3 demo,
                        // some SIF files can refer to actors that don't actually
                        // exist in the demo, so we need to ignore these errors
                    }
                }
                else if (actor.Idle != null)
                {
                    // play the idle animation
                    _sceneContentManager.Load <GasResource>(actor.Idle).Play();
                }
            }
        }
Esempio n. 5
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);
        }