Ejemplo n.º 1
0
        //adds or subtracts one from direction
        public void ChangeCurrentRuleset(int direction)
        {
            int newIndex = CAMath.Mod(CurrentRulesetIndex + direction, Rulesets.list.Count);

            PlayerPrefs.SetInt(c_CurrentRulesetKey, newIndex);
            PlayerPrefs.Save();
        }
Ejemplo n.º 2
0
        public int[] GetNeighbors(Vector2Int i2D, bool b_Toroidal = true)
        {
            //TODO:
            if (b_Toroidal == false)
            {
                throw new NotImplementedException();
            }

            int[] n = new int[8];
            int   c = 0;

            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    //skip self
                    if (j == 0 && i == 0)
                    {
                        continue;
                    }

                    n[c] = m_Cells[Get1D(
                                       CAMath.Mod((i2D.x + i), m_Width),
                                       CAMath.Mod((i2D.y + j), m_Height),
                                       m_Width)
                           ];
                    c++;
                }
            }

            return(n);
        }
Ejemplo n.º 3
0
        //directly sets integer index of rulesets
        public void SetCurrentRuleset(int i)
        {
            int newIndex = CAMath.Mod(i, Rulesets.list.Count);

            PlayerPrefs.SetInt(c_CurrentRulesetKey, newIndex);
            PlayerPrefs.Save();
        }
Ejemplo n.º 4
0
        public int OnMaxNeighborsChange(RuleBehavior ruleBehavior, int direction)
        {
            int rbIndex = ruleBehavior.transform.GetSiblingIndex();

            SaveLoadManager.Instance.SetMaxNeighbors(rbIndex,
                                                     CAMath.Mod(SaveLoadManager.Instance.CurrentRuleset[rbIndex].m_MaxNumNeighbors + direction, 9)); //9 directions
            return(SaveLoadManager.Instance.CurrentRuleset[rbIndex].m_MaxNumNeighbors);
        }
Ejemplo n.º 5
0
 public static int ChangeColorInt(int currentColor, int direction, bool b_includeClear = false)
 {
     if (!b_includeClear && currentColor == 1 && direction < 0)
     {
         return(CAColor.colors.Count - 1);
     }
     return(CAMath.Mod(currentColor + direction, b_includeClear ? 0 : 1, CAColor.colors.Count));
 }
Ejemplo n.º 6
0
        //-1 = slower, +1 = faster, 0 = no change
        public void ChangeFPS(int direction)
        {
            //update fps index
            m_FPSIndex += direction;
            m_FPSIndex  = CAMath.Mod(m_FPSIndex, m_FPSOptions.Length);

            //update ui
            m_FPSText.text = FPS.ToString();
        }
        public void SetZoom(int zoomLevel)
        {
            m_Zoom = CAMath.Mod(zoomLevel, MAX_ZOOM_LEVEL + 1);
            GetComponent <RawImage>().texture = m_ZoomLevels[m_Zoom].m_Tex;
            UpdateCellPixelSize();

            if (m_CellGrid != null)
            {
                //resize cellgrid, if it is expading, new cells will be the clear to color
                m_CellGrid.Resize(m_ZoomLevels[m_Zoom].m_Size, m_ClearToColor == 0 ? 1 : m_ClearToColor);
            }
            else
            {
                ResetGrid();
            }

            //copy cell grid to texture
            SyncZoomTexture();
        }