示例#1
0
 void Awake()
 {
     partyNoteParent = GameObject.Find("PartyNote").transform;
     enemyNoteParent = GameObject.Find("EnemyNote").transform;
     //それぞれの変数にオブジェクトを格納する
     //enemySliderのhpスクリプトを取得
     notes = GameObject.Find("enemySlider");
     hp    = notes.GetComponent <hp>();
     //CharaStatusスクリプトを取得
     CharaStatus = GetComponent <Charastatus>();
     //partyNoteのnoteスクリプトを取得
     partyNote = GameObject.Find("PartyNote");
     note      = partyNote.GetComponent <note>();
     //Frequencyスクリプト取得
     noteFrequency = partyNote.GetComponent <NoteFrequency>();
     //TouchHanteiスクリプト取得
     touchHantei = GetComponent <TouchHantei>();
     //enemyNoteのenemynoteスクリプトを取得
     enemyNote = GameObject.Find("EnemyNote");
     enemynote = enemyNote.GetComponent <enemynote>();
     //ScenairoTextのScenarioTextスクリプトを取得
     text         = GameObject.Find("ScenarioText");
     scenarioText = text.GetComponent <ScenarioText>();
     //ScenarioCharaのScenarioCharaスクリプトを取得
     chara         = GameObject.Find("Image");
     scenarioChara = chara.GetComponent <ScinarioChara>();
     //BGMスタート
     audioSource = GetComponent <AudioSource>();
 }
示例#2
0
 public void AddNote(note note)
 {
     note.transform.position = startPosition.position;
     note.transform.parent   = transform;
     note.SetChecker(this);
     notes.Add(note);
 }
示例#3
0
    void NoteGeneratorUpdate()
    {
        if (createdLastNote)
        {
            return;
        }

        float offset = (noteCreatePosY - judgelinePosY) / noteSpeed;

        while (nextNote.time < musicTime + offset)
        {
            float      posX      = nextNote.pos * screenWidth;
            float      posY      = judgelinePosY + (nextNote.time - musicTime) * noteSpeed;
            Vector3    createPos = new Vector3(posX, posY, 0);
            GameObject prefab    = nextNote.slide ? slideNotePrefab : notePrefab;
            prefab = Instantiate(prefab, createPos, Quaternion.identity) as GameObject;
            prefab.GetComponent <NoteBehaviour> ().Init(this);
            noteObjects.Add(prefab);

            if (noteIterator.MoveNext())
            {
                nextNote = noteIterator.Current;
            }
            else
            {
                createdLastNote = true;
                break;
            }
        }
    }
        public void AddLyrics_Syllabics_MiddleCorrect(string input)
        {
            var  sut   = new LyricsProcessor(input);
            note note1 = new note();
            note note2 = new note();
            note note3 = new note();

            sut.AddLyrics(note1);
            sut.AddLyrics(note2);
            sut.AddLyrics(note3);

            using (new AssertionScope())
            {
                note1.lyric.Should().BeEquivalentTo(
                    new
                {
                    number = "1",
                    Items  = new dynamic[] { syllabic.begin, new { Value = "Mu" } }
                });

                note2.lyric.Should().BeEquivalentTo(
                    new
                {
                    number = "1",
                    Items  = new dynamic[] { syllabic.middle, new { Value = "sic" } }
                });

                note3.lyric.Should().BeEquivalentTo(
                    new
                {
                    number = "1",
                    Items  = new dynamic[] { syllabic.end, new { Value = "xml" } }
                });
            }
        }
        public void AddLyrics_Syllabics_StartAndEndCorrect(string input)
        {
            var  sut   = new LyricsProcessor(input);
            note note1 = new note();
            note note2 = new note();
            note note3 = new note();

            sut.AddLyrics(note1);
            sut.AddLyrics(note2);
            sut.AddLyrics(note3);

            using (new AssertionScope())
            {
                note1.lyric.Should().BeEquivalentTo(
                    new
                {
                    number = "1",
                    Items  = new dynamic[] { syllabic.begin, new { Value = "Ly" } }
                });

                note2.lyric.Should().BeNullOrEmpty();

                note3.lyric.Should().BeEquivalentTo(
                    new
                {
                    number = "1",
                    Items  = new dynamic[] { syllabic.end, new { Value = "rics" } }
                });
            }
        }
