Пример #1
0
 public EventPage()
 {
     this.Name          = "Untitled Page";
     this.Graphic       = new EventGraphic();
     this.TriggerMode   = TriggerMode.Action;
     this.AutoMoveRoute = new AutoMoveRoute();
     this.Settings      = new EventSettings();
 }
Пример #2
0
        public EventGraphic Clone()
        {
            EventGraphic o = new EventGraphic();

            o.Type          = this.Type;
            o.Param         = this.Param;
            o.Direction     = this.Direction;
            o.NumDirections = this.NumDirections;
            o.NumFrames     = this.NumFrames;
            return(o);
        }
Пример #3
0
        public EventPage(Dictionary <string, object> Data)
        {
            if (Data.ContainsKey("^c"))
            {
                if ((string)Data["^c"] != "MKD::Event::Page")
                {
                    throw new Exception("Invalid class - Expected class of type MKD::Event::Page but got " + (string)Data["^c"] + ".");
                }
            }
            else
            {
                throw new Exception("Could not find a ^c key to identify this class.");
            }
            foreach (object o in ((JArray)Data["@commands"]).ToObject <List <object> >())
            {
                if (!(o is JArray))
                {
                    throw new Exception($"A command must have the format [indentation, identifier, parameters]!");
                }
                List <object> command = ((JArray)o).ToObject <List <object> >();
                if (command.Count != 2 && command.Count != 3)
                {
                    throw new Exception($"A command must have the format [indentation, identifier, parameters]!");
                }
                int    indent = Convert.ToInt32(command[0]);
                string id     = (string)command[1];
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                if (command.Count == 3)
                {
                    if (!(command[2] is JObject))
                    {
                        throw new Exception($"A command's third argument (command parameter) must be a hash!");
                    }
                    parameters = (Dictionary <string, object>)Utilities.JsonToNative(command[2]);
                }
                this.Commands.Add(BasicCommand.IDToCommand(indent, id, parameters));
            }
            foreach (object o in ((JArray)Data["@conditions"]).ToObject <List <object> >())
            {
                if (!(o is JArray))
                {
                    throw new Exception($"A condition must have the format [identifier, parameters]!");
                }
                List <object> command = ((JArray)o).ToObject <List <object> >();
                if (command.Count != 1 && command.Count != 2)
                {
                    throw new Exception($"A condition must have the format [identifier, parameters]!");
                }
                string id = (string)command[0];
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                if (command.Count == 2)
                {
                    if (!(command[1] is JObject))
                    {
                        throw new Exception($"A condition's second argument (condition parameter) must be a hash!");
                    }
                    parameters = (Dictionary <string, object>)Utilities.JsonToNative(command[1]);
                }
                this.Conditions.Add(BasicCondition.IDToCondition(id, parameters));
            }
            this.Name    = (string)Data["@name"];
            this.Graphic = new EventGraphic(((JObject)Data["@graphic"]).ToObject <Dictionary <string, object> >());
            string mode = (string)Data["@trigger_mode"];

            if (mode == ":action")
            {
                TriggerMode = TriggerMode.Action;
            }
            else if (mode == ":player_touch")
            {
                TriggerMode = TriggerMode.PlayerTouch;
            }
            else if (mode == ":event_touch")
            {
                TriggerMode = TriggerMode.EventTouch;
            }
            else if (mode == ":autorun")
            {
                TriggerMode = TriggerMode.Autorun;
            }
            else if (mode == ":parallel_process")
            {
                TriggerMode = TriggerMode.ParallelProcess;
            }
            this.TriggerParam  = Data["@trigger_param"];
            this.AutoMoveRoute = new AutoMoveRoute(((JObject)Data["@automoveroute"]).ToObject <Dictionary <string, object> >());
            this.Settings      = new EventSettings(((JObject)Data["@settings"]).ToObject <Dictionary <string, object> >());
        }