Beispiel #1
0
        public void Execute(string tutorialID)
        {
            GameModel game = AmbitionApp.Game;

            if (game.Tutorials.Contains(tutorialID))
            {
                UFlowSvc uflow   = AmbitionApp.GetService <UFlowSvc>();
                UMachine machine = uflow.IsActiveFlow(tutorialID)
                    ? null
                    : uflow.Invoke(tutorialID);
            }
        }
Beispiel #2
0
        private void HandleSnapShot(byte[] snapshot)
        {
            LocalizationModel loc      = AmbitionApp.GetModel <LocalizationModel>();
            GameModel         model    = AmbitionApp.GetModel <GameModel>();
            IncidentModel     incident = AmbitionApp.GetModel <IncidentModel>();
            string            path     = Path.Combine(UnityEngine.Application.persistentDataPath, Filepath.SAVE_FILE);
            List <string[]>   saves;
            string            result;
            string            saveID       = loc?.HeaderTitlePhrase;
            string            snapshotPath = DateTime.Now.Ticks.ToString() + ".jpg";

            if (File.Exists(path))
            {
                result = File.ReadAllText(path);
                saves  = JsonConvert.DeserializeObject <List <string[]> >(result);
            }
            else
            {
                saves = new List <string[]>();
            }

            if (!string.IsNullOrEmpty(saveID))
            {
                saveID = AmbitionApp.Localize(saveID);
                saveID = string.IsNullOrEmpty(saveID)
                    ? model.PlayerName + " - " + loc.HeaderTitlePhrase + " - " + DateTime.Now.ToString()
                    : model.PlayerName + " - " + saveID + " - " + DateTime.Now.ToString();
            }
            else
            {
                saveID = model.PlayerName + " - " + DateTime.Now.ToString();
            }

            string[] savedGame = new string[]
            {
                saveID,
                snapshotPath,
                AmbitionApp.GetService <ModelSvc>().Save()
            };
            if (snapshot != null)
            {
                snapshotPath = Path.Combine(UnityEngine.Application.persistentDataPath, snapshotPath);
                System.IO.File.WriteAllBytes(snapshotPath, snapshot);
            }
            model.SaveSlotID = saves.Count;
            saves.Add(savedGame);
            result = JsonConvert.SerializeObject(saves);
            File.WriteAllText(path, result);
        }
Beispiel #3
0
        public override void OnClose()
        {
            AudioSvc audio = AmbitionApp.GetService <AudioSvc>();
            string   path  = Path.Combine(UnityEngine.Application.persistentDataPath, Filepath.SETTINGS);

            _settings.Volume = new Dictionary <AudioChannel, int>()
            {
                { AudioChannel.Ambient, audio.GetVolume(AudioChannel.Ambient) },
                { AudioChannel.Sfx, audio.GetVolume(AudioChannel.Sfx) },
                { AudioChannel.Music, audio.GetVolume(AudioChannel.Music) },
                { AudioChannel.Master, audio.GetVolume(AudioChannel.Master) }
            };
            _settings.Resolution = Screen.currentResolution;
            _settings.Language   = _languages[LocSelector.value];
            File.WriteAllText(path, JsonConvert.SerializeObject(_settings));
        }
Beispiel #4
0
 public void OnVolumeChanged()
 {
     AmbitionApp.GetService <AudioSvc>().SetVolume(Channel, (int)Slider.value);
 }
Beispiel #5
0
 void OnEnable()
 {
     Slider.value = AmbitionApp.GetService <AudioSvc>().GetVolume(Channel);
 }
Beispiel #6
0
 public void Execute(string tutorialID)
 {
     AmbitionApp.Game.Tutorials.RemoveAll(t => t == tutorialID);
     AmbitionApp.GetService <UFlow.UFlowSvc>().Unregister(tutorialID);
 }