示例#6
0
        /// <summary>
        /// Creates a note from an item record in TE
        /// </summary>
        /// <remarks>
        /// Mapping info:
        /// ckey = ChecklistTemplateItemCkey
        /// text = VisibleText
        /// </remarks>
        /// <param name="dr">item record with note information</param>
        /// <returns>a note class for the specific item</returns>
        private note MapNote(DataRow dr)
        {
            note a = _srTmpTreeBuilder.MapNote(
                //!Base item metadata
                (String)(dr["type"]),         //need standard type lists for Q, H, A, AF, Note, etc
                (String)(dr["styleClass"]),   //
                (String)(dr["ShortName"]),    //@name

                //!All Displayed Items
                (Decimal)(dr["ChecklistTemplateItemCkey"]),
                (String)(dr["VisibleText"]),  //@title or @val
                (String)(dr["longText"]),     //@alt-TextElementEnumerator in eCC, OtherText in SDC
                (String)(dr["ReportText"]),   //OtherText element in SDC

                (Boolean)(dr["enabled"]),
                !(Boolean)(dr["Hidden"]),     //may conflict with styleClass, and may not be used; may be usefu for reporting notes/coments
                (String)(dr["ControlTip"]),   //@toolTip
                (String)(dr["popupText"]),    //@popupText
                (String)(dr["linkText"]),
                (String)(dr["linkText2"]),
                (String)(dr["AuthorityID"]),      //@AuthorityID
                (Boolean)(dr["showInReport"]),    //values are true, false, conditional
                (Boolean)(dr["mustImplement"]),
                (Int32)(dr["SortOrder"]),

                //!Sections, Questions, Notes
                (Boolean)(dr["AuthorityRequired"]) //@required, @minCard, @mustImplemenet
                );

            return(a);
        }
示例#7
0
 /// <summary>
 /// 音符の追加
 /// </summary>
 /// <param name="_note"></param>
 public void AddNote(note _note)
 {
     _note.t = mNowT;
     note.Add(_note);
     playTime += _note.dur;
     mNowT    += _note.dur;
 }
示例#8
0
 // Use this for initialization
 void Start()
 {
     note      = GetComponent <note>();
     enemyNote = GameObject.Find("EnemyNote");
     enemynote = enemyNote.GetComponent <enemynote>();
     if (BattleManager.Instance.nowBattleScene == 0)
     {
         maxRenge     = 5;
         maxFrequency = 300;
     }
     else if (BattleManager.Instance.nowBattleScene == 1)
     {
         maxRenge     = 3;
         maxFrequency = 180;
     }
     else if (BattleManager.Instance.nowBattleScene == 2)
     {
         maxRenge     = 2;
         maxFrequency = 120;
     }
     NoteCreateFrequency("tokagenote");
     NoteCreateFrequency("datyonote");
     NoteCreateFrequency("kamenote");
     NoteCreateFrequency("momonganote");
     NoteCreateFrequency("enemyNote1");
     NoteCreateFrequency("enemyNote2");
     NoteCreateFrequency("enemyNote3");
 }
