Ejemplo n.º 1
0
 // Load saved data
 public void Setup(ClockSaveData save)
 {
     _alarmEnabled = save.AlarmEnabled;
     _alarmHour    = save.AlarmHour;
     _alarmMinute  = save.AlarmMinute;
     _color        = save.DisplayColor;
 }
Ejemplo n.º 2
0
        public override void OnSave()
        {
            DigitalClockBehaviour c = _clock.GetComponent <DigitalClockBehaviour>();

            ClockSaveData.Serialize(new ClockSaveData()
            {
                Position     = this._clock.transform.position,
                Rotation     = this._clock.transform.rotation,
                AlarmEnabled = c.AlarmEnabled,
                AlarmHour    = c.AlarmHour,
                AlarmMinute  = c.AlarmMinute,
                DisplayColor = c.DisplayColor
            }, this._savePath);
        }
Ejemplo n.º 3
0
 public static void Serialize(ClockSaveData data, string path)
 {
     try
     {
         XmlSerializer serializer = new XmlSerializer(typeof(ClockSaveData));
         XmlWriter     writer     = XmlWriter.Create(new StreamWriter(path));
         serializer.Serialize(writer, data);
         writer.Close();
     }
     catch (Exception ex)
     {
         ModConsole.Error(ex.ToString());
     }
 }
Ejemplo n.º 4
0
        public override void OnLoad()
        {
            AssetBundle ab       = LoadAssets.LoadBundle(this, "digitalclock.unity3d");
            GameObject  original = ab.LoadAsset <GameObject>("digitalclock.prefab");

            _clock       = GameObject.Instantiate <GameObject>(original);
            _clock.name  = "'Atomnyje' clock(Clone)";
            _clock.layer = LayerMask.NameToLayer("Parts");
            _clock.tag   = "PART";
            DigitalClockBehaviour c = _clock.AddComponent <DigitalClockBehaviour>();

            ClockSaveData save = ClockSaveData.Deserialize(_savePath);

            _clock.transform.position = save.Position;
            _clock.transform.rotation = save.Rotation;
            c.Setup(save);

            GameObject.Destroy(original);
            ab.Unload(false);

            ConsoleCommand.Add(new ClockCommand(this, c));

            ModConsole.Print(string.Format("[Clock24] 24-hour clock has loaded.\nThe current time is {0:0}:{1:00}", c.Clock.Hour24, c.Clock.Minute));
        }