public bool ChangeState(PlotColor color, int h, int w, PlotState state, int waitTime) { if (h >= 0 && h < m_field.GetLength(0) && w >= 0 && w < m_field.GetLength(1)) { // append transaction m_transaction += SwarmUtil.Encode(color, h, w, state, waitTime); // upate color counts m_count[(int)m_field[h, w].Color]--; m_count[(int)color]++; m_field[h, w].State = state; m_field[h, w].Color = color; m_field[h, w].WaitDuration = waitTime; return(true); } return(false); }
// must be run on UI thread private void ChangeState(string[] states) { PlotColor color; PlotState state; int w, h; int wait; float opacity; foreach (string str in states) { if (SwarmUtil.Decode(str, out color, out h, out w, out state, out wait)) { opacity = m_visitedOpacity; switch (state) { case PlotState.Occupied: opacity = m_occupiedOpacity; break; case PlotState.Defended: opacity = m_defendedOpacity; break; case PlotState.Duplication: opacity = m_duplicationOpacity; break; case PlotState.Unoccupied: opacity = m_unoccupiedOpacity; break; case PlotState.Forbidden: opacity = 0f; break; } FlipColor(color, h, w, opacity); /* when there were 5 types of rectangles * FlipColor(PlotColor.Clear, h, w, (PlotColor.Clear == color) ? opacity : 0f); * FlipColor(PlotColor.Red, h, w, (PlotColor.Red == color) ? opacity : 0f); * FlipColor(PlotColor.Blue, h, w, (PlotColor.Blue == color) ? opacity : 0f); * FlipColor(PlotColor.Green, h, w, (PlotColor.Green == color) ? opacity : 0f); * FlipColor(PlotColor.Yellow, h, w, (PlotColor.Yellow == color) ? opacity : 0f); */ } } }