コード例 #1
0
 public void mod(CommandNoteAdd modable)
 {
     if (modable == null)
     {
         return;
     }
     mod(this, modable);
 }
コード例 #2
0
    public override IModable copyDeep()
    {
        var result = new CommandNoteAdd();

        result.NoteID = Modable.copyDeep(NoteID);
        result.Text   = Modable.copyDeep(Text);

        return(result);
    }
コード例 #3
0
    public override void mod(IModable modable)
    {
        CommandNoteAdd modCommand = modable as CommandNoteAdd;

        if (modCommand == null)
        {
            Debug.LogError("Type mismatch");
            return;
        }

        mod(modCommand);
    }
コード例 #4
0
 private void mod(CommandNoteAdd original, CommandNoteAdd mod)
 {
     NoteID = Modable.mod(original.NoteID, mod.NoteID);
     Text   = Modable.mod(original.Text, mod.Text);
 }
コード例 #5
0
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
        Command result;

        JObject jo = JObject.Load(reader);

        if (!Enum.TryParse((string)jo["Type"], out Command.Type commandType))
        {
            Debug.LogError($"CommandType {jo["Type"]} not recognized in {jo}");
            return(new CommandNone());
        }

        switch (commandType)
        {
        case (Command.Type.Break):
            result = new CommandBreak();
            break;

        case (Command.Type.Call):
            result = new CommandCall();
            break;

        case (Command.Type.Conditional):
            result = new CommandConditional();
            break;

        case (Command.Type.Consume):
            result = new CommandConsume();
            break;

        case (Command.Type.Continue):
            result = new CommandContinue();
            break;

        case (Command.Type.Debug):
            result = new CommandDebug();
            break;

        case (Command.Type.Dialog):
            result = new CommandDialog();
            break;

        case (Command.Type.Dialogue):
            result = new CommandDialogue();
            break;

        case (Command.Type.Event):
            result = new CommandEvent();
            break;

        case (Command.Type.EventEnd):
            result = new CommandEventEnd();
            break;

        case (Command.Type.Flush):
            result = new CommandFlush();
            break;

        case (Command.Type.GotoLocation):
            result = new CommandGotoLocation();
            break;

        case (Command.Type.Interrupt):
            result = new CommandInterrupt();
            break;

        case (Command.Type.ItemAdd):
            result = new CommandItemAdd();
            break;

        case (Command.Type.ItemRemove):
            result = new CommandItemRemove();
            break;

        case (Command.Type.NoteAdd):
            result = new CommandNoteAdd();
            break;

        case (Command.Type.NoteRemove):
            result = new CommandNoteRemove();
            break;

        case (Command.Type.Outfit):
            result = new CommandOutfit();
            break;

        case (Command.Type.OutfitManage):
            result = new CommandOutfitManage();
            break;

        case (Command.Type.Pause):
            result = new CommandPause();
            break;

        case (Command.Type.Services):
            result = new CommandServices();
            break;

        case (Command.Type.Set):
            result = new CommandSet();
            break;

        case (Command.Type.Shop):
            result = new CommandShop();
            break;

        case (Command.Type.Sleep):
            result = new CommandSleep();
            break;

        case (Command.Type.TimePass):
            result = new CommandTimePass();
            break;

        case (Command.Type.None):
        default:
            result = new CommandNone();
            break;
        }

        serializer.Populate(jo.CreateReader(), result);

        return(result);

        /*if (reader.TokenType == JsonToken.Null)
         *  return new CText();
         *
         * if (reader.TokenType == JsonToken.StartObject)
         * {
         *  //https://stackoverflow.com/questions/35586987/json-net-custom-serialization-with-jsonconverter-how-to-get-the-default-beha
         *  existingValue = existingValue ?? serializer.ContractResolver.ResolveContract(objectType).DefaultCreator();
         *  serializer.Populate(reader, existingValue);
         *  return existingValue;
         * }
         *
         * if (reader.TokenType == JsonToken.String)
         *  return new CText((string)reader.Value);
         *
         */
        //throw new JsonSerializationException();
    }