示例#9
0
        public async Task <IActionResult> Putnote([FromRoute] int id, [FromBody] note Znote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != Znote.id)
            {
                return(BadRequest());
            }

            _context.Entry(Znote).State = EntityState.Modified;

            try {
                _repo.Update(Znote);
                var save = await _repo.SaveAsync(Znote);
            } catch (DbUpdateConcurrencyException) {
                if (!noteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#10
0
        public async Task <ActionResult <note> > PostNote(note note)
        {
            _context.note.Add(note);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getnote", new { id = note.noteId }, note));
        }
示例#11
0
    IEnumerator spawning()
    {
        //for (int i = 0; i < 1; i++)
        //{
        //    yield return new WaitForSeconds(2);

        //  var clone = Instantiate(arrayspawning[1],tf.transform.position, Quaternion.identity);

        //    clone.transform.SetParent(can.transform);
        //    i--;
        //}
        for (int e = 0; e < 4; e++)
        {
            yield return(new WaitForSeconds(2));

            var cloneS = Instantiate(arrayspawning[e], spawningpoints[0].transform.position, Quaternion.identity);
            var cloneL = Instantiate(arrayspawning[e], spawningpoints[1].transform.position, Quaternion.identity);
            var cloneQ = Instantiate(arrayspawning[e], spawningpoints[2].transform.position, Quaternion.identity);
            var cloneP = Instantiate(arrayspawning[e], spawningpoints[3].transform.position, Quaternion.identity);

            cloneS.transform.SetParent(can.transform);
            cloneL.transform.SetParent(can.transform);
            cloneQ.transform.SetParent(can.transform);
            cloneP.transform.SetParent(can.transform);


            nt = cloneL.GetComponent <note>();

            if (e == 3)
            {
                e = -1;
            }
        }
    }
示例#12
0
        public async Task <IActionResult> PutNote(int id, note note)
        {
            if (id != note.noteId)
            {
                return(BadRequest());
            }

            _context.Entry(note).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!noteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#13
0
        /// <summary>
        /// Edits a note from the database.
        /// </summary>
        public void EditNote()
        {
            view.PrintContentTitle(notesContentTitle);
            view.ClearContent();
            view.PrintNotes(context.notes.ToList());
            view.PrintContent(new List <string>(), "Edit note with ID ");

            int noteID;

            if (int.TryParse(view.ReadLine(), out noteID))
            {
                view.PrintContentTitle("Editing note...");
                view.ClearContent();

                note selectedNote = context.notes.SingleOrDefault(x => x.note_id == noteID);

                if (selectedNote != null)
                {
                    view.PrintEditableContent(selectedNote.content);

                    string inputContent = view.ReadLine();

                    if (inputContent != string.Empty)
                    {
                        selectedNote.content = inputContent;

                        context.SaveChanges();
                    }
                }
            }
        }
 public IHttpActionResult Posttextnote([FromBody] note textnote)
 {
     textnote.img = null;
     db.notes.Add(textnote);
     db.SaveChanges();
     return(Ok(new { result = "success" }));
 }
 public HttpResponseMessage UploadFiles()
 {
     try {
         var res = new HttpResponseMessage(HttpStatusCode.OK);
         var req = HttpContext.Current.Request;
         if (req.Files.Count > 0)
         {
             var  files    = new List <string>();
             note notemain = new note();
             db.notes.Add(notemain);
             db.SaveChanges();
             foreach (string item in req.Files)
             {
                 var postedfile = req.Files[item];
                 var filepath   = HttpContext.Current.Server.MapPath("~/Images/" + postedfile.FileName);
                 postedfile.SaveAs(filepath);
                 files.Add(filepath);
             }
             return(new HttpResponseMessage(HttpStatusCode.OK));
         }
         else
         {
             return(new HttpResponseMessage(HttpStatusCode.BadRequest));
         }
     }
     catch
     {
         return(new HttpResponseMessage(HttpStatusCode.BadRequest));
     }
 }
示例#16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Chord"/> class.
 /// </summary>
 /// <param name="newKey">Desired Key</param>
 /// <param name="newType">Desired Scale Type</param>
 public Chord(note newKey, chordType newType)
 {
     Key       = newKey;
     Name      = newKey.ToString() + " " + type.ToString();
     Intervals = ChordSpellings.intervalsIn[type];
     Notes     = GenerateNotes(newKey, Intervals);
 }
        public IHttpActionResult Deletenote(int id)
        {
            note item = db.notes.Where(x => x.id == id).ToList().FirstOrDefault();

            db.notes.Remove(item);
            db.SaveChanges();
            return(Ok(new { result = "success" }));
        }
示例#18
0
文件: Note.cs 项目: mweechzing/Theory
 /// <summary>
 /// Initializes a new instance of the <see cref="Note"/> class.
 /// </summary>
 /// <param name="newNote">New note.</param>
 /// <param name="newOctave">Desired Octave</param>
 public Note(note newNote, int newOctave)
 {
     duration     = Beat.quarter;
     name         = newNote.ToString() + newOctave.ToString();
     key          = newNote;
     octave       = newOctave;
     frequencyKey = GetFrequencyKey(newNote, octave);
 }
示例#19
0
文件: Note.cs 项目: mweechzing/Theory
 /// <summary>
 /// Initializes a C note.
 /// </summary>
 public Note()
 {
     duration     = Beat.quarter;
     name         = note.C.ToString();
     key          = note.C;
     octave       = 2;
     frequencyKey = GetFrequencyKey(note.C, octave);
 }
示例#20
0
            public note pop()
            {
                note n = data[top];

                data.RemoveAt(top);
                top--;
                return(n);
            }
        public ActionResult DeleteConfirmed(int id)
        {
            note note = db.notes.Find(id);

            db.notes.Remove(note);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#22
0
        public static note Createnote(int ID, string subject, int notes)
        {
            note note = new note();

            note.id      = ID;
            note.subject = subject;
            note.notes   = notes;
            return(note);
        }
示例#23
0
    void Start()
    {
        NoteData notedata = noter.data;

        if (null != notedata)
        {
            List <note.Data> notelist = notedata.notes;

            var length = audio.clip.length;

            note          checker0_last = null;
            note          checker1_last = null;
            GameObject    connector     = null;
            NoteConnector conn          = null;

            for (var i = 0; i < notelist.Count; ++i)
            {
                var obj        = Instantiate(prefab_notes[notelist[i].type]);
                var note_compo = obj.GetComponent <note>();
                note_compo.Setup(new note.Data(notelist[i].timing, notelist[i].type));
                switch (notelist[i].type)
                {
                case (int)note.Type.UP:
                    checker0.AddNote(note_compo);
                    checker0_last = note_compo;
                    break;

                case (int)note.Type.OUT_UP:
                    checker0.AddNote(note_compo);
                    connector = Instantiate(prefab_connector, checker0.transform);
                    conn      = connector.GetComponent <NoteConnector>();
                    conn.SetJoint(checker0_last.transform, note_compo.transform);
                    checker0_last.SetConnector(conn);
                    note_compo.SetConnector(conn);
                    break;

                case (int)note.Type.DOWN:
                    checker1.AddNote(note_compo);
                    checker1_last = note_compo;
                    break;

                case (int)note.Type.OUT_DOWN:
                    checker1.AddNote(note_compo);
                    connector = Instantiate(prefab_connector, checker1.transform);
                    conn      = connector.GetComponent <NoteConnector>();
                    conn.SetJoint(checker1_last.transform, note_compo.transform);
                    checker1_last.SetConnector(conn);
                    note_compo.SetConnector(conn);
                    break;

                default: break;
                }
            }
            checker0.EndAdding();
            checker1.EndAdding();
        }
    }
示例#24
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     view       = e.Parameter as note ?? new note();
     view.frame = frame;
     //viewModel view_model = e.Parameter as viewModel;
     //view.key = view_model.key;
     //view.frame = view_model.frame;
     view.deserilization();
 }
示例#25
0
 static void ShowPath()
 {
     Console.WriteLine("----");
     for (int i = 0; i < stack.data.Count; i++)
     {
         note n = stack.data[i];
         Console.WriteLine($"{i}:({n.x}, {n.y}), f:{n.f}, s:{n.s}");
     }
 }
示例#26
0
    protected void deleteNoteExecute(object sender, EventArgs e)
    {
        note       dn  = new note();
        deleteNote dnn = new deleteNote();

        dn.overallID = "deleteNote";
        dn.noteId    = deleteNoteName.SelectedValue.ToString();

        dnn.deleteN(dn);
    }
示例#27
0
文件: Note.cs 项目: mweechzing/Theory
    /// <summary>
    /// Initializes a new diatonic <see cref="Note"/>.
    /// </summary>
    /// <param name="newNote">Desired Note</param>
    /// <param name="currentDiatonicInterval">Position in scale</param>
    public Note(note newNote, interval currentDiatonicInterval)
    {
        duration = Beat.quarter;
        key      = theory.AdjustForScale(key - (int)currentDiatonicInterval);
        octave   = 0;
        name     = newNote.ToString() + octave.ToString();

        diatonicInterval = currentDiatonicInterval;
        frequencyKey     = GetFrequencyKey(currentDiatonicInterval);
    }
示例#28
0
    //Public member functions==============

    /// <summary>
    /// Generates note array adjusting for max range of intervals.
    /// </summary>
    /// <returns>Adjusted Notes</returns>
    /// <param name="_key">Base offset</param>
    /// <param name="_buildIntervals">Intervals to consier</param>
    public Note[] GenerateNotes(note _key, interval[] _buildIntervals)     //TODO what really is an octave?
    {
        Note[] tempNotes = new Note[_buildIntervals.Length];
        for (int i = 0; i < _buildIntervals.Length; i++)
        {
            note adjustedForScale = theory.AdjustForScale(_key + (int)_buildIntervals [i]);
            tempNotes [i] = new Note(adjustedForScale, _buildIntervals[i]);
        }
        return(tempNotes);
    }
示例#29
0
文件: Program.cs 项目: Condara/Doop
        static void Main(string[] args)
        {
            note note = new note("Naslov", "text, tijelo poruke");

            note.Show();

            StringBuilder sbTitle  = new StringBuilder("Naslov p");
            StringBuilder sbBody   = new StringBuilder("Text pp0");
            Notebook      notebook = new Notebook();

            for (int i = 0; i < 8; i++)
            {
                sbTitle.Append('w', i / 2);
                sbBody.Append('b', i / 3);
                notebook.AddNote(new note(sbTitle.ToString(), sbBody.ToString()));
            }

            CIterator iterator = new CIterator(notebook);

            iterator.First().Show();
            while (iterator.Next() != null)
            {
                iterator.Current.Show();
            }

            notebook.Clear();

            CareTaker careTaker = new CareTaker();
            ToDoItem  tdi1      = new ToDoItem("naslov1", "text1", DateTime.Now);
            ToDoItem  tdi2      = new ToDoItem("naslov12", "text12", DateTime.Now);
            ToDoItem  tdi3      = new ToDoItem("naslov123", "text123", DateTime.MinValue);
            ToDoItem  tdi4      = new ToDoItem("naslov1234", "text1234", DateTime.MaxValue);

            tdi1.AddStateCT(careTaker);
            tdi2.AddStateCT(careTaker);
            tdi3.AddStateCT(careTaker);
            tdi4.AddStateCT(careTaker);

            ToDoItem getStateTdi = new ToDoItem("", "", DateTime.MinValue);

            getStateTdi.RestoreState(careTaker.GetByTitle("naslov12"));

            Console.WriteLine(getStateTdi.ToString());

            HomeThermostat termostat1    = new HomeThermostat();
            HomeThermostat termostat2    = new HomeThermostat();
            CarThermostat  termostatAuto = new CarThermostat();
            WeatherStation station       = new WeatherStation(44);

            station.AddObserver(termostat1);
            station.AddObserver(termostat2);
            station.AddObserver(termostatAuto);
            station.SetTemperature(22);
            station.SetTemperature(2);
        }
 public ActionResult Edit([Bind(Include = "note_id,title,synopsis,content,note_image,note_date,archive,user_id")] note note)
 {
     if (ModelState.IsValid)
     {
         db.Entry(note).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.user_id = new SelectList(db.users, "user_id", "user_asp_id", note.user_id);
     return(View(note));
 }
示例#31
0
        public static List<section> Load(System.Xml.XmlElement parent)
        {
            var elementList = parent.GetElementsByTagName("section");
            List<section> sections = new List<section>();
            foreach (System.Xml.XmlElement e in elementList)
            {
                section s = new section();
                s.name = e.GetAttribute("name");
                s.instrumentid = int.Parse(e.GetAttribute("instrumentID"));
                s.starttime = float.Parse(e.GetAttribute("startTime"));
                var notes = e.GetElementsByTagName("note");
                foreach(System.Xml.XmlElement n in notes)
                {
                    note nx = new note();
                    nx.pitch = n.GetAttribute("pitch");
                    nx.time = float.Parse(n.GetAttribute("time"));
                    nx.duration = float.Parse(n.GetAttribute("duration"));
                    s.notes.Add(nx);
                }
                sections.Add(s);

            }
            return sections;
        }
示例#32
0
 public note addNote(string pitch, float time, float duration)
 {
     lock (sectionLock)
     {
         note n = new note();
         n.pitch = pitch;
         n.time = time;
         n.duration = duration;
         notes.Add(n);
         return n;
     }
 }
示例#33
0
 public void pushUndo()
 {
     List<note> currentState = new List<note>();
     foreach(note n in notes)
     {
         note c = new note();
         c.duration = n.duration;
         c.pitch = n.pitch;
         c.time = n.time;
         currentState.Add(c);
     }
     undo.Push(currentState);
 }
示例#34
0
 public void popUndo()
 {
     if (undo.Count > 0)
     {
         var lastState = undo.Pop();
         notes.Clear();
         foreach(note n  in lastState)
         {
             note c = new note();
             c.duration = n.duration;
             c.pitch = n.pitch;
             c.time = n.time;
             notes.Add(c);
         }
     }
 }
示例#35
0
        private void curNote_KeyDown(object sender, KeyEventArgs e) {
            string s = util.key_to_action(e);
            if (s == "return") {
                // add note
                string note_text = curNote.Text.Trim();
                if (note_text == "")
                    return;
                // see if I'm on a user's note (thus, i'm updating), or on a line (thus, i'm adding a note for that line)
                string reply_to_note_id = "";
                int sel = notesCtrl.SelectedIndex;
                if (sel >= 0) {
                    var i = notesCtrl.GetItem(sel).RowObject as note_item;
                    bool is_edit = i.the_note != null && i.the_note.author_name == author_name_;
                    if (is_edit) {
                        dirty_ = true;
                        i.the_note.note_text = note_text;
                        // user modified the note
                        i.utc_last_edited = DateTime.UtcNow;
                        refresh_note(i);
                        return;
                    }
                    bool is_reply = i.the_note != null && i.the_note.author_name != author_name_;
                    if (is_reply)
                        reply_to_note_id = i.note_id;
                }

                note new_ = new note() { author_name = author_name_, author_initials = author_initials_, 
                    author_color = author_color_, note_text = note_text, made_by_current_user = true, is_new = true };
                add_note(new_, "", reply_to_note_id, false, DateTime.UtcNow);
                refresh_notes();
            }
        }
示例#36
0
 public note_item(note_ctrl self, string unique_id, string line_id, bool deleted, DateTime utc_added) {
     this.self = self;
     note_id = unique_id;
     this.line_id = line_id;
     reply_id = "";
     this.deleted = deleted;
     the_note = null;
     this.utc_last_edited = utc_added;
 }
示例#37
0
        // returns the ID assigned to this note that we're adding;
        // if null, something went wrong
        //
        // note_id - the unique ID of the note, or "" if a new unique ID is to be created
        //           the reason we have this is that we can persist notes (together with their IDs)
        private note_item add_note(line l, note n, string note_id, string reply_to_note_id, bool deleted, DateTime utc_added) {
            // a note: can be added on a line, or as reply to someone
            // new notes: always at the end

            string line_id = "";
            // ... first, try to see if we already have a valid line
            var found_line = lines_.FirstOrDefault(x => x.Key != cur_line_id_ && x.Value == l);
            if ( found_line.Value == null)
                found_line = lines_.FirstOrDefault(x => x.Value == l);
            Debug.Assert(found_line.Value != null);
            if (found_line.Key == cur_line_id_) {
                // it's the current line
                line_id = next_guid;
                lines_.Add(line_id, l);
            } 
            else 
                line_id = found_line.Key;

            note_id = note_id != "" ? note_id : next_guid;
            // ... this note should not exist already
            Debug.Assert( notes_sorted_by_line_index_.Count(x => x.note_id == note_id) == 0);
            if ( reply_to_note_id != "")
                // note we're replying to should exist already
                Debug.Assert( notes_sorted_by_line_index_.Count(x => x.note_id == reply_to_note_id) == 1);

            var new_ = new note_item(this, n, note_id, reply_to_note_id, line_id, deleted, utc_added);
            bool inserted = false;
            if (reply_to_note_id != "") {
                // add this note as the last reply to this reply note
                var note = notes_sorted_by_line_index_.FirstOrDefault(x => x.line_id == line_id);
                // when it's a reply, we need to find the original note!
                Debug.Assert(note != null);
                if (note != null) {
                    Debug.Assert(note.is_note_header);
                    // everything following this, is related to this line (until we get to next line)
                    int idx_note = notes_sorted_by_line_index_.IndexOf(note);
                    for (; idx_note < notes_sorted_by_line_index_.Count && !inserted; idx_note++)
                        if (notes_sorted_by_line_index_[idx_note].line_id == line_id) {
                            if (reply_to_note_id != "") {
                                // in this case, look for this note (that we're replying to)
                                if (notes_sorted_by_line_index_[idx_note].note_id == reply_to_note_id) {
                                    log_notes_sorted_idx(idx_note + 1, new_);
                                    notes_sorted_by_line_index_.Insert(idx_note + 1, new_);                                    
                                    inserted = true;
                                }
                            } else {
                                // look for the last note about this line, and insert it after that
                                if ( idx_note < notes_sorted_by_line_index_.Count - 1)
                                    if (notes_sorted_by_line_index_[idx_note + 1].line_id != line_id) {
                                        // found the last note that relates to this line
                                        notes_sorted_by_line_index_.Insert(idx_note + 1, new_);
                                        log_notes_sorted_idx(idx_note + 1, new_);
                                        inserted = true;                                        
                                    }
                            }
                        } else
                            // went to next line
                            break;
                }
            }
            else {
                var note = notes_sorted_by_line_index_.FirstOrDefault(x => x.line_id == line_id);
                if (note != null) {
                    // in this case, there may be other notes - we're adding it to the end (as last note on this line)
                    Debug.Assert(note.is_note_header);
                    int idx = notes_sorted_by_line_index_.IndexOf(note);
                    for ( ; idx < notes_sorted_by_line_index_.Count; ++idx)
                        if ( idx < notes_sorted_by_line_index_.Count - 1)
                            if (notes_sorted_by_line_index_[idx + 1].line_id != line_id)
                                break;
                    if (idx < notes_sorted_by_line_index_.Count) {
                        log_notes_sorted_idx(idx + 1, new_);
                        notes_sorted_by_line_index_.Insert(idx + 1, new_);
                    } else {
                        log_notes_sorted_idx(-1, new_);
                        notes_sorted_by_line_index_.Add(new_);
                    }
                    inserted = true;
                } else {
                    // this is the first entry that relates to this line
                    // ... find the note before which we should insert ourselves
                    int line_index = lines_[line_id].idx;
                    note = notes_sorted_by_line_index_.FirstOrDefault(x => lines_[x.line_id].idx > line_index);

                    var header = new note_item(this, next_guid, line_id, deleted, utc_added);
                    if (note != null) {
                        int idx = notes_sorted_by_line_index_.IndexOf(note);
                        bool has_header = note.is_note_header && note.line_id == line_id;
                        if (!has_header) {
                            log_notes_sorted_idx(idx, header);
                            notes_sorted_by_line_index_.Insert(idx, header);
                            log_notes_sorted_idx(idx + 1, new_);
                            notes_sorted_by_line_index_.Insert(idx + 1, new_);
                        } else {
                            // header is already added
                            if (header.deleted && !deleted)
                                // in this case, the header was deleted (probably we removed all items related to this line a while ago,
                                // and now we have added a new note here)
                                header.deleted = false;
                            log_notes_sorted_idx(idx, new_);
                            notes_sorted_by_line_index_.Insert(idx, new_);
                        }
                    } else {
                        log_notes_sorted_idx(-1, header);
                        log_notes_sorted_idx(-1, new_);
                        notes_sorted_by_line_index_.Add(header);
                        notes_sorted_by_line_index_.Add(new_);
                    }
                    inserted = true;
                }
            }
            Debug.Assert(inserted);

            // update the UI
            if (inserted)
                add_note_to_ui(new_);

            dirty_ = true;
            return new_;
        }
示例#38
0
        private static Tuple<Dictionary<string, line>, List<note_item>> load_settings_file(note_ctrl self, string file_name) {
            Dictionary<string, line> lines = new Dictionary<string, line>();
            List<note_item> notes = new List<note_item>();

            settings_file sett = new settings_file(file_name);
            // first, load lines
            int line_count = int.Parse(sett.get("line_count", "0"));
            for (int idx = 0; idx < line_count; ++idx) {
                string prefix = "line." + idx + ".";
                line l = new line();
                l.idx = int.Parse(sett.get(prefix + "index", "0"));
                l.view_name = sett.get(prefix + "view_name");
                l.msg = sett.get(prefix + "msg");
                var id = sett.get(prefix + "id", "");
                lines.Add(id, l);
            }

            // load notes
            // if author name = ourselves -> made_by_current_user = true
            int note_count = int.Parse(sett.get("note_count", "0"));
            for (int idx = 0; idx < note_count; ++idx) {
                string prefix = "note." + idx + ".";
                note n = null;
                string author_name = sett.get(prefix + "author_name");
                if (author_name != "") {
                    n = new note() {author_name = author_name};
                    n.author_initials = sett.get(prefix + "author_initials");
                    n.author_color = util.str_to_color(sett.get(prefix + "author_color"));
                    n.note_text = sett.get(prefix + "note_text");
                }
                bool deleted = sett.get(prefix + "deleted", "0") != "0";
                var note_id = sett.get(prefix + "note_id", "");
                var reply_id = sett.get(prefix + "reply_id", "");
                var line_id = sett.get(prefix + "line_id", "");
                long ticks = long.Parse(sett.get(prefix + "added_at", "0"));
                note_item note;
                if (n != null)
                    note = new note_item(self, n, note_id, reply_id, line_id, deleted, new DateTime(ticks));
                else
                    note = new note_item(self, note_id, line_id, deleted, new DateTime(ticks));
                notes.Add(note);
            }
            return new Tuple<Dictionary<string, line>, List<note_item>>(lines, notes);
        }
示例#39
0
	// Use this for initialization
	void Start () {
		NM = GameObject.FindGameObjectWithTag("NoteManager").GetComponent<NoteManager>();
		//SMS = GameObject.FindGameObjectWithTag ("SoundManager").GetComponent<SoundManagerScript> ();

		SMS = SoundManagerScript.Instance;

		if(noteName == "MiddleC"){
			currentNote = note.MiddleC;
			Yposition = -1.5f;
		}
		if(noteName == "CSharp"){
			currentNote = note.CSharp;
			Yposition = -1.5f;
		}
		if(noteName == "D"){
			currentNote = note.D;
			Yposition = -1.25f;
		}
		if(noteName == "DSharp"){
			currentNote = note.DSharp;
			Yposition = -1.25f;
		}
		if(noteName == "E"){
			currentNote = note.E;
			Yposition = -1f;
		}
		if(noteName == "F"){
			currentNote = note.F;
			Yposition = -0.75f;
		}
		if(noteName == "FSharp"){
			currentNote = note.FSharp;
			Yposition = -0.75f;
		}
		if(noteName == "G"){
			currentNote = note.G;
			Yposition = -0.5f;
		}
		if(noteName == "GSharp"){
			currentNote = note.GSharp;
			Yposition = -0.5f;
		}
		if(noteName == "A"){
			currentNote = note.A;
			Yposition = -0.25f;
		}
		if(noteName == "ASharp"){
			currentNote = note.ASharp;
			Yposition = -0.25f;
		}
		if(noteName == "B"){
			currentNote = note.B;
			Yposition = 0f;
		}
		if(noteName == "HighC"){
			currentNote = note.HighC;
			Yposition = 0.25f;
		}
		if(noteName == "HighCSharp"){
			currentNote = note.HighCSharp;
			Yposition = 0.25f;
		}
		if(noteName == "HighD"){
			currentNote = note.HighD;
			Yposition = 0.5f;
		}
		if(noteName == "HighDSharp"){
			currentNote = note.HighDSharp;
			Yposition = 0.5f;
		}
		if(noteName == "HighE"){
			currentNote = note.HighE;
			Yposition = 0.75f;
		}
		if(noteName == "HighF"){
			currentNote = note.HighF;
			Yposition = 1f;
		}
		this.gameObject.transform.position = new Vector3(transform.position.x, Yposition, transform.position.z);
	}
示例#40
0
        // helper - add to the currently selected line
        private note_item add_note(note n, string note_id, string reply_to_note_id, bool deleted, DateTime utc_added) {
            Debug.Assert(cur_line != null);
            if (cur_line == null) {
                Debug.Assert(false);
                return null;
            }

            line new_ = new line();
            if (reply_to_note_id == "")
                new_.copy_from(cur_line);
            else {
                // find the line we're replying to
                var reply_to_note = notes_sorted_by_line_index_.FirstOrDefault(x => x.note_id == reply_to_note_id);
                Debug.Assert(reply_to_note != null && lines_.ContainsKey(reply_to_note.line_id));
                new_.copy_from( lines_[reply_to_note.line_id] );
            }
            return add_note(new_, n, note_id, reply_to_note_id, deleted, utc_added);
        }