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); }
//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(); }
//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(); }
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); }
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)); }
//-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(); }
private void Update() { switch (m_State) { case EState.FADING_IN: t += Time.deltaTime; if (t >= m_FadeTime) { m_State = EState.WAITING; t = 0f; TutorialManager.Instance.UpdateFocusObjects(1f, true); } else { //fade in focus objects float a = Mathf.Lerp(TutorialManager.MIN_ALPHA, 1f, CAMath.SmoothStep(t / m_FadeTime)); m_InfoText.alpha = a; TutorialManager.Instance.UpdateFocusObjects(a, true); } break; case EState.WAITING: t += Time.deltaTime; if (t > (m_ClickToContinueTime) && t < (m_ClickToContinueTime + m_FadeTime)) //if timer still counting { //fade in click anywhere to continue text if (m_ClickToContinueText != null) { float a = Mathf.Lerp(0f, c_ClickToContinueAlphaMax, Mathf.Min(1.0f, CAMath.SmoothStep((t - m_ClickToContinueTime) / m_FadeTime))); m_ClickToContinueText.alpha = a; m_ClickToContinueEtc.ForEach(item => TutorialManager.Instance.ChangeAlphaOnCompatibleComponents(item, a)); } } else if (b_CanAdvanceWithoutEventTrigger) { AdvanceTutorialStage(true); } break; case EState.FADING_OUT: t += Time.deltaTime; if (b_FadeOut || t >= m_FadeTime) { t = 0f; OnFadeOut(); } else { //fade out focus objects if (m_ClickToContinueText != null) { m_ClickToContinueText.alpha = 0f; m_ClickToContinueEtc.ForEach(item => TutorialManager.Instance.ChangeAlphaOnCompatibleComponents(item, 0f)); } float a = Mathf.Lerp(1f, 0f, Mathf.Min(1.0f, CAMath.SmoothStep(t / m_FadeTime))); m_InfoText.alpha = a; } break; default: break; } }