/// <summary> /// Function to initialize some internal properties. Should be called in Start() /// </summary> /// <param name="Index">Index to control the menu index</param> public override void Init(LimitedIndex Index) { base.Init(Index); elementArea.SetParent(menuArea); for (int i = 0; i < menuIndex.Max(); i++) { float angle = startAngle - (360 / (float)menuIndex.Max()) * i; positions.Add(new Area.Position(center.x + (Mathf.Cos(Mathf.Deg2Rad * angle) * radius / 2.0f), center.y + (-Mathf.Sin(Mathf.Deg2Rad * angle) * radius / 2.0f))); } //for (int k=0; k<100;k++) //{ // List<Area.Position> newPositions = new List<Area.Position>(); // CircularIndex index = new CircularIndex(positions.Count); // for (int i = 0; i < positions.Count; i++) // { // float x_center = (positions[index.IndexMovedBy(-1)].x + positions[index.IndexMovedBy(1)].x) / 2; // newPositions.Add(new Area.Position(x_center, positions[index.Get()].y)); // index++; // } // positions = newPositions; //} }
/// <summary> /// Returns a new LimitedIndex deviated apart the current index /// </summary> /// <param name="deviation">Deviation value</param> public virtual LimitedIndex OffsetCopy(int deviation) { LimitedIndex index = new LimitedIndex(max); index.Set(IndexMovedBy(deviation)); return(index); }
void Awake() { if (gameManager == null) { gameManager = this; } else { Destroy(gameObject); return; } PersistObjets(); saveJson.Load("save.json"); currentLanguage = new LimitedIndex(languagues.Length); for (int i = 0; i < languagues.Length; i++) { if (languagues[i].name == saveJson.config.languageName) { currentLanguage.Set(i); } } if (languagues.Length > 0) { ChangeLanguage(languagues[currentLanguage.Get()].name, true); } saveIndex = 0; }
/// <summary> /// Function to initialize some internal properties. Should be called in Start() /// </summary> /// <param name="Index">Index to control the menu index</param> public virtual void Init(LimitedIndex Index) { innerArea.SetParent(menuArea); verticalSeparation = true; updateDelay = 15; qtdUpdates = 0; menuIndex = Index; }
public virtual void Init(LimitedIndex rowIndex, LimitedIndex columnIndex) { base.Init(columnIndex); this.rowIndex = rowIndex; this.columnIndex = columnIndex; rowUpdateDelay = 15; rowQtdUpdates = 0; }
/// <summary> /// Calculate how many times the first index should be increment to achieve the second index /// </summary> /// <param name="one">The one.</param> /// <param name="two">The two.</param> public static int UpDiff(LimitedIndex one, LimitedIndex two) { int diff = two.Get() - one.Get(); if (diff > 0) { return(diff); } return(one.Max() + diff); }
/// <summary> /// Function to initialize some internal properties. Should be called in Start() /// </summary> /// <param name="menu">Index to control the menu index</param> /// <param name="background">Index to control the background index</param> public void Init(LimitedIndex menu, LimitedIndex background, bool verticalSeparation = true) { base.Init(menu); this.verticalSeparation = verticalSeparation; elementsArea = new List <Area>(); topMenuIndex = new CircularIndex(menu.Max()); backgroundIndex = background; offsetPosition = 0; isMoving = false; UpdateNumberOfElements(); }
public override void ChangeSelection() { base.ChangeSelection(); int index = rowIndex.Get() * columnIndex.Max() + columnIndex.Get(); if (index >= activeList.Count) { rowIndex.Set(lastRow.Get()); columnIndex.Set(lastColumn.Get()); return; } lastRow = rowIndex.OffsetCopy(0); lastColumn = columnIndex.OffsetCopy(0); }
/// <summary> /// Class to extend the concept of a Rect. Define a region as part of a other region, with all the values as percentages. /// Defines a region that occupies part of an area (width and height) and centered on the position (x and y). /// </summary> /// <param name="x">Horizontal relatives position of the center</param> /// <param name="y">Vertical relatives position of the center</param> /// <param name="width">Relative horizontal size</param> /// <param name="heigth">Relative vertical size</param> /// <param name="growStep">Increase step for change in sizes</param> /// <param name="moveStep">Increase step for change in moves</param> public Area(float x, float y, float width, float heigth, float growStep = 0.05f, float moveStep = 0.05f) { this.centerPosition.x = x; this.centerPosition.y = y; this.size.width = width; this.size.height = heigth; this.growStep = growStep; this.moveStep = moveStep; percentSizeWidth = new LimitedIndex(10000); percentSizeWidth.Set(percentSizeWidth.Max() - 1); percentSizeHeigth = new LimitedIndex(10000); percentSizeHeigth.Set(percentSizeWidth.Max() - 1); percentMove = new LimitedIndex(10000); percentMove.Set(percentMove.Max() - 1); parent = null; }
/// <summary> /// Calculate the minimal difference up or down /// </summary> /// <param name="one">The one.</param> /// <param name="two">The two.</param> /// <returns></returns> public static int CircularDiff(LimitedIndex one, LimitedIndex two) { int diff = two.Get() - one.Get(); if (diff > 0) { if (diff > one.Max() / 2) { diff -= one.Max(); } } else { if (diff < -one.Max() / 2) { diff += one.Max(); } } return(diff); }
public virtual void Init(ref Ability.AbilityDictionary abilities) { this.abilities = abilities; abilitiyMenu = UIManager.GetInstance().ability; activeList = new List <Ability.AbilitySettings>(); foreach (KeyValuePair <Ability.AbilityId, Ability.AbilitySettings> pair in abilities) { if (isSelectable(pair.Value)) { activeList.Add(pair.Value); } } base.Init(new CircularIndex(rows), new CircularIndex(columns)); selectedBorderBlinked = new BlinkTexture(selectedBorder, blinkControl); Update(); lastRow = rowIndex.OffsetCopy(0); lastColumn = columnIndex.OffsetCopy(0); ChangeSelection(); }
/// <summary> /// Calculate how many times the first index should be decrement to achieve the second index /// </summary> /// <param name="one">The one.</param> /// <param name="two">The two.</param> public static int DownDiff(LimitedIndex one, LimitedIndex two) { return(one.Max() - UpDiff(one, two)); }