private void Form1_KeyUp(object sender, KeyEventArgs e) { //# 刪除 if (e.KeyCode == Keys.Delete) { //# 移除項目 if (m_selectedState != null) { // 移除 SimsAffect foreach (var o in m_affects.Where(c => c.A == m_selectedState || c.B == m_selectedState).ToList()) { m_affects.Remove(o); } // 移除 SimsState m_states.Remove(m_selectedState); m_selectedState = null; this.Invalidate(); // 重繪畫面 } else if (m_selectedAffect != null) { // 移除 SimsAffect m_affects.Remove(m_selectedAffect); m_selectedAffect = null; this.Invalidate(); // 重繪畫面 } } }
private void Form1_MouseDown(object sender, MouseEventArgs e) { Debug.Print("ON : Form1_MouseDown"); switch (e.Button) { case MouseButtons.Left: if (f_addnewAffect) { foreach (var c in m_states) { if (c.HitTest(e.Location)) { m_affects.Add(new SimsAffect(m_selectedState, c, +1.0f)); this.f_addnewAffect = false; this.m_selectedState = null; } } this.Invalidate(); break; // } //# 選取 SimsAffect this.m_selectedAffect = null; foreach (var c in m_affects) { if (c.HitTest(e.Location)) { this.m_selectedAffect = c; // 選取 SimsState propViewer.SelectedObject = c; // 顯示屬性 break; } } //# 選取 SimsState this.m_selectedState = null; foreach (var c in m_states) { if (c.HitTest(e.Location)) { this.m_selectedState = c; // 選取 SimsState propViewer.SelectedObject = c; // 顯示屬性 this.m_selectedAffect = null; break; } } // 重繪畫面 this.Invalidate(); break; case MouseButtons.Right: //# 選取 SimsState this.m_selectedState = null; this.f_addnewAffect = false; foreach (var c in m_states) { if (c.HitTest(e.Location)) { this.m_selectedState = c; // 選取 SimsState propViewer.SelectedObject = c; // 顯示屬性 this.f_addnewAffect = true; // 開始新增 SimsAffect this.m_selectedAffect = null; break; } } // 重繪畫面 this.Invalidate(); break; } }
public void RunOnce(SimsAffect affect) { this.nextDelta += affect.affectVolumn * affect.A.delta; //Debug.Print(@"{0:-8} → {1:N0} \ {2:N0} \ {3:N0}", this.name, this.value, this.delta, this.nextDelta